master #16

Merged
chiu merged 4 commits from 123/seminar:master into master 2024-02-28 07:00:38 +00:00
4 changed files with 281 additions and 276 deletions
Showing only changes of commit 1ae15033a8 - Show all commits

View File

@ -320,9 +320,9 @@ module CustomAnnouncementsHelper
if @target_action == "index"
filename = overridehtml.nil? ? params[:layout_type] : overridehtml
f = File.join(Rails.root, 'app', 'templates', "#{@key}", 'modules', 'custom_announcement', "#{filename}.html.erb")
if !File.exists?f
if !File.exist?(f)
f = File.join(Rails.root, 'app', 'templates', "#{@key}", 'modules', 'custom_announcement', "index.html.erb")
if !File.exists?f
if !File.exist?(f)
return "<div class='well'>Maybe the administrator has changed the theme, please select the index page design again from the page settings.</div>".html_safe
end
end
@ -333,7 +333,7 @@ module CustomAnnouncementsHelper
begin
data = @data# rescue nil
rescue Exception => e
write_debug_file(e,'custom_announcements',@target_action) if Site::DEBUG
write_debug_file(e,'custom_announcements',@target_action) if Site::DEBUG
end
if !data.nil?
wrap_elements = doc.css("*[data-list][data-level='0']")
@ -362,7 +362,7 @@ module CustomAnnouncementsHelper
else
filename = overridehtml.nil? ? @target_action : overridehtml
f = File.join(Rails.root, 'app', 'templates', "#{@key}", 'modules', 'custom_announcement', "#{filename}.html.erb")
if File.exists?f
if File.exist?(f)
file = File.open(f)
doc = Nokogiri::HTML(file, nil, "UTF-8")
file.close
@ -464,7 +464,7 @@ module CustomAnnouncementsHelper
layout_types = []
@key = Site.first.template
f = File.join("#{Rails.root}/app/templates/#{@key}/modules/#{module_app}/info.json")
if File.exists?f
if File.exist?(f)
info = File.read(f)
hash = JSON.parse(info) rescue {}
frontends = hash["frontend"] || []

View File

@ -2,153 +2,155 @@ require "yaml"
module CustomAnnouncement
class Engine < ::Rails::Engine
initializer "custom_announcement" do
begin
translate_data = Dir["#{CustomAnnouncement::Engine.root}/config/locales/*.yml"] .map{|yaml_file| YAML.load(File.read(yaml_file))}
data = {}
key1 = {}
key2 = {}
key3 = {}
key4 = {}
key1_attr = []
key2_attr = []
key3_attr = []
key4_attr = []
data_item = {}
key_item1 = {}
key_item2 = {}
key_item3 = {}
value_item1 = {}
value_item2 = {}
value_item3 = {}
value2_item1 = {}
value2_item2 = {}
key1_options = ['small_size','medium_size','orignal_size']
key2_options = ['not_enable_tabs','enable_tabs_with_categories_include_all','enable_tabs_with_categories']
key3_options = ['default','upper_left','lower_left','upper_right','lower_right']
key4_options = ['the_same_as_data_count','display_all_in_other_tabs']
key1_options.each_with_index do |k,i|
key1_attr[i] = {}
end
key2_options.each_with_index do |k,i|
key2_attr[i] = {}
end
key3_options.each_with_index do |k,i|
key3_attr[i] = {}
end
key4_options.each_with_index do |k,i|
key4_attr[i] = {}
end
translate_data.each do |t_data|
v = t_data.values
k = t_data.keys[0]
key1[k] = v[0]['custom_announcement']['picture_showing_size']
key2[k] = v[0]['custom_announcement']['tabs_options']
key3[k] = v[0]['custom_announcement']['read_more_position_options']
key4[k] = v[0]['custom_announcement']['all_tabs_setting']
key1_options.each_with_index do |kk,i|
key1_attr[i][k] = v[0]['custom_announcement'][kk]
end
key2_options.each_with_index do |kk,i|
key2_attr[i][k] = v[0]['custom_announcement'][kk]
end
key3_options.each_with_index do |kk,i|
key3_attr[i][k] = v[0]['custom_announcement'][kk]
end
key4_options.each_with_index do |kk,i|
key4_attr[i][k] = v[0]['custom_announcement'][kk]
end
key_item1[k] = v[0]['custom_announcement']['showing_back_and_next']
key_item2[k] = v[0]['custom_announcement']['enable_search']
value_item1[k] = v[0]['custom_announcement']['not_show']
value_item2[k] = v[0]['custom_announcement']['show_bottom']
value_item3[k] = v[0]['custom_announcement']['show_top']
value2_item1[k] = v[0]['custom_announcement']['no']
value2_item2[k] = v[0]['custom_announcement']['yes']
end
data[key1] = key1_attr
data[key2] = key2_attr
data[key3] = key3_attr
data[key4] = key4_attr
data_item[key_item1] = [value_item1,value_item2,value_item3]
data_item[key_item2] = [value2_item1,value2_item2]
require File.expand_path('../../../app/models/custom_anns_cache', __FILE__)
if defined? CustomAnnsCache
CustomAnnsCache.destroy_all
end
rescue => e
puts ['error in custom_announcement',e]
end
OrbitApp.registration "CustomAnnouncement", :type => "ModuleApp" do
module_label "custom_announcement.custom_announcement"
base_url File.expand_path File.dirname(__FILE__)
widget_methods ["widget","random_custom_announcement_widget", "tag_cloud"]
widget_settings [{"data_count"=>30,"enable_custom_widget_data"=>true}]
taggable "CustomBulletin"
categorizable
authorizable
frontend_enabled
feeds_url "/xhr/custom_announcements/feeds"
data_count 1..30
Rails.application.config.to_prepare do
begin
show_options data
show_option_items data_item
rescue => e
puts ['there_was_no_show_option_method',e]
translate_data = Dir["#{CustomAnnouncement::Engine.root}/config/locales/*.yml"] .map{|yaml_file| YAML.load(File.read(yaml_file))}
data = {}
key1 = {}
key2 = {}
key3 = {}
key4 = {}
key1_attr = []
key2_attr = []
key3_attr = []
key4_attr = []
data_item = {}
key_item1 = {}
key_item2 = {}
key_item3 = {}
value_item1 = {}
value_item2 = {}
value_item3 = {}
value2_item1 = {}
value2_item2 = {}
key1_options = ['small_size','medium_size','orignal_size']
key2_options = ['not_enable_tabs','enable_tabs_with_categories_include_all','enable_tabs_with_categories']
key3_options = ['default','upper_left','lower_left','upper_right','lower_right']
key4_options = ['the_same_as_data_count','display_all_in_other_tabs']
key1_options.each_with_index do |k,i|
key1_attr[i] = {}
end
key2_options.each_with_index do |k,i|
key2_attr[i] = {}
end
key3_options.each_with_index do |k,i|
key3_attr[i] = {}
end
key4_options.each_with_index do |k,i|
key4_attr[i] = {}
end
translate_data.each do |t_data|
v = t_data.values
k = t_data.keys[0]
key1[k] = v[0]['custom_announcement']['picture_showing_size']
key2[k] = v[0]['custom_announcement']['tabs_options']
key3[k] = v[0]['custom_announcement']['read_more_position_options']
key4[k] = v[0]['custom_announcement']['all_tabs_setting']
key1_options.each_with_index do |kk,i|
key1_attr[i][k] = v[0]['custom_announcement'][kk]
end
key2_options.each_with_index do |kk,i|
key2_attr[i][k] = v[0]['custom_announcement'][kk]
end
key3_options.each_with_index do |kk,i|
key3_attr[i][k] = v[0]['custom_announcement'][kk]
end
key4_options.each_with_index do |kk,i|
key4_attr[i][k] = v[0]['custom_announcement'][kk]
end
key_item1[k] = v[0]['custom_announcement']['showing_back_and_next']
key_item2[k] = v[0]['custom_announcement']['enable_search']
value_item1[k] = v[0]['custom_announcement']['not_show']
value_item2[k] = v[0]['custom_announcement']['show_bottom']
value_item3[k] = v[0]['custom_announcement']['show_top']
value2_item1[k] = v[0]['custom_announcement']['no']
value2_item2[k] = v[0]['custom_announcement']['yes']
end
data[key1] = key1_attr
data[key2] = key2_attr
data[key3] = key3_attr
data[key4] = key4_attr
data_item[key_item1] = [value_item1,value_item2,value_item3]
data_item[key_item2] = [value2_item1,value2_item2]
require File.expand_path('../../../app/models/custom_anns_cache', __FILE__)
if defined? CustomAnnsCache
CustomAnnsCache.destroy_all
end
rescue => e
puts ['error in custom_announcement',e]
end
side_bar do
set_sidebar_order(100) rescue nil
head_label_i18n 'custom_announcement.custom_announcement', icon_class: "icon-bullhorn"
available_for "users"
active_for_controllers (['admin/custom_announcements'])
head_link_path "admin_custom_announcements_path"
OrbitApp.registration "CustomAnnouncement", :type => "ModuleApp" do
module_label "custom_announcement.custom_announcement"
base_url File.expand_path File.dirname(__FILE__)
widget_methods ["widget","random_custom_announcement_widget", "tag_cloud"]
widget_settings [{"data_count"=>30,"enable_custom_widget_data"=>true}]
taggable "CustomBulletin"
categorizable
authorizable
frontend_enabled
feeds_url "/xhr/custom_announcements/feeds"
data_count 1..30
begin
show_options data
show_option_items data_item
rescue => e
puts ['there_was_no_show_option_method',e]
end
side_bar do
set_sidebar_order(100) rescue nil
head_label_i18n 'custom_announcement.custom_announcement', icon_class: "icon-bullhorn"
available_for "users"
active_for_controllers (['admin/custom_announcements'])
head_link_path "admin_custom_announcements_path"
context_link 'custom_announcement.all_articles',
:link_path=>"admin_custom_announcements_path" ,
:priority=>1,
:active_for_action=>{'admin/custom_announcements'=>'index'},
:available_for => 'users'
# context_link 'new_',
# :link_path=>"new_admin_custom_announcement_path" ,
# :priority=>2,
# :active_for_action=>{'admin/custom_announcements'=>'new'},
# :available_for => 'sub_managers'
context_link 'categories',
:link_path=>"admin_module_app_categories_path" ,
:link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'custom_announcement').id}",
:priority=>3,
:active_for_action=>{'admin/custom_announcements'=>'categories'},
:active_for_category => 'CustomAnnouncement',
:available_for => 'managers'
context_link 'tags',
:link_path=>"admin_module_app_tags_path" ,
:link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'custom_announcement').id}",
:priority=>4,
:active_for_action=>{'admin/custom_announcements'=>'tags'},
:active_for_tag => 'CustomAnnouncement',
:available_for => 'managers'
context_link 'custom_announcement.feed_list',
:link_path=>"admin_custom_announcement_feed_path" ,
:priority=>5,
:active_for_action=>{'admin/custom_announcements'=>'feed'},
:available_for => 'managers'
context_link 'custom_announcement.import',
:link_path=>"admin_custom_announcement_import_path" ,
:priority=>6,
:active_for_action=>{'admin/custom_announcements'=>'import'},
:available_for => 'managers'
context_link 'custom_announcement.settings',
:link_path=>"admin_custom_announcement_settings_path" ,
:priority=>6,
:active_for_action=>{'admin/custom_announcements'=>'settings'},
:available_for => 'managers'
end
context_link 'custom_announcement.all_articles',
:link_path=>"admin_custom_announcements_path" ,
:priority=>1,
:active_for_action=>{'admin/custom_announcements'=>'index'},
:available_for => 'users'
# context_link 'new_',
# :link_path=>"new_admin_custom_announcement_path" ,
# :priority=>2,
# :active_for_action=>{'admin/custom_announcements'=>'new'},
# :available_for => 'sub_managers'
context_link 'categories',
:link_path=>"admin_module_app_categories_path" ,
:link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'custom_announcement').id}",
:priority=>3,
:active_for_action=>{'admin/custom_announcements'=>'categories'},
:active_for_category => 'CustomAnnouncement',
:available_for => 'managers'
context_link 'tags',
:link_path=>"admin_module_app_tags_path" ,
:link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'custom_announcement').id}",
:priority=>4,
:active_for_action=>{'admin/custom_announcements'=>'tags'},
:active_for_tag => 'CustomAnnouncement',
:available_for => 'managers'
context_link 'custom_announcement.feed_list',
:link_path=>"admin_custom_announcement_feed_path" ,
:priority=>5,
:active_for_action=>{'admin/custom_announcements'=>'feed'},
:available_for => 'managers'
context_link 'custom_announcement.import',
:link_path=>"admin_custom_announcement_import_path" ,
:priority=>6,
:active_for_action=>{'admin/custom_announcements'=>'import'},
:available_for => 'managers'
context_link 'custom_announcement.settings',
:link_path=>"admin_custom_announcement_settings_path" ,
:priority=>6,
:active_for_action=>{'admin/custom_announcements'=>'settings'},
:available_for => 'managers'
end
# temp = YAML.load_file(File.join(Rails.root,"config","mongoid.yml"))
# dbsettings = temp["production"]["sessions"]["default"]
# s = Moped::Session.new(dbsettings["hosts"])
# s.use dbsettings["database"]
# s[:custom_bulletins].indexes.create({expirable_created_at: 1},{ expireAfterSeconds: 180 })
end
# temp = YAML.load_file(File.join(Rails.root,"config","mongoid.yml"))
# dbsettings = temp["production"]["sessions"]["default"]
# s = Moped::Session.new(dbsettings["hosts"])
# s.use dbsettings["database"]
# s[:custom_bulletins].indexes.create({expirable_created_at: 1},{ expireAfterSeconds: 180 })
end
end
end

View File

@ -1,94 +1,96 @@
module CustomGallery
class Engine < ::Rails::Engine
initializer "custom_gallery" do
begin
translate_data = Dir["#{CustomGallery::Engine.root}/config/locales/*.yml"] .map{|yaml_file| YAML.load(File.read(yaml_file))}
data = {}
key1 = {}
value1 = {}
value2 = {}
value3 = {}
translate_data.each do |t_data|
v = t_data.values
k = t_data.keys[0]
key1[k] = v[0]['custom_gallery']['inner_page_layout']
value1[k] = v[0]['custom_gallery']['grid_style']
value2[k] = v[0]['custom_gallery']['card_style']
value3[k] = v[0]['custom_gallery']['slideshow_style']
Rails.application.config.to_prepare do
begin
translate_data = Dir["#{CustomGallery::Engine.root}/config/locales/*.yml"] .map{|yaml_file| YAML.load(File.read(yaml_file))}
data = {}
key1 = {}
value1 = {}
value2 = {}
value3 = {}
translate_data.each do |t_data|
v = t_data.values
k = t_data.keys[0]
key1[k] = v[0]['custom_gallery']['inner_page_layout']
value1[k] = v[0]['custom_gallery']['grid_style']
value2[k] = v[0]['custom_gallery']['card_style']
value3[k] = v[0]['custom_gallery']['slideshow_style']
end
data[key1] = [value1,value2,value3]
rescue => e
puts ['error in custom_gallery',e]
end
data[key1] = [value1,value2,value3]
rescue => e
puts ['error in custom_gallery',e]
end
require File.expand_path('../../../app/models/custom_album_setting', __FILE__)
if defined?(CustomAlbumSetting)
if CustomAlbumSetting.first.nil?
CustomAlbumSetting.create()
elsif CustomAlbumSetting.count > 1
CustomAlbumSetting.all.to_a[1..-1].each do |custom_album_setting|
custom_album_setting.destroy
require File.join(CustomGallery::Engine.root, 'app/models/custom_album_setting')
if defined?(CustomAlbumSetting)
if CustomAlbumSetting.first.nil?
CustomAlbumSetting.create()
elsif CustomAlbumSetting.count > 1
CustomAlbumSetting.all.to_a[1..-1].each do |custom_album_setting|
custom_album_setting.destroy
end
end
end
end
OrbitApp.registration "CustomGallery", :type => "ModuleApp" do
module_label "custom_gallery.custom_gallery"
base_url File.expand_path File.dirname(__FILE__)
widget_methods ["widget","custom_album_widget"]
# widget_settings []
widget_settings [{"data_count"=>30,"enable_custom_widget_data"=>true}]
models_to_cache [:custom_album,:custom_album_image]
taggable "CustomAlbum"
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
set_sidebar_order(100) rescue nil
head_label_i18n 'custom_gallery.custom_gallery', icon_class: "fa fa-file-image-o"
available_for "users"
active_for_controllers (['admin/custom_galleries','admin/images'])
head_link_path "admin_custom_galleries_path"
OrbitApp.registration "CustomGallery", :type => "ModuleApp" do
module_label "custom_gallery.custom_gallery"
base_url File.expand_path File.dirname(__FILE__)
widget_methods ["widget","custom_album_widget"]
# widget_settings []
widget_settings [{"data_count"=>30,"enable_custom_widget_data"=>true}]
models_to_cache [:custom_album,:custom_album_image]
taggable "CustomAlbum"
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
set_sidebar_order(100) rescue nil
head_label_i18n 'custom_gallery.custom_gallery', icon_class: "fa fa-file-image-o"
available_for "users"
active_for_controllers (['admin/custom_galleries','admin/images'])
head_link_path "admin_custom_galleries_path"
context_link 'custom_gallery.all',
:link_path=>"admin_custom_galleries_path" ,
:priority=>1,
:active_for_action=>{'admin/custom_galleries'=>"index"},
:available_for => 'users'
context_link 'custom_gallery.all',
:link_path=>"admin_custom_galleries_path" ,
:priority=>1,
:active_for_action=>{'admin/custom_galleries'=>"index"},
:available_for => 'users'
# context_link 'custom_gallery.new',
# :link_path=>"new_admin_custom_gallery_path" ,
# :priority=>2,
# :active_for_action=>{'admin/custom_galleries'=>"new"},
# :available_for => 'sub_managers'
# context_link 'custom_gallery.new',
# :link_path=>"new_admin_custom_gallery_path" ,
# :priority=>2,
# :active_for_action=>{'admin/custom_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=>'custom_gallery').id}",
:priority=>3,
:active_for_action=>{'admin/custom_galleries'=>'categories'},
:active_for_category => 'CustomGallery',
:available_for => 'managers'
context_link 'categories',
:link_path=>"admin_module_app_categories_path" ,
:link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'custom_gallery').id}",
:priority=>3,
:active_for_action=>{'admin/custom_galleries'=>'categories'},
:active_for_category => 'CustomGallery',
:available_for => 'managers'
context_link 'tags',
:link_path=>"admin_module_app_tags_path" ,
:link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'custom_gallery').id}",
:priority=>4,
:active_for_action=>{'admin/custom_galleries'=>'tags'},
:active_for_tag => 'CustomGallery',
:available_for => 'managers'
context_link 'setting',
:link_path=>"admin_custom_galleries_setting_path" ,
:priority=>5,
:active_for_action=>{'admin/custom_galleries'=>'setting'},
:available_for => 'managers'
end
context_link 'tags',
:link_path=>"admin_module_app_tags_path" ,
:link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'custom_gallery').id}",
:priority=>4,
:active_for_action=>{'admin/custom_galleries'=>'tags'},
:active_for_tag => 'CustomGallery',
:available_for => 'managers'
context_link 'setting',
:link_path=>"admin_custom_galleries_setting_path" ,
:priority=>5,
:active_for_action=>{'admin/custom_galleries'=>'setting'},
:available_for => 'managers'
end
end
end
end
end

View File

@ -1,55 +1,56 @@
module Seminar
class Engine < ::Rails::Engine
initializer "seminar" do
OrbitApp.registration "Seminar", :type => "ModuleApp" do
module_label "seminar.seminar"
base_url File.expand_path File.dirname(__FILE__)
authorizable
categorizable
frontend_enabled
data_count 1..20
widget_methods ["widget"]
widget_settings [{"data_count"=>30}]
side_bar do
head_label_i18n 'seminar.seminar', icon_class: "icon-globe"
available_for "users"
active_for_controllers (['admin/seminars'])
head_link_path "admin_seminars_path"
Rails.application.config.to_prepare do
OrbitApp.registration "Seminar", :type => "ModuleApp" do
module_label "seminar.seminar"
base_url File.expand_path File.dirname(__FILE__)
authorizable
categorizable
frontend_enabled
data_count 1..20
widget_methods ["widget"]
widget_settings [{"data_count"=>30}]
side_bar do
head_label_i18n 'seminar.seminar', icon_class: "icon-globe"
available_for "users"
active_for_controllers (['admin/seminars'])
head_link_path "admin_seminars_path"
context_link 'list_',
:link_path=>"admin_seminars_path" ,
:priority=>1,
:active_for_action=>{'admin/seminars'=>'index'},
:available_for => 'users'
context_link 'new_',
:link_path=>"new_admin_seminar_path" ,
:priority=>2,
:active_for_action=>{'admin/seminars'=>'new'},
:available_for => 'sub_managers'
context_link 'categories',
:link_path=>"admin_module_app_categories_path" ,
:link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'seminar').id}",
:priority=>3,
:active_for_action=>{'admin/seminars'=>'categories'},
:active_for_category => 'Seminar',
:available_for => 'managers'
context_link 'seminar.set_seminar_items',
:link_path=>"admin_seminar_items_path" ,
:priority=>4,
:active_for_action=>{'admin/seminars'=>'seminar_items'},
:available_for => 'managers'
context_link 'seminar.set_seminar_agreements',
:link_path=>"admin_seminar_agreements_path" ,
:priority=>5,
:active_for_action=>{'admin/seminars'=>'seminar_agreements'},
:available_for => 'managers'
context_link 'seminar.enquiry_for_applicants',
:link_path=>"admin_seminar_enquiry_for_applicants_path" ,
:priority=>6,
:active_for_action=>{'admin/seminars'=>'enquiry_for_applicants'},
:available_for => 'users'
context_link 'list_',
:link_path=>"admin_seminars_path" ,
:priority=>1,
:active_for_action=>{'admin/seminars'=>'index'},
:available_for => 'users'
context_link 'new_',
:link_path=>"new_admin_seminar_path" ,
:priority=>2,
:active_for_action=>{'admin/seminars'=>'new'},
:available_for => 'sub_managers'
context_link 'categories',
:link_path=>"admin_module_app_categories_path" ,
:link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'seminar').id}",
:priority=>3,
:active_for_action=>{'admin/seminars'=>'categories'},
:active_for_category => 'Seminar',
:available_for => 'managers'
context_link 'seminar.set_seminar_items',
:link_path=>"admin_seminar_items_path" ,
:priority=>4,
:active_for_action=>{'admin/seminars'=>'seminar_items'},
:available_for => 'managers'
context_link 'seminar.set_seminar_agreements',
:link_path=>"admin_seminar_agreements_path" ,
:priority=>5,
:active_for_action=>{'admin/seminars'=>'seminar_agreements'},
:available_for => 'managers'
context_link 'seminar.enquiry_for_applicants',
:link_path=>"admin_seminar_enquiry_for_applicants_path" ,
:priority=>6,
:active_for_action=>{'admin/seminars'=>'enquiry_for_applicants'},
:available_for => 'users'
end
end
end
end
end