67 lines
2.7 KiB
Ruby
67 lines
2.7 KiB
Ruby
module Feeds
|
|
class Engine < ::Rails::Engine
|
|
initializer "feeds" do
|
|
Rails.application.config.to_prepare do
|
|
gem_root = Feeds::Engine.root
|
|
if ENV['worker_num']=='0' && File.basename($0) != 'rake' && !Rails.const_defined?('Console')
|
|
require File.join(gem_root, 'app/models/site_feed_setting')
|
|
if defined?(SiteFeedSetting)
|
|
if SiteFeedSetting.count==0
|
|
SiteFeedSetting.create
|
|
end
|
|
end
|
|
end
|
|
OrbitApp.registration "Feeds", :type => "ModuleApp" do
|
|
module_label "feed.feed"
|
|
base_url File.expand_path File.dirname(__FILE__)
|
|
categorizable
|
|
authorizable
|
|
if File.basename($0) != 'rake'
|
|
begin
|
|
avoid_page_cache SiteFeed
|
|
rescue => e
|
|
puts ["avoid_page_cache", e.to_s]
|
|
end
|
|
end
|
|
side_bar do
|
|
head_label_i18n 'feed.feed', icon_class: "icons-rss"
|
|
available_for "managers"
|
|
active_for_controllers (['admin/feeds'])
|
|
head_link_path "admin_feeds_path"
|
|
|
|
context_link 'feed.all_feeds',
|
|
:link_path=>"admin_feeds_path" ,
|
|
:priority=>1,
|
|
:active_for_action=>{'admin/feeds'=>'index'},
|
|
:available_for => 'managers'
|
|
context_link 'feed.new_',
|
|
:link_path=>"new_admin_feed_path" ,
|
|
:priority=>2,
|
|
:active_for_action=>{'admin/feeds'=>'new'},
|
|
:available_for => 'managers'
|
|
context_link 'feed.all_announcements',
|
|
:link_path=>"admin_feeds_announcements_path" ,
|
|
:priority=>3,
|
|
:active_for_action=>{'admin/feeds'=>'announcements'},
|
|
:available_for => 'managers'
|
|
context_link 'feed.settings',
|
|
:link_path=>"admin_feeds_settings_path" ,
|
|
:priority=>3,
|
|
:active_for_action=>{'admin/feeds'=>'settings'},
|
|
:available_for => 'managers'
|
|
|
|
end
|
|
|
|
end
|
|
gem_tmp = File.join(gem_root, 'tmp')
|
|
f = File.join(gem_tmp, "install_bash")
|
|
if File.exist?(f)
|
|
File.delete(f)
|
|
%x(cp "#{gem_root}/config/schedule.rb" config/schedule.rb)
|
|
%x(whenever --update-crontab feeds --set environment="#{ENV["RAILS_ENV"]}")
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|