browsercms-artirix 4.0.1.1 → 4.0.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: c583e14fa12a74f972234f11511a962188130dbe
4
- data.tar.gz: 11cc22e7c560d79463b17162c340663f72e198ed
3
+ metadata.gz: a57902749d033539ac45bb99f421e92e3f9daf29
4
+ data.tar.gz: 13dcbcd60d6db9caade2157947c28e95a5b4bd06
5
5
  SHA512:
6
- metadata.gz: 8ae938f94dd7d6135bee6c3b041533730171449f1da563087bfd1570b3222bfef97ce1746c7fc4addeb41f3f0a543670b212680b5a69426fc9758cf92dee1ba0
7
- data.tar.gz: 2a28a07e19f40207217060314715102733189ff936e33cc05b4ec2f5eee4d060d0377d1e17c2fcd046fde4ed6cb94e607ae6d1f0509b60db6eb8e1105a50c09b
6
+ metadata.gz: 0eb504ff8c8d24e30270e068ef7782e6fc0b7f7ca9bd457663fe3573c8f709212bc2dd5e86c8dfa510c1744d2750c5b94a801c39aa50a9c2621a117006d3548d
7
+ data.tar.gz: acfd15b494b1e6d1ef6d7b3fa402724e8a14e4496ebc7b7eaca5cbd18baccf837a19bfaf8df522e661df0221e7e8c4a47862b688e9abcbf6837d56b8b3f5b107
@@ -1,7 +1,13 @@
1
1
  module Cms
2
2
  class ApplicationController < ::ApplicationController
3
3
  include Cms::AdminController
4
-
4
+
5
+ unless Cms.allow_guests?
6
+ before_filter :redirect_to_cms_site
7
+ before_action :authenticate_cms_user!
8
+ before_filter :cms_access_required
9
+ end
10
+
5
11
  before_action :no_browser_caching
6
12
 
7
13
  def no_browser_caching
@@ -13,6 +13,7 @@ module Cms
13
13
  #
14
14
  # @param [Array<Symbol>] methods List of methods to disable security for.
15
15
  def self.allow_guests_to(methods)
16
+ return true unless Cms.allow_guests?
16
17
  skip_before_action :redirect_to_cms_site, only: methods
17
18
  skip_before_action :authenticate_cms_user!, only: methods
18
19
  skip_before_action :cms_access_required, only: methods
@@ -75,7 +75,7 @@ module Cms
75
75
 
76
76
  def render_page
77
77
  prepare_connectables_for_render
78
- prepend_view_path DynamicView.resolver
78
+ prepend_view_path DynamicView.resolver if Cms.allow_dynamic_views?
79
79
  respond_with @page, determine_page_layout
80
80
  end
81
81
 
@@ -9,8 +9,14 @@ module Cms
9
9
 
10
10
  include Cms::UsersService::GuestUserModule
11
11
 
12
+ DEFAULT_ATTRIBUTES = {
13
+ login: Cms::Group::GUEST_CODE,
14
+ first_name: 'Anonymous',
15
+ last_name: 'User'
16
+ }
17
+
12
18
  def initialize(attributes={})
13
- super({:login => Cms::Group::GUEST_CODE, :first_name => "Anonymous", :last_name => "User"}.merge(attributes))
19
+ super DEFAULT_ATTRIBUTES.merge(attributes)
14
20
  @guest = true
15
21
  end
16
22
 
@@ -21,11 +21,19 @@ module Cms
21
21
  end
22
22
 
23
23
  def markdown?
24
- Object.const_defined?("Markdown")
24
+ Object.const_defined?('Markdown')
25
25
  end
26
26
 
27
27
  def reserved_paths
28
- @reserved_paths ||= ["/cms", "/cache"]
28
+ @reserved_paths ||= ['/cms', '/cache']
29
+ end
30
+
31
+ def allow_dynamic_views?
32
+ Rails.application.config.cms.allow_dynamic_views
33
+ end
34
+
35
+ def allow_guests?
36
+ Rails.application.config.cms.allow_guests
29
37
  end
30
38
 
31
39
  # User Class
@@ -153,7 +161,7 @@ module Cms
153
161
  module Errors
154
162
  class AccessDenied < StandardError
155
163
  def initialize
156
- super("Access Denied")
164
+ super('Access Denied')
157
165
  end
158
166
  end
159
167
 
data/lib/cms/engine.rb CHANGED
@@ -8,6 +8,9 @@ module Cms
8
8
 
9
9
  config.cms = ActiveSupport::OrderedOptions.new
10
10
 
11
+ config.cms.allow_guests = true
12
+ config.cms.allow_dynamic_views = true
13
+
11
14
  # USER BASE defaults
12
15
  config.cms.user_class_name = 'Cms::PersistentUser'
13
16
  config.cms.user_key_field = :login
@@ -167,7 +170,7 @@ module Cms
167
170
  ActiveSupport::Dependencies.autoload_paths += %W( #{Rails.root}/app/portlets )
168
171
  ActiveSupport::Dependencies.autoload_paths += %W( #{Rails.root}/app/presenters )
169
172
  ActiveSupport::Dependencies.autoload_paths += %W( #{Rails.root}/app/portlets/helpers )
170
- ActionController::Base.append_view_path DynamicView.base_path
173
+ ActionController::Base.append_view_path DynamicView.base_path if Cms.allow_dynamic_views?
171
174
  ActionController::Base.append_view_path %W( #{self.root}/app/views)
172
175
  require 'jdbc_adapter' if defined?(JRUBY_VERSION)
173
176
  end
@@ -58,15 +58,15 @@ module Cms
58
58
  end
59
59
 
60
60
  def permissions
61
- @permissions ||= Cms::Permission.by_group_ids groups.map(&:id)
61
+ @permissions ||= load_permissions
62
62
  end
63
63
 
64
64
  def viewable_sections
65
- @viewable_sections ||= Cms::Section.by_group_ids groups.map(&:id)
65
+ @viewable_sections ||= load_viewable_sections
66
66
  end
67
67
 
68
68
  def modifiable_sections
69
- @modifiable_sections ||= Cms::Section.by_group_ids groups_with_cms_access.map(&:id)
69
+ @modifiable_sections ||= load_modifiable_sections
70
70
  end
71
71
 
72
72
  # Expects a list of codes of Permissions
@@ -132,6 +132,20 @@ module Cms
132
132
  def cms_access?
133
133
  groups.cms_access.present?
134
134
  end
135
+
136
+ private
137
+
138
+ def load_permissions
139
+ Cms::Permission.by_group_ids groups.map(&:id)
140
+ end
141
+
142
+ def load_viewable_sections
143
+ Cms::Section.by_group_ids groups.map(&:id)
144
+ end
145
+
146
+ def load_modifiable_sections
147
+ Cms::Section.by_group_ids groups_with_cms_access.map(&:id)
148
+ end
135
149
  end
136
150
  end
137
151
  end
@@ -37,6 +37,19 @@ module Cms
37
37
  def save(_perform_validation = true)
38
38
  false
39
39
  end
40
+
41
+ def permissions
42
+ @permissions ||= Cms.allow_guests? ? load_permissions : Cms::Permission.none
43
+ end
44
+
45
+ def viewable_sections
46
+ @viewable_sections ||= Cms.allow_guests? ? load_viewable_sections : Cms::Section.none
47
+ end
48
+
49
+ def modifiable_sections
50
+ @modifiable_sections ||= Cms.allow_guests? ? load_modifiable_sections : Cms::Section.none
51
+ end
52
+
40
53
  end
41
54
  end
42
- end
55
+ end
@@ -10,7 +10,7 @@ module Cms
10
10
  end
11
11
 
12
12
  def guest_user
13
- load_guest_user.tap { |u| extend_user u }
13
+ load_guest_user
14
14
  end
15
15
 
16
16
  def user(login, group_codes: nil)
@@ -42,6 +42,7 @@ module Cms
42
42
  }
43
43
 
44
44
  Cms.user_class.new(params).tap do |guest_user|
45
+ extend_user guest_user
45
46
  guest_user.send :extend, GuestUserModule
46
47
  end
47
48
  end
data/lib/cms/version.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  # Allows the precise version of BrowserCMS to be determined programatically.
3
3
  #
4
4
  module Cms
5
- VERSION = '4.0.1.1'
5
+ VERSION = '4.0.2'
6
6
 
7
7
  # Return the current version of the CMS.
8
8
  def self.version
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: browsercms-artirix
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1.1
4
+ version: 4.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - BrowserMedia
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-07-23 00:00:00.000000000 Z
12
+ date: 2015-07-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails