effective_posts 0.6.2 → 1.0.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
- SHA256:
3
- metadata.gz: d24520205ad7c50a0c2b87db4f98973823d6ce0019121100552f5f6e9acb37ba
4
- data.tar.gz: b741010f991174f86dec40373f44d62e82c58112adf8bed342a7cb01e10a6826
2
+ SHA1:
3
+ metadata.gz: c022efd2bcc520c8c917470ed78cfc6d59383a6d
4
+ data.tar.gz: 7b0e965d6149141d91764bff9405ba0bf5407d17
5
5
  SHA512:
6
- metadata.gz: 28729dbb2aea8030f3c558e986c2002de9c40b6b7566e40ab07a9d8f7b8c16c13aa29ffa815f2cf9c8843e44fa86c9be0ed69c54b637ba56e93a1f9121404298
7
- data.tar.gz: 1399466d936f9210462d3f07cdd7f49b994ad897be35ea34f32355bc04f151287e51425063dd5b4e14b84421886d41cda5c311f2588f2ecba501d14a5e2ee205
6
+ metadata.gz: 0fdd4fe4cbb4e0a5bd4ca0d965464bea38a54075470cd326529d9b3d297626dc1235a14292aa90093b99863d91a5596adc58b27e667c309f883303967fece7ca
7
+ data.tar.gz: fcc25d31d20948003c2759801034cf981a522a3e5cc8541751e11f46bad4552ecbd9abab7fb769f2317b4464c2b705e36a64bcc0f8c07bf5631574f889fab35b
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2015 Code and Effect Inc.
1
+ Copyright 2018 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
@@ -7,11 +7,19 @@ Built ontop of effective_regions for post content entry and Kaminari for paginat
7
7
  Rails 3.2.x and 4.x
8
8
 
9
9
 
10
+ ## effective_posts 1.0
11
+
12
+ This is the 1.0 series of effective_posts.
13
+
14
+ This requires Twitter Bootstrap 4 and Rails 5.1+
15
+
16
+ Please check out [Effective Posts 0.x](https://github.com/code-and-effect/effective_posts/tree/bootstrap3) for more information using this gem with Bootstrap 3.
17
+
10
18
  ## Getting Started
11
19
 
12
20
  Please first install the [effective_regions](https://github.com/code-and-effect/effective_regions) and [effective_datatables](https://github.com/code-and-effect/effective_datatables) gems.
13
21
 
14
- Please download and install [Twitter Bootstrap3](http://getbootstrap.com)
22
+ Please download and install [Twitter Bootstrap4](http://getbootstrap.com)
15
23
 
16
24
  Add to your Gemfile:
17
25
 
@@ -6,12 +6,7 @@ module Admin
6
6
 
7
7
  def index
8
8
  @page_title = 'Posts'
9
-
10
- if Gem::Version.new(EffectiveDatatables::VERSION) < Gem::Version.new('3.0')
11
- @datatable = Effective::Datatables::Posts.new()
12
- else
13
- @datatable = EffectivePostsDatatable.new(self)
14
- end
9
+ @datatable = EffectivePostsDatatable.new(self)
15
10
 
16
11
  authorize_effective_posts!
17
12
  end
@@ -126,8 +121,8 @@ module Admin
126
121
  private
127
122
 
128
123
  def authorize_effective_posts!
129
- EffectivePosts.authorized?(self, :admin, :effective_posts)
130
- EffectivePosts.authorized?(self, action_name.to_sym, @post || Effective::Post)
124
+ EffectivePosts.authorize!(self, :admin, :effective_posts)
125
+ EffectivePosts.authorize!(self, action_name.to_sym, @post || Effective::Post)
131
126
  end
132
127
 
133
128
  def post_params
@@ -5,8 +5,6 @@ module Effective
5
5
  before_action :authenticate_user!, only: [:new, :create, :edit, :update],
6
6
  if: -> { EffectivePosts.submissions_require_current_user }
7
7
 
8
- after_action :monkey_patch_for_kaminari, only: [:index]
9
-
10
8
  def index
11
9
  @posts ||= Effective::Post.posts(user: current_user, category: params[:category])
12
10
  @posts = @posts.page(params[:page]).per(EffectivePosts.per_page)
@@ -20,7 +18,7 @@ module Effective
20
18
  @posts = @posts.where(search) if search.present?
21
19
  end
22
20
 
23
- EffectivePosts.authorized?(self, :index, Effective::Post)
21
+ EffectivePosts.authorize!(self, :index, Effective::Post)
24
22
 
25
23
  @page_title = (params[:page_title] || params[:category] || params[:defaults].try(:[], :category) || 'Posts').titleize
26
24
  end
@@ -30,10 +28,10 @@ module Effective
30
28
  @post = @posts.find(params[:id])
31
29
 
32
30
  if @post.respond_to?(:roles_permit?)
33
- raise Effective::AccessDenied unless @post.roles_permit?(current_user)
31
+ raise Effective::AccessDenied.new('Access Denied', :show, @post) unless @post.roles_permit?(current_user)
34
32
  end
35
33
 
36
- EffectivePosts.authorized?(self, :show, @post)
34
+ EffectivePosts.authorize!(self, :show, @post)
37
35
 
38
36
  @page_title = @post.title
39
37
  end
@@ -43,7 +41,7 @@ module Effective
43
41
  @post ||= Effective::Post.new(published_at: Time.zone.now)
44
42
  @page_title = 'New Post'
45
43
 
46
- EffectivePosts.authorized?(self, :new, @post)
44
+ EffectivePosts.authorize!(self, :new, @post)
47
45
  end
48
46
 
49
47
  def create
@@ -51,7 +49,7 @@ module Effective
51
49
  @post.user = current_user if defined?(current_user)
52
50
  @post.draft = (EffectivePosts.submissions_require_approval == true)
53
51
 
54
- EffectivePosts.authorized?(self, :create, @post)
52
+ EffectivePosts.authorize!(self, :create, @post)
55
53
 
56
54
  if @post.save
57
55
  @page_title ||= 'Post Submitted'
@@ -73,7 +71,7 @@ module Effective
73
71
  @post ||= Effective::Post.find(params[:id])
74
72
  @page_title ||= 'Edit Post'
75
73
 
76
- EffectivePosts.authorized?(self, :edit, @post)
74
+ EffectivePosts.authorize!(self, :edit, @post)
77
75
  end
78
76
 
79
77
  def update
@@ -81,7 +79,7 @@ module Effective
81
79
  draft_was = @post.draft
82
80
  @post.draft = (EffectivePosts.submissions_require_approval == true)
83
81
 
84
- EffectivePosts.authorized?(self, :update, @post)
82
+ EffectivePosts.authorize!(self, :update, @post)
85
83
 
86
84
  if @post.update_attributes(post_params)
87
85
  @page_title ||= 'Post Submitted'
@@ -102,7 +100,7 @@ module Effective
102
100
  def destroy
103
101
  @post ||= Effective::Post.find(params[:id])
104
102
 
105
- EffectivePosts.authorized?(self, :destroy, @post)
103
+ EffectivePosts.authorize!(self, :destroy, @post)
106
104
 
107
105
  if @post.destroy
108
106
  flash[:success] = 'Successfully deleted post'
@@ -119,9 +117,5 @@ module Effective
119
117
  params.require(:effective_post).permit(EffectivePosts.permitted_params)
120
118
  end
121
119
 
122
- def monkey_patch_for_kaminari
123
- @template = @template.tap { |template| template.extend(EffectiveKaminariHelper) }
124
- end
125
-
126
120
  end
127
121
  end
@@ -1,35 +1,33 @@
1
- unless Gem::Version.new(EffectiveDatatables::VERSION) < Gem::Version.new('3.0')
2
- class EffectivePostsDatatable < Effective::Datatable
3
- datatable do
4
- order :published_at, :desc
1
+ class EffectivePostsDatatable < Effective::Datatable
2
+ datatable do
3
+ order :published_at, :desc
5
4
 
6
- col :published_at
7
- col :id, visible: false
5
+ col :published_at
6
+ col :id, visible: false
8
7
 
9
- col :title
10
- col :category, search: { collection: EffectivePosts.categories }
8
+ col :title
9
+ col :category, search: { collection: EffectivePosts.categories }
11
10
 
12
- if EffectivePosts.submissions_enabled
13
- col :approved, sql_column: 'NOT(draft)', as: :boolean do |post|
14
- post.draft? ? 'No' : 'Yes'
15
- end
16
-
17
- col :draft, visible: false
18
- else
19
- col :draft
11
+ if EffectivePosts.submissions_enabled
12
+ col :approved, sql_column: 'NOT(draft)', as: :boolean do |post|
13
+ post.draft? ? 'No' : 'Yes'
20
14
  end
21
15
 
22
- col :start_at
23
- col :end_at, visible: false
24
- col :location, visible: false
16
+ col :draft, visible: false
17
+ else
18
+ col :draft
19
+ end
25
20
 
26
- col :created_at, label: 'Submitted at', visible: false
21
+ col :start_at
22
+ col :end_at, visible: false
23
+ col :location, visible: false
27
24
 
28
- actions_col partial: '/admin/posts/actions', partial_as: :post
29
- end
25
+ col :created_at, label: 'Submitted at', visible: false
30
26
 
31
- collection do
32
- Effective::Post.all
33
- end
27
+ actions_col partial: '/admin/posts/actions', partial_as: :post
28
+ end
29
+
30
+ collection do
31
+ Effective::Post.all
34
32
  end
35
33
  end
@@ -8,7 +8,20 @@ module EffectivePostsHelper
8
8
  if EffectivePosts.use_category_routes
9
9
  effective_posts.post_path(post, opts).sub('/posts', "/#{category}")
10
10
  else
11
- effective_posts.post_path(post, opts)
11
+ effective_posts.post_path(post, opts.merge(category: category))
12
+ end
13
+ end
14
+
15
+ def effective_post_category_path(category, opts = nil)
16
+ return effective_posts.posts_path unless category.present?
17
+
18
+ category = category.to_s.downcase
19
+ opts ||= {}
20
+
21
+ if EffectivePosts.use_category_routes
22
+ "/#{category}"
23
+ else
24
+ effective_posts.posts_path(opts.merge(category: category))
12
25
  end
13
26
  end
14
27
 
@@ -16,12 +29,13 @@ module EffectivePostsHelper
16
29
  render(partial: 'effective/posts/post', locals: { post: post })
17
30
  end
18
31
 
19
- def post_meta(post)
32
+ def post_meta(post, date: true, datetime: false, category: true, author: true)
20
33
  [
21
34
  'Published',
22
- "on #{post.published_at.strftime('%B %d, %Y at %l:%M %p')}",
23
- ("to #{link_to_post_category(post.category)}" if Array(EffectivePosts.categories).length > 1),
24
- ("by #{post.user.to_s.presence || 'Unknown'}" if EffectivePosts.post_meta_author && post.user.present?)
35
+ ("on #{post.published_at.strftime('%B %d, %Y')}" if date),
36
+ ("on #{post.published_at.strftime('%B %d, %Y at %l:%M %p')}" if datetime),
37
+ ("to #{link_to_post_category(post.category)}" if category && Array(EffectivePosts.categories).length > 1),
38
+ ("by #{post.user.to_s.presence || 'Unknown'}" if author && EffectivePosts.post_meta_author && post.user.present?)
25
39
  ].compact.join(' ').html_safe
26
40
  end
27
41
 
@@ -1,7 +1,6 @@
1
1
  module Effective
2
2
  class Post < ActiveRecord::Base
3
- acts_as_role_restricted if defined?(EffectiveRoles)
4
- acts_as_asset_box :image if defined?(EffectiveAssets)
3
+ acts_as_role_restricted if defined?(EffectiveRoles) && EffectivePosts.use_effective_roles
5
4
  acts_as_regionable
6
5
 
7
6
  self.table_name = EffectivePosts.posts_table_name.to_s
@@ -33,21 +32,19 @@ module Effective
33
32
 
34
33
  scope :drafts, -> { where(draft: true) }
35
34
  scope :published, -> { where(draft: false).where("#{EffectivePosts.posts_table_name}.published_at < ?", Time.zone.now) }
35
+ scope :with_category, -> (category) { where(category: category.to_s.downcase) }
36
36
 
37
37
  scope :posts, -> (user: nil, category: nil, drafts: false) {
38
- scope = (Rails::VERSION::MAJOR > 3 ? all : scoped)
39
- scope = scope.includes(:regions).order(published_at: :desc)
38
+ scope = all.includes(:regions).order(published_at: :desc)
40
39
 
41
- if defined?(EffectiveAssets)
42
- scope = scope.includes(attachments: :asset)
43
- end
44
-
45
- if user.present? && user.respond_to?(:roles) && defined?(EffectiveRoles)
46
- scope = scope.for_role(user.roles)
40
+ if defined?(EffectiveRoles) && EffectivePosts.use_effective_roles
41
+ if user.present? && user.respond_to?(:roles)
42
+ scope = scope.for_role(user.roles)
43
+ end
47
44
  end
48
45
 
49
46
  if category.present?
50
- scope = scope.where(category: category)
47
+ scope = scope.with_category(category)
51
48
  end
52
49
 
53
50
  if drafts.blank?
@@ -96,10 +93,6 @@ module Effective
96
93
  post.title = post.title + ' (Copy)'
97
94
  post.draft = true
98
95
 
99
- if defined?(EffectiveAssets) && image.present?
100
- post.add_to_asset_box(:image, image)
101
- end
102
-
103
96
  regions.each do |region|
104
97
  post.regions.build(region.attributes.except('id', 'updated_at', 'created_at'))
105
98
  end
@@ -3,10 +3,7 @@ module Effective
3
3
  class ReadMoreDivider < Snippet
4
4
  TOKEN = "<div style='display: none;'>READ_MORE_DIVIDER</div>"
5
5
 
6
- def snippet_attributes
7
- super + [:throwaway]
8
- end
9
-
6
+ attribute :throwaway, String
10
7
  end
11
8
  end
12
9
  end
@@ -1,16 +1,13 @@
1
- - if EffectivePosts.submissions_enabled && EffectivePosts.submissions_require_approval && !post.approved?
2
- = link_to effective_posts.admin_approve_post_path(post.id), title: 'Approve' do
3
- %span.glyphicon.glyphicon-ok
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)
4
5
 
5
- = link_to effective_posts.edit_admin_post_path(post.id), title: 'Settings' do
6
- %span.glyphicon.glyphicon-cog
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, target: '_blank'
7
9
 
8
- = link_to effective_post_path(post, (post.draft? ? {preview: true} : nil)), title: 'View', target: '_blank' do
9
- %span.glyphicon.glyphicon-eye-open
10
+ = dropdown_link_to 'View', effective_post_path(post, preview: true), target: '_blank'
10
11
 
11
- - if EffectivePosts.use_fullscreen_editor
12
- = link_to effective_post_path(post, edit: true), title: 'Edit Content', 'data-no-turbolink': true, target: '_blank' do
13
- %span.glyphicon.glyphicon-edit
14
-
15
- = link_to effective_posts.admin_post_path(post.id), title: 'Delete', data: { method: :delete, confirm: 'Are you sure you want to delete? This cannot be undone.' } do
16
- %span.glyphicon.glyphicon-trash
12
+ = dropdown_link_to "Delete", effective_posts.admin_post_path(post),
13
+ data: { method: :delete, confirm: "Really delete #{post}?" }
@@ -1,36 +1,25 @@
1
- = simple_form_for(post, (EffectivePosts.admin_simple_form_options || {}).merge(:url => (post.persisted? ? effective_posts.admin_post_path(post.id) : effective_posts.admin_posts_path))) do |f|
2
- = f.input :title, hint: 'The title of your post.'
1
+ = effective_form_with(model: post, url: post.persisted? ? effective_posts.admin_post_path(post.id) : effective_posts.admin_posts_path) do |f|
2
+ = f.text_field :title, hint: 'The title of your post.'
3
3
 
4
4
  - if Array(EffectivePosts.categories).length > 1
5
- = f.input :category,
6
- as: (defined?(EffectiveFormInputs) ? :effective_select : :select),
7
- collection: EffectivePosts.categories,
8
- include_blank: false
5
+ = f.select :category, EffectivePosts.categories
9
6
  - else
10
- = f.input :category, as: :hidden, input_html: { value: (EffectivePosts.categories.first || 'posts') }
7
+ = f.hidden_field :category, (EffectivePosts.categories.first || 'posts')
11
8
 
12
9
  = render partial: '/effective/posts/additional_fields', locals: { post: post, form: f, f: f }
13
10
 
14
- = f.input :draft, hint: 'Save this post as a draft. It will not be accessible on the website.'
11
+ = f.datetime_field :published_at, label: 'Publish date', hint: 'When should this be displayed on the website.'
15
12
 
16
- = f.input :published_at,
17
- as: (defined?(EffectiveFormInputs) ? :effective_date_time_picker : :datetime),
18
- label: 'Publish date',
19
- hint: 'When your post will be displayed on the website.'
13
+ = f.check_box :draft, hint: 'Save this post as a draft. It will not be accessible on the website.'
20
14
 
21
- = f.input :body,
22
- as: (defined?(EffectiveFormInputs) ? :effective_ckeditor_text_area : :text),
23
- hint: 'The body of your post.',
24
- toolbar: 'full',
25
- required: true
15
+ = f.editor :body, delta: false
26
16
 
27
17
  - if defined?(EffectiveRoles) and f.object.respond_to?(:roles) && EffectivePosts.use_effective_roles
28
- = f.input :roles, collection: EffectiveRoles.roles_collection(f.object), as: :check_boxes, hint: '* leave blank for a regular public post that anyone can view'
18
+ = f.checks :roles, EffectiveRoles.roles_collection(f.object), hint: '* leave blank for a regular public post that anyone can view'
29
19
 
30
- .form-actions.effective-post-actions
31
- = f.button :submit, 'Save', data: { disable_with: 'Saving...' }, class: 'btn btn-primary'
20
+ = f.submit do
21
+ = f.save 'Save'
32
22
  - if EffectivePosts.use_fullscreen_editor
33
- = f.button :submit, 'Save and Edit Content', data: { disable_with: 'Saving...' }, class: 'btn btn-primary'
34
- = f.button :submit, 'Save and Add New', data: { disable_with: 'Saving...' }, class: 'btn btn-default'
35
- = f.button :submit, 'Save and Duplicate', data: { disable_with: 'Saving...' }, class: 'btn btn-default'
36
- = link_to 'Cancel', effective_posts.admin_posts_path
23
+ = f.save 'Save and Edit Content'
24
+ = f.save 'Save and Add New'
25
+ = f.save 'Save and Duplicate'
@@ -1,19 +1,17 @@
1
1
  -# Adding additional .effective-posts-category-#{category} will correctly show/hide on Posts#new forms
2
2
 
3
3
  - # Event specific fields
4
- .effective-post-category-events.well{style: ('display: none' unless f.object.category == 'events')}
5
- %h4 Event Information
6
- = form.input :start_at, as: (:effective_date_time_picker if defined?(EffectiveFormInputs)),
7
- required: false,
8
- hint: 'Display a start time for this event.'
4
+ .effective-post-category-events.card.mb-4{style: ('display: none' unless f.object.category == 'events')}
5
+ .card-body
6
+ %h5.card-title Event Info
7
+ = form.datetime_field :start_at, required: false, hint: 'Display a start time for this event.'
9
8
 
10
- = form.input :end_at, as: (:effective_date_time_picker if defined?(EffectiveFormInputs)),
11
- hint: 'Display an end time of this event.'
9
+ = form.datetime_field :end_at, required: false, hint: 'Display an end time of this event.'
12
10
 
13
- = form.input :location, required: false, hint: 'Display a location where this event is taking place.'
11
+ = form.text_field :location, required: false, hint: 'Display a location where this event is taking place.'
14
12
 
15
- = form.input :website_name, label: 'External website',
16
- placeholder: 'Buy Tickets', hint: 'The label of an external website.'
13
+ = form.text_field :website_name, label: 'External website',
14
+ placeholder: 'Buy Tickets', hint: 'The label of an external website.'
17
15
 
18
- = form.input :website_href, label: 'External website address',
19
- placeholder: 'http://', hint: 'The address of an external website (start with http:// or https://).'
16
+ = form.url_field :website_href, label: 'External website address',
17
+ placeholder: 'http://', hint: 'The address of an external website (start with http:// or https://).'
@@ -1,27 +1,21 @@
1
- = simple_form_for(post, (EffectivePosts.simple_form_options || {}).merge(url: (post.persisted? ? effective_posts.post_path(post.id) : effective_posts.posts_path))) do |f|
2
- = f.input :title, hint: 'The title of your post.'
1
+ = effective_form_with(model: post, url: post.persisted? ? effective_posts.post_path(post.id) : effective_posts.posts_path) do |f|
2
+ = f.text_field :title, hint: 'The title of your post.'
3
3
 
4
4
  - if Array(EffectivePosts.categories).length > 1
5
- = f.input :category,
6
- as: (defined?(EffectiveFormInputs) ? :effective_select : :select),
7
- collection: EffectivePosts.categories,
8
- include_blank: false
5
+ = f.select :category, EffectivePosts.categories
9
6
  - else
10
- = f.input :category, as: :hidden, input_html: { value: (EffectivePosts.categories.first || 'posts') }
7
+ = f.hidden_field :category, (EffectivePosts.categories.first || 'posts')
11
8
 
12
9
  = render partial: '/effective/posts/additional_fields', locals: { post: post, form: f, f: f }
13
10
 
14
- = f.input :published_at,
15
- as: (defined?(EffectiveFormInputs) ? :effective_date_time_picker : :datetime),
16
- label: 'Publish date',
17
- hint: 'When should this be displayed on the website.'
11
+ = f.datetime_field :published_at, label: 'Publish date', hint: 'When should this be displayed on the website.'
18
12
 
19
- = f.input :body,
20
- as: (defined?(EffectiveFormInputs) ? :effective_ckeditor_text_area : :text),
21
- hint: 'The body of your post. You can add content here, or with the full screen editor on the next page.',
22
- toolbar: 'simple',
23
- required: true
13
+ = f.text_area :body
24
14
 
25
- .form-actions
26
- = f.button :submit, 'Save', data: { disable_with: 'Saving...' }, class: 'btn btn-primary'
27
- = link_to 'Cancel', effective_posts.posts_path
15
+ / = f.input :body,
16
+ / as: (defined?(EffectiveFormInputs) ? :effective_ckeditor_text_area : :text),
17
+ / hint: 'The body of your post. You can add content here, or with the full screen editor on the next page.',
18
+ / toolbar: 'simple',
19
+ / required: true
20
+
21
+ = f.submit 'Save'
@@ -2,7 +2,7 @@
2
2
 
3
3
  %p= EffectivePosts.submissions_note
4
4
 
5
- - if (EffectivePosts.authorized?(controller, :edit, @post) rescue false)
5
+ - if EffectivePosts.authorized?(controller, :edit, @post)
6
6
  %p= link_to 'Edit Post', effective_posts.edit_post_path(@post), class: 'btn btn-primary btn-edit-post'
7
7
 
8
8
  %hr
@@ -1,6 +1,6 @@
1
1
  %p A new post has been submitted and needs your approval before it may be displayed on the website:
2
2
 
3
- %p= link_to 'Approve Post', effective_posts.admin_approve_post_url(@post)
3
+ %p= link_to 'Approve Post', effective_posts.admin_approve_post_path(@post)
4
4
 
5
5
  %hr
6
6
 
@@ -19,4 +19,4 @@
19
19
 
20
20
  %hr
21
21
 
22
- %p= link_to 'Approve Post', effective_posts.admin_approve_post_url(@post)
22
+ %p= link_to 'Approve Post', effective_posts.admin_approve_post_path(@post)
@@ -56,21 +56,6 @@ EffectivePosts.setup do |config|
56
56
  # Add additional permitted params
57
57
  # config.permitted_params += [:additional_field]
58
58
 
59
- # SimpleForm Options
60
- # This Hash of options will be passed into any client facing simple_form_for() calls
61
- config.simple_form_options = {}
62
- config.admin_simple_form_options = {} # For the /admin/posts/new form
63
-
64
- # config.simple_form_options = {
65
- # html: {class: 'form-horizontal'},
66
- # wrapper: :horizontal_form,
67
- # wrapper_mappings: {
68
- # boolean: :horizontal_boolean,
69
- # check_boxes: :horizontal_radio_and_checkboxes,
70
- # radio_buttons: :horizontal_radio_and_checkboxes
71
- # }
72
- # }
73
-
74
59
  # Display the effective roles 'choose roles' input when an admin creates a new post
75
60
  config.use_effective_roles = true
76
61
 
@@ -1,3 +1,3 @@
1
1
  module EffectivePosts
2
- VERSION = '0.6.2'.freeze
2
+ VERSION = '1.0.0'.freeze
3
3
  end
@@ -37,17 +37,26 @@ module EffectivePosts
37
37
  end
38
38
 
39
39
  def self.authorized?(controller, action, resource)
40
- if authorization_method.respond_to?(:call) || authorization_method.kind_of?(Symbol)
41
- raise Effective::AccessDenied.new() unless (controller || self).instance_exec(controller, action, resource, &authorization_method)
40
+ @_exceptions ||= [Effective::AccessDenied, (CanCan::AccessDenied if defined?(CanCan)), (Pundit::NotAuthorizedError if defined?(Pundit))].compact
41
+
42
+ return !!authorization_method unless authorization_method.respond_to?(:call)
43
+ controller = controller.controller if controller.respond_to?(:controller)
44
+
45
+ begin
46
+ !!(controller || self).instance_exec((controller || self), action, resource, &authorization_method)
47
+ rescue *@_exceptions
48
+ false
42
49
  end
43
- true
50
+ end
51
+
52
+ def self.authorize!(controller, action, resource)
53
+ raise Effective::AccessDenied.new('Access Denied', action, resource) unless authorized?(controller, action, resource)
44
54
  end
45
55
 
46
56
  def self.permitted_params
47
57
  @@permitted_params ||= [
48
58
  :title, :draft, :category, :published_at, :body, :tags, :extra,
49
- :start_at, :end_at, :location, :website_name, :website_href,
50
- (EffectiveAssets.permitted_params if defined?(EffectiveAssets)), roles: []
59
+ :start_at, :end_at, :location, :website_name, :website_href, roles: []
51
60
  ].compact
52
61
  end
53
62
 
@@ -11,7 +11,7 @@ module EffectivePosts
11
11
  if not ActiveRecord::Base.timestamped_migrations
12
12
  Time.new.utc.strftime("%Y%m%d%H%M%S")
13
13
  else
14
- "%.3d" % (current_migration_number(dirname) + 1)
14
+ '%.3d' % (current_migration_number(dirname) + 1)
15
15
  end
16
16
  end
17
17
 
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: 0.6.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-02 00:00:00.000000000 Z
11
+ date: 2018-09-05 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: sass
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -67,7 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: simple_form
70
+ name: effective_ckeditor
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -80,48 +80,34 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: effective_ckeditor
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: 1.2.0
90
- type: :runtime
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: 1.2.0
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: effective_datatables
99
85
  requirement: !ruby/object:Gem::Requirement
100
86
  requirements:
101
87
  - - ">="
102
88
  - !ruby/object:Gem::Version
103
- version: 2.0.0
89
+ version: 4.0.0
104
90
  type: :runtime
105
91
  prerelease: false
106
92
  version_requirements: !ruby/object:Gem::Requirement
107
93
  requirements:
108
94
  - - ">="
109
95
  - !ruby/object:Gem::Version
110
- version: 2.0.0
96
+ version: 4.0.0
111
97
  - !ruby/object:Gem::Dependency
112
98
  name: effective_regions
113
99
  requirement: !ruby/object:Gem::Requirement
114
100
  requirements:
115
101
  - - ">="
116
102
  - !ruby/object:Gem::Version
117
- version: 1.6.9
103
+ version: '0'
118
104
  type: :runtime
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
107
  requirements:
122
108
  - - ">="
123
109
  - !ruby/object:Gem::Version
124
- version: 1.6.9
110
+ version: '0'
125
111
  description: A blog implementation with WYSIWYG content editing, post scheduling,
126
112
  pagination and optional top level routes for each post category.
127
113
  email:
@@ -132,7 +118,6 @@ extra_rdoc_files: []
132
118
  files:
133
119
  - MIT-LICENSE
134
120
  - README.md
135
- - Rakefile
136
121
  - app/assets/javascripts/effective/snippets/read_more_divider.js.coffee
137
122
  - app/assets/javascripts/effective_pages/additional_fields.js.coffee
138
123
  - app/assets/javascripts/effective_posts.js
@@ -140,7 +125,6 @@ files:
140
125
  - app/controllers/admin/posts_controller.rb
141
126
  - app/controllers/effective/posts_controller.rb
142
127
  - app/datatables/effective_posts_datatable.rb
143
- - app/helpers/effective_kaminari_helper.rb
144
128
  - app/helpers/effective_posts_helper.rb
145
129
  - app/helpers/effective_truncate_html_helper.rb
146
130
  - app/mailers/effective/posts_mailer.rb
@@ -203,7 +187,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
203
187
  - !ruby/object:Gem::Version
204
188
  version: '0'
205
189
  requirements: []
206
- rubygems_version: 3.1.2
190
+ rubyforge_project:
191
+ rubygems_version: 2.5.2.3
207
192
  signing_key:
208
193
  specification_version: 4
209
194
  summary: A blog implementation with WYSIWYG content editing, post scheduling, pagination
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_posts_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,16 +0,0 @@
1
- # This extends the @template.url_for method to work with Kaminari
2
- # It is only extended on the posts#index method, for minimal pollution
3
-
4
- module EffectiveKaminariHelper
5
- def url_for(params)
6
- if params.kind_of?(Hash) && params[:controller] == 'effective/posts' && params[:action] == 'index'
7
- params.delete(:page) if params[:page].blank?
8
- params.delete(:category) if EffectivePosts.use_category_routes
9
- params = params.except(:action, :controller, :only_path)
10
-
11
- request.path.to_s + (params.present? ? '?' : '') + params.to_param
12
- else
13
- super
14
- end
15
- end
16
- end