diff --git a/lib/e_paper/engine.rb b/lib/e_paper/engine.rb index 540453e..a8b0559 100644 --- a/lib/e_paper/engine.rb +++ b/lib/e_paper/engine.rb @@ -1,80 +1,82 @@ module EPaper class Engine < ::Rails::Engine initializer "e_paper" do - env_pwd = ENV['PWD'] - begin - require File.expand_path('app/models/sub_part.rb', env_pwd) - if defined? SubPart - SubPart.where(:module => 'e_paper',:widget_method.ne => 'widget').each do |sub_part| - sub_part.widget_method = 'widget' - sub_part.save + Rails.application.config.to_prepare do + env_pwd = ENV['PWD'] + begin + require File.expand_path('app/models/sub_part.rb', env_pwd) + if defined? SubPart + SubPart.where(:module => 'e_paper',:widget_method.ne => 'widget').each do |sub_part| + sub_part.widget_method = 'widget' + sub_part.save + end end + rescue => e + puts ["can't find subpart",e] end - rescue => e - puts ["can't find subpart",e] - end - OrbitApp.registration "EPaper", :type => "ModuleApp" do - module_label "e_paper.e_paper" - base_url File.expand_path File.dirname(__FILE__) - #widget_methods ["criteria_list","category_wise_articles","latest_criteria", "latest_slider", "subscribe"] - widget_methods ["widget"] - widget_settings [{"data_count"=>30, "enable_custom_widget_data"=>true}] - taggable "EPaperCriteria" - categorizable - authorizable - frontend_enabled - data_count 1..30 + OrbitApp.registration "EPaper", :type => "ModuleApp" do + module_label "e_paper.e_paper" + base_url File.expand_path File.dirname(__FILE__) + #widget_methods ["criteria_list","category_wise_articles","latest_criteria", "latest_slider", "subscribe"] + widget_methods ["widget"] + widget_settings [{"data_count"=>30, "enable_custom_widget_data"=>true}] + taggable "EPaperCriteria" + categorizable + authorizable + frontend_enabled + data_count 1..30 - side_bar do - head_label_i18n 'e_paper.e_paper', icon_class: "icons-book" - available_for "users" - active_for_controllers (['admin/e_papers', 'admin/e_paper_criterias']) - head_link_path "admin_e_papers_path" + side_bar do + head_label_i18n 'e_paper.e_paper', icon_class: "icons-book" + available_for "users" + active_for_controllers (['admin/e_papers', 'admin/e_paper_criterias']) + head_link_path "admin_e_papers_path" - context_link 'e_paper.all_articles', - :link_path=>"admin_e_papers_path" , - :priority=>1, - :active_for_action=>{'admin/e_papers'=>'index'}, - :available_for => 'users' - context_link 'new_', - :link_path=>"new_admin_e_paper_path" , - :priority=>2, - :active_for_action=>{'admin/e_papers'=>'new'}, - :available_for => 'sub_managers' - context_link 'categories', - :link_path=>"admin_module_app_categories_path" , - :link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'e_paper').id}", - :priority=>3, - :active_for_action=>{'admin/e_papers'=>'categories'}, - :active_for_category => 'EPaper', - :available_for => 'managers' - context_link 'tags', - :link_path=>"admin_module_app_tags_path" , - :link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'e_paper').id}", - :priority=>4, - :active_for_action=>{'admin/e_papers'=>'tags'}, - :active_for_tag => 'e_paper', - :available_for => 'managers' - context_link 'e_paper.paper_criteria', - :link_path=>"admin_e_paper_criterias_path" , - :priority=>5, - :active_for_action=>{'admin/e_paper_criterias'=>'index'}, - :available_for => 'managers' - context_link 'e_paper.subscribers', - :link_path=>"admin_e_paper_subscribers_path" , - :priority=>6, - :active_for_action=>{'admin/e_paper_subscribers'=>'index'}, - :available_for => 'managers' - context_link 'e_paper.batch_delete_subscribers', - :link_path=>"admin_e_paper_subscribers_batch_delete_subscribers_path" , - :priority=>7, - :active_for_action=>{'admin/e_paper_subscribers'=>'batch_delete_subscribers'}, - :available_for => 'managers' - context_link 'e_paper.instructions', - :link_path=>"instructions_admin_e_papers_path" , - :priority=>8, - :active_for_action=>{'admin/e_paper'=>'instructions'}, - :available_for => 'users' + context_link 'e_paper.all_articles', + :link_path=>"admin_e_papers_path" , + :priority=>1, + :active_for_action=>{'admin/e_papers'=>'index'}, + :available_for => 'users' + context_link 'new_', + :link_path=>"new_admin_e_paper_path" , + :priority=>2, + :active_for_action=>{'admin/e_papers'=>'new'}, + :available_for => 'sub_managers' + context_link 'categories', + :link_path=>"admin_module_app_categories_path" , + :link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'e_paper').id}", + :priority=>3, + :active_for_action=>{'admin/e_papers'=>'categories'}, + :active_for_category => 'EPaper', + :available_for => 'managers' + context_link 'tags', + :link_path=>"admin_module_app_tags_path" , + :link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'e_paper').id}", + :priority=>4, + :active_for_action=>{'admin/e_papers'=>'tags'}, + :active_for_tag => 'e_paper', + :available_for => 'managers' + context_link 'e_paper.paper_criteria', + :link_path=>"admin_e_paper_criterias_path" , + :priority=>5, + :active_for_action=>{'admin/e_paper_criterias'=>'index'}, + :available_for => 'managers' + context_link 'e_paper.subscribers', + :link_path=>"admin_e_paper_subscribers_path" , + :priority=>6, + :active_for_action=>{'admin/e_paper_subscribers'=>'index'}, + :available_for => 'managers' + context_link 'e_paper.batch_delete_subscribers', + :link_path=>"admin_e_paper_subscribers_batch_delete_subscribers_path" , + :priority=>7, + :active_for_action=>{'admin/e_paper_subscribers'=>'batch_delete_subscribers'}, + :available_for => 'managers' + context_link 'e_paper.instructions', + :link_path=>"instructions_admin_e_papers_path" , + :priority=>8, + :active_for_action=>{'admin/e_paper'=>'instructions'}, + :available_for => 'users' + end end end end