effective_posts 1.1.10 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +5 -58
  4. data/app/controllers/admin/posts_controller.rb +10 -125
  5. data/app/controllers/effective/posts_controller.rb +20 -15
  6. data/app/datatables/effective_posts_datatable.rb +3 -1
  7. data/app/helpers/effective_posts_helper.rb +10 -29
  8. data/app/mailers/effective/posts_mailer.rb +2 -1
  9. data/app/models/effective/post.rb +46 -61
  10. data/app/views/admin/posts/_form.html.haml +8 -11
  11. data/app/views/admin/posts/excerpts.html.haml +2 -2
  12. data/app/views/effective/posts/_form.html.haml +2 -3
  13. data/app/views/effective/posts/_post.html.haml +1 -1
  14. data/app/views/effective/posts/_recent_posts.html.haml +1 -4
  15. data/app/views/effective/posts/_sidebar.html.haml +1 -2
  16. data/app/views/effective/posts/show.html.haml +1 -2
  17. data/app/views/effective/posts/submitted.html.haml +1 -1
  18. data/config/effective_posts.rb +2 -37
  19. data/config/routes.rb +22 -28
  20. data/db/migrate/01_create_effective_posts.rb.erb +1 -2
  21. data/lib/effective_posts.rb +14 -50
  22. data/lib/effective_posts/engine.rb +1 -1
  23. data/lib/effective_posts/version.rb +1 -1
  24. metadata +9 -59
  25. data/app/assets/javascripts/effective/snippets/read_more_divider.js.coffee +0 -22
  26. data/app/helpers/effective_truncate_html_helper.rb +0 -73
  27. data/app/models/effective/access_denied.rb +0 -17
  28. data/app/models/effective/snippets/read_more_divider.rb +0 -11
  29. data/app/views/admin/posts/_actions.html.haml +0 -13
  30. data/app/views/admin/posts/edit.html.haml +0 -3
  31. data/app/views/admin/posts/new.html.haml +0 -3
  32. data/app/views/effective/snippets/_read_more_divider.html.haml +0 -9
@@ -1,64 +1,28 @@
1
- require 'nokogiri'
2
- require 'effective_datatables'
3
- require 'effective_regions'
1
+ require 'effective_resources'
4
2
  require 'effective_posts/engine'
5
3
  require 'effective_posts/version'
6
4
 
7
5
  module EffectivePosts
8
- mattr_accessor :posts_table_name
9
6
 
10
- mattr_accessor :authorization_method
11
- mattr_accessor :permitted_params
12
-
13
- mattr_accessor :layout
14
- mattr_accessor :simple_form_options
15
- mattr_accessor :admin_simple_form_options
16
-
17
- mattr_accessor :categories
18
- mattr_accessor :use_category_routes
19
- mattr_accessor :use_blog_routes
20
-
21
- mattr_accessor :use_effective_roles
22
- mattr_accessor :use_fullscreen_editor
23
- mattr_accessor :use_active_storage
24
-
25
- mattr_accessor :per_page
26
- mattr_accessor :post_meta_author
27
-
28
- mattr_accessor :submissions_enabled
29
- mattr_accessor :submissions_require_current_user
30
- mattr_accessor :submissions_require_approval
31
- mattr_accessor :submissions_note
32
-
33
- # These are hashes of configs
34
- mattr_accessor :mailer
35
-
36
- def self.setup
37
- yield self
38
- end
39
-
40
- def self.authorized?(controller, action, resource)
41
- @_exceptions ||= [Effective::AccessDenied, (CanCan::AccessDenied if defined?(CanCan)), (Pundit::NotAuthorizedError if defined?(Pundit))].compact
42
-
43
- return !!authorization_method unless authorization_method.respond_to?(:call)
44
- controller = controller.controller if controller.respond_to?(:controller)
45
-
46
- begin
47
- !!(controller || self).instance_exec((controller || self), action, resource, &authorization_method)
48
- rescue *@_exceptions
49
- false
50
- end
7
+ def self.config_keys
8
+ [
9
+ :posts_table_name, :layout, :categories,
10
+ :use_category_routes, :use_blog_routes,
11
+ :use_effective_roles, :use_active_storage,
12
+ :per_page, :post_meta_author,
13
+ :submissions_enabled, :submissions_require_current_user,
14
+ :submissions_require_approval, :submissions_note,
15
+ :mailer
16
+ ]
51
17
  end
52
18
 
53
- def self.authorize!(controller, action, resource)
54
- raise Effective::AccessDenied.new('Access Denied', action, resource) unless authorized?(controller, action, resource)
55
- end
19
+ include EffectiveGem
56
20
 
57
21
  def self.permitted_params
58
- [
22
+ @permitted_params ||= [
59
23
  :title, :excerpt, :description, :draft, :category, :slug, :published_at, :body, :tags, :extra,
60
24
  :image, :start_at, :end_at, :location, :website_name, :website_href, roles: []
61
- ].compact
25
+ ]
62
26
  end
63
27
 
64
28
  end
@@ -10,7 +10,7 @@ module EffectivePosts
10
10
  end
11
11
 
12
12
  # Set up our default configuration options.
13
- initializer "effective_posts.defaults", :before => :load_config_initializers do |app|
13
+ initializer "effective_posts.defaults", before: :load_config_initializers do |app|
14
14
  # Set up our defaults, as per our initializer template
15
15
  eval File.read("#{config.root}/config/effective_posts.rb")
16
16
  end
@@ -1,3 +1,3 @@
1
1
  module EffectivePosts
2
- VERSION = '1.1.10'.freeze
2
+ VERSION = '2.0.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_posts
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.10
4
+ version: 2.0.2
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: 2020-03-10 00:00:00.000000000 Z
11
+ date: 2021-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 3.2.0
19
+ version: '6'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 3.2.0
26
+ version: '6'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: sass
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: nokogiri
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: effective_bootstrap
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -67,7 +53,7 @@ dependencies:
67
53
  - !ruby/object:Gem::Version
68
54
  version: '0'
69
55
  - !ruby/object:Gem::Dependency
70
- name: effective_ckeditor
56
+ name: effective_resources
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
59
  - - ">="
@@ -82,34 +68,6 @@ dependencies:
82
68
  version: '0'
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: effective_datatables
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: 4.0.0
90
- type: :runtime
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: 4.0.0
97
- - !ruby/object:Gem::Dependency
98
- name: effective_regions
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :runtime
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: effective_resources
113
71
  requirement: !ruby/object:Gem::Requirement
114
72
  requirements:
115
73
  - - ">="
@@ -132,7 +90,6 @@ extra_rdoc_files: []
132
90
  files:
133
91
  - MIT-LICENSE
134
92
  - README.md
135
- - app/assets/javascripts/effective/snippets/read_more_divider.js.coffee
136
93
  - app/assets/javascripts/effective_posts.js
137
94
  - app/assets/javascripts/effective_posts/additional_fields.js.coffee
138
95
  - app/assets/stylesheets/effective_posts.scss
@@ -140,18 +97,12 @@ files:
140
97
  - app/controllers/effective/posts_controller.rb
141
98
  - app/datatables/effective_posts_datatable.rb
142
99
  - app/helpers/effective_posts_helper.rb
143
- - app/helpers/effective_truncate_html_helper.rb
144
100
  - app/mailers/effective/posts_mailer.rb
145
- - app/models/effective/access_denied.rb
146
101
  - app/models/effective/post.rb
147
- - app/models/effective/snippets/read_more_divider.rb
148
- - app/views/admin/posts/_actions.html.haml
149
102
  - app/views/admin/posts/_form.html.haml
150
103
  - app/views/admin/posts/_roles.html.haml
151
- - app/views/admin/posts/edit.html.haml
152
104
  - app/views/admin/posts/excerpts.html.haml
153
105
  - app/views/admin/posts/index.html.haml
154
- - app/views/admin/posts/new.html.haml
155
106
  - app/views/effective/posts/_additional_fields.html.haml
156
107
  - app/views/effective/posts/_categories.html.haml
157
108
  - app/views/effective/posts/_event.html.haml
@@ -168,7 +119,6 @@ files:
168
119
  - app/views/effective/posts/show.html.haml
169
120
  - app/views/effective/posts/submitted.html.haml
170
121
  - app/views/effective/posts_mailer/post_submitted_to_admin.html.haml
171
- - app/views/effective/snippets/_read_more_divider.html.haml
172
122
  - app/views/layouts/effective_posts_mailer_layout.html.haml
173
123
  - config/effective_posts.rb
174
124
  - config/routes.rb
@@ -182,7 +132,7 @@ homepage: https://github.com/code-and-effect/effective_posts
182
132
  licenses:
183
133
  - MIT
184
134
  metadata: {}
185
- post_install_message:
135
+ post_install_message:
186
136
  rdoc_options: []
187
137
  require_paths:
188
138
  - lib
@@ -197,8 +147,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
197
147
  - !ruby/object:Gem::Version
198
148
  version: '0'
199
149
  requirements: []
200
- rubygems_version: 3.0.3
201
- signing_key:
150
+ rubygems_version: 3.1.2
151
+ signing_key:
202
152
  specification_version: 4
203
153
  summary: A blog implementation with WYSIWYG content editing, post scheduling, pagination
204
154
  and optional top level routes for each post category.
@@ -1,22 +0,0 @@
1
- CKEDITOR.dialog.add 'read_more_divider', (editor) -> # Must match the class name of the snippet
2
- title: 'Read more divider',
3
- minWidth: 200,
4
- minHeight: 100,
5
- contents: [
6
- {
7
- id: 'read_more_info', # Just an html id, doesn't really matter what is here
8
- elements: [
9
- {
10
- id: 'throwaway'
11
- type: 'html',
12
- html: 'Insert a read more divider to separate excerpt content from the full content.',
13
- setup: (widget) -> this.setValue(widget.data.throwaway)
14
- commit: (widget) -> widget.setData('throwaway', 'throwaway')
15
- },
16
- {
17
- type: 'html',
18
- html: 'Anything above the read more divider will be treated as excerpt content<br>and everything below the divider will also be included in the full content.'
19
- }
20
- ]
21
- }
22
- ]
@@ -1,73 +0,0 @@
1
- module EffectiveTruncateHtmlHelper
2
- # Truncates HTML or text to a certain inner_text character limit.
3
- #
4
- # If given HTML, the underlying markup may be much longer than length, but the displayed text
5
- # will be no longer than (length + omission) characters.
6
- def truncate_html(text, length_or_content = 200, omission = '...')
7
- doc = Nokogiri::HTML::DocumentFragment.parse(text)
8
-
9
- if length_or_content.kind_of?(String)
10
- content = (Nokogiri::HTML::DocumentFragment.parse(length_or_content).children.first.inner_text rescue length_or_content)
11
- doc.tap { |doc| _truncate_node_to_content(doc, content, omission) }.inner_html
12
- elsif length_or_content.kind_of?(Integer)
13
- doc.tap { |doc| _truncate_node_to_length(doc, length_or_content, omission) }.inner_html
14
- else
15
- raise 'Unsupported datatype passed to second argument of truncate_html. Expecting integer or string.'
16
- end
17
- end
18
-
19
- def _truncate_node_to_content(node, content, omission, seen = false)
20
- if seen == true
21
- node.remove
22
- elsif node.children.blank?
23
- index = node.content.index(content)
24
-
25
- if index.present?
26
- if node.parent.try(:content) == content # If my parent node just has my text in it, remove parent node too
27
- node.parent.remove
28
- elsif index == 0
29
- node.remove
30
- else
31
- node.content = truncate(node.content, length: index+omission.to_s.length, separator: ' ', omission: omission)
32
- end
33
-
34
- seen = true
35
- end
36
- else
37
- node.children.each { |child| seen = _truncate_node_to_content(child, content, omission, seen) }
38
- end
39
-
40
- seen
41
- end
42
-
43
-
44
- def _truncate_node_to_length(node, length, omission)
45
- if node.inner_text.length <= length
46
- # Do nothing, we're already reached base case
47
- elsif node.name == 'a'
48
- node.remove # I don't want to truncate anything in a link
49
- elsif node.children.blank?
50
- # I need to truncate myself, and I'm certainly a text node
51
- if node.text?
52
- node.content = truncate(node.content, length: length+omission.to_s.length, separator: ' ', omission: omission)
53
- else
54
- node.remove
55
- end
56
- else # Go through all the children, and delete anything after the length has been reached
57
- child_length = 0
58
-
59
- node.children.each do |child|
60
- child_length > length ? (child.remove) : (child_length += child.inner_text.length)
61
- end
62
-
63
- # We have now removed all nodes after length, but the last node is longer than our length
64
- # child_length is the inner_text length of all included nodes
65
- # And we only have to truncate the last child to get under length
66
-
67
- child = node.children.last
68
- child_max_length = length - (child_length - child.inner_text.length)
69
-
70
- _truncate_node_to_length(child, child_max_length, omission)
71
- end
72
- end
73
- end
@@ -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,11 +0,0 @@
1
- module Effective
2
- module Snippets
3
- class ReadMoreDivider < Snippet
4
- TOKEN = "<div style='display: none;'>READ_MORE_DIVIDER</div>"
5
-
6
- def snippet_attributes
7
- super + [:throwaway]
8
- end
9
- end
10
- end
11
- end
@@ -1,13 +0,0 @@
1
- = dropdown(variation: :dropleft) do
2
- - if datatable.admin_namespace?
3
- - if EffectivePosts.submissions_enabled && EffectivePosts.submissions_require_approval && !post.approved?
4
- = dropdown_link_to 'Approve', effective_posts.admin_approve_post_path(post)
5
-
6
- = dropdown_link_to 'Edit', effective_posts.edit_admin_post_path(post)
7
- - if EffectivePosts.use_fullscreen_editor
8
- = dropdown_link_to 'Edit Content', effective_post_path(post, edit: true), title: 'Edit Content', 'data-no-turbolink': true, 'data-turbolinks': false, target: '_blank'
9
-
10
- = dropdown_link_to 'View', effective_post_path(post), target: '_blank'
11
-
12
- = dropdown_link_to "Delete", effective_posts.admin_post_path(post),
13
- data: { method: :delete, confirm: "Really delete #{post}?" }
@@ -1,3 +0,0 @@
1
- %h1.effective-admin-heading= @page_title
2
-
3
- = render partial: 'form', as: :post, object: @post
@@ -1,3 +0,0 @@
1
- %h1.effective-admin-heading= @page_title
2
-
3
- = render partial: 'form', as: :post, object: @post
@@ -1,9 +0,0 @@
1
- - if effectively_editting?
2
- %p.show-block-adjust{:style => 'border-top: 2px dashed black; text-align: center;', :title => 'anything above this line will be treated as excerpt content'}
3
- %span{:style => 'background: #ddd; display: inline-block; padding: 0px 6px 4px 6px; border-radius: 0px 0px 10px 10px;'}
4
- Read more...
5
- - else
6
- = Effective::Snippets::ReadMoreDivider::TOKEN.html_safe
7
-
8
-
9
-