Prepare to support ruby 3.3.

This commit is contained in:
邱博亞 2024-02-24 21:22:36 +08:00
parent d7651a1716
commit 9f9c76a0d4
4 changed files with 281 additions and 276 deletions

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
@ -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,6 +2,7 @@ require "yaml"
module CustomAnnouncement
class Engine < ::Rails::Engine
initializer "custom_announcement" do
Rails.application.config.to_prepare do
begin
translate_data = Dir["#{CustomAnnouncement::Engine.root}/config/locales/*.yml"] .map{|yaml_file| YAML.load(File.read(yaml_file))}
data = {}
@ -151,4 +152,5 @@ module CustomAnnouncement
# s[:custom_bulletins].indexes.create({expirable_created_at: 1},{ expireAfterSeconds: 180 })
end
end
end
end

View File

@ -1,6 +1,7 @@
module CustomGallery
class Engine < ::Rails::Engine
initializer "custom_gallery" do
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 = {}
@ -21,7 +22,7 @@ module CustomGallery
puts ['error in custom_gallery',e]
end
require File.expand_path('../../../app/models/custom_album_setting', __FILE__)
require File.join(CustomGallery::Engine.root, 'app/models/custom_album_setting')
if defined?(CustomAlbumSetting)
if CustomAlbumSetting.first.nil?
CustomAlbumSetting.create()
@ -92,4 +93,5 @@ module CustomGallery
end
end
end
end
end

View File

@ -1,6 +1,7 @@
module Seminar
class Engine < ::Rails::Engine
initializer "seminar" do
Rails.application.config.to_prepare do
OrbitApp.registration "Seminar", :type => "ModuleApp" do
module_label "seminar.seminar"
base_url File.expand_path File.dirname(__FILE__)
@ -49,7 +50,7 @@ module Seminar
:active_for_action=>{'admin/seminars'=>'enquiry_for_applicants'},
:available_for => 'users'
end
end
end
end
end