effective_pages 1.2.0 → 1.3.1

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
  SHA256:
3
- metadata.gz: bffac68aca6d5b8bf6eb6d49addc6440cf029d784f084e6aad1b61c5be9c6134
4
- data.tar.gz: 65199de9b7977a8ca49da7804419e2b4dda375e119005e82c9617e7f8a4812d2
3
+ metadata.gz: 41e4524f61448f30e7c0f746a97f5bedca824d2cbabd20843c33ccf494ba3abd
4
+ data.tar.gz: 3bb6fc1fabc93d7dfd68508d546bb021a8060d5c6a1bf1cc96a40f89b2fbd220
5
5
  SHA512:
6
- metadata.gz: 778e6319b2a2ea1d3aeb77d581e7646f0e2899ba65140c029cd537683596543f1c182ed2ba3a4d155acff1eaf5e4b850674255ff2cae17e436ec24db27e736ee
7
- data.tar.gz: eeffa1a33cdba787cfe34cb1658683dd416d1c9988012d229ee80ad3036d058eaf919a0c5726373bfcfd924837e47b5985bccae9c6a5aab8888dd909334546d3
6
+ metadata.gz: c1e667eb86d0bbbe5bb0baa8f098c9cc02f3509392d926ab1eeb33e92ad5504dff2342c44b16e07fc6e6df685b90a44bea229c37c3e397890502afaf317ea2c7
7
+ data.tar.gz: ece1510127050a09a8a6d0ff2324f4f063c19574f5a8cf3980d0664be768d5434fd4660f9d0da2e7a8c98566f5615a6d7f10dc3c9a8dbb4a7b8c9d446f509586
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,15 +1,12 @@
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])
8
8
 
9
- raise ActiveRecord::RecordNotFound unless @page.present? # Incase .find() isn't raising it
10
- raise Effective::AccessDenied unless @page.roles_permit?(current_user)
11
-
12
- EffectivePages.authorized?(self, :show, @page)
9
+ EffectiveResources.authorize!(self, :show, @page)
13
10
 
14
11
  @page_title = @page.title
15
12
  @meta_description = @page.meta_description
@@ -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
@@ -5,7 +5,6 @@ module Effective
5
5
  acts_as_role_restricted
6
6
 
7
7
  self.table_name = EffectivePages.menus_table_name.to_s
8
- attr_protected() if Rails::VERSION::MAJOR == 3
9
8
 
10
9
  # structure do
11
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
@@ -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.2.0'.freeze
2
+ VERSION = '1.3.1'.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,39 +7,18 @@ 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
23
  def self.templates
44
24
  ApplicationController.view_paths.map { |path| Dir["#{path}/#{pages_path}/**"] }.flatten.reverse.map do |file|
@@ -67,8 +47,4 @@ module EffectivePages
67
47
  @@pages_path = filepath.chomp('/')
68
48
  end
69
49
 
70
- def self.permitted_params
71
- @@permitted_params ||= [:title, :meta_description, :draft, :layout, :template, :slug, (EffectiveAssets.permitted_params if EffectivePages.acts_as_asset_box), roles: []].compact
72
- end
73
-
74
50
  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.2.0
4
+ version: 1.3.1
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: 2019-08-06 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
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: 3.2.0
27
27
  - !ruby/object:Gem::Dependency
28
- name: sass-rails
28
+ name: sassc
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -119,6 +119,7 @@ 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
125
  - app/assets/stylesheets/effective_pages/dropdown-submenu.scss
@@ -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
@@ -207,7 +205,7 @@ homepage: https://github.com/code-and-effect/effective_pages
207
205
  licenses:
208
206
  - MIT
209
207
  metadata: {}
210
- post_install_message:
208
+ post_install_message:
211
209
  rdoc_options: []
212
210
  require_paths:
213
211
  - lib
@@ -222,8 +220,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
222
220
  - !ruby/object:Gem::Version
223
221
  version: '0'
224
222
  requirements: []
225
- rubygems_version: 3.0.3
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.
@@ -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