effective_pages 3.10.3 → 3.12.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 65cee10f754283599ad7b184e91bc8c86be7b9fb9105c8ac73eea21dffb715d2
4
- data.tar.gz: aa5392fe1adef1c6938400e10be3c337bacfa418c6d3708a5119c0b1ef4d07f8
3
+ metadata.gz: a415e3b0c2a07052c1c2be02f5444637ce620debf117d680939a0ed57dffc4c0
4
+ data.tar.gz: aa71beffd9b9b95c841a329c19e6813d6f860dad393e6a0dfddd1150420c7de8
5
5
  SHA512:
6
- metadata.gz: 4a3ddad10e69703c863560f5db63815fdcaa9a3f16662e9c7e0890d99c57a33290df385987d7b4f5d219b5e05d3ef4a881787de608405325c5c28c5935260733
7
- data.tar.gz: 5175e36de922d314b6010911b88a2102685b8b42105058ed0e3eaf5041bca8aaeb3d7d8d9740b2620ea6579593ce21b10114c78912ef6a44e6cfff5fc43d8ece
6
+ metadata.gz: a93466db870f0d256d864c49ca2cec4f21e644198c05959490b6918a45ecfc83da350a94d68f669dc94cdf00e1b7d6a85ecfd769d7904e6a4f1d2cb070e16654
7
+ data.tar.gz: 24407df9909682c9cf3d781625e84b9eb0037b33a5da778541b8b8fed9f5988cd8dec5c2da1300387778d00ace3b36101a7a2548eb4863dc12ce62aad749299f
@@ -1,9 +1,11 @@
1
1
  module Effective
2
2
  class PermalinksController < ApplicationController
3
- def redirect
3
+ include Effective::CrudController
4
+
5
+ def show
4
6
  @permalink = Effective::Permalink.find_by! slug: params[:slug]
5
7
 
6
- authorize! :redirect, @permalink
8
+ authorize! :show, @permalink
7
9
 
8
10
  redirect_to redirect_path_for(@permalink), allow_other_host: (@permalink.target == :url)
9
11
  end
@@ -20,7 +20,10 @@ class EffectivePagesDatatable < Effective::Datatable
20
20
  link_to(page.slug, effective_pages.page_path(page), target: '_blank')
21
21
  end
22
22
 
23
- col :draft
23
+ col :draft?, as: :boolean, visible: false
24
+ col :published?, as: :boolean
25
+ col :published_start_at
26
+ col :published_end_at
24
27
 
25
28
  col :layout, visible: false
26
29
  col :tempate, visible: false
@@ -5,9 +5,18 @@ class EffectivePermalinksDatatable < Effective::Datatable
5
5
  col :updated_at, visible: false
6
6
 
7
7
  col :title
8
- col :slug
8
+
9
+ col(:url) do |permalink|
10
+ url = (root_url + "link/" + permalink.slug)
11
+ link_to(url, url, target: '_blank')
12
+ end
13
+
9
14
  col :summary
10
- col :tags
15
+
16
+ col :slug, visible: false
17
+ col :tags, visible: false
18
+
19
+ col :tracks_count, label: 'Views'
11
20
 
12
21
  actions_col
13
22
  end
@@ -19,19 +19,21 @@ module Effective
19
19
  has_many :menu_children, -> { Effective::Page.menuable }, class_name: 'Effective::Page',
20
20
  foreign_key: :menu_parent_id, inverse_of: :menu_parent
21
21
 
22
- acts_as_role_restricted
23
- acts_as_paginable if respond_to?(:acts_as_paginable) # Effective Resources
22
+ acts_as_role_restricted if respond_to?(:acts_as_role_restricted)
23
+ acts_as_paginable
24
+ acts_as_published
24
25
  acts_as_slugged
25
26
  acts_as_tagged
26
27
  has_many_rich_texts
27
-
28
28
  log_changes if respond_to?(:log_changes)
29
29
 
30
30
  effective_resource do
31
31
  title :string
32
32
  meta_description :string
33
33
 
34
- draft :boolean
34
+ published_start_at :datetime
35
+ published_end_at :datetime
36
+ legacy_draft :boolean # No longer used. To be removed.
35
37
 
36
38
  layout :string
37
39
  template :string
@@ -68,9 +70,6 @@ module Effective
68
70
  }
69
71
 
70
72
  scope :deep_menuable, -> { includes(:menu_parent, menu_children: [:menu_parent, :menu_children]) }
71
-
72
- scope :draft, -> { where(draft: true) }
73
- scope :published, -> { where(draft: false) }
74
73
  scope :sorted, -> { order(:title) }
75
74
 
76
75
  scope :on_menu, -> { where(menu: true) }
@@ -154,10 +153,6 @@ module Effective
154
153
  rich_text_sidebar
155
154
  end
156
155
 
157
- def published?
158
- !draft?
159
- end
160
-
161
156
  # Returns a duplicated post object, or throws an exception
162
157
  def duplicate
163
158
  Page.new(attributes.except('id', 'updated_at', 'created_at')).tap do |page|
@@ -168,7 +163,7 @@ module Effective
168
163
  page.send("rich_text_#{rt.name}=", rt.body)
169
164
  end
170
165
 
171
- page.draft = true
166
+ page.assign_attributes(published_start_at: nil, published_end_at: nil)
172
167
  end
173
168
  end
174
169
 
@@ -14,6 +14,7 @@ module Effective
14
14
  acts_as_tagged
15
15
  acts_as_slugged
16
16
 
17
+ acts_as_trackable if respond_to?(:acts_as_trackable)
17
18
  log_changes if respond_to?(:log_changes)
18
19
 
19
20
  scope :deep, -> {
@@ -2,8 +2,15 @@
2
2
 
3
3
  = f.text_field :title
4
4
 
5
- = f.check_box :draft,
6
- label: 'Save this page as a draft. It will not appear in a menu and can only be accessed by admin users.'
5
+ -# acts_as_published
6
+ = f.hide_if(:save_as_draft, true) do
7
+ .row
8
+ .col-md-6
9
+ = f.datetime_field :published_start_at, hint: 'The page will be available starting on this date and time.'
10
+ .col-md-6
11
+ = f.datetime_field :published_end_at, hint: 'The page will no longer be available after this date and time. Leave blank for no end date.', date_linked: false
12
+
13
+ = f.check_box :save_as_draft, label: "Save as a draft. It will not appear in a menu and can only be accessed by admin users."
7
14
 
8
15
  = f.text_field :meta_description,
9
16
  hint: "150 character summary. Appears on Google search results underneath the page title. ",
@@ -3,5 +3,11 @@
3
3
  = render '/admin/permalinks/form_permalink', permalink: permalink
4
4
 
5
5
  - if permalink.persisted?
6
- = tab 'Logs' do
7
- = render_datatable(permalink.log_changes_datatable, inline: true, namespace: :admin)
6
+ - if permalink.class.respond_to?(:acts_as_trackable?)
7
+ = tab 'Tracks' do
8
+ - datatable = Admin::EffectiveTracksDatatable.new(owner: permalink)
9
+ = render_datatable(datatable, inline: true, namespace: :admin)
10
+
11
+ - if permalink.respond_to?(:log_changes_datatable)
12
+ = tab 'Logs' do
13
+ = render_datatable(permalink.log_changes_datatable, inline: true, namespace: :admin)
data/config/routes.rb CHANGED
@@ -14,7 +14,7 @@ EffectivePages::Engine.routes.draw do
14
14
  end
15
15
 
16
16
  scope module: 'effective' do
17
- get '/link/:slug', to: 'permalinks#redirect', as: :permalink_redirect
17
+ get '/link/:slug', to: 'permalinks#show', as: :permalink_redirect
18
18
 
19
19
  match '*id', to: 'pages#show', via: :get, as: :page, constraints: lambda { |req|
20
20
  Effective::Page.find_by_slug_or_id(req.path_parameters[:id] || '/').present?
@@ -6,7 +6,9 @@ class CreateEffectivePages < ActiveRecord::Migration[6.0]
6
6
  t.string :title
7
7
  t.string :meta_description
8
8
 
9
- t.boolean :draft, default: false
9
+ t.datetime :published_start_at
10
+ t.datetime :published_end_at
11
+ t.boolean :legacy_draft, default: false
10
12
 
11
13
  t.string :layout, default: 'application'
12
14
  t.string :template
@@ -88,6 +90,7 @@ class CreateEffectivePages < ActiveRecord::Migration[6.0]
88
90
  t.string :slug
89
91
  t.string :url
90
92
  t.text :summary
93
+ t.integer :tracks_count, default: 0
91
94
 
92
95
  t.timestamps
93
96
  end
@@ -1,3 +1,3 @@
1
1
  module EffectivePages
2
- VERSION = '3.10.3'.freeze
2
+ VERSION = '3.12.0'.freeze
3
3
  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: 3.10.3
4
+ version: 3.12.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: 2024-05-06 00:00:00.000000000 Z
11
+ date: 2024-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails