Prepare to support ruby 3.3.

This commit is contained in:
邱博亞 2024-02-24 20:47:22 +08:00
parent b80208cfbc
commit 8f738acce6
1 changed files with 94 additions and 94 deletions

View File

@ -1,109 +1,109 @@
module Archive module Archive
class Engine < ::Rails::Engine class Engine < ::Rails::Engine
initializer "archive" do initializer "archive" do
require File.expand_path('../../../app/models/archive_category', __FILE__) Rails.application.config.to_prepare do
require File.expand_path('../../../app/models/archive_sort_order', __FILE__) require File.expand_path('../../../app/models/archive_category', __FILE__)
if defined?(ArchiveSortOrder) require File.expand_path('../../../app/models/archive_sort_order', __FILE__)
if ArchiveSortOrder.count == 0 if defined?(ArchiveSortOrder)
ArchiveSortOrder.create('sort_order' => false) if ArchiveSortOrder.count == 0
end ArchiveSortOrder.create('sort_order' => false)
end
require "#{ENV['PWD']}/app/models/category"
require "#{ENV['PWD']}/app/models/module_app"
tmp = OrbitApp.registration "Archive", :type => "ModuleApp" do
module_label "archive.archive"
base_url File.expand_path File.dirname(__FILE__)
feeds_url "/xhr/archive_files/feeds"
begin
feeds_model "ArchiveFile"
feeds_uid_field "feed_uid"
feeds_update_callback "update_feed_data"
feeds_update_statuses_callback "update_feed_statuses"
feeds_time_field "created_at"
feeds_finish_callback "feeds_finish_callback"
rescue => e
puts "orbit kernel need update!"
end
widget_methods ["widget","group_by_category"]
widget_settings [{"data_count"=>30,"enable_custom_widget_data"=>true}]
data_count 0..30
models_to_cache [:archive_file]
begin
avoid_page_cache ArchiveCache
avoid_page_cache ArchiveFileFeed
avoid_page_cache ArchiveFileFeedCache
rescue => e
puts ["avoid_page_cache", e.to_s]
end
if ENV['worker_num']=='0' && File.basename($0) != 'rake' && !Rails.const_defined?('Console')
require File.expand_path('../../../app/models/archive_cache', __FILE__)
if defined?(ArchiveCache)
ArchiveCache.all.delete
end end
end end
taggable "ArchiveFile" require "#{ENV['PWD']}/app/models/category"
categorizable require "#{ENV['PWD']}/app/models/module_app"
authorizable
frontend_enabled tmp = OrbitApp.registration "Archive", :type => "ModuleApp" do
side_bar do module_label "archive.archive"
head_label_i18n 'archive.archive', icon_class: "icons-archive" base_url File.expand_path File.dirname(__FILE__)
available_for "users" feeds_url "/xhr/archive_files/feeds"
active_for_controllers (['admin/archive_files']) begin
head_link_path "admin_archive_files_path" feeds_model "ArchiveFile"
feeds_uid_field "feed_uid"
feeds_update_callback "update_feed_data"
feeds_update_statuses_callback "update_feed_statuses"
feeds_time_field "created_at"
feeds_finish_callback "feeds_finish_callback"
rescue => e
puts "orbit kernel need update!"
end
widget_methods ["widget","group_by_category"]
widget_settings [{"data_count"=>30,"enable_custom_widget_data"=>true}]
data_count 0..30
models_to_cache [:archive_file]
begin
avoid_page_cache ArchiveCache
avoid_page_cache ArchiveFileFeed
avoid_page_cache ArchiveFileFeedCache
rescue => e
puts ["avoid_page_cache", e.to_s]
end
if ENV['worker_num']=='0' && File.basename($0) != 'rake' && !Rails.const_defined?('Console')
require File.expand_path('../../../app/models/archive_cache', __FILE__)
if defined?(ArchiveCache)
ArchiveCache.all.delete
end
end
taggable "ArchiveFile"
categorizable
authorizable
frontend_enabled
side_bar do
head_label_i18n 'archive.archive', icon_class: "icons-archive"
available_for "users"
active_for_controllers (['admin/archive_files'])
head_link_path "admin_archive_files_path"
context_link 'all', context_link 'all',
:link_path=>"admin_archive_files_path" , :link_path=>"admin_archive_files_path" ,
:priority=>1, :priority=>1,
:active_for_action=>{'admin/archive_files'=>"index"}, :active_for_action=>{'admin/archive_files'=>"index"},
:available_for => 'users' :available_for => 'users'
context_link 'new_', context_link 'new_',
:link_path=>"new_admin_archive_file_path" , :link_path=>"new_admin_archive_file_path" ,
:priority=>2, :priority=>2,
:active_for_action=>{'admin/archive_files'=>"new"}, :active_for_action=>{'admin/archive_files'=>"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=>'archive').id}", :link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'archive').id}",
:priority=>3, :priority=>3,
:active_for_action=>{'admin/archive_files'=>'categories'}, :active_for_action=>{'admin/archive_files'=>'categories'},
:active_for_category => 'Archive', :active_for_category => 'Archive',
: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=>'archive').id}", :link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'archive').id}",
:priority=>4, :priority=>4,
:active_for_action=>{'admin/archive_files'=>'tags'}, :active_for_action=>{'admin/archive_files'=>'tags'},
:active_for_tag => 'Archive', :active_for_tag => 'Archive',
:available_for => 'managers' :available_for => 'managers'
context_link 'archive.categories_order', context_link 'archive.categories_order',
:link_path=>"admin_archive_files_categories_order_path" , :link_path=>"admin_archive_files_categories_order_path" ,
:priority=>5, :priority=>5,
:active_for_action=>{'admin/archive_files'=>'categories_order'}, :active_for_action=>{'admin/archive_files'=>'categories_order'},
:available_for => 'managers' :available_for => 'managers'
context_link 'archive.feed_list', context_link 'archive.feed_list',
:link_path=>"admin_archive_file_feed_path" , :link_path=>"admin_archive_file_feed_path" ,
:priority=>6, :priority=>6,
:active_for_action=>{'admin/archive_files'=>'feed'}, :active_for_action=>{'admin/archive_files'=>'feed'},
:available_for => 'managers' :available_for => 'managers'
end
end end
end categories_temp = ModuleApp.where(:key => "archive").first.categories
categories_temp = ModuleApp.where(:key => "archive").first.categories
categories_temp.each do |category|
categories_temp.each do |category| archive_cat = ArchiveCategory.where(:category_id => category.id)
archive_cat = ArchiveCategory.where(:category_id => category.id) if archive_cat.count == 0
if archive_cat.count == 0 ArchiveCategory.create(category_id: category.id.to_s)
ArchiveCategory.create(category_id: category.id.to_s) else
else archive_cat[1..-1].each do |cat|
archive_cat[1..-1].each do |cat| cat.delete
cat.delete end
end end
end end
end end
tmp
end end
end end
end end