cms-fortress 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.rdoc +50 -3
- data/VERSION +1 -1
- data/app/controllers/cms/fortress/admin_controller.rb +0 -16
- data/app/helpers/cms/fortress/application_helper.rb +10 -10
- data/app/models/cms/fortress/role.rb +4 -12
- data/app/models/cms_ability.rb +26 -25
- data/app/views/admin/cms/pages/_form.html.haml +7 -6
- data/app/views/cms/fortress/roles/show.html.haml +2 -2
- data/app/views/cms/fortress/shared/_admin_topnav.html.haml +10 -6
- data/app/views/cms/fortress/shared/_page_extend.html.haml +6 -4
- data/app/views/layouts/admin/cms/_left.html.haml +15 -16
- data/cms-fortress.gemspec +2 -3
- data/lib/cms-fortress.rb +53 -0
- data/lib/cms/fortress/application_controller_methods.rb +22 -1
- data/lib/cms/fortress/routes/admin.rb +0 -3
- data/lib/generators/cms/fortress/fortress_generator.rb +10 -0
- metadata +2 -3
- data/.rvmrc +0 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 3dcc3b976c1e83c56a15ac187a00cc34eabd6d00
         | 
| 4 | 
            +
              data.tar.gz: 769030e4388d0733a4041d1d26b8eb7529752a3f
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: bcc9faa7bd1203baa3736678e33e144f41e59a91578e837729c653a9f1bca6d2767128fd18855a6f222398b218aa559e9a1cb96e8aeccaa2251e5e8e34a6ae23
         | 
| 7 | 
            +
              data.tar.gz: c835238762bf86ec188ffec4cc0aa0dcc3414277c48afe836c4522dd2bdbd98e98725fc8d514ad2a0d880e46b46c8621c9289bbc6ee9f25b0844b64f5e76c679
         | 
    
        data/README.rdoc
    CHANGED
    
    | @@ -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 | 
            -
            === | 
| 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.2
         | 
| @@ -14,22 +14,22 @@ module Cms | |
| 14 14 |  | 
| 15 15 |  | 
| 16 16 | 
             
                  def admin_page?
         | 
| 17 | 
            -
                    controller_name.eql?('admin') && %w{ | 
| 18 | 
            -
                       | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 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 | 
            -
                     | 
| 25 | 
            -
             | 
| 26 | 
            -
             | 
| 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 | 
            -
                     | 
| 31 | 
            -
             | 
| 32 | 
            -
             | 
| 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 | 
| 36 | 
            -
                      :command | 
| 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 | 
| 32 | 
            +
                      :can_view   => true
         | 
| 41 33 | 
             
                    ) unless role_details.map(&:command).include?("#{k}.#{m}")
         | 
| 42 34 | 
             
                  end
         | 
| 43 35 | 
             
                end
         | 
    
        data/app/models/cms_ability.rb
    CHANGED
    
    | @@ -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( | 
| 6 | 
            -
            #     if  | 
| 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 "#{  | 
| 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 | | 
| 21 | 
            -
                    can :view,  | 
| 22 | 
            -
                    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  | 
| 25 | 
            -
                       | 
| 26 | 
            -
                         | 
| 27 | 
            -
             | 
| 28 | 
            -
                         | 
| 29 | 
            -
             | 
| 30 | 
            -
                         | 
| 31 | 
            -
             | 
| 32 | 
            -
                         | 
| 33 | 
            -
             | 
| 34 | 
            -
                         | 
| 35 | 
            -
             | 
| 36 | 
            -
                         | 
| 37 | 
            -
             | 
| 38 | 
            -
                         | 
| 39 | 
            -
             | 
| 40 | 
            -
                         | 
| 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 | 
            -
             | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 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 | 
            -
             | 
| 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
         | 
| @@ -9,14 +9,18 @@ | |
| 9 9 | 
             
                  .nav-collapse.collapse
         | 
| 10 10 | 
             
                    %ul.nav
         | 
| 11 11 | 
             
                      - if @site && !@site.new_record?
         | 
| 12 | 
            -
                        - if can? :view,  | 
| 13 | 
            -
                          = topnav_item t("cms.fortress.contents"),  | 
| 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,  | 
| 16 | 
            -
                          = topnav_item t("cms.fortress.design"),  | 
| 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 | 
            -
             | 
| 19 | 
            -
             | 
| 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 | 
            -
             | 
| 2 | 
            -
              =  | 
| 3 | 
            -
             | 
| 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 | 
            -
             | 
| 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 | 
            -
                -  | 
| 7 | 
            -
                   | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 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 | 
            -
                -  | 
| 17 | 
            -
                  - if can? :view,  | 
| 18 | 
            -
                    =  | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 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 | 
            -
                -  | 
| 26 | 
            -
                  - if can? :view,  | 
| 27 | 
            -
                    =  | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 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 |  | 
    
        data/cms-fortress.gemspec
    CHANGED
    
    | @@ -5,11 +5,11 @@ | |
| 5 5 |  | 
| 6 6 | 
             
            Gem::Specification.new do |s|
         | 
| 7 7 | 
             
              s.name = "cms-fortress"
         | 
| 8 | 
            -
              s.version = "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- | 
| 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",
         | 
    
        data/lib/cms-fortress.rb
    CHANGED
    
    | @@ -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 | 
            -
                         | 
| 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. | 
| 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- | 
| 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
         |