effective_pages 1.3.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +5 -5
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +11 -197
  4. data/app/controllers/admin/menus_controller.rb +4 -4
  5. data/app/controllers/admin/pages_controller.rb +3 -3
  6. data/app/controllers/effective/pages_controller.rb +5 -2
  7. data/app/datatables/effective_pages_datatable.rb +8 -1
  8. data/app/helpers/effective_menus_helper.rb +1 -1
  9. data/app/models/effective/access_denied.rb +17 -0
  10. data/app/models/effective/menu.rb +0 -2
  11. data/app/models/effective/menu_item.rb +1 -2
  12. data/app/models/effective/page.rb +8 -5
  13. data/app/views/admin/menus/_actions.html.haml +2 -6
  14. data/app/views/admin/menus/_form.html.haml +3 -5
  15. data/app/views/admin/pages/_actions.html.haml +6 -12
  16. data/app/views/admin/pages/_form.html.haml +13 -23
  17. data/app/views/admin/pages/index.html.haml +1 -1
  18. data/config/effective_pages.rb +21 -20
  19. data/config/routes.rb +5 -8
  20. data/lib/effective_pages/engine.rb +4 -0
  21. data/lib/effective_pages/version.rb +1 -1
  22. data/lib/effective_pages.rb +47 -17
  23. metadata +21 -135
  24. data/Rakefile +0 -24
  25. data/app/assets/config/effective_pages_manifest.js +0 -2
  26. data/app/assets/javascripts/effective_pages.js +0 -0
  27. data/app/assets/stylesheets/effective_pages/dropdown-submenu.scss +0 -7
  28. data/app/assets/stylesheets/effective_pages.scss +0 -1
  29. data/app/views/admin/pages/_asset_box_fields.html.haml +0 -2
  30. data/spec/controllers/effective/pages_controller_spec.rb +0 -66
  31. data/spec/dummy/README.rdoc +0 -261
  32. data/spec/dummy/Rakefile +0 -7
  33. data/spec/dummy/app/assets/javascripts/application.js +0 -15
  34. data/spec/dummy/app/assets/stylesheets/application.css +0 -13
  35. data/spec/dummy/app/controllers/application_controller.rb +0 -3
  36. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  37. data/spec/dummy/app/views/effective/pages/example.html.haml +0 -2
  38. data/spec/dummy/app/views/layouts/application.html.erb +0 -14
  39. data/spec/dummy/config/application.rb +0 -66
  40. data/spec/dummy/config/boot.rb +0 -10
  41. data/spec/dummy/config/database.yml +0 -25
  42. data/spec/dummy/config/environment.rb +0 -5
  43. data/spec/dummy/config/environments/development.rb +0 -37
  44. data/spec/dummy/config/environments/production.rb +0 -67
  45. data/spec/dummy/config/environments/test.rb +0 -37
  46. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  47. data/spec/dummy/config/initializers/inflections.rb +0 -15
  48. data/spec/dummy/config/initializers/mime_types.rb +0 -5
  49. data/spec/dummy/config/initializers/secret_token.rb +0 -7
  50. data/spec/dummy/config/initializers/session_store.rb +0 -8
  51. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
  52. data/spec/dummy/config/locales/en.yml +0 -5
  53. data/spec/dummy/config/routes.rb +0 -60
  54. data/spec/dummy/config.ru +0 -4
  55. data/spec/dummy/db/migrate/01_create_effective_pages.rb +0 -51
  56. data/spec/dummy/db/schema.rb +0 -52
  57. data/spec/dummy/db/test.sqlite3 +0 -0
  58. data/spec/dummy/public/404.html +0 -26
  59. data/spec/dummy/public/422.html +0 -26
  60. data/spec/dummy/public/500.html +0 -25
  61. data/spec/dummy/public/favicon.ico +0 -0
  62. data/spec/dummy/script/rails +0 -6
  63. data/spec/dummy/spec +0 -1
  64. data/spec/dummy/spec_link +0 -3
  65. data/spec/effective_pages_spec.rb +0 -7
  66. data/spec/helpers/effective_menus_helper_spec.rb +0 -281
  67. data/spec/models/effective/menu_spec.rb +0 -133
  68. data/spec/spec_helper.rb +0 -43
  69. data/spec/support/factories.rb +0 -15
@@ -1,24 +1,58 @@
1
- require 'effective_resources'
2
1
  require 'effective_datatables'
3
2
  require 'effective_regions'
4
3
  require 'effective_roles'
5
- require 'effective_slugs'
6
4
  require 'effective_pages/engine'
7
5
  require 'effective_pages/version'
8
6
 
9
7
  module EffectivePages
8
+ mattr_accessor :pages_table_name
9
+ mattr_accessor :menus_table_name
10
+ mattr_accessor :menu_items_table_name
10
11
 
11
- def self.config_keys
12
- [
13
- :pages_table_name, :menus_table_name, :menu_items_table_name,
14
- :pages_path, :excluded_pages, :excluded_layouts,
15
- :site_og_image, :site_title, :site_title_suffix, :fallback_meta_description,
16
- :silence_missing_page_title_warnings, :silence_missing_meta_description_warnings,
17
- :simple_form_options, :layout, :menu, :acts_as_asset_box
18
- ]
12
+ mattr_accessor :pages_path
13
+ mattr_accessor :excluded_pages
14
+ mattr_accessor :excluded_layouts
15
+
16
+ mattr_accessor :site_og_image
17
+ mattr_accessor :site_title
18
+ mattr_accessor :site_title_suffix
19
+ mattr_accessor :fallback_meta_description
20
+
21
+ mattr_accessor :silence_missing_page_title_warnings
22
+ mattr_accessor :silence_missing_meta_description_warnings
23
+
24
+ mattr_accessor :authorization_method
25
+ mattr_accessor :layout
26
+ mattr_accessor :menu
27
+
28
+ def self.setup
29
+ yield self
30
+ end
31
+
32
+ def self.authorized?(controller, action, resource)
33
+ @_exceptions ||= [Effective::AccessDenied, (CanCan::AccessDenied if defined?(CanCan)), (Pundit::NotAuthorizedError if defined?(Pundit))].compact
34
+
35
+ return !!authorization_method unless authorization_method.respond_to?(:call)
36
+ controller = controller.controller if controller.respond_to?(:controller)
37
+
38
+ begin
39
+ !!(controller || self).instance_exec((controller || self), action, resource, &authorization_method)
40
+ rescue *@_exceptions
41
+ false
42
+ end
19
43
  end
20
44
 
21
- include EffectiveGem
45
+ def self.authorize!(controller, action, resource)
46
+ raise Effective::AccessDenied.new('Access Denied', action, resource) unless authorized?(controller, action, resource)
47
+ end
48
+
49
+ # Remove leading and trailing '/' characters
50
+ # Will return: "effective/pages"
51
+ def self.pages_path=(filepath)
52
+ filepath = filepath.to_s
53
+ filepath = filepath[1..-1] if filepath.starts_with?('/')
54
+ @@pages_path = filepath.chomp('/')
55
+ end
22
56
 
23
57
  def self.templates
24
58
  ApplicationController.view_paths.map { |path| Dir["#{path}/#{pages_path}/**"] }.flatten.reverse.map do |file|
@@ -39,12 +73,8 @@ module EffectivePages
39
73
  end.compact
40
74
  end
41
75
 
42
- # Remove leading and trailing '/' characters
43
- # Will return: "effective/pages"
44
- def self.pages_path=(filepath)
45
- filepath = filepath.to_s
46
- filepath = filepath[1..-1] if filepath.starts_with?('/')
47
- @@pages_path = filepath.chomp('/')
76
+ def self.permitted_params
77
+ @@permitted_params ||= [:title, :meta_description, :draft, :layout, :template, :slug, roles: []]
48
78
  end
49
79
 
50
80
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_pages
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-26 00:00:00.000000000 Z
11
+ date: 2018-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -24,92 +24,63 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 3.2.0
27
- - !ruby/object:Gem::Dependency
28
- name: sassc
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: effective_ckeditor
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: 1.6.2
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: 1.6.2
55
27
  - !ruby/object:Gem::Dependency
56
28
  name: effective_datatables
57
29
  requirement: !ruby/object:Gem::Requirement
58
30
  requirements:
59
31
  - - ">="
60
32
  - !ruby/object:Gem::Version
61
- version: 2.0.0
33
+ version: 4.0.0
62
34
  type: :runtime
63
35
  prerelease: false
64
36
  version_requirements: !ruby/object:Gem::Requirement
65
37
  requirements:
66
38
  - - ">="
67
39
  - !ruby/object:Gem::Version
68
- version: 2.0.0
40
+ version: 4.0.0
69
41
  - !ruby/object:Gem::Dependency
70
42
  name: effective_regions
71
43
  requirement: !ruby/object:Gem::Requirement
72
44
  requirements:
73
45
  - - ">="
74
46
  - !ruby/object:Gem::Version
75
- version: 1.4.4
47
+ version: '0'
76
48
  type: :runtime
77
49
  prerelease: false
78
50
  version_requirements: !ruby/object:Gem::Requirement
79
51
  requirements:
80
52
  - - ">="
81
53
  - !ruby/object:Gem::Version
82
- version: 1.4.4
54
+ version: '0'
83
55
  - !ruby/object:Gem::Dependency
84
- name: effective_roles
56
+ name: effective_resources
85
57
  requirement: !ruby/object:Gem::Requirement
86
58
  requirements:
87
59
  - - ">="
88
60
  - !ruby/object:Gem::Version
89
- version: 1.2.1
61
+ version: '0'
90
62
  type: :runtime
91
63
  prerelease: false
92
64
  version_requirements: !ruby/object:Gem::Requirement
93
65
  requirements:
94
66
  - - ">="
95
67
  - !ruby/object:Gem::Version
96
- version: 1.2.1
68
+ version: '0'
97
69
  - !ruby/object:Gem::Dependency
98
- name: effective_slugs
70
+ name: effective_roles
99
71
  requirement: !ruby/object:Gem::Requirement
100
72
  requirements:
101
73
  - - ">="
102
74
  - !ruby/object:Gem::Version
103
- version: 1.1.0
75
+ version: '0'
104
76
  type: :runtime
105
77
  prerelease: false
106
78
  version_requirements: !ruby/object:Gem::Requirement
107
79
  requirements:
108
80
  - - ">="
109
81
  - !ruby/object:Gem::Version
110
- version: 1.1.0
111
- description: Content pages, bootstrap3 menu builder and page-specific header tag helpers
112
- for your Rails app.
82
+ version: '0'
83
+ description: Content pages for your rails app
113
84
  email:
114
85
  - info@codeandeffect.com
115
86
  executables: []
@@ -118,11 +89,6 @@ extra_rdoc_files: []
118
89
  files:
119
90
  - MIT-LICENSE
120
91
  - README.md
121
- - Rakefile
122
- - app/assets/config/effective_pages_manifest.js
123
- - app/assets/javascripts/effective_pages.js
124
- - app/assets/stylesheets/effective_pages.scss
125
- - app/assets/stylesheets/effective_pages/dropdown-submenu.scss
126
92
  - app/controllers/admin/menus_controller.rb
127
93
  - app/controllers/admin/pages_controller.rb
128
94
  - app/controllers/effective/pages_controller.rb
@@ -132,6 +98,7 @@ files:
132
98
  - app/helpers/effective_menus_admin_helper.rb
133
99
  - app/helpers/effective_menus_helper.rb
134
100
  - app/helpers/effective_pages_helper.rb
101
+ - app/models/effective/access_denied.rb
135
102
  - app/models/effective/menu.rb
136
103
  - app/models/effective/menu_item.rb
137
104
  - app/models/effective/page.rb
@@ -147,7 +114,6 @@ files:
147
114
  - app/views/admin/menus/show.html.haml
148
115
  - app/views/admin/pages/_actions.html.haml
149
116
  - app/views/admin/pages/_additional_fields.html.haml
150
- - app/views/admin/pages/_asset_box_fields.html.haml
151
117
  - app/views/admin/pages/_form.html.haml
152
118
  - app/views/admin/pages/edit.html.haml
153
119
  - app/views/admin/pages/index.html.haml
@@ -161,51 +127,11 @@ files:
161
127
  - lib/generators/effective_pages/install_generator.rb
162
128
  - lib/generators/templates/example.html.haml
163
129
  - lib/tasks/effective_pages_tasks.rake
164
- - spec/controllers/effective/pages_controller_spec.rb
165
- - spec/dummy/README.rdoc
166
- - spec/dummy/Rakefile
167
- - spec/dummy/app/assets/javascripts/application.js
168
- - spec/dummy/app/assets/stylesheets/application.css
169
- - spec/dummy/app/controllers/application_controller.rb
170
- - spec/dummy/app/helpers/application_helper.rb
171
- - spec/dummy/app/views/effective/pages/example.html.haml
172
- - spec/dummy/app/views/layouts/application.html.erb
173
- - spec/dummy/config.ru
174
- - spec/dummy/config/application.rb
175
- - spec/dummy/config/boot.rb
176
- - spec/dummy/config/database.yml
177
- - spec/dummy/config/environment.rb
178
- - spec/dummy/config/environments/development.rb
179
- - spec/dummy/config/environments/production.rb
180
- - spec/dummy/config/environments/test.rb
181
- - spec/dummy/config/initializers/backtrace_silencers.rb
182
- - spec/dummy/config/initializers/inflections.rb
183
- - spec/dummy/config/initializers/mime_types.rb
184
- - spec/dummy/config/initializers/secret_token.rb
185
- - spec/dummy/config/initializers/session_store.rb
186
- - spec/dummy/config/initializers/wrap_parameters.rb
187
- - spec/dummy/config/locales/en.yml
188
- - spec/dummy/config/routes.rb
189
- - spec/dummy/db/migrate/01_create_effective_pages.rb
190
- - spec/dummy/db/schema.rb
191
- - spec/dummy/db/test.sqlite3
192
- - spec/dummy/public/404.html
193
- - spec/dummy/public/422.html
194
- - spec/dummy/public/500.html
195
- - spec/dummy/public/favicon.ico
196
- - spec/dummy/script/rails
197
- - spec/dummy/spec
198
- - spec/dummy/spec_link
199
- - spec/effective_pages_spec.rb
200
- - spec/helpers/effective_menus_helper_spec.rb
201
- - spec/models/effective/menu_spec.rb
202
- - spec/spec_helper.rb
203
- - spec/support/factories.rb
204
130
  homepage: https://github.com/code-and-effect/effective_pages
205
131
  licenses:
206
132
  - MIT
207
133
  metadata: {}
208
- post_install_message:
134
+ post_install_message:
209
135
  rdoc_options: []
210
136
  require_paths:
211
137
  - lib
@@ -220,49 +146,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
220
146
  - !ruby/object:Gem::Version
221
147
  version: '0'
222
148
  requirements: []
223
- rubygems_version: 3.1.2
224
- signing_key:
149
+ rubyforge_project:
150
+ rubygems_version: 2.4.5.1
151
+ signing_key:
225
152
  specification_version: 4
226
- summary: Content pages, bootstrap3 menu builder and page-specific header tag helpers
227
- for your Rails app.
228
- test_files:
229
- - spec/spec_helper.rb
230
- - spec/dummy/app/controllers/application_controller.rb
231
- - spec/dummy/app/views/layouts/application.html.erb
232
- - spec/dummy/app/views/effective/pages/example.html.haml
233
- - spec/dummy/app/assets/javascripts/application.js
234
- - spec/dummy/app/assets/stylesheets/application.css
235
- - spec/dummy/app/helpers/application_helper.rb
236
- - spec/dummy/config/routes.rb
237
- - spec/dummy/config/locales/en.yml
238
- - spec/dummy/config/environments/production.rb
239
- - spec/dummy/config/environments/development.rb
240
- - spec/dummy/config/environments/test.rb
241
- - spec/dummy/config/environment.rb
242
- - spec/dummy/config/application.rb
243
- - spec/dummy/config/database.yml
244
- - spec/dummy/config/boot.rb
245
- - spec/dummy/config/initializers/backtrace_silencers.rb
246
- - spec/dummy/config/initializers/mime_types.rb
247
- - spec/dummy/config/initializers/session_store.rb
248
- - spec/dummy/config/initializers/wrap_parameters.rb
249
- - spec/dummy/config/initializers/secret_token.rb
250
- - spec/dummy/config/initializers/inflections.rb
251
- - spec/dummy/config.ru
252
- - spec/dummy/spec
253
- - spec/dummy/spec_link
254
- - spec/dummy/script/rails
255
- - spec/dummy/Rakefile
256
- - spec/dummy/public/favicon.ico
257
- - spec/dummy/public/422.html
258
- - spec/dummy/public/500.html
259
- - spec/dummy/public/404.html
260
- - spec/dummy/db/schema.rb
261
- - spec/dummy/db/test.sqlite3
262
- - spec/dummy/db/migrate/01_create_effective_pages.rb
263
- - spec/dummy/README.rdoc
264
- - spec/models/effective/menu_spec.rb
265
- - spec/support/factories.rb
266
- - spec/controllers/effective/pages_controller_spec.rb
267
- - spec/effective_pages_spec.rb
268
- - spec/helpers/effective_menus_helper_spec.rb
153
+ summary: Content pages for your rails app
154
+ test_files: []
data/Rakefile DELETED
@@ -1,24 +0,0 @@
1
- #!/usr/bin/env rake
2
- begin
3
- require 'bundler/setup'
4
- rescue LoadError
5
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
- end
7
-
8
- # Our tasks
9
- load 'lib/tasks/effective_pages_tasks.rake'
10
-
11
- # Testing tasks
12
- APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
13
- load 'rails/tasks/engine.rake'
14
-
15
- require "bundler/vendored_thor"
16
- Bundler::GemHelper.install_tasks
17
-
18
- require 'rspec/core'
19
- require 'rspec/core/rake_task'
20
-
21
- desc "Run all specs in spec directory (excluding plugin specs)"
22
- RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
23
-
24
- task :default => :spec
@@ -1,2 +0,0 @@
1
- //= link_directory ../javascripts .js
2
- //= link_directory ../stylesheets .css
File without changes
@@ -1,7 +0,0 @@
1
- /* http://www.bootply.com/71520 */
2
- li.dropdown > ul.dropdown-menu > li.dropdown{position:relative;}
3
- li.dropdown > ul.dropdown-menu > li.dropdown>.dropdown-menu{top:0;left:100%;margin-top:-6px;margin-left:-1px;-webkit-border-radius:0 6px 6px 6px;-moz-border-radius:0 6px 6px 6px;border-radius:0 6px 6px 6px;}
4
- li.dropdown > ul.dropdown-menu > li.dropdown:hover>.dropdown-menu{display:block;}
5
- li.dropdown > ul.dropdown-menu > li.dropdown>a:after{display:block;content:" ";float:right;width:0;height:0;border-color:transparent;border-style:solid;border-width:5px 0 5px 5px;border-left-color:#cccccc;margin-top:5px;margin-right:-10px;}
6
- li.dropdown > ul.dropdown-menu > li.dropdown:hover>a:after{border-left-color:#ffffff;}
7
- li.dropdown > ul.dropdown-menu > li.dropdown.pull-left{float:none;}li.dropdown > ul.dropdown-menu > li.dropdown.pull-left>.dropdown-menu{left:-100%;margin-left:10px;-webkit-border-radius:6px 0 6px 6px;-moz-border-radius:6px 0 6px 6px;border-radius:6px 0 6px 6px;}
@@ -1 +0,0 @@
1
- @import 'effective_pages/dropdown-submenu';
@@ -1,2 +0,0 @@
1
- - Effective::Page.new().asset_boxes.each do |asset_box, opts|
2
- = form.input asset_box, as: :asset_box, required: (opts.present?), hint: "The #{asset_box.to_s.titleize.downcase} of your page."
@@ -1,66 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Effective::PagesController do
4
- routes { EffectivePages::Engine.routes }
5
-
6
- let(:page) { FactoryGirl.create(:page) }
7
- let(:draft) { FactoryGirl.create(:page, :draft => true) }
8
- let(:page_with_invalid_template) { FactoryGirl.create(:page, :template => 'notemplate') }
9
- let(:page_with_invalid_layout) { FactoryGirl.create(:page, :layout => 'nolayout') }
10
-
11
- before (:each) do
12
- end
13
-
14
- context "#show" do
15
- context 'valid requests' do
16
- it 'raises RecordNotFound when the page is a draft' do
17
- expect {
18
- get :show, :id => draft.id
19
- }.to raise_error(ActiveRecord::RecordNotFound)
20
- end
21
-
22
- it 'renders a draft page when edit=true is passed' do
23
- get :show, :id => draft.id, :edit => true
24
-
25
- response.should be_success
26
- end
27
-
28
- it 'renders the appropriate page template' do
29
- get :show, :id => page.id
30
-
31
- expect(response).to render_template('layouts/application')
32
- expect(response).to render_template('effective/pages/example')
33
- end
34
- end
35
-
36
- context 'invalid requests' do
37
- it 'raises RecordNotFound when passed invalid ID' do
38
- expect { get :show, :id => 999 }.to raise_error(ActiveRecord::RecordNotFound)
39
- end
40
-
41
- it 'raises MissingTemplate when the page has an unknown template' do
42
- expect {
43
- get :show, :id => page_with_invalid_template.id
44
- }.to raise_error(ActionView::MissingTemplate)
45
- end
46
-
47
- it 'raises MissingTemplate when the page has an unknown layout' do
48
- expect {
49
- get :show, :id => page_with_invalid_layout.id
50
- }.to raise_error(ActionView::MissingTemplate)
51
- end
52
- end
53
-
54
- context 'authentication' do
55
- it 'prevents the page from being viewed when not authorized' do
56
- original_auth_method = EffectivePages.authorization_method
57
- EffectivePages.authorization_method = Proc.new { |controller, action, resource| false }
58
-
59
- expect { get :show, :id => page.id }.to raise_error(Effective::AccessDenied)
60
-
61
- EffectivePages.authorization_method = original_auth_method
62
- end
63
- end
64
- end # /show
65
-
66
- end