Prepare to support ruby 3.3.
This commit is contained in:
parent
d4d1e65a6d
commit
fbb2b30d66
|
@ -1,101 +1,103 @@
|
||||||
module Gallery
|
module Gallery
|
||||||
class Engine < ::Rails::Engine
|
class Engine < ::Rails::Engine
|
||||||
initializer "gallery" do
|
initializer "gallery" do
|
||||||
begin
|
Rails.application.config.to_prepare do
|
||||||
translate_data = Dir["#{Gallery::Engine.root}/config/locales/*.yml"] .map{|yaml_file| YAML.load(File.read(yaml_file))}
|
begin
|
||||||
data = {}
|
translate_data = Dir["#{Gallery::Engine.root}/config/locales/*.yml"] .map{|yaml_file| YAML.load(File.read(yaml_file))}
|
||||||
key1 = {}
|
data = {}
|
||||||
key1_options = ['grid_style','card_style','slideshow_style']
|
key1 = {}
|
||||||
key1_attrs = []
|
key1_options = ['grid_style','card_style','slideshow_style']
|
||||||
key1_options.each_with_index do |v, i|
|
key1_attrs = []
|
||||||
key1_attrs[i] = {}
|
key1_options.each_with_index do |v, i|
|
||||||
|
key1_attrs[i] = {}
|
||||||
|
end
|
||||||
|
key2 = {}
|
||||||
|
key2_options = ['small_size','medium_size','large_size']
|
||||||
|
key2_attrs = []
|
||||||
|
|
||||||
|
key2_options.each_with_index do |v, i|
|
||||||
|
key2_attrs[i] = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
translate_data.each do |t_data|
|
||||||
|
v = t_data.values
|
||||||
|
k = t_data.keys[0]
|
||||||
|
key1[k] = v[0]['gallery']['inner_page_layout']
|
||||||
|
key1_options.each_with_index do |kk, i|
|
||||||
|
key1_attrs[i][k] = v[0]['gallery'][kk]
|
||||||
|
end
|
||||||
|
|
||||||
|
key2[k] = v[0]['gallery']['picture_thumb_size']
|
||||||
|
key2_options.each_with_index do |kk, i|
|
||||||
|
key2_attrs[i][k] = v[0]['gallery'][kk]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
data[key1] = key1_attrs
|
||||||
|
data[key2] = key2_attrs
|
||||||
|
rescue => e
|
||||||
|
puts ['error in gallery',e]
|
||||||
end
|
end
|
||||||
key2 = {}
|
|
||||||
key2_options = ['small_size','medium_size','large_size']
|
OrbitApp.registration "Gallery", :type => "ModuleApp" do
|
||||||
key2_attrs = []
|
module_label "gallery.gallery"
|
||||||
|
base_url File.expand_path File.dirname(__FILE__)
|
||||||
|
widget_methods ["widget","album_widget"]
|
||||||
|
# widget_settings []
|
||||||
|
widget_settings [{"data_count"=>30}]
|
||||||
|
models_to_cache [:album,:album_image]
|
||||||
|
taggable "Album"
|
||||||
|
categorizable
|
||||||
|
authorizable
|
||||||
|
frontend_enabled
|
||||||
|
data_count 1..30
|
||||||
|
|
||||||
key2_options.each_with_index do |v, i|
|
begin
|
||||||
key2_attrs[i] = {}
|
show_option_items data
|
||||||
|
rescue => e
|
||||||
|
puts ['there_was_no_show_option_method',e]
|
||||||
|
end
|
||||||
|
side_bar do
|
||||||
|
head_label_i18n 'gallery.gallery', icon_class: "icons-pictures"
|
||||||
|
available_for "users"
|
||||||
|
active_for_controllers (['admin/galleries','admin/images'])
|
||||||
|
head_link_path "admin_galleries_path"
|
||||||
|
|
||||||
|
context_link 'gallery.all',
|
||||||
|
:link_path=>"admin_galleries_path" ,
|
||||||
|
:priority=>1,
|
||||||
|
:active_for_action=>{'admin/galleries'=>"index"},
|
||||||
|
:available_for => 'users'
|
||||||
|
|
||||||
|
context_link 'gallery.new',
|
||||||
|
:link_path=>"new_admin_gallery_path" ,
|
||||||
|
:priority=>2,
|
||||||
|
:active_for_action=>{'admin/galleries'=>"new"},
|
||||||
|
:available_for => 'sub_managers'
|
||||||
|
|
||||||
|
context_link 'categories',
|
||||||
|
:link_path=>"admin_module_app_categories_path" ,
|
||||||
|
:link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'gallery').id}",
|
||||||
|
:priority=>3,
|
||||||
|
:active_for_action=>{'admin/galleries'=>'categories'},
|
||||||
|
:active_for_category => 'Gallery',
|
||||||
|
:available_for => 'managers'
|
||||||
|
|
||||||
|
context_link 'tags',
|
||||||
|
:link_path=>"admin_module_app_tags_path" ,
|
||||||
|
:link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'gallery').id}",
|
||||||
|
:priority=>4,
|
||||||
|
:active_for_action=>{'admin/galleries'=>'tags'},
|
||||||
|
:active_for_tag => 'Gallery',
|
||||||
|
:available_for => 'managers'
|
||||||
|
context_link 'gallery.setting',
|
||||||
|
:link_path=>"admin_galleries_setting_path" ,
|
||||||
|
:priority=>5,
|
||||||
|
:active_for_action=>{'admin/galleries'=>'setting'},
|
||||||
|
:available_for => 'managers'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
translate_data.each do |t_data|
|
|
||||||
v = t_data.values
|
|
||||||
k = t_data.keys[0]
|
|
||||||
key1[k] = v[0]['gallery']['inner_page_layout']
|
|
||||||
key1_options.each_with_index do |kk, i|
|
|
||||||
key1_attrs[i][k] = v[0]['gallery'][kk]
|
|
||||||
end
|
|
||||||
|
|
||||||
key2[k] = v[0]['gallery']['picture_thumb_size']
|
|
||||||
key2_options.each_with_index do |kk, i|
|
|
||||||
key2_attrs[i][k] = v[0]['gallery'][kk]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
data[key1] = key1_attrs
|
|
||||||
data[key2] = key2_attrs
|
|
||||||
rescue => e
|
|
||||||
puts ['error in gallery',e]
|
|
||||||
end
|
|
||||||
|
|
||||||
OrbitApp.registration "Gallery", :type => "ModuleApp" do
|
|
||||||
module_label "gallery.gallery"
|
|
||||||
base_url File.expand_path File.dirname(__FILE__)
|
|
||||||
widget_methods ["widget","album_widget"]
|
|
||||||
# widget_settings []
|
|
||||||
widget_settings [{"data_count"=>30}]
|
|
||||||
models_to_cache [:album,:album_image]
|
|
||||||
taggable "Album"
|
|
||||||
categorizable
|
|
||||||
authorizable
|
|
||||||
frontend_enabled
|
|
||||||
data_count 1..30
|
|
||||||
|
|
||||||
begin
|
|
||||||
show_option_items data
|
|
||||||
rescue => e
|
|
||||||
puts ['there_was_no_show_option_method',e]
|
|
||||||
end
|
|
||||||
side_bar do
|
|
||||||
head_label_i18n 'gallery.gallery', icon_class: "icons-pictures"
|
|
||||||
available_for "users"
|
|
||||||
active_for_controllers (['admin/galleries','admin/images'])
|
|
||||||
head_link_path "admin_galleries_path"
|
|
||||||
|
|
||||||
context_link 'gallery.all',
|
|
||||||
:link_path=>"admin_galleries_path" ,
|
|
||||||
:priority=>1,
|
|
||||||
:active_for_action=>{'admin/galleries'=>"index"},
|
|
||||||
:available_for => 'users'
|
|
||||||
|
|
||||||
context_link 'gallery.new',
|
|
||||||
:link_path=>"new_admin_gallery_path" ,
|
|
||||||
:priority=>2,
|
|
||||||
:active_for_action=>{'admin/galleries'=>"new"},
|
|
||||||
:available_for => 'sub_managers'
|
|
||||||
|
|
||||||
context_link 'categories',
|
|
||||||
:link_path=>"admin_module_app_categories_path" ,
|
|
||||||
:link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'gallery').id}",
|
|
||||||
:priority=>3,
|
|
||||||
:active_for_action=>{'admin/galleries'=>'categories'},
|
|
||||||
:active_for_category => 'Gallery',
|
|
||||||
:available_for => 'managers'
|
|
||||||
|
|
||||||
context_link 'tags',
|
|
||||||
:link_path=>"admin_module_app_tags_path" ,
|
|
||||||
:link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'gallery').id}",
|
|
||||||
:priority=>4,
|
|
||||||
:active_for_action=>{'admin/galleries'=>'tags'},
|
|
||||||
:active_for_tag => 'Gallery',
|
|
||||||
:available_for => 'managers'
|
|
||||||
context_link 'gallery.setting',
|
|
||||||
:link_path=>"admin_galleries_setting_path" ,
|
|
||||||
:priority=>5,
|
|
||||||
:active_for_action=>{'admin/galleries'=>'setting'},
|
|
||||||
:available_for => 'managers'
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue