Update README and add top_menu accessor for page
This commit is contained in:
+32
-1
@@ -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 <tt>app/controllers/pages_controller.rb</tt>:
|
||||
class PagesController
|
||||
include Cmtool::Includes::PagesController
|
||||
end
|
||||
|
||||
in <tt>app/models/page.rb</tt>:
|
||||
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'
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user