cms-fortress 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6c5f4c7b4d6f02f6dd8fa2989e5aded60c09d4b6
4
- data.tar.gz: 6bec6b1fcdd207cc46731691cab8fd479c7abcea
3
+ metadata.gz: 3dcc3b976c1e83c56a15ac187a00cc34eabd6d00
4
+ data.tar.gz: 769030e4388d0733a4041d1d26b8eb7529752a3f
5
5
  SHA512:
6
- metadata.gz: 7a097385abbf62c706491e7faf8db34b91130b845d55a3948b7ef39483a9bba2cd6d3993eac7a5528f9188f0e334af7abc0cf3fa92204462bc848dac811305bc
7
- data.tar.gz: cd6e48d2f3167886c1b744af90ca59757161f299fb99100a69e110de100c00f0e05d83baacb8b7245ece77cb6b0e60269e658f8f96da0dc429ebaacd36009add
6
+ metadata.gz: bcc9faa7bd1203baa3736678e33e144f41e59a91578e837729c653a9f1bca6d2767128fd18855a6f222398b218aa559e9a1cb96e8aeccaa2251e5e8e34a6ae23
7
+ data.tar.gz: c835238762bf86ec188ffec4cc0aa0dcc3414277c48afe836c4522dd2bdbd98e98725fc8d514ad2a0d880e46b46c8621c9289bbc6ee9f25b0844b64f5e76c679
@@ -26,16 +26,63 @@ Then from the Rails project's root run:
26
26
  After that run your app and navigate to http://localhost:3000/cms-admin to start creating your pages, and also don't forget to delete your public/index.html file.
27
27
 
28
28
  login using the following info below:
29
-
29
+
30
30
  username: admin@cmsfortress.com
31
31
  password: 1234qwer
32
32
 
33
- ===TODO: Customization documents and sample
33
+ ===Adding custom role details
34
+
35
+ You can create a custom role ability via a three-step process.
36
+
37
+ 1: Edit <tt>config/roles.yml</tt> and add the new role under the category you wish.
38
+
39
+ contents:
40
+ - pages
41
+ - files
42
+ - page.review
43
+ - page.publish
44
+ designs:
45
+ - layouts
46
+ - snippets
47
+ settings:
48
+ - sites
49
+ - roles
50
+ - users
51
+ - *my_role_detail*
52
+
53
+ 2: Configure cms-fortress to add a new resource. Add this in an initializer:
54
+
55
+ Cms::Fortress.configure do |config|
56
+ config.settings_resources << {
57
+ :name => 'my_role_detail',
58
+ :title => 'i18n.label.title', # this is passed to the t() function - can be plain text
59
+ :path => 'admin_my_role_details_path'
60
+ }
61
+ # the other two lists are "content_resources" and "design_resources"
62
+ end
63
+
64
+ The path is eval'd at runtime, so you can use Rails helper methods such as
65
+ +current_user+ or <tt>@site</tt> in it. If the result is nil, the link will not show up
66
+ in the left nav bar.
67
+
68
+ 3: Restart the server. Go into each Role you have defined and click
69
+ "Load New Roles". Voila!
70
+
71
+ === Other configuration
72
+
73
+ You can turn off page workflow or page caching via configuration:
74
+
75
+ Cms::Fortress.configure do |config|
76
+ config.enable_page_workflow = false
77
+ config.enable_page_caching = false
78
+ end
79
+
80
+ ===TODO: More customization documents and sample
34
81
 
35
82
  For more Comfortable Mexican Sofa awesomeness visit the wiki page here https://github.com/comfy/comfortable-mexican-sofa/wiki
36
83
 
37
84
  == Contributing to cms-fortress
38
-
85
+
39
86
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
40
87
  * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
41
88
  * Fork the project.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.1
1
+ 1.1.2
@@ -2,22 +2,6 @@ module Cms
2
2
  module Fortress
3
3
  class AdminController < Admin::Cms::BaseController
4
4
 
5
- def designs
6
-
7
- end
8
-
9
- def settings
10
-
11
- end
12
-
13
- def contents
14
-
15
- end
16
-
17
- def index
18
-
19
- end
20
-
21
5
  def roles
22
6
  @roles = Role.all
23
7
  end
@@ -14,22 +14,22 @@ module Cms
14
14
 
15
15
 
16
16
  def admin_page?
17
- controller_name.eql?('admin') && %w{settings roles users}.include?(action_name) ||
18
- controller_name.eql?('sites') && %w{index}.include?(action_name) ||
19
- controller_name.eql?('roles') ||
20
- controller_name.eql?('users')
17
+ controller_name.eql?('admin') && %w{roles users}.include?(action_name) ||
18
+ Cms::Fortress.configuration.settings_resources.
19
+ map { |resource| resource[:name] }.
20
+ include?(controller_name)
21
21
  end
22
22
 
23
23
  def design_page?
24
- controller_name.eql?('admin') && %{design}.include?(action_name) ||
25
- controller_name.eql?('layouts') ||
26
- controller_name.eql?('snippets')
24
+ Cms::Fortress.configuration.design_resources.
25
+ map { |resource| resource[:name] }.
26
+ include?(controller_name)
27
27
  end
28
28
 
29
29
  def content_page?
30
- controller_name.eql?('admin') && %{contents}.include?(action_name) ||
31
- controller_name.eql?('pages') ||
32
- controller_name.eql?('files')
30
+ Cms::Fortress.configuration.content_resources.
31
+ map { |resource| resource[:name] }.
32
+ include?(controller_name)
33
33
  end
34
34
 
35
35
  end
@@ -21,23 +21,15 @@ class Cms::Fortress::Role < ActiveRecord::Base
21
21
  def load_from_file(file)
22
22
  data = YAML.load_file(file)
23
23
  data.each do |k,v|
24
- role_details.build(
25
- :name => k.humanize,
26
- :command => k,
27
- :can_create => false,
28
- :can_update => false,
29
- :can_delete => false,
30
- :can_view => true
31
- ) unless role_details.map(&:command).include?(k)
32
-
33
24
  v.each do |m|
25
+ description = m.split('.').map(&:humanize).join(' - ')
34
26
  role_details.build(
35
- :name => m.humanize,
36
- :command => "#{k}.#{m}",
27
+ :name => description,
28
+ :command => "#{k}.#{m}",
37
29
  :can_create => true,
38
30
  :can_update => true,
39
31
  :can_delete => true,
40
- :can_view => true
32
+ :can_view => true
41
33
  ) unless role_details.map(&:command).include?("#{k}.#{m}")
42
34
  end
43
35
  end
@@ -1,15 +1,15 @@
1
1
  # Create a generator for an override file for this class
2
2
  # sample below:
3
3
  # class Ability < CmsAbility
4
- #
5
- # def setup_role(role)
6
- # if role.command.eql?('contents.blog')
4
+ #
5
+ # def setup_role(role_detail, user)
6
+ # if role_detail.command.eql?('contents.blog')
7
7
  # can :manage, Blog
8
8
  # else
9
- # warn "#{ role.command } is not yet handled."
9
+ # warn "#{ role_detail.command } is not yet handled."
10
10
  # end
11
11
  # end
12
- #
12
+ #
13
13
  # end
14
14
  class CmsAbility
15
15
  include CanCan::Ability
@@ -17,27 +17,28 @@ class CmsAbility
17
17
  def initialize(user)
18
18
 
19
19
  if user && user.role && user.role.role_details
20
- user.role.role_details.each do |role|
21
- can :view, role.command if role.can_view?
22
- can :manage, role.command if role.can_manage?
20
+ user.role.role_details.each do |role_detail|
21
+ can :view, role_detail.command if role_detail.can_view?
22
+ can :manage, role_detail.command if role_detail.can_manage?
23
23
 
24
- if role.can_manage?
25
- if role.command.eql?("settings.roles")
26
- can :manage, Cms::Fortress::Role
27
- elsif role.command.eql?("settings.sites")
28
- can :manage, Cms::Site
29
- elsif role.command.eql?("settings.users")
30
- can :manage, Cms::Fortress::User
31
- elsif role.command.eql?("contents.pages")
32
- can :manage, Cms::Page
33
- elsif role.command.eql?("contents.files")
34
- can :manage, Cms::File
35
- elsif role.command.eql?("designs.layouts")
36
- can :manage, Cms::Layout
37
- elsif role.command.eql?("designs.snippets")
38
- can :manage, Cms::Snippet
39
- else
40
- setup_role(role) if defined?(setup_role)
24
+ if role_detail.can_manage?
25
+ case role_detail.command
26
+ when 'settings.roles'
27
+ can :manage, Cms::Fortress::Role
28
+ when 'settings.sites'
29
+ can :manage, Cms::Site
30
+ when 'settings.users'
31
+ can :manage, Cms::Fortress::User
32
+ when 'contents.pages'
33
+ can :manage, Cms::Page
34
+ when 'contents.files'
35
+ can :manage, Cms::File
36
+ when 'designs.layouts'
37
+ can :manage, Cms::Layout
38
+ when 'designs.snippets'
39
+ can :manage, Cms::Snippet
40
+ else
41
+ setup_role(role_detail, user) if defined?(setup_role)
41
42
  end
42
43
  end
43
44
  end
@@ -2,10 +2,10 @@
2
2
 
3
3
  - content_for :right_column do
4
4
  #form-save.box
5
-
6
- /%label.checkbox.inline
7
- / %input{:type => 'checkbox'}
8
- / = ::Cms::Page.human_attribute_name(:is_published)
5
+ - unless Cms::Fortress.configuration.enable_page_workflow
6
+ %label.checkbox.inline
7
+ %input{:type => 'checkbox'}
8
+ = ::Cms::Page.human_attribute_name(:is_published)
9
9
  %button.btn.btn-small.btn-primary.pull-right
10
10
  = render :partial => 'admin/cms/files/index'
11
11
 
@@ -20,7 +20,7 @@
20
20
 
21
21
  - if (options = ::Cms::Layout.options_for_select(@site)).present?
22
22
  = form.select :layout_id, options, {}, 'data-url' => form_blocks_admin_cms_site_page_path(@site, @page.id.to_i)
23
-
23
+
24
24
  - if (options = ::Cms::Page.options_for_select(@site, @page)).present?
25
25
  = form.select :parent_id, options
26
26
 
@@ -33,7 +33,8 @@
33
33
 
34
34
  = render :partial => 'form_blocks'
35
35
 
36
- =# form.check_box :is_published, :label => t('.is_published')
36
+ - unless Cms::Fortress.configuration.enable_page_workflow
37
+ = form.check_box :is_published, :label => t('.is_published')
37
38
  = render :partial => 'cms/fortress/shared/page_extend', :locals => {form: form}
38
39
 
39
40
  = render 'admin/cms/partials/page_form_after', :object => form
@@ -11,12 +11,12 @@
11
11
 
12
12
  %table.table
13
13
  %tr
14
- %th
14
+ %th
15
15
  %th Show
16
16
  %th Manage
17
17
  = f.fields_for :role_details do |role|
18
18
  %tr
19
- %td= role.object.command
19
+ %td= role.object.name
20
20
  %td= role.check_box :can_view
21
21
  %td= role.check_box :can_create
22
22
 
@@ -9,14 +9,18 @@
9
9
  .nav-collapse.collapse
10
10
  %ul.nav
11
11
  - if @site && !@site.new_record?
12
- - if can? :view, 'contents'
13
- = topnav_item t("cms.fortress.contents"), cms_fortress_contents_path, content_page?
12
+ - if Cms::Fortress.configuration.content_resources.any? {|resource| can? :view, "contents.#{resource[:name]}" }
13
+ = topnav_item t("cms.fortress.contents"), |
14
+ @site && !@site.new_record? ? admin_cms_site_pages_path(@site) : admin_cms_sites_pages_path, |
15
+ content_page?
14
16
 
15
- - if can? :view, 'designs'
16
- = topnav_item t("cms.fortress.design"), cms_fortress_design_path, design_page?
17
+ - if Cms::Fortress.configuration.design_resources.any? {|resource| can? :view, "designs.#{resource[:name]}" }
18
+ = topnav_item t("cms.fortress.design"), |
19
+ @site && !@site.new_record? ? admin_cms_site_layouts_path(@site) : admin_cms_sites_pages_path, |
20
+ design_page?
17
21
 
18
- - if can? :view, 'settings'
19
- = topnav_item t("cms.fortress.settings"), cms_fortress_settings_path, admin_page?
22
+ - if Cms::Fortress.configuration.settings_resources.any? {|resource| can? :view, "settings.#{resource[:name]}" }
23
+ = topnav_item t("cms.fortress.settings"), admin_cms_sites_path, admin_page?
20
24
 
21
25
  = render 'cms/fortress/admin/topnav'
22
26
  %ul.nav.nav-pill.pull-right
@@ -1,5 +1,7 @@
1
- = form.fields_for :page_workflow do |wf|
2
- = wf.select :status_id, Cms::PageWorkflow.statuses_for_select(can?(:manage, 'contents.page.publish'), can?(:manage, 'contents.page.review')), {}, {class: "status-control"}
3
- = wf.text_field :published_date, label: 'Published', class: "status-control", :data => {:utc_date => (@page.page_workflow.published_date.nil? ? Time.now : @page.page_workflow.published_date).strftime("%d %B, %Y") }
1
+ - if Cms::Fortress.configuration.enable_page_workflow
2
+ = form.fields_for :page_workflow do |wf|
3
+ = wf.select :status_id, Cms::PageWorkflow.statuses_for_select(can?(:manage, 'contents.page.publish'), can?(:manage, 'contents.page.review')), {}, {class: "status-control"}
4
+ = wf.text_field :published_date, label: 'Published', class: "status-control", :data => {:utc_date => (@page.page_workflow.published_date.nil? ? Time.now : @page.page_workflow.published_date).strftime("%d %B, %Y") }
4
5
 
5
- = form.select :cached_timeout, Cms::PageWorkflow.cached_timeout_for_select, {label: 'Cached Timeout'}, {class: 'status-control'}
6
+ - if Cms::Fortress.configuration.enable_page_caching
7
+ = form.select :cached_timeout, Cms::PageWorkflow.cached_timeout_for_select, {label: 'Cached Timeout'}, {class: 'status-control'}
@@ -3,30 +3,29 @@
3
3
 
4
4
  %ul.navigation
5
5
  - if admin_page?
6
- - if can? :view, 'settings.sites'
7
- = leftnav_item t('admin.cms.base.sites'), admin_cms_sites_path, :active => ['admin/cms/sites']
8
- - if can? :view, 'settings.roles'
9
- = leftnav_item t('cms.fortress.roles.title'), cms_fortress_roles_path
10
- - if can? :view, 'settings.users'
11
- = leftnav_item t('cms.fortress.users.title'), cms_fortress_users_path
6
+ - Cms::Fortress.configuration.settings_resources.each do |resource|
7
+ - if can? :view, "settings.#{resource[:name]}"
8
+ - path = begin; eval(resource[:path]); rescue; end
9
+ - if path
10
+ = leftnav_item t(resource[:title]), path
12
11
 
13
12
  = render 'cms/fortress/admin/left_settings_nav'
14
13
 
15
14
  - elsif design_page?
16
- - if @site && !@site.new_record?
17
- - if can? :view, 'designs.layouts'
18
- = leftnav_item t('admin.cms.base.layouts'), admin_cms_site_layouts_path(@site)
19
- - if can? :view, 'designs.snippets'
20
- = leftnav_item t('admin.cms.base.snippets'), admin_cms_site_snippets_path(@site)
15
+ - Cms::Fortress.configuration.design_resources.each do |resource|
16
+ - if can? :view, "designs.#{resource[:name]}"
17
+ - path = begin; eval(resource[:path]);rescue;end
18
+ - if path
19
+ = leftnav_item t(resource[:title]), path
21
20
 
22
21
  = render 'cms/fortress/admin/left_designs_nav'
23
22
 
24
23
  - elsif content_page?
25
- - if @site && !@site.new_record?
26
- - if can? :view, 'contents.pages'
27
- = leftnav_item t('admin.cms.base.pages'), admin_cms_site_pages_path(@site)
28
- - if can? :view, 'contents.files'
29
- = leftnav_item t('admin.cms.base.files'), admin_cms_site_files_path(@site)
24
+ - Cms::Fortress.configuration.content_resources.each do |resource|
25
+ - if can? :view, "contents.#{resource[:name]}"
26
+ - path = begin; eval(resource[:path]);rescue;end
27
+ - if path
28
+ = leftnav_item t(resource[:title]), path
30
29
 
31
30
  = render 'cms/fortress/admin/left_contents_nav'
32
31
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "cms-fortress"
8
- s.version = "1.1.1"
8
+ s.version = "1.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Melvin Sembrano"]
12
- s.date = "2014-02-04"
12
+ s.date = "2014-02-16"
13
13
  s.description = "Comfortable Mexican Sofa (CMS) - User and role management extension"
14
14
  s.email = "melvinsembrano@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -20,7 +20,6 @@ Gem::Specification.new do |s|
20
20
  ".document",
21
21
  ".rbenv-gemsets",
22
22
  ".ruby-version",
23
- ".rvmrc",
24
23
  "Gemfile",
25
24
  "Gemfile.lock",
26
25
  "LICENSE.txt",
@@ -13,3 +13,56 @@ require_relative 'cms/fortress/comfortable_mexican_sofa'
13
13
  require_relative 'cms/fortress/devise'
14
14
  require_relative 'cms/fortress/routing'
15
15
  require_relative '../app/models/cms_ability'
16
+
17
+ module Cms
18
+ module Fortress
19
+ class Configuration
20
+
21
+ attr_accessor :content_resources
22
+ attr_accessor :design_resources
23
+ attr_accessor :settings_resources
24
+ attr_accessor :enable_page_workflow
25
+ attr_accessor :enable_page_caching
26
+
27
+ def initialize
28
+ self.class.send(:include, Rails.application.routes.url_helpers)
29
+ @enable_page_workflow = true
30
+ @enable_page_caching = true
31
+ @content_resources = [
32
+ {:name => 'pages', :title => 'admin.cms.base.pages',
33
+ :path => 'admin_cms_site_pages_path(@site) if @site && !@site.new_record?'},
34
+ {:name => 'files', :title => 'admin.cms.base.files',
35
+ :path => 'admin_cms_site_files_path(@site) if @site && !@site.new_record?'}
36
+ ]
37
+ @design_resources = [
38
+ {:name => 'layouts', :title => 'admin.cms.base.layouts',
39
+ :path => 'admin_cms_site_layouts_path(@site) if @site && !@site.new_record?'
40
+ },
41
+ {:name => 'snippets', :title => 'admin.cms.base.snippets',
42
+ :path => 'admin_cms_site_snippets_path(@site) if @site && !@site.new_record?'}
43
+ ]
44
+ @settings_resources = [
45
+ {:name => 'sites', :title => 'admin.cms.base.sites',
46
+ :path => 'admin_cms_sites_path'},
47
+ {:name => 'roles', :title => 'cms.fortress.roles.title',
48
+ :path => 'cms_fortress_roles_path'},
49
+ {:name => 'users', :title => 'cms.fortress.users.title',
50
+ :path => 'cms_fortress_users_path'}
51
+ ]
52
+ end
53
+
54
+ end
55
+
56
+ class << self
57
+ def configure
58
+ yield configuration
59
+ end
60
+
61
+ def configuration
62
+ @configuration ||= Configuration.new
63
+ end
64
+
65
+ end
66
+
67
+ end
68
+ end
@@ -27,7 +27,28 @@ module Cms
27
27
  base.class_eval do
28
28
 
29
29
  rescue_from CanCan::AccessDenied do |ex|
30
- redirect_to cms_fortress_unauthorised_path #, :alert => ex.message
30
+ # if cannot view page check if can on files
31
+ if controller_name.eql?('pages')
32
+ if can? :view, Cms::File
33
+ redirect_to admin_cms_site_files_path
34
+ else
35
+ redirect_to cms_fortress_unauthorised_path
36
+ end
37
+ elsif controller_name.eql?('layouts')
38
+ if can? :view, Cms::Snippet
39
+ redirect_to admin_cms_site_snippets_path
40
+ else
41
+ redirect_to cms_fortress_unauthorised_path
42
+ end
43
+ elsif controller_name.eql?('sites')
44
+ if can? :view, Cms::Fortress::Role
45
+ redirect_to cms_fortress_roles_path
46
+ else
47
+ redirect_to cms_fortress_unauthorised_path
48
+ end
49
+ else
50
+ redirect_to cms_fortress_unauthorised_path #, :alert => ex.message
51
+ end
31
52
  end
32
53
 
33
54
  end
@@ -20,9 +20,6 @@ class ActionDispatch::Routing::Mapper
20
20
  end
21
21
  resources :users, :as => 'cms_fortress_users'
22
22
 
23
- get 'settings' => 'admin#settings', :as => 'cms_fortress_settings'
24
- get 'design' => 'admin#design', :as => 'cms_fortress_design'
25
- get 'contents' => 'admin#contents', :as => 'cms_fortress_contents'
26
23
  get 'settings/users' => 'admin#users', :as => 'cms_fortress_user_settings'
27
24
  get 'unauthorised' => 'admin#unauthorised', :as => 'cms_fortress_unauthorised'
28
25
 
@@ -14,6 +14,16 @@ class Cms::FortressGenerator < Rails::Generators::Base
14
14
  def generate_migrations
15
15
  rake("cms_fortress_engine:install:migrations")
16
16
  end
17
+
18
+ def copy_files
19
+ log 'Copying files...'
20
+ files = [
21
+ 'config/roles.yml'
22
+ ]
23
+ files.each do |file|
24
+ copy_file file, file
25
+ end
26
+ end
17
27
  =begin
18
28
  def generate_assets
19
29
  directory 'app/assets/javascripts/cms/fortress',
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cms-fortress
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Melvin Sembrano
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-04 00:00:00.000000000 Z
11
+ date: 2014-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -147,7 +147,6 @@ files:
147
147
  - .document
148
148
  - .rbenv-gemsets
149
149
  - .ruby-version
150
- - .rvmrc
151
150
  - Gemfile
152
151
  - Gemfile.lock
153
152
  - LICENSE.txt
data/.rvmrc DELETED
@@ -1 +0,0 @@
1
- rvm use --create 1.9.3@cms-fortress