cms-fortress 0.2.0

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.
Files changed (89) hide show
  1. data/.document +5 -0
  2. data/.rvmrc +1 -0
  3. data/Gemfile +15 -0
  4. data/Gemfile.lock +161 -0
  5. data/LICENSE.txt +20 -0
  6. data/README.rdoc +38 -0
  7. data/Rakefile +56 -0
  8. data/VERSION +1 -0
  9. data/app/assets/javascripts/cms/fortress/bootstrap-affix.js +117 -0
  10. data/app/assets/javascripts/cms/fortress/bootstrap-alert.js +99 -0
  11. data/app/assets/javascripts/cms/fortress/bootstrap-button.js +105 -0
  12. data/app/assets/javascripts/cms/fortress/bootstrap-carousel.js +207 -0
  13. data/app/assets/javascripts/cms/fortress/bootstrap-collapse.js +167 -0
  14. data/app/assets/javascripts/cms/fortress/bootstrap-dropdown.js +165 -0
  15. data/app/assets/javascripts/cms/fortress/bootstrap-modal.js +247 -0
  16. data/app/assets/javascripts/cms/fortress/bootstrap-popover.js +114 -0
  17. data/app/assets/javascripts/cms/fortress/bootstrap-scrollspy.js +162 -0
  18. data/app/assets/javascripts/cms/fortress/bootstrap-tab.js +144 -0
  19. data/app/assets/javascripts/cms/fortress/bootstrap-tooltip.js +361 -0
  20. data/app/assets/javascripts/cms/fortress/bootstrap-transition.js +60 -0
  21. data/app/assets/javascripts/cms/fortress/bootstrap-typeahead.js +335 -0
  22. data/app/assets/javascripts/cms/fortress/bootstrap.js +2276 -0
  23. data/app/assets/javascripts/cms/fortress/cms_fortress.js +14 -0
  24. data/app/assets/javascripts/html5shiv.js +8 -0
  25. data/app/assets/stylesheets/cms/fortress/admin_overrides.css +11 -0
  26. data/app/assets/stylesheets/cms/fortress/bootstrap-responsive.css +1109 -0
  27. data/app/assets/stylesheets/cms/fortress/bootstrap.css +6158 -0
  28. data/app/assets/stylesheets/cms/fortress/session.css +39 -0
  29. data/app/controllers/cms/fortress/admin_controller.rb +17 -0
  30. data/app/controllers/cms/fortress/roles_controller.rb +84 -0
  31. data/app/controllers/cms/fortress/users_controller.rb +89 -0
  32. data/app/helpers/cms/fortress/application_helper.rb +27 -0
  33. data/app/helpers/cms/fortress/roles_helper.rb +2 -0
  34. data/app/models/cms/fortress.rb +5 -0
  35. data/app/models/cms/fortress/role.rb +17 -0
  36. data/app/models/cms/fortress/role_detail.rb +6 -0
  37. data/app/models/cms/fortress/user.rb +14 -0
  38. data/app/models/cms_ability.rb +32 -0
  39. data/app/views/cms/fortress/admin/design.html.haml +1 -0
  40. data/app/views/cms/fortress/admin/roles.html.haml +1 -0
  41. data/app/views/cms/fortress/admin/settings.html.haml +1 -0
  42. data/app/views/cms/fortress/admin/users.html.haml +1 -0
  43. data/app/views/cms/fortress/roles/_form.html.haml +19 -0
  44. data/app/views/cms/fortress/roles/edit.html.haml +5 -0
  45. data/app/views/cms/fortress/roles/index.html.haml +20 -0
  46. data/app/views/cms/fortress/roles/new.html.haml +5 -0
  47. data/app/views/cms/fortress/roles/show.html.haml +12 -0
  48. data/app/views/cms/fortress/shared/_admin_topnav.html.haml +19 -0
  49. data/app/views/cms/fortress/shared/_navbar.html.erb +14 -0
  50. data/app/views/cms/fortress/users/_form.html.haml +27 -0
  51. data/app/views/cms/fortress/users/edit.html.haml +5 -0
  52. data/app/views/cms/fortress/users/index.html.haml +20 -0
  53. data/app/views/cms/fortress/users/new.html.haml +5 -0
  54. data/app/views/cms_users/sessions/new.html.erb +19 -0
  55. data/app/views/layouts/cms/fortress/default.html.erb +96 -0
  56. data/app/views/layouts/cms/fortress/session.html.erb +31 -0
  57. data/app/views/layouts/cms_admin/_body.html.haml +22 -0
  58. data/app/views/layouts/cms_admin/_head.html.haml +14 -0
  59. data/app/views/layouts/cms_admin/_left.html.haml +18 -0
  60. data/cms-fortress.gemspec +148 -0
  61. data/config/initializers/devise.rb +243 -0
  62. data/config/locales/en.yml +25 -0
  63. data/config/roles.yml +10 -0
  64. data/config/routes.rb +34 -0
  65. data/db/migrate/01_devise_create_cms_fortress_users.rb +56 -0
  66. data/db/migrate/02_create_cms_fortress_role_details.rb +15 -0
  67. data/db/migrate/03_create_cms_fortress_roles.rb +33 -0
  68. data/lib/cms-fortress.rb +9 -0
  69. data/lib/cms/fortress/application_controller_methods.rb +14 -0
  70. data/lib/cms/fortress/auth.rb +11 -0
  71. data/lib/cms/fortress/comfortable_mexican_sofa.rb +8 -0
  72. data/lib/cms/fortress/devise.rb +3 -0
  73. data/lib/cms/fortress/rails/engine.rb +19 -0
  74. data/lib/generators/cms/fortress/USAGE +8 -0
  75. data/lib/generators/cms/fortress/fortress_generator.rb +17 -0
  76. data/lib/generators/cms/fortress/templates/README +23 -0
  77. data/lib/generators/comfy/cms/cms_generator.rb +55 -0
  78. data/test/fixtures/cms/fortress/role_details.yml +17 -0
  79. data/test/fixtures/cms/fortress/roles.yml +9 -0
  80. data/test/functional/cms/fortress/roles_controller_test.rb +49 -0
  81. data/test/functional/cms/fortress/users_controller_test.rb +49 -0
  82. data/test/helper.rb +18 -0
  83. data/test/test_cms-fortress.rb +7 -0
  84. data/test/unit/cms/fortress/role_detail_test.rb +7 -0
  85. data/test/unit/cms/fortress/role_test.rb +7 -0
  86. data/test/unit/cms/fortress/role_user_test.rb +7 -0
  87. data/test/unit/helpers/cms/fortress/roles_helper_test.rb +4 -0
  88. data/test/unit/helpers/cms/fortress/users_helper_test.rb +4 -0
  89. metadata +226 -0
@@ -0,0 +1,39 @@
1
+ /*
2
+ *= require ./bootstrap
3
+ *= require ./bootstrap-responsive
4
+ */
5
+
6
+ body {
7
+ padding-top: 40px;
8
+ padding-bottom: 40px;
9
+ background-color: #f5f5f5;
10
+ }
11
+
12
+ .form-signin {
13
+ max-width: 300px;
14
+ padding: 19px 29px 29px;
15
+ margin: 3em auto 20px;
16
+ background-color: #fff;
17
+ border: 1px solid #e5e5e5;
18
+ -webkit-border-radius: 5px;
19
+ -moz-border-radius: 5px;
20
+ border-radius: 5px;
21
+ -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.05);
22
+ -moz-box-shadow: 0 1px 2px rgba(0,0,0,.05);
23
+ box-shadow: 0 1px 2px rgba(0,0,0,.05);
24
+ }
25
+
26
+ .form-signin .form-signin-heading,
27
+ .form-signin .checkbox {
28
+ margin-bottom: 10px;
29
+ }
30
+
31
+ .form-signin input[type="text"],
32
+ .form-signin input[type="password"] {
33
+ font-size: 16px;
34
+ height: auto;
35
+ margin-bottom: 15px;
36
+ }
37
+
38
+ /*
39
+ */
@@ -0,0 +1,17 @@
1
+ module Cms
2
+ module Fortress
3
+ class AdminController < CmsAdmin::BaseController
4
+
5
+ def index
6
+
7
+ end
8
+
9
+ def roles
10
+ @roles = Role.all
11
+ end
12
+
13
+
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,84 @@
1
+ class Cms::Fortress::RolesController < CmsAdmin::BaseController
2
+
3
+ # GET /cms/fortress/roles
4
+ # GET /cms/fortress/roles.json
5
+ def index
6
+ @cms_fortress_roles = Cms::Fortress::Role.all
7
+
8
+ respond_to do |format|
9
+ format.html # index.html.erb
10
+ format.json { render json: @cms_fortress_roles }
11
+ end
12
+ end
13
+
14
+ # GET /cms/fortress/roles/1
15
+ # GET /cms/fortress/roles/1.json
16
+ def show
17
+ @cms_fortress_role = Cms::Fortress::Role.find(params[:id])
18
+
19
+ respond_to do |format|
20
+ format.html # show.html.erb
21
+ format.json { render json: @cms_fortress_role }
22
+ end
23
+ end
24
+
25
+ # GET /cms/fortress/roles/new
26
+ # GET /cms/fortress/roles/new.json
27
+ def new
28
+ @cms_fortress_role = Cms::Fortress::Role.new
29
+
30
+ respond_to do |format|
31
+ format.html # new.html.erb
32
+ format.json { render json: @cms_fortress_role }
33
+ end
34
+ end
35
+
36
+ # GET /cms/fortress/roles/1/edit
37
+ def edit
38
+ @cms_fortress_role = Cms::Fortress::Role.find(params[:id])
39
+ end
40
+
41
+ # POST /cms/fortress/roles
42
+ # POST /cms/fortress/roles.json
43
+ def create
44
+ @cms_fortress_role = Cms::Fortress::Role.new(params[:cms_fortress_role])
45
+
46
+ respond_to do |format|
47
+ if @cms_fortress_role.save
48
+ format.html { redirect_to @cms_fortress_role, notice: 'Role was successfully created.' }
49
+ format.json { render json: @cms_fortress_role, status: :created, location: @cms_fortress_role }
50
+ else
51
+ format.html { render action: "new" }
52
+ format.json { render json: @cms_fortress_role.errors, status: :unprocessable_entity }
53
+ end
54
+ end
55
+ end
56
+
57
+ # PUT /cms/fortress/roles/1
58
+ # PUT /cms/fortress/roles/1.json
59
+ def update
60
+ @cms_fortress_role = Cms::Fortress::Role.find(params[:id])
61
+
62
+ respond_to do |format|
63
+ if @cms_fortress_role.update_attributes(params[:cms_fortress_role])
64
+ format.html { redirect_to cms_fortress_roles_path, notice: 'Role was successfully updated.' }
65
+ format.json { head :no_content }
66
+ else
67
+ format.html { render action: "edit" }
68
+ format.json { render json: @cms_fortress_role.errors, status: :unprocessable_entity }
69
+ end
70
+ end
71
+ end
72
+
73
+ # DELETE /cms/fortress/roles/1
74
+ # DELETE /cms/fortress/roles/1.json
75
+ def destroy
76
+ @cms_fortress_role = Cms::Fortress::Role.find(params[:id])
77
+ @cms_fortress_role.destroy
78
+
79
+ respond_to do |format|
80
+ format.html { redirect_to cms_fortress_roles_url }
81
+ format.json { head :no_content }
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,89 @@
1
+ class Cms::Fortress::UsersController < CmsAdmin::BaseController
2
+ # GET /cms/fortress/users
3
+ # GET /cms/fortress/users.json
4
+ def index
5
+ @cms_fortress_users = Cms::Fortress::User.all
6
+
7
+ respond_to do |format|
8
+ format.html # index.html.erb
9
+ format.json { render json: @cms_fortress_users }
10
+ end
11
+ end
12
+
13
+ # GET /cms/fortress/users/1
14
+ # GET /cms/fortress/users/1.json
15
+ def show
16
+ @cms_fortress_user = Cms::Fortress::User.find(params[:id])
17
+
18
+ respond_to do |format|
19
+ format.html # show.html.erb
20
+ format.json { render json: @cms_fortress_user }
21
+ end
22
+ end
23
+
24
+ # GET /cms/fortress/users/new
25
+ # GET /cms/fortress/users/new.json
26
+ def new
27
+ @cms_fortress_user = Cms::Fortress::User.new
28
+
29
+ respond_to do |format|
30
+ format.html # new.html.erb
31
+ format.json { render json: @cms_fortress_user }
32
+ end
33
+ end
34
+
35
+ # GET /cms/fortress/users/1/edit
36
+ def edit
37
+ @cms_fortress_user = Cms::Fortress::User.find(params[:id])
38
+ end
39
+
40
+ # POST /cms/fortress/users
41
+ # POST /cms/fortress/users.json
42
+ def create
43
+ @cms_fortress_user = Cms::Fortress::User.new(params[:cms_fortress_user])
44
+
45
+ respond_to do |format|
46
+ if @cms_fortress_user.save
47
+ format.html { redirect_to cms_fortress_users_path, notice: 'User was successfully created.' }
48
+ format.json { render json: @cms_fortress_user, status: :created, location: @cms_fortress_user }
49
+ else
50
+ format.html { render action: "new" }
51
+ format.json { render json: @cms_fortress_user.errors, status: :unprocessable_entity }
52
+ end
53
+ end
54
+ end
55
+
56
+ # PUT /cms/fortress/users/1
57
+ # PUT /cms/fortress/users/1.json
58
+ def update
59
+ @cms_fortress_user = Cms::Fortress::User.find(params[:id])
60
+
61
+ user_params = params[:cms_fortress_user]
62
+ if user_params[:password].blank?
63
+ user_params.delete(:password)
64
+ user_params.delete(:password_confirmation) if user_params[:password_confirmation].blank?
65
+ end
66
+
67
+ respond_to do |format|
68
+ if @cms_fortress_user.update_attributes(user_params)
69
+ format.html { redirect_to cms_fortress_users_path, notice: 'User was successfully updated.' }
70
+ format.json { head :no_content }
71
+ else
72
+ format.html { render action: "edit" }
73
+ format.json { render json: @cms_fortress_user.errors, status: :unprocessable_entity }
74
+ end
75
+ end
76
+ end
77
+
78
+ # DELETE /cms/fortress/users/1
79
+ # DELETE /cms/fortress/users/1.json
80
+ def destroy
81
+ @cms_fortress_user = Cms::Fortress::User.find(params[:id])
82
+ @cms_fortress_user.destroy
83
+
84
+ respond_to do |format|
85
+ format.html { redirect_to cms_fortress_users_url }
86
+ format.json { head :no_content }
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,27 @@
1
+ module Cms
2
+ module Fortress
3
+
4
+ module ApplicationHelper
5
+
6
+ def admin_page?
7
+ controller_name.eql?('admin') && %w{settings roles users}.include?(action_name) ||
8
+ controller_name.eql?('sites') && %w{index}.include?(action_name) ||
9
+ controller_name.eql?('roles') ||
10
+ controller_name.eql?('users')
11
+ end
12
+
13
+ def design_page?
14
+ controller_name.eql?('admin') && %{design}.include?(action_name) ||
15
+ controller_name.eql?('layouts') ||
16
+ controller_name.eql?('snippets')
17
+ end
18
+
19
+ def content_page?
20
+ controller_name.eql?('pages') ||
21
+ controller_name.eql?('files')
22
+ end
23
+
24
+ end
25
+ end
26
+ end
27
+
@@ -0,0 +1,2 @@
1
+ module Cms::Fortress::RolesHelper
2
+ end
@@ -0,0 +1,5 @@
1
+ module Cms::Fortress
2
+ def self.table_name_prefix
3
+ 'cms_fortress_'
4
+ end
5
+ end
@@ -0,0 +1,17 @@
1
+ class Cms::Fortress::Role < ActiveRecord::Base
2
+ set_table_name :cms_fortress_roles
3
+ attr_accessible :description, :name
4
+ has_many :users
5
+ has_many :role_details
6
+
7
+ def load_defaults
8
+ file = File.expand_path(File.join(File.dirname(__FILE__), "../../../../", "config", "roles.yml"))
9
+ data = YAML.load_file(file)
10
+
11
+ data.each do |k,v|
12
+ role_details.build(:name => k.humanize, :command => k, :can_create => false, :can_update => false, :can_delete => false, :can_view => true)
13
+ v.each {|m| role_details.build(:name => m.humanize, :command => "#{k}.#{m}", :can_create => true, :can_update => true, :can_delete => true, :can_view => true) }
14
+ end
15
+ end
16
+
17
+ end
@@ -0,0 +1,6 @@
1
+ class Cms::Fortress::RoleDetail < ActiveRecord::Base
2
+ set_table_name :cms_fortress_role_details
3
+ attr_accessible :command, :can_create, :can_delete, :name, :can_update, :can_view
4
+ belongs_to :role
5
+
6
+ end
@@ -0,0 +1,14 @@
1
+ class Cms::Fortress::User < ActiveRecord::Base
2
+ set_table_name :cms_fortress_users
3
+ # Include default devise modules. Others available are:
4
+ # :token_authenticatable, :confirmable,
5
+ # :lockable, :timeoutable and :omniauthable
6
+ devise :database_authenticatable,
7
+ :recoverable, :rememberable, :trackable, :validatable
8
+
9
+ # Setup accessible (or protected) attributes for your model
10
+ attr_accessible :email, :password, :password_confirmation, :remember_me, :role_id
11
+ # attr_accessible :title, :body
12
+ belongs_to :role
13
+
14
+ end
@@ -0,0 +1,32 @@
1
+ class CmsAbility
2
+ include CanCan::Ability
3
+
4
+ def initialize(user)
5
+ # Define abilities for the passed in user here. For example:
6
+ #
7
+ # user ||= User.new # guest user (not logged in)
8
+ # if user.admin?
9
+ # can :manage, :all
10
+ # else
11
+ # can :read, :all
12
+ # end
13
+ #
14
+ # The first argument to `can` is the action you are giving the user
15
+ # permission to do.
16
+ # If you pass :manage it will apply to every action. Other common actions
17
+ # here are :read, :create, :update and :destroy.
18
+ #
19
+ # The second argument is the resource the user can perform the action on.
20
+ # If you pass :all it will apply to every resource. Otherwise pass a Ruby
21
+ # class of the resource.
22
+ #
23
+ # The third argument is an optional hash of conditions to further filter the
24
+ # objects.
25
+ # For example, here the user can only update published articles.
26
+ #
27
+ # can :update, Article, :published => true
28
+ #
29
+ # See the wiki for details:
30
+ # https://github.com/ryanb/cancan/wiki/Defining-Abilities
31
+ end
32
+ end
@@ -0,0 +1 @@
1
+ %h2 Design Dashboard
@@ -0,0 +1 @@
1
+ %h2 Settings Dashboard
@@ -0,0 +1,19 @@
1
+ = form_for @cms_fortress_role, :html => {:class => 'form-horizontal'} do |f|
2
+ - if @cms_fortress_role.errors.any?
3
+ #error_explanation
4
+ %h2= "#{pluralize(@cms_fortress_role.errors.count, "error")} prohibited this role from being saved:"
5
+ %ul
6
+ - @cms_fortress_role.errors.full_messages.each do |msg|
7
+ %li= msg
8
+
9
+ .control-group
10
+ = f.label :name, :class => 'control-label'
11
+ .controls
12
+ = f.text_field :name, :class => 'input-large'
13
+ .control-group
14
+ = f.label :description, :class => 'control-label'
15
+ .controls
16
+ = f.text_area :description, :rows => 2, :class => 'input-xxlarge'
17
+ .form-actions
18
+ = f.submit 'Save', :class => 'btn btn-primary'
19
+ = link_to 'Cancel', cms_fortress_roles_path, :class => 'btn'
@@ -0,0 +1,5 @@
1
+ .page-header
2
+ %h3= t('cms.fortress.roles.edit_title')
3
+
4
+ = render 'form'
5
+
@@ -0,0 +1,20 @@
1
+ .page-header
2
+ = link_to t('cms.fortress.roles.new_link'), new_cms_fortress_role_path, :class => 'btn pull-right'
3
+ %h2= t('cms.fortress.roles.title')
4
+
5
+ %table.table.table-hover.table-bordered
6
+ %tr
7
+ %th Name
8
+ %th{:style => 'width: 60%;'} Description
9
+ %th
10
+
11
+ - @cms_fortress_roles.each do |cms_fortress_role|
12
+ %tr
13
+ %td= cms_fortress_role.name
14
+ %td= cms_fortress_role.description
15
+ %td
16
+ .btn-group.pull-right
17
+ = link_to 'Show', cms_fortress_role, :class => 'btn btn-small btn-primary'
18
+ = link_to 'Edit', edit_cms_fortress_role_path(cms_fortress_role), :class => 'btn btn-small btn-primary'
19
+ = link_to 'Destroy', cms_fortress_role, :method => :delete, :data => { :confirm => 'Are you sure?' }, :class => 'btn btn-small btn-danger'
20
+
@@ -0,0 +1,5 @@
1
+ .page-header
2
+ %h3= t('cms.fortress.roles.new_title')
3
+
4
+ = render 'form'
5
+
@@ -0,0 +1,12 @@
1
+ .page-header
2
+ .btn-group.pull-right
3
+ = link_to t('.edit'), edit_cms_fortress_role_path(@cms_fortress_role), :class => 'btn'
4
+ = link_to t('cms.fortress.roles.back'), cms_fortress_roles_path, :class => 'btn'
5
+ %h2= "Role: #{ @cms_fortress_role.name }"
6
+ %p= @cms_fortress_role.description
7
+
8
+ %table.table
9
+ - @cms_fortress_role.role_details.each do |d|
10
+ %tr
11
+ %td= d.command
12
+ %td= d.can_create
@@ -0,0 +1,19 @@
1
+ .navbar.navbar-inverse.navbar-fixed-top
2
+ .navbar-inner
3
+ .navbar-container
4
+ %button.btn.btn-navbar{'type' => 'button', 'data-toggle' => 'collapse', 'data-target' => '.nav-collapse'}
5
+ %span.icon-bar
6
+ %span.icon-bar
7
+ %span.icon-bar
8
+ %a.brand{'href' => '#'}= t('cms.fortress.title')
9
+ .nav-collapse.collapse
10
+ %ul.nav
11
+ - if @site && !@site.new_record?
12
+ %li{:class => content_page? ? 'active' : ''}
13
+ = link_to t("cms.fortress.contents"), cms_admin_site_pages_path(@site)
14
+ %li{:class => design_page? ? 'active' : ''}
15
+ = link_to t("cms.fortress.design"), cms_admin_site_layouts_path(@site)
16
+ %li{:class => admin_page? ? 'active' : ''}
17
+ = link_to t("cms.fortress.settings"), cms_admin_sites_path
18
+ %li
19
+ = link_to "Logout", destroy_cms_user_session_path, :method => 'delete'