cms-fortress 1.0.7 → 1.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/app/controllers/cms/fortress/users/sessions_controller.rb +4 -0
- data/app/models/cms/fortress/role.rb +0 -1
- data/app/models/cms/page_workflow.rb +13 -0
- data/app/models/cms_ability.rb +14 -7
- data/app/views/admin/cms/pages/_form.html.haml +2 -19
- data/app/views/cms/fortress/shared/_page_extend.html.haml +5 -0
- data/app/views/cms/fortress/shared/_page_extend_js.html.haml +16 -0
- data/cms-fortress.gemspec +6 -3
- data/db/migrate/05_add_caching_info_to_pages.rb +5 -0
- data/lib/cms/fortress/application_controller_methods.rb +9 -1
- data/lib/cms/fortress/content_renderer.rb +1 -4
- data/lib/cms/fortress/rails/engine.rb +6 -6
- data/lib/cms/fortress/routes/admin.rb +8 -3
- data/lib/generators/cms/fortress/fortress_generator.rb +2 -2
- metadata +7 -4
- data/app/views/.DS_Store +0 -0
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.8
|
@@ -11,7 +11,6 @@ class Cms::Fortress::Role < ActiveRecord::Base
|
|
11
11
|
if File.exist?(file = File.join(Rails.root, "config", "roles.yml"))
|
12
12
|
load_from_file(file)
|
13
13
|
end
|
14
|
-
puts file
|
15
14
|
|
16
15
|
file = File.expand_path(File.join(File.dirname(__FILE__), "../../../../", "config", "roles.yml"))
|
17
16
|
load_from_file(file)
|
@@ -24,6 +24,19 @@ class Cms::PageWorkflow < ActiveRecord::Base
|
|
24
24
|
ret
|
25
25
|
end
|
26
26
|
|
27
|
+
def self.cached_timeout_for_select
|
28
|
+
{
|
29
|
+
"Uncached" => 0,
|
30
|
+
"15 minutes" => 15.minutes,
|
31
|
+
"30 minutes" => 30.minutes,
|
32
|
+
"1 hour" => 1.hour,
|
33
|
+
"3 hours" => 3.hours,
|
34
|
+
"24 hours" => 1.day,
|
35
|
+
"15 days" => 15.days,
|
36
|
+
"30 days" => 30.days
|
37
|
+
}.map {|k,v| [k, v.to_i] }
|
38
|
+
end
|
39
|
+
|
27
40
|
def page_published?
|
28
41
|
(status_id.eql?(3) || status_id.eql?(2)) && published_date <= Date.today
|
29
42
|
end
|
data/app/models/cms_ability.rb
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
# Create a generator for an override file for this class
|
2
|
+
# sample below:
|
3
|
+
# class Ability < CmsAbility
|
4
|
+
#
|
5
|
+
# def setup_role(role)
|
6
|
+
# if role.command.eql?('contents.blog')
|
7
|
+
# can :manage, Blog
|
8
|
+
# else
|
9
|
+
# warn "#{ role.command } is not yet handled."
|
10
|
+
# end
|
11
|
+
# end
|
12
|
+
#
|
13
|
+
# end
|
1
14
|
class CmsAbility
|
2
15
|
include CanCan::Ability
|
3
16
|
|
@@ -24,7 +37,7 @@ class CmsAbility
|
|
24
37
|
elsif role.command.eql?("designs.snippets")
|
25
38
|
can :manage, Cms::Snippet
|
26
39
|
else
|
27
|
-
setup_role(role)
|
40
|
+
setup_role(role) if defined?(setup_role)
|
28
41
|
end
|
29
42
|
end
|
30
43
|
end
|
@@ -32,10 +45,4 @@ class CmsAbility
|
|
32
45
|
|
33
46
|
end
|
34
47
|
|
35
|
-
# override this if you have custom role assignment
|
36
|
-
def setup_role(role)
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
|
41
48
|
end
|
@@ -34,9 +34,7 @@
|
|
34
34
|
= render :partial => 'form_blocks'
|
35
35
|
|
36
36
|
=# form.check_box :is_published, :label => t('.is_published')
|
37
|
-
=
|
38
|
-
= wf.select :status_id, Cms::PageWorkflow.statuses_for_select(can?(:manage, 'contents.page.publish'), can?(:manage, 'contents.page.review')), {}, {class: "status-control"}
|
39
|
-
= wf.text_field :published_date, class: "status-control", :data => {:utc_date => (@page.page_workflow.published_date.nil? ? Time.now : @page.page_workflow.published_date).strftime("%d %B, %Y") }
|
37
|
+
= render :partial => 'cms/fortress/shared/page_extend', :locals => {form: form}
|
40
38
|
|
41
39
|
= render 'admin/cms/partials/page_form_after', :object => form
|
42
40
|
|
@@ -45,19 +43,4 @@
|
|
45
43
|
= form.submit t(@page.new_record?? '.create' : '.update'), :class => 'btn btn-primary'
|
46
44
|
|
47
45
|
|
48
|
-
:
|
49
|
-
dateControl = $("#page_page_workflow_attributes_published_date")
|
50
|
-
wkControl = $("#page_page_workflow_attributes_status_id")
|
51
|
-
parentControl = $("#page_page_workflow_attributes_published_date").parents(".control-group:first")
|
52
|
-
|
53
|
-
dateControl.val(dateControl.data("utcDate")).datepicker(dateFormat: "d MM, yy")
|
54
|
-
|
55
|
-
if wkControl.val() in ["0","1"]
|
56
|
-
parentControl.hide()
|
57
|
-
|
58
|
-
wkControl.change ->
|
59
|
-
if $(this).val() in ["0","1"]
|
60
|
-
parentControl.hide()
|
61
|
-
else
|
62
|
-
parentControl.show()
|
63
|
-
|
46
|
+
= render :partial => 'cms/fortress/shared/page_extend_js'
|
@@ -0,0 +1,5 @@
|
|
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") }
|
4
|
+
|
5
|
+
= form.select :cached_timeout, Cms::PageWorkflow.cached_timeout_for_select, {label: 'Cached Timeout'}, {class: 'status-control'}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
:coffeescript
|
2
|
+
dateControl = $("#page_page_workflow_attributes_published_date")
|
3
|
+
wkControl = $("#page_page_workflow_attributes_status_id")
|
4
|
+
parentControl = $("#page_page_workflow_attributes_published_date").parents(".control-group:first")
|
5
|
+
|
6
|
+
dateControl.val(dateControl.data("utcDate")).datepicker(dateFormat: "d MM, yy")
|
7
|
+
|
8
|
+
if wkControl.val() in ["0","1"]
|
9
|
+
parentControl.hide()
|
10
|
+
|
11
|
+
wkControl.change ->
|
12
|
+
if $(this).val() in ["0","1"]
|
13
|
+
parentControl.hide()
|
14
|
+
else
|
15
|
+
parentControl.show()
|
16
|
+
|
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.0.
|
8
|
+
s.version = "1.0.8"
|
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 = "2013-12-
|
12
|
+
s.date = "2013-12-18"
|
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 = [
|
@@ -35,6 +35,7 @@ Gem::Specification.new do |s|
|
|
35
35
|
"app/assets/stylesheets/cms/fortress/session.css",
|
36
36
|
"app/controllers/cms/fortress/admin_controller.rb",
|
37
37
|
"app/controllers/cms/fortress/roles_controller.rb",
|
38
|
+
"app/controllers/cms/fortress/users/sessions_controller.rb",
|
38
39
|
"app/controllers/cms/fortress/users_controller.rb",
|
39
40
|
"app/helpers/cms/fortress/application_helper.rb",
|
40
41
|
"app/helpers/cms/fortress/roles_helper.rb",
|
@@ -44,7 +45,6 @@ Gem::Specification.new do |s|
|
|
44
45
|
"app/models/cms/fortress/user.rb",
|
45
46
|
"app/models/cms/page_workflow.rb",
|
46
47
|
"app/models/cms_ability.rb",
|
47
|
-
"app/views/.DS_Store",
|
48
48
|
"app/views/admin/cms/pages/_form.html.haml",
|
49
49
|
"app/views/admin/cms/partials/_body_before.html.haml",
|
50
50
|
"app/views/cms/fortress/admin/_leftnav.html.haml",
|
@@ -62,6 +62,8 @@ Gem::Specification.new do |s|
|
|
62
62
|
"app/views/cms/fortress/roles/show.html.haml",
|
63
63
|
"app/views/cms/fortress/shared/_admin_topnav.html.haml",
|
64
64
|
"app/views/cms/fortress/shared/_navbar.html.haml",
|
65
|
+
"app/views/cms/fortress/shared/_page_extend.html.haml",
|
66
|
+
"app/views/cms/fortress/shared/_page_extend_js.html.haml",
|
65
67
|
"app/views/cms/fortress/users/_form.html.haml",
|
66
68
|
"app/views/cms/fortress/users/edit.html.haml",
|
67
69
|
"app/views/cms/fortress/users/index.html.haml",
|
@@ -80,6 +82,7 @@ Gem::Specification.new do |s|
|
|
80
82
|
"db/migrate/02_create_cms_fortress_role_details.rb",
|
81
83
|
"db/migrate/03_create_cms_fortress_roles.rb",
|
82
84
|
"db/migrate/04_create_cms_page_workflows.rb",
|
85
|
+
"db/migrate/05_add_caching_info_to_pages.rb",
|
83
86
|
"lib/cms-fortress.rb",
|
84
87
|
"lib/cms/fortress/application_controller_methods.rb",
|
85
88
|
"lib/cms/fortress/auth.rb",
|
@@ -11,8 +11,16 @@ module Cms
|
|
11
11
|
admin_cms_path
|
12
12
|
end
|
13
13
|
|
14
|
+
def ability_class
|
15
|
+
if defined?(Ability) #File.exist?(File.join(Rails.root, "app", "models", "ability.rb"))
|
16
|
+
Ability
|
17
|
+
else
|
18
|
+
CmsAbility
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
14
22
|
def current_ability
|
15
|
-
@current_ability ||=
|
23
|
+
@current_ability ||= ability_class.new(current_cms_fortress_user)
|
16
24
|
end
|
17
25
|
|
18
26
|
def self.included(base)
|
@@ -7,14 +7,11 @@ module Cms
|
|
7
7
|
base.class_eval do
|
8
8
|
|
9
9
|
def render_html(status = 200)
|
10
|
-
|
11
10
|
fresh_when etag: @cms_page, last_modified: @cms_page.updated_at.utc, public: true
|
11
|
+
response.cache_control[:max_age] = @cms_page.cached_timeout.seconds
|
12
12
|
|
13
13
|
if @cms_layout = @cms_page.layout
|
14
14
|
|
15
|
-
#TODO: put the caching config in the page
|
16
|
-
response.cache_control[:max_age] = 5.minutes
|
17
|
-
|
18
15
|
app_layout = (@cms_layout.app_layout.blank? || request.xhr?) ? false : @cms_layout.app_layout
|
19
16
|
render(:inline => @cms_page.content, :layout => app_layout, :status => status, :content_type => 'text/html') unless performed?
|
20
17
|
else
|
@@ -4,7 +4,7 @@ module Cms
|
|
4
4
|
|
5
5
|
initializer 'cms-fortress.setup' do |app|
|
6
6
|
app.config.to_prepare do
|
7
|
-
Devise::SessionsController.layout "cms/fortress/session"
|
7
|
+
# Devise::SessionsController.layout "cms/fortress/session"
|
8
8
|
ApplicationController.helper(Cms::Fortress::ApplicationHelper)
|
9
9
|
|
10
10
|
Cms::ContentController.send(:include, Cms::Fortress::ContentRenderer)
|
@@ -12,27 +12,27 @@ module Cms
|
|
12
12
|
|
13
13
|
# Insert Roles
|
14
14
|
Admin::Cms::SitesController.class_eval do
|
15
|
-
|
15
|
+
before_action do
|
16
16
|
authorize! :manage, Cms::Site
|
17
17
|
end
|
18
18
|
end
|
19
19
|
Admin::Cms::LayoutsController.class_eval do
|
20
|
-
|
20
|
+
before_action do
|
21
21
|
authorize! :manage, Cms::Layout
|
22
22
|
end
|
23
23
|
end
|
24
24
|
Admin::Cms::SnippetsController.class_eval do
|
25
|
-
|
25
|
+
before_action do
|
26
26
|
authorize! :manage, Cms::Snippet
|
27
27
|
end
|
28
28
|
end
|
29
29
|
Admin::Cms::PagesController.class_eval do
|
30
|
-
|
30
|
+
before_action do
|
31
31
|
authorize! :manage, Cms::Page
|
32
32
|
end
|
33
33
|
end
|
34
34
|
Admin::Cms::FilesController.class_eval do
|
35
|
-
|
35
|
+
before_action do
|
36
36
|
authorize! :manage, Cms::File
|
37
37
|
end
|
38
38
|
end
|
@@ -3,9 +3,14 @@ class ActionDispatch::Routing::Mapper
|
|
3
3
|
def cms_fortress_routes(options = {})
|
4
4
|
path = options[:path] || "cms-admin"
|
5
5
|
|
6
|
-
devise_for "cms/fortress/users",
|
7
|
-
:
|
8
|
-
|
6
|
+
devise_for "cms/fortress/users",
|
7
|
+
:path => path,
|
8
|
+
:path_names => {
|
9
|
+
:sign_in => 'login', :sign_out => 'logout'
|
10
|
+
},
|
11
|
+
:controllers => {
|
12
|
+
:sessions => 'cms/fortress/users/sessions'
|
13
|
+
}
|
9
14
|
|
10
15
|
scope path, module: 'cms/fortress' do
|
11
16
|
resources :roles, :as => 'cms_fortress_roles' do
|
@@ -14,7 +14,7 @@ class Cms::FortressGenerator < Rails::Generators::Base
|
|
14
14
|
def generate_migrations
|
15
15
|
rake("cms_fortress_engine:install:migrations")
|
16
16
|
end
|
17
|
-
|
17
|
+
=begin
|
18
18
|
def generate_assets
|
19
19
|
directory 'app/assets/javascripts/cms/fortress',
|
20
20
|
'app/assets/javascripts/cms/fortress'
|
@@ -22,7 +22,7 @@ class Cms::FortressGenerator < Rails::Generators::Base
|
|
22
22
|
directory 'app/assets/stylesheets/cms/fortress',
|
23
23
|
'app/assets/stylesheets/cms/fortress'
|
24
24
|
end
|
25
|
-
|
25
|
+
=end
|
26
26
|
def show_readme
|
27
27
|
readme 'lib/generators/cms/fortress/templates/README'
|
28
28
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cms-fortress
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-12-
|
12
|
+
date: 2013-12-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -181,6 +181,7 @@ files:
|
|
181
181
|
- app/assets/stylesheets/cms/fortress/session.css
|
182
182
|
- app/controllers/cms/fortress/admin_controller.rb
|
183
183
|
- app/controllers/cms/fortress/roles_controller.rb
|
184
|
+
- app/controllers/cms/fortress/users/sessions_controller.rb
|
184
185
|
- app/controllers/cms/fortress/users_controller.rb
|
185
186
|
- app/helpers/cms/fortress/application_helper.rb
|
186
187
|
- app/helpers/cms/fortress/roles_helper.rb
|
@@ -190,7 +191,6 @@ files:
|
|
190
191
|
- app/models/cms/fortress/user.rb
|
191
192
|
- app/models/cms/page_workflow.rb
|
192
193
|
- app/models/cms_ability.rb
|
193
|
-
- app/views/.DS_Store
|
194
194
|
- app/views/admin/cms/pages/_form.html.haml
|
195
195
|
- app/views/admin/cms/partials/_body_before.html.haml
|
196
196
|
- app/views/cms/fortress/admin/_leftnav.html.haml
|
@@ -208,6 +208,8 @@ files:
|
|
208
208
|
- app/views/cms/fortress/roles/show.html.haml
|
209
209
|
- app/views/cms/fortress/shared/_admin_topnav.html.haml
|
210
210
|
- app/views/cms/fortress/shared/_navbar.html.haml
|
211
|
+
- app/views/cms/fortress/shared/_page_extend.html.haml
|
212
|
+
- app/views/cms/fortress/shared/_page_extend_js.html.haml
|
211
213
|
- app/views/cms/fortress/users/_form.html.haml
|
212
214
|
- app/views/cms/fortress/users/edit.html.haml
|
213
215
|
- app/views/cms/fortress/users/index.html.haml
|
@@ -226,6 +228,7 @@ files:
|
|
226
228
|
- db/migrate/02_create_cms_fortress_role_details.rb
|
227
229
|
- db/migrate/03_create_cms_fortress_roles.rb
|
228
230
|
- db/migrate/04_create_cms_page_workflows.rb
|
231
|
+
- db/migrate/05_add_caching_info_to_pages.rb
|
229
232
|
- lib/cms-fortress.rb
|
230
233
|
- lib/cms/fortress/application_controller_methods.rb
|
231
234
|
- lib/cms/fortress/auth.rb
|
@@ -267,7 +270,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
267
270
|
version: '0'
|
268
271
|
segments:
|
269
272
|
- 0
|
270
|
-
hash:
|
273
|
+
hash: 1036308534323409436
|
271
274
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
272
275
|
none: false
|
273
276
|
requirements:
|
data/app/views/.DS_Store
DELETED
Binary file
|