Prepare to support ruby 3.3.

This commit is contained in:
邱博亞 2024-02-24 20:56:13 +08:00
parent a55848b554
commit 6c89f33caa
2 changed files with 201 additions and 199 deletions

View File

@ -334,9 +334,9 @@ module EventNewsHelper
if @target_action == "index"
filename = File.basename(overridehtml.nil? ? params[:layout_type] : overridehtml)
f = File.join(Rails.root, 'app', 'templates', "#{@key}", 'modules', 'event_news_mod', "#{filename}.html.erb")
if !File.exists?f
if !File.exist?(f)
f = File.join(Rails.root, 'app', 'templates', "#{@key}", 'modules', 'event_news_mod', "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
@ -376,7 +376,7 @@ module EventNewsHelper
else
filename = overridehtml.nil? ? @target_action : overridehtml
f = File.join(Rails.root, 'app', 'templates', "#{@key}", 'modules', 'event_news_mod', "#{filename}.html.erb")
if File.exists?f
if File.exist?(f)
file = File.open(f)
doc = Nokogiri::HTML(file, nil, "UTF-8")
file.close
@ -478,7 +478,7 @@ module EventNewsHelper
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

@ -1,7 +1,8 @@
require "yaml"
module EventNewsMod
class Engine < ::Rails::Engine
initializer "event_news_mod" do
Rails.application.config.to_prepare do
require "yaml"
begin
translate_data = Dir["#{EventNewsMod::Engine.root}/config/locales/*.yml"] .map{|yaml_file| YAML.load(File.read(yaml_file))}
data = {}
@ -193,4 +194,5 @@ module EventNewsMod
# s[:bulletins].indexes.create({expirable_created_at: 1},{ expireAfterSeconds: 180 })
end
end
end
end