Prepare to support ruby 3.3.

This commit is contained in:
邱博亞 2024-02-28 19:19:32 +08:00
parent b2c3627afa
commit 6c2a5caf30
1 changed files with 72 additions and 70 deletions

View File

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