effective_posts 1.1.9 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -1
- data/README.md +4 -9
- data/app/controllers/admin/posts_controller.rb +10 -125
- data/app/controllers/effective/posts_controller.rb +20 -15
- data/app/datatables/effective_posts_datatable.rb +3 -1
- data/app/helpers/effective_posts_helper.rb +8 -27
- data/app/mailers/effective/posts_mailer.rb +2 -1
- data/app/models/effective/post.rb +45 -60
- data/app/views/admin/posts/_form.html.haml +8 -11
- data/app/views/admin/posts/excerpts.html.haml +2 -2
- data/app/views/effective/posts/_form.html.haml +2 -3
- data/app/views/effective/posts/_post.html.haml +1 -1
- data/app/views/effective/posts/_recent_posts.html.haml +1 -4
- data/app/views/effective/posts/_sidebar.html.haml +1 -2
- data/app/views/effective/posts/show.html.haml +1 -2
- data/app/views/effective/posts/submitted.html.haml +1 -1
- data/config/effective_posts.rb +2 -37
- data/config/routes.rb +7 -10
- data/db/migrate/01_create_effective_posts.rb.erb +1 -2
- data/lib/effective_posts.rb +14 -49
- data/lib/effective_posts/engine.rb +1 -1
- data/lib/effective_posts/version.rb +1 -1
- metadata +9 -60
- data/app/assets/javascripts/effective/snippets/read_more_divider.js.coffee +0 -22
- data/app/helpers/effective_truncate_html_helper.rb +0 -73
- data/app/models/effective/access_denied.rb +0 -17
- data/app/models/effective/datatables/posts.rb +0 -40
- data/app/models/effective/snippets/read_more_divider.rb +0 -11
- data/app/views/admin/posts/_actions.html.haml +0 -13
- data/app/views/admin/posts/edit.html.haml +0 -3
- data/app/views/admin/posts/new.html.haml +0 -3
- data/app/views/effective/snippets/_read_more_divider.html.haml +0 -9
|
@@ -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,40 +0,0 @@
|
|
|
1
|
-
if Gem::Version.new(EffectiveDatatables::VERSION) < Gem::Version.new('3.0')
|
|
2
|
-
module Effective
|
|
3
|
-
module Datatables
|
|
4
|
-
class Posts < Effective::Datatable
|
|
5
|
-
datatable do
|
|
6
|
-
default_order :published_at, :desc
|
|
7
|
-
|
|
8
|
-
table_column :published_at
|
|
9
|
-
table_column :id, visible: false
|
|
10
|
-
|
|
11
|
-
table_column :title
|
|
12
|
-
col :slug, visible: false
|
|
13
|
-
table_column :category, filter: { type: :select, values: EffectivePosts.categories }
|
|
14
|
-
|
|
15
|
-
if EffectivePosts.submissions_enabled
|
|
16
|
-
table_column :approved, column: 'NOT(draft)', as: :boolean do |post|
|
|
17
|
-
post.draft ? 'No' : 'Yes'
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
table_column :draft, visible: false
|
|
21
|
-
else
|
|
22
|
-
table_column :draft
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
table_column :start_at
|
|
26
|
-
table_column :end_at, visible: false
|
|
27
|
-
table_column :location, visible: false
|
|
28
|
-
|
|
29
|
-
table_column :created_at, label: 'Submitted at', visible: false
|
|
30
|
-
|
|
31
|
-
table_column :actions, sortable: false, filter: false, partial: '/admin/posts/actions'
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def collection
|
|
35
|
-
Effective::Post.all
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
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,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
|
-
|