diff --git a/Gemfile b/Gemfile
index 61fffd8..b737a30 100644
--- a/Gemfile
+++ b/Gemfile
@@ -5,7 +5,7 @@ source "http://rubygems.org"
# development dependencies will be added by default to the :development group.
gemspec
-gem "rails", " ~> 4.2.3"
+gem "rails", " ~> 7.0.1"
group :assets do
gem 'sass-rails' #, ' ~> 5.0.0'
gem 'bourbon', '~> 4.3.1'
diff --git a/README.md b/README.md
index d94721f..2884e9b 100644
--- a/README.md
+++ b/README.md
@@ -120,7 +120,7 @@ If you add a method `cmtool_locale` to your application controller Cmtool will
take this value:
```ruby
class ApplicationController
- before_filter :set_locale
+ before_action :set_locale
private
diff --git a/lib/cmtool/engine.rb b/lib/cmtool/engine.rb
index de8ea0a..b9d5fc3 100644
--- a/lib/cmtool/engine.rb
+++ b/lib/cmtool/engine.rb
@@ -13,15 +13,28 @@ require 'tinymce-rails'
module Cmtool
class Engine < ::Rails::Engine
isolate_namespace Cmtool
- initializer "cmtool.build_menu" do
+ initializer 'cmtool.build_menu', after: 'load_config_initializers' do |app|
require 'email_validator'
- require 'bourbon'
+ #require 'bourbon'
require 'slim-rails'
require 'paperclip'
require 'devise'
require 'devise_simply_stored'
require 'jquery-rails'
require 'tinymce-rails'
+
+ require 'page' # app/models/page.rb
+ require 'user' # app/models/user.rb
+ require 'cmtool/yml_file'
+ require 'cmtool/keyword'
+ require 'cmtool/news'
+ require 'cmtool/faq'
+ require 'cmtool/quote'
+ require 'cmtool/contact_form'
+ require 'cmtool/newsletter_subscription'
+ require 'cmtool/image'
+ require 'cmtool/directory'
+
Cmtool::Menu.register do
group label: :site do
title t('cmtool.menu.site.title')
diff --git a/lib/cmtool/includes/pages_controller.rb b/lib/cmtool/includes/pages_controller.rb
index 74c011d..ed17e24 100644
--- a/lib/cmtool/includes/pages_controller.rb
+++ b/lib/cmtool/includes/pages_controller.rb
@@ -1,67 +1,68 @@
module Cmtool
- module Includes
- module PagesController
- extend ActiveSupport::Concern
- def home
- page_name = "home"
- @page = find_page(page_name)
- @sub_pages = @page.children.select{|child| child.in_menu.present? }
- render template: "pages/#{page_name}", layout: @page.layout.presence || ::Page.layouts.first.to_s, formats: [:html]
+ module Includes
+ module PagesController
+ extend ActiveSupport::Concern
+
+ def home
+ page_name = 'home'
+ @page = find_page(page_name)
+ @sub_pages = @page.children.select{|child| child.in_menu.present? }
+ render template: "pages/#{page_name}", layout: @page.layout.presence || ::Page.layouts.first.to_s, formats: [:html]
+ end
+
+ # General catcher for pages
+ def show
+ @page = ::Page.find_by_name_and_locale(params[:name], I18n.locale.to_s)
+ not_found and return unless @page
+
+ @sub_pages = [@page] + @page.children.select{|child| child.in_menu.present? }
+ template = "pages/#{@page.name}"
+ if template_exists?(template)
+ render template: template, formats: [:html], layout: @page.layout.presence || ::Page.layouts.first
+ return
+ else
+ render formats: [:html], layout: @page.layout.presence || ::Page.layouts.first
end
+ end
- # General catcher for pages
- def show
- @page = ::Page.find_by_name_and_locale(params[:name], I18n.locale.to_s)
- not_found and return unless @page
-
- @sub_pages = [@page] + @page.children.select{|child| child.in_menu.present? }
- template = "pages/#{@page.name}"
- if template_exists?(template)
- render template: template, formats: [:html], layout: @page.layout.presence || ::Page.layouts.first
- return
- else
- render formats: [:html], layout: @page.layout.presence || ::Page.layouts.first
- end
+ def not_found
+ @page = ::Page.find_by_name_and_locale('404', I18n.locale.to_s) || ::Page.new(name: '404', body: "404 Page Not Found")
+ @sub_pages = []
+ page_name_extension = params[:name].to_s[/(?<=\.)\w{2,4}$/]
+ format = %w[html css js json].find{|f| f == request.format.symbol.to_s or f == page_name_extension }.try(:to_sym) || :html
+ case format
+ when :json
+ render json: {}, status: 404
+ when :html
+ render template: 'pages/404', formats: [:html], layout: @page.layout.presence || ::Page.layouts.first.to_s, status: 404
+ else
+ render nothing: true, status: 404
end
+ end
- def not_found
- @page = ::Page.find_by_name_and_locale('404', I18n.locale.to_s) || ::Page.new(name: '404', body: "404 Page Not Found")
- @sub_pages = []
- page_name_extension = params[:name].to_s[/(?<=\.)\w{2,4}$/]
- format = %w[html css js json].find{|f| f == request.format.symbol.to_s or f == page_name_extension }.try(:to_sym) || :html
- case format
- when :json
- render json: {}, status: 404
- when :html
- render template: 'pages/404', formats: [:html], layout: @page.layout.presence || ::Page.layouts.first.to_s, status: 404
- else
- render nothing: true, status: 404
- end
- end
-
- def sitemap
- respond_to do |format|
- format.xml do
- pages_xml = ::Page.for_sitemap.map do |page|
- uri = page_url(page.name, locale: page.locale)
- "#{uri}#{page.updated_at.strftime('%Y-%m-%d')}"
- end.join("\n")
- result = <<-XML
+ def sitemap
+ respond_to do |format|
+ format.xml do
+ pages_xml = ::Page.for_sitemap.map do |page|
+ uri = page_url(page.name, locale: page.locale)
+ "#{uri}#{page.updated_at.strftime('%Y-%m-%d')}"
+ end.join("\n")
+ result = <<-XML
#{pages_xml}
- XML
- render xml: result
- end
+ XML
+ render xml: result
end
end
+ end
- private
+ private
- def find_page(name)
- ::Page.find_by_name_and_locale(name, I18n.locale.to_s) || ::Page.new(name: name, locale: I18n.locale.to_s)
- end
- end
- end
+ def find_page(name)
+ ::Page.find_by_name_and_locale(name, I18n.locale.to_s) || ::Page.new(name: name, locale: I18n.locale.to_s)
+ end
+ end
+ end
end