diff --git a/README.rdoc b/README.rdoc index 9c78f12..a959d44 100644 --- a/README.rdoc +++ b/README.rdoc @@ -31,12 +31,43 @@ This will add some gems you might like anyway, here a list: * paperclip * email_validator (validates :email, email: true) +=== Controllers + +in app/controllers/pages_controller.rb: + class PagesController + include Cmtool::Includes::PagesController + end + +in app/models/page.rb: + class Page + include Cmtool::Includes::Page + + def self.layouts + %w[home application contact] + end + end + +=== Securing + +Cmtool is looking for an authorize_cmtool method present in the application controller. Something like: + class ApplicationController + ... + + private + + def authorize_cmtool + redirect_to root_path, alert: t('general.unauthorized'), status: 403 unless current_user.present? && current_user.admin? + end + end + === Routing Add the following routes: devise_for :users, :controllers => {:sessions => 'cmtool/sessions', :passwords => 'cmtool/passwords'} mount Cmtool::Engine => '/cmtool' - match "/:name" => "pages#show" + scope '(/:locale)', constraints: {locale: /nl|be|de|fr|en/}, defaults: { locale: :nl } do + get "/:name" => "pages#show", constraints: {name: /.*/}, as: :page + end match "/*url" => "pages#not_found" root :to => 'pages#home' diff --git a/lib/cmtool/engine.rb b/lib/cmtool/engine.rb index 932409e..66a5a4f 100644 --- a/lib/cmtool/engine.rb +++ b/lib/cmtool/engine.rb @@ -6,11 +6,11 @@ require 'devise' require 'devise_simply_stored' require 'haml-rails' require 'sass-rails' -require 'tinymce-rails' require 'paperclip' +require 'jquery-rails' require 'bourbon' =end -require 'jquery-rails' +require 'tinymce-rails' module Cmtool class Engine < ::Rails::Engine isolate_namespace Cmtool diff --git a/lib/cmtool/includes/page.rb b/lib/cmtool/includes/page.rb index 2c3f15a..952e9cf 100644 --- a/lib/cmtool/includes/page.rb +++ b/lib/cmtool/includes/page.rb @@ -16,7 +16,7 @@ module Cmtool klass.property :priority, type: Float, default: 0.5 klass.property :active, type: :boolean, default: true klass.property :layout - klass.property :in_menu, type: :boolean + klass.property :in_menu, type: :boolean, default: true klass.has_ancestry :by_property => :locale @@ -66,6 +66,10 @@ module Cmtool def default_locale :en end + + def top_menu + Page.roots(I18n.locale).select(&:in_menu?) + end end end end