Prepare to support ruby 3.3.
This commit is contained in:
parent
6d14f05e15
commit
b3a4dc479b
|
@ -320,9 +320,9 @@ module CustomAnnouncementsHelper
|
||||||
if @target_action == "index"
|
if @target_action == "index"
|
||||||
filename = overridehtml.nil? ? params[:layout_type] : overridehtml
|
filename = overridehtml.nil? ? params[:layout_type] : overridehtml
|
||||||
f = File.join(Rails.root, 'app', 'templates', "#{@key}", 'modules', 'custom_announcement', "#{filename}.html.erb")
|
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")
|
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
|
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
|
||||||
end
|
end
|
||||||
|
@ -362,7 +362,7 @@ module CustomAnnouncementsHelper
|
||||||
else
|
else
|
||||||
filename = overridehtml.nil? ? @target_action : overridehtml
|
filename = overridehtml.nil? ? @target_action : overridehtml
|
||||||
f = File.join(Rails.root, 'app', 'templates', "#{@key}", 'modules', 'custom_announcement', "#{filename}.html.erb")
|
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)
|
file = File.open(f)
|
||||||
doc = Nokogiri::HTML(file, nil, "UTF-8")
|
doc = Nokogiri::HTML(file, nil, "UTF-8")
|
||||||
file.close
|
file.close
|
||||||
|
@ -464,7 +464,7 @@ module CustomAnnouncementsHelper
|
||||||
layout_types = []
|
layout_types = []
|
||||||
@key = Site.first.template
|
@key = Site.first.template
|
||||||
f = File.join("#{Rails.root}/app/templates/#{@key}/modules/#{module_app}/info.json")
|
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)
|
info = File.read(f)
|
||||||
hash = JSON.parse(info) rescue {}
|
hash = JSON.parse(info) rescue {}
|
||||||
frontends = hash["frontend"] || []
|
frontends = hash["frontend"] || []
|
||||||
|
|
|
@ -2,6 +2,7 @@ require "yaml"
|
||||||
module CustomAnnouncement
|
module CustomAnnouncement
|
||||||
class Engine < ::Rails::Engine
|
class Engine < ::Rails::Engine
|
||||||
initializer "custom_announcement" do
|
initializer "custom_announcement" do
|
||||||
|
Rails.application.config.to_prepare do
|
||||||
begin
|
begin
|
||||||
translate_data = Dir["#{CustomAnnouncement::Engine.root}/config/locales/*.yml"] .map{|yaml_file| YAML.load(File.read(yaml_file))}
|
translate_data = Dir["#{CustomAnnouncement::Engine.root}/config/locales/*.yml"] .map{|yaml_file| YAML.load(File.read(yaml_file))}
|
||||||
data = {}
|
data = {}
|
||||||
|
@ -151,4 +152,5 @@ module CustomAnnouncement
|
||||||
# s[:custom_bulletins].indexes.create({expirable_created_at: 1},{ expireAfterSeconds: 180 })
|
# s[:custom_bulletins].indexes.create({expirable_created_at: 1},{ expireAfterSeconds: 180 })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
Loading…
Reference in New Issue