effective_pages 1.1.9 → 1.3.0

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
- SHA1:
3
- metadata.gz: 10232000ebdfe564ff4a0ef275a2dd2de7286f88
4
- data.tar.gz: fd42311db48022159ba9c363ed92b13d09e0d675
2
+ SHA256:
3
+ metadata.gz: 8fb3aea6d94ec45d0c366ab6fe818d1bb2979bb59d2d88d9f194e7d0dd212682
4
+ data.tar.gz: 4cb2f4ac2f0a63ab3d1c2635815b1b5b0e80ca5d3eed2d0acc5d4390285144b3
5
5
  SHA512:
6
- metadata.gz: b667a9f24a264ea2bcde76dab7be3553954a6237e0662e67d3f362de960b522620cfe81bf6cb482a29c60ce4a657225999d0ea0e627536775d2660a5a3939ba2
7
- data.tar.gz: 526e8332b63783c119efc1a52ac995d20c6db4f0a2ab67c990c09ed2852fb7f8f70ebebdcd0f684842cec7f85314cfc4908459bc8739ba8775fcb6f3a891d352
6
+ metadata.gz: 10ae029db472e823b42500407aa201caf9ffd615b8845622cc2d9c3c71d414ce7db7aeb3fb2be5c2ef573c17e62f977e7d7b5eb4adb4720f556a5500142e9c7c
7
+ data.tar.gz: 76b70355bf3982f0fad8e0ff39d4b5b8da882f790acfbe8f28e9de3c7f1080f897ca000876aa0858336944731ee375153e91a1245a9a4194c6ac6a7bc0f9b51e
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2014 Code and Effect Inc.
1
+ Copyright 2023 Code and Effect Inc.
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -15,9 +15,9 @@ Rails 3.2.x and 4.x
15
15
 
16
16
  ## Bootstrap3
17
17
 
18
- This is the `bootstrap3` branch of effective_datatables which supports Twitter Bootstrap 3.
18
+ This is the `bootstrap3` branch of effective_pages which supports Twitter Bootstrap 3.
19
19
 
20
- All published effective_datatables 3.x gems will support Twitter Bootstrap 3 and SimpleForm.
20
+ All published effective_pages 1.x gems will support Twitter Bootstrap 3 and SimpleForm.
21
21
 
22
22
  For Bootstrap 4 please see the master branch and/or effective_pages 2.x gems.
23
23
 
@@ -438,5 +438,3 @@ guard
438
438
  4. Push to the branch (`git push origin my-new-feature`)
439
439
  5. Bonus points for test coverage
440
440
  6. Create new Pull Request
441
-
442
-
@@ -0,0 +1,2 @@
1
+ //= link_directory ../javascripts .js
2
+ //= link_directory ../stylesheets .css
@@ -1,18 +1,13 @@
1
1
  module Admin
2
2
  class MenusController < ApplicationController
3
- respond_to?(:before_action) ? before_action(:authenticate_user!) : before_filter(:authenticate_user!) # Devise
3
+ before_action(:authenticate_user!)
4
4
 
5
5
  helper EffectiveMenusAdminHelper
6
6
 
7
7
  layout (EffectivePages.layout.kind_of?(Hash) ? EffectivePages.layout[:admin] : EffectivePages.layout)
8
8
 
9
9
  def index
10
- if Gem::Version.new(EffectiveDatatables::VERSION) < Gem::Version.new('3.0')
11
- @datatable = Effective::Datatables::Menus.new()
12
- else
13
- @datatable = EffectiveMenusDatatable.new(self)
14
- end
15
-
10
+ @datatable = EffectiveMenusDatatable.new(self)
16
11
  @page_title = 'Menus'
17
12
 
18
13
  authorize_effective_menus!
@@ -50,12 +45,12 @@ module Admin
50
45
  private
51
46
 
52
47
  def authorize_effective_menus!
53
- EffectivePages.authorized?(self, :admin, :effective_pages)
54
- EffectivePages.authorized?(self, action_name.to_sym, @menu || Effective::Menu)
48
+ EffectiveResources.authorize!(self, :admin, :effective_pages)
49
+ EffectiveResources.authorize!(self, action_name.to_sym, @menu || Effective::Menu)
55
50
  end
56
51
 
57
52
  def menu_params
58
- params.require(:effective_menu).permit(:title)
53
+ params.require(:effective_menu).permit!
59
54
  end
60
55
 
61
56
  end
@@ -1,16 +1,11 @@
1
1
  module Admin
2
2
  class PagesController < ApplicationController
3
- respond_to?(:before_action) ? before_action(:authenticate_user!) : before_filter(:authenticate_user!) # Devise
3
+ before_action(:authenticate_user!) # Devise
4
4
 
5
5
  layout (EffectivePages.layout.kind_of?(Hash) ? EffectivePages.layout[:admin] : EffectivePages.layout)
6
6
 
7
7
  def index
8
- if Gem::Version.new(EffectiveDatatables::VERSION) < Gem::Version.new('3.0')
9
- @datatable = Effective::Datatables::Pages.new()
10
- else
11
- @datatable = EffectivePagesDatatable.new(self)
12
- end
13
-
8
+ @datatable = EffectivePagesDatatable.new(self)
14
9
  @page_title = 'Pages'
15
10
 
16
11
  authorize_effective_pages!
@@ -89,12 +84,12 @@ module Admin
89
84
  private
90
85
 
91
86
  def authorize_effective_pages!
92
- EffectivePages.authorized?(self, :admin, :effective_pages)
93
- EffectivePages.authorized?(self, action_name.to_sym, @page|| Effective::Page)
87
+ EffectiveResources.authorize!(self, :admin, :effective_pages)
88
+ EffectiveResources.authorize!(self, action_name.to_sym, @page|| Effective::Page)
94
89
  end
95
90
 
96
91
  def page_params
97
- params.require(:effective_page).permit(EffectivePages.permitted_params)
92
+ params.require(:effective_page).permit!
98
93
  end
99
94
 
100
95
  end
@@ -1,7 +1,7 @@
1
1
  module Effective
2
2
  class PagesController < ApplicationController
3
3
  def show
4
- @pages = (Rails::VERSION::MAJOR > 3 ? Effective::Page.all : Effective::Page.scoped)
4
+ @pages = Effective::Page.all
5
5
  @pages = @pages.published unless (params[:edit] || params[:preview])
6
6
 
7
7
  @page = @pages.find(params[:id])
@@ -1,18 +1,16 @@
1
- unless Gem::Version.new(EffectiveDatatables::VERSION) < Gem::Version.new('3.0')
2
- class EffectiveMenusDatatable < Effective::Datatable
1
+ class EffectiveMenusDatatable < Effective::Datatable
3
2
 
4
- datatable do
5
- col :id, visible: false
6
- col :updated_at, visible: false
3
+ datatable do
4
+ col :id, visible: false
5
+ col :updated_at, visible: false
7
6
 
8
- col :title
7
+ col :title
9
8
 
10
- actions_col partial: 'admin/menus/actions', partial_as: :menu
11
- end
12
-
13
- collection do
14
- Effective::Menu.all
15
- end
9
+ actions_col partial: 'admin/menus/actions', partial_as: :menu
10
+ end
16
11
 
12
+ collection do
13
+ Effective::Menu.all
17
14
  end
15
+
18
16
  end
@@ -1,23 +1,21 @@
1
- unless Gem::Version.new(EffectiveDatatables::VERSION) < Gem::Version.new('3.0')
2
- class EffectivePagesDatatable < Effective::Datatable
1
+ class EffectivePagesDatatable < Effective::Datatable
3
2
 
4
- datatable do
5
- order :title, :asc
6
- length :all
3
+ datatable do
4
+ order :title, :asc
5
+ length :all
7
6
 
8
- col :id, visible: false
9
- col :updated_at, visible: false
7
+ col :id, visible: false
8
+ col :updated_at, visible: false
10
9
 
11
- col :title
12
- col :slug
13
- col :draft
10
+ col :title
11
+ col :slug
12
+ col :draft
14
13
 
15
- actions_col partial: 'admin/pages/actions', partial_as: :page
16
- end
17
-
18
- collection do
19
- Effective::Page.all
20
- end
14
+ actions_col partial: 'admin/pages/actions', partial_as: :page
15
+ end
21
16
 
17
+ collection do
18
+ Effective::Page.all
22
19
  end
20
+
23
21
  end
@@ -2,8 +2,9 @@ module Effective
2
2
  class Menu < ActiveRecord::Base
3
3
  has_many :menu_items, dependent: :delete_all
4
4
 
5
+ acts_as_role_restricted
6
+
5
7
  self.table_name = EffectivePages.menus_table_name.to_s
6
- attr_protected() if Rails::VERSION::MAJOR == 3
7
8
 
8
9
  # structure do
9
10
  # title :string
@@ -3,7 +3,7 @@ module Effective
3
3
  attr_accessor :parent # This gets set on the Root node and a node created by Dropdown, so the item function knows whether to go down or to go accross
4
4
 
5
5
  belongs_to :menu, inverse_of: :menu_items
6
- belongs_to :menuable, polymorphic: true # Optionaly belong to an object
6
+ belongs_to :menuable, polymorphic: true, optional: true # Optionaly belong to an object
7
7
 
8
8
  self.table_name = EffectivePages.menu_items_table_name.to_s
9
9
  attr_protected() if Rails::VERSION::MAJOR == 3
@@ -13,15 +13,15 @@
13
13
 
14
14
  = f.input :meta_description, hint: "A one or two sentence summary of this page. Appears on Google search results underneath the page title.", input_html: { maxlength: 150 }
15
15
 
16
- - if EffectivePages.pages.length == 1
17
- = f.input :template, as: :hidden, input_html: { value: EffectivePages.pages.first.first }
16
+ - if (templates = EffectivePages.templates).length == 1
17
+ = f.hidden_field :template, value: templates.first
18
18
  - else
19
- = f.input :template, as: (defined?(EffectiveFormInputs) ? :effective_select : :select), collection: EffectivePages.pages, include_blank: false
19
+ = f.input :template, as: (defined?(EffectiveFormInputs) ? :effective_select : :select), collection: templates
20
20
 
21
- - if EffectivePages.layouts.length == 1
22
- = f.input :layout, as: :hidden, value: EffectivePages.layouts.first
21
+ - if (layouts = EffectivePages.layouts).length == 1
22
+ = f.hidden_field :layout, value: layouts.first
23
23
  - else
24
- = f.input :layout, as: (defined?(EffectiveFormInputs) ? :effective_select : :select), collection: EffectivePages.layouts, include_blank: false
24
+ = f.input :layout, as: (defined?(EffectiveFormInputs) ? :effective_select : :select), collection: layouts
25
25
 
26
26
  - if f.object.respond_to?(:roles)
27
27
  = f.input :roles, collection: EffectiveRoles.roles_collection(f.object), as: :check_boxes, hint: '* leave blank for a regular public page that anyone can view'
@@ -43,28 +43,6 @@ EffectivePages.setup do |config|
43
43
  #config.acts_as_asset_box = header_image: true
44
44
  #config.acts_as_asset_box = { header_image: true, body_images: 1..4 }
45
45
 
46
- # Authorization Method
47
- #
48
- # This method is called by all controller actions with the appropriate action and resource
49
- # If the method returns false, an Effective::AccessDenied Error will be raised (see README.md for complete info)
50
- #
51
- # Use via Proc (and with CanCan):
52
- # config.authorization_method = Proc.new { |controller, action, resource| can?(action, resource) }
53
- #
54
- # Use via custom method:
55
- # config.authorization_method = :my_authorization_method
56
- #
57
- # And then in your application_controller.rb:
58
- #
59
- # def my_authorization_method(action, resource)
60
- # current_user.is?(:admin)
61
- # end
62
- #
63
- # Or disable the check completely:
64
- # config.authorization_method = false
65
- config.authorization_method = Proc.new { |controller, action, resource| authorize!(action, resource) && resource.roles_permit?(current_user) } # CanCanCan
66
- # Use effective_roles: resource.roles_permit?(current_user)
67
-
68
46
  # Layout Settings
69
47
  # Configure the Layout per controller, or all at once
70
48
 
@@ -12,15 +12,5 @@ module EffectivePages
12
12
  eval File.read("#{config.root}/config/effective_pages.rb")
13
13
  end
14
14
 
15
- initializer 'effective_pages.effective_assets_validation', after: :load_config_initializers do
16
- if EffectivePages.acts_as_asset_box
17
- begin
18
- require 'effective_assets'
19
- rescue Exception
20
- raise "unable to load effective_assets. Plese add gem 'effective_assets' to your Gemfile and then 'bundle install'"
21
- end
22
- end
23
- end
24
-
25
15
  end
26
16
  end
@@ -1,3 +1,3 @@
1
1
  module EffectivePages
2
- VERSION = '1.1.9'.freeze
2
+ VERSION = '1.3.0'.freeze
3
3
  end
@@ -1,3 +1,4 @@
1
+ require 'effective_resources'
1
2
  require 'effective_datatables'
2
3
  require 'effective_regions'
3
4
  require 'effective_roles'
@@ -6,46 +7,36 @@ require 'effective_pages/engine'
6
7
  require 'effective_pages/version'
7
8
 
8
9
  module EffectivePages
9
- mattr_accessor :pages_table_name
10
- mattr_accessor :menus_table_name
11
- mattr_accessor :menu_items_table_name
12
10
 
13
- mattr_accessor :pages_path
14
- mattr_accessor :excluded_pages
15
- mattr_accessor :excluded_layouts
16
-
17
- mattr_accessor :site_og_image
18
- mattr_accessor :site_title
19
- mattr_accessor :site_title_suffix
20
- mattr_accessor :fallback_meta_description
21
-
22
- mattr_accessor :silence_missing_page_title_warnings
23
- mattr_accessor :silence_missing_meta_description_warnings
24
-
25
- mattr_accessor :authorization_method
26
- mattr_accessor :simple_form_options
27
- mattr_accessor :layout
28
- mattr_accessor :menu
29
-
30
- mattr_accessor :acts_as_asset_box
31
-
32
- def self.setup
33
- yield self
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
+ ]
34
19
  end
35
20
 
36
- def self.authorized?(controller, action, resource)
37
- if authorization_method.respond_to?(:call) || authorization_method.kind_of?(Symbol)
38
- raise Effective::AccessDenied.new() unless (controller || self).instance_exec(controller, action, resource, &authorization_method)
39
- end
40
- true
41
- end
21
+ include EffectiveGem
42
22
 
43
- def self.pages
44
- Rails.env.development? ? read_pages : (@@pages ||= read_pages)
23
+ def self.templates
24
+ ApplicationController.view_paths.map { |path| Dir["#{path}/#{pages_path}/**"] }.flatten.reverse.map do |file|
25
+ name = File.basename(file).split('.').first
26
+ next if name.starts_with?('_')
27
+ next if Array(EffectivePages.excluded_pages).map { |str| str.to_s }.include?(name)
28
+ name
29
+ end.compact
45
30
  end
46
31
 
47
32
  def self.layouts
48
- Rails.env.development? ? read_layouts : (@@layouts ||= read_layouts)
33
+ ApplicationController.view_paths.map { |path| Dir["#{path}/layouts/**"] }.flatten.reverse.map do |file|
34
+ name = File.basename(file).split('.').first
35
+ next if name.starts_with?('_')
36
+ next if name.include?('mailer')
37
+ next if Array(EffectivePages.excluded_layouts).map { |str| str.to_s }.include?(name)
38
+ name
39
+ end.compact
49
40
  end
50
41
 
51
42
  # Remove leading and trailing '/' characters
@@ -56,38 +47,4 @@ module EffectivePages
56
47
  @@pages_path = filepath.chomp('/')
57
48
  end
58
49
 
59
- def self.permitted_params
60
- @@permitted_params ||= [:title, :meta_description, :draft, :layout, :template, :slug, (EffectiveAssets.permitted_params if EffectivePages.acts_as_asset_box), roles: []].compact
61
- end
62
-
63
- private
64
-
65
- def self.read_pages
66
- files = ApplicationController.view_paths.map { |path| Dir["#{path}/#{pages_path}/**"] }.flatten.reverse
67
-
68
- HashWithIndifferentAccess.new().tap do |pages|
69
- files.each do |file|
70
- name = File.basename(file).split('.').first
71
- next if name.starts_with?('_') || Array(EffectivePages.excluded_pages).map { |str| str.to_s }.include?(name)
72
-
73
- pages[name.to_sym] = {}
74
- end
75
- end
76
- end
77
-
78
- def self.read_layouts
79
- files = ApplicationController.view_paths.map { |path| Dir["#{path}/layouts/**"] }.flatten.reverse
80
-
81
- HashWithIndifferentAccess.new().tap do |layouts|
82
- files.each do |file|
83
- name = File.basename(file).split('.').first
84
- next if name.starts_with?('_')
85
- next if name.include?('mailer')
86
- next if Array(EffectivePages.excluded_layouts).map { |str| str.to_s }.include?(name)
87
-
88
- layouts[name.to_sym] = {}
89
- end
90
- end
91
- end
92
-
93
50
  end
data/spec/dummy/spec ADDED
@@ -0,0 +1 @@
1
+ ../../spec
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.1.9
4
+ version: 1.3.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: 2018-10-31 00:00:00.000000000 Z
11
+ date: 2023-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -119,9 +119,10 @@ files:
119
119
  - MIT-LICENSE
120
120
  - README.md
121
121
  - Rakefile
122
+ - app/assets/config/effective_pages_manifest.js
122
123
  - app/assets/javascripts/effective_pages.js
123
124
  - app/assets/stylesheets/effective_pages.scss
124
- - app/assets/stylesheets/effective_pages/dropdown-submenu.css
125
+ - app/assets/stylesheets/effective_pages/dropdown-submenu.scss
125
126
  - app/controllers/admin/menus_controller.rb
126
127
  - app/controllers/admin/pages_controller.rb
127
128
  - app/controllers/effective/pages_controller.rb
@@ -131,9 +132,6 @@ files:
131
132
  - app/helpers/effective_menus_admin_helper.rb
132
133
  - app/helpers/effective_menus_helper.rb
133
134
  - app/helpers/effective_pages_helper.rb
134
- - app/models/effective/access_denied.rb
135
- - app/models/effective/datatables/menus.rb
136
- - app/models/effective/datatables/pages.rb
137
135
  - app/models/effective/menu.rb
138
136
  - app/models/effective/menu_item.rb
139
137
  - app/models/effective/page.rb
@@ -196,6 +194,7 @@ files:
196
194
  - spec/dummy/public/500.html
197
195
  - spec/dummy/public/favicon.ico
198
196
  - spec/dummy/script/rails
197
+ - spec/dummy/spec
199
198
  - spec/dummy/spec_link
200
199
  - spec/effective_pages_spec.rb
201
200
  - spec/helpers/effective_menus_helper_spec.rb
@@ -206,7 +205,7 @@ homepage: https://github.com/code-and-effect/effective_pages
206
205
  licenses:
207
206
  - MIT
208
207
  metadata: {}
209
- post_install_message:
208
+ post_install_message:
210
209
  rdoc_options: []
211
210
  require_paths:
212
211
  - lib
@@ -221,9 +220,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
221
220
  - !ruby/object:Gem::Version
222
221
  version: '0'
223
222
  requirements: []
224
- rubyforge_project:
225
- rubygems_version: 2.4.5.1
226
- signing_key:
223
+ rubygems_version: 3.1.2
224
+ signing_key:
227
225
  specification_version: 4
228
226
  summary: Content pages, bootstrap3 menu builder and page-specific header tag helpers
229
227
  for your Rails app.
@@ -251,6 +249,7 @@ test_files:
251
249
  - spec/dummy/config/initializers/secret_token.rb
252
250
  - spec/dummy/config/initializers/inflections.rb
253
251
  - spec/dummy/config.ru
252
+ - spec/dummy/spec
254
253
  - spec/dummy/spec_link
255
254
  - spec/dummy/script/rails
256
255
  - spec/dummy/Rakefile
@@ -1,17 +0,0 @@
1
- unless defined?(Effective::AccessDenied)
2
- module Effective
3
- class AccessDenied < StandardError
4
- attr_reader :action, :subject
5
-
6
- def initialize(message = nil, action = nil, subject = nil)
7
- @message = message
8
- @action = action
9
- @subject = subject
10
- end
11
-
12
- def to_s
13
- @message || I18n.t(:'unauthorized.default', :default => 'Access Denied')
14
- end
15
- end
16
- end
17
- end
@@ -1,19 +0,0 @@
1
- if Gem::Version.new(EffectiveDatatables::VERSION) < Gem::Version.new('3.0')
2
- module Effective
3
- module Datatables
4
- class Menus < Effective::Datatable
5
- datatable do
6
- table_column :id, visible: false
7
- table_column :updated_at, visible: false
8
-
9
- table_column :title
10
- actions_column partial: '/admin/menus/actions'
11
- end
12
-
13
- def collection
14
- Effective::Menu.all
15
- end
16
- end
17
- end
18
- end
19
- end
@@ -1,25 +0,0 @@
1
- if Gem::Version.new(EffectiveDatatables::VERSION) < Gem::Version.new('3.0')
2
- module Effective
3
- module Datatables
4
- class Pages < Effective::Datatable
5
- datatable do
6
- default_order :title, :asc
7
- default_entries :all
8
-
9
- table_column :id, visible: false
10
- table_column :updated_at, visible: false
11
-
12
- table_column :title
13
- table_column :slug
14
- table_column :draft
15
-
16
- actions_column partial: '/admin/pages/actions'
17
- end
18
-
19
- def collection
20
- Effective::Page.all
21
- end
22
- end
23
- end
24
- end
25
- end