effective_pages 3.14.6 → 3.15.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/app/controllers/admin/banner_ads_controller.rb +15 -0
- data/app/controllers/effective/banner_ads_controller.rb +13 -0
- data/app/datatables/admin/effective_banner_ads_datatable.rb +50 -0
- data/app/helpers/effective_banner_ads_helper.rb +26 -0
- data/app/models/effective/banner_ad.rb +55 -0
- data/app/models/effective/permalink.rb +6 -3
- data/app/views/admin/alerts/_form.html.haml +1 -1
- data/app/views/admin/banner_ads/_form.html.haml +12 -0
- data/app/views/admin/banner_ads/_form_banner_ad.html.haml +14 -0
- data/app/views/admin/carousel_items/_form.html.haml +1 -1
- data/app/views/admin/page_banners/_form.html.haml +1 -1
- data/app/views/admin/page_sections/_form.html.haml +1 -1
- data/app/views/admin/pages/_form.html.haml +1 -1
- data/app/views/admin/permalinks/_form.html.haml +1 -1
- data/app/views/admin/tags/_form.html.haml +1 -1
- data/app/views/admin/tags/_form_tag.html.haml +1 -1
- data/app/views/effective/banner_ads/_banner_ad.html.haml +6 -0
- data/config/effective_pages.rb +5 -0
- data/config/locales/effective_pages.en.yml +1 -0
- data/config/routes.rb +4 -1
- data/db/migrate/101_create_effective_pages.rb +20 -0
- data/lib/effective_pages/version.rb +1 -1
- data/lib/effective_pages.rb +7 -3
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed9ffe173d713a8999837028219fca1ce882f4f03580183dcd4ddf4135948dfe
|
4
|
+
data.tar.gz: f5ca5181a12892ef012a7406a7ccb376c4cab15736d11fa8177e0ca5081602f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13682af4c80831be3220bd2d23916642af4ebd476a4d4d2e1451bb522e063e7530ae84d8553c8c859eff842878ceb383790ec8bfa20a8baff7fd42acef808759
|
7
|
+
data.tar.gz: 388b9768973107d126abaecba4a521ef2cc9cdea3bec045d4e9a6d2e1930dbed6d2d01aabfbe9ff06e28057aa7bd9a750f9a90c1d309aba169d86dba5705572b
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Admin
|
2
|
+
class BannerAdsController < ApplicationController
|
3
|
+
before_action(:authenticate_user!) if defined?(Devise)
|
4
|
+
before_action { EffectiveResources.authorize!(self, :admin, :effective_pages) }
|
5
|
+
|
6
|
+
include Effective::CrudController
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def permitted_params
|
11
|
+
params.require(:effective_banner_ad).permit!
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Effective
|
2
|
+
class BannerAdsController < ApplicationController
|
3
|
+
include Effective::CrudController
|
4
|
+
|
5
|
+
def show
|
6
|
+
@banner_ad = Effective::BannerAd.find_by!(slug: params[:slug])
|
7
|
+
|
8
|
+
authorize! :show, @banner_ad
|
9
|
+
|
10
|
+
redirect_to @banner_ad.url, allow_other_host: true
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Admin
|
2
|
+
class EffectiveBannerAdsDatatable < Effective::Datatable
|
3
|
+
filters do
|
4
|
+
scope :all
|
5
|
+
scope :published
|
6
|
+
scope :draft
|
7
|
+
end
|
8
|
+
|
9
|
+
datatable do
|
10
|
+
order :updated_at
|
11
|
+
|
12
|
+
col :updated_at, visible: false
|
13
|
+
col :created_at, visible: false
|
14
|
+
col :id, visible: false
|
15
|
+
|
16
|
+
col :published?, as: :boolean
|
17
|
+
col :published_start_at, label: "Published start", visible: false
|
18
|
+
col :published_end_at, label: "Published end", visible: false
|
19
|
+
|
20
|
+
col :location, search: EffectivePages.banner_ads
|
21
|
+
col :name
|
22
|
+
|
23
|
+
col :file, label: 'Image' do |banner_ad|
|
24
|
+
if banner_ad.file.attached?
|
25
|
+
image_tag(url_for(banner_ad.file), style: 'max-width: 200px;')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
col :caption, visible: false
|
30
|
+
|
31
|
+
col(:path) do |banner_ad|
|
32
|
+
if banner_ad.redirect_path.present?
|
33
|
+
url = (root_url.chomp('/') + banner_ad.redirect_path)
|
34
|
+
link_to(url, url, target: '_blank')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
col :url, visible: false
|
39
|
+
col :slug, visible: false
|
40
|
+
|
41
|
+
col :tracks_count, label: 'Clicks'
|
42
|
+
|
43
|
+
actions_col
|
44
|
+
end
|
45
|
+
|
46
|
+
collection do
|
47
|
+
Effective::BannerAd.deep.all
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EffectiveBannerAdsHelper
|
4
|
+
|
5
|
+
def effective_banner_ads
|
6
|
+
@_effective_banner_ads ||= Effective::BannerAd.published.deep.all
|
7
|
+
end
|
8
|
+
|
9
|
+
def render_banner_ad(location, opts = {}, &block)
|
10
|
+
location = EffectivePages.banner_ads.find { |obj| obj == location }
|
11
|
+
raise("unknown banner ad location: #{location.presence || 'nil'}. Please add it to EffectivePages.banner_ads config option") if location.blank?
|
12
|
+
|
13
|
+
banner_ads = effective_banner_ads.select { |ba| ba.location == location }
|
14
|
+
return if banner_ads.blank?
|
15
|
+
|
16
|
+
# Choose a random banner ad
|
17
|
+
banner_ad = banner_ads.sample
|
18
|
+
|
19
|
+
if block_given?
|
20
|
+
yield(banner_ad); nil
|
21
|
+
else
|
22
|
+
render('effective/banner_ads/banner_ad', banner_ad: banner_ad, banner_ad_opts: opts)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# Banner ads have an image attachment, title, location, and optional external URL
|
2
|
+
# Ads are assigned to a named location.
|
3
|
+
# If more than one published ad is assigned to a location, randomly select an ad when rendering the page. If there is only one ad for the location and date/time, always show the one ad.
|
4
|
+
module Effective
|
5
|
+
class BannerAd < ActiveRecord::Base
|
6
|
+
self.table_name = (EffectivePages.banner_ads_table_name || :banner_ads).to_s
|
7
|
+
|
8
|
+
acts_as_published
|
9
|
+
acts_as_slugged
|
10
|
+
|
11
|
+
acts_as_trackable if respond_to?(:acts_as_trackable)
|
12
|
+
log_changes if respond_to?(:log_changes)
|
13
|
+
|
14
|
+
has_one_attached :file
|
15
|
+
|
16
|
+
effective_resource do
|
17
|
+
name :string
|
18
|
+
location :string
|
19
|
+
|
20
|
+
published_start_at :datetime
|
21
|
+
published_end_at :datetime
|
22
|
+
|
23
|
+
caption :string
|
24
|
+
url :string
|
25
|
+
|
26
|
+
# acts_as_slugged
|
27
|
+
slug :string
|
28
|
+
|
29
|
+
# acts_as_trackable
|
30
|
+
tracks_count :integer
|
31
|
+
|
32
|
+
timestamps
|
33
|
+
end
|
34
|
+
|
35
|
+
validates :name, presence: true
|
36
|
+
validates :location, presence: true
|
37
|
+
validates :file, presence: true
|
38
|
+
validates :url, url: true
|
39
|
+
|
40
|
+
scope :deep, -> { with_attached_file }
|
41
|
+
scope :sorted, -> { order(:name) }
|
42
|
+
|
43
|
+
def to_s
|
44
|
+
name.presence || model_name.human
|
45
|
+
end
|
46
|
+
|
47
|
+
def redirect_path
|
48
|
+
"/ad/#{slug}" if url.present?
|
49
|
+
end
|
50
|
+
|
51
|
+
def track!(action: 'click', user: nil, details: nil)
|
52
|
+
tracks.create!(action: action, user: user, details: details)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
= tabs do
|
2
|
+
= tab(banner_ad) do
|
3
|
+
= render '/admin/banner_ads/form_banner_ad', banner_ad: banner_ad
|
4
|
+
|
5
|
+
- if banner_ad.persisted?
|
6
|
+
- if banner_ad.class.respond_to?(:acts_as_trackable?)
|
7
|
+
= tab 'Tracks' do
|
8
|
+
- datatable = Admin::EffectiveTracksDatatable.new(owner: banner_ad)
|
9
|
+
= render_datatable(datatable, inline: true, namespace: :admin)
|
10
|
+
|
11
|
+
= tab 'Logs' do
|
12
|
+
= render_datatable(banner_ad.log_changes_datatable, inline: true, namespace: :admin)
|
@@ -0,0 +1,14 @@
|
|
1
|
+
= effective_form_with(model: [:admin, banner_ad], engine: true) do |f|
|
2
|
+
= f.text_field :name
|
3
|
+
= acts_as_slugged_fields(f, url: (effective_pages.banner_ad_url(f.object) rescue nil))
|
4
|
+
|
5
|
+
= f.select :location, EffectivePages.banner_ads, label: 'Location', hint: 'Each location will display one random banner ad. Please contact us to add more locations.'
|
6
|
+
= acts_as_published_fields(f)
|
7
|
+
|
8
|
+
= f.file_field :file, label: 'Image attachment', hint: EffectivePages.banner_ads_hint_text
|
9
|
+
= f.text_field :caption, hint: 'Optional. Displayed alongside the image'
|
10
|
+
|
11
|
+
.row
|
12
|
+
.col-md-6= f.url_field :url, label: 'Redirect url', hint: 'Optional. When present clicking the banner ad will redirect to this url and track clicks.'
|
13
|
+
|
14
|
+
= effective_submit(f)
|
data/config/effective_pages.rb
CHANGED
@@ -57,6 +57,11 @@ EffectivePages.setup do |config|
|
|
57
57
|
# Only 2 or 3 are supported right now
|
58
58
|
config.max_menu_depth = 2
|
59
59
|
|
60
|
+
# Banner Ads
|
61
|
+
config.banner_ads = false
|
62
|
+
# config.banner_ads = [:home, :secondary]
|
63
|
+
config.banner_ads_hint_text = 'Hint text that includes required image dimensions'
|
64
|
+
|
60
65
|
# Page Banners
|
61
66
|
# Allow a page banner to be selected on the Admin::Pages#edit screen
|
62
67
|
# Banners can be CRUD by the admin
|
data/config/routes.rb
CHANGED
@@ -5,9 +5,11 @@ EffectivePages::Engine.routes.draw do
|
|
5
5
|
resources :pages, except: [:show]
|
6
6
|
resources :page_sections, only: [:index, :edit, :update]
|
7
7
|
resources :page_banners, except: [:show]
|
8
|
+
|
8
9
|
resources :menus, only: [:index]
|
9
|
-
resources :carousel_items, except: [:show]
|
10
10
|
resources :alerts, except: [:show]
|
11
|
+
resources :banner_ads, except: [:show]
|
12
|
+
resources :carousel_items, except: [:show]
|
11
13
|
resources :permalinks, except: [:show]
|
12
14
|
resources :tags, except: [:show]
|
13
15
|
resources :taggings, only: [:index]
|
@@ -15,6 +17,7 @@ EffectivePages::Engine.routes.draw do
|
|
15
17
|
|
16
18
|
scope module: 'effective' do
|
17
19
|
get '/link/:slug', to: 'permalinks#show', as: :permalink_redirect
|
20
|
+
get '/ad/:slug', to: 'banner_ads#show', as: :banner_ad
|
18
21
|
|
19
22
|
match '*id', to: 'pages#show', via: :get, as: :page, constraints: lambda { |req|
|
20
23
|
Effective::Page.find_by_slug_or_id(req.path_parameters[:id] || '/').present?
|
@@ -128,6 +128,26 @@ class CreateEffectivePages < ActiveRecord::Migration[6.0]
|
|
128
128
|
|
129
129
|
add_index :taggings, [:taggable_type, :taggable_id], if_not_exists: true
|
130
130
|
add_index :taggings, :tag_id, if_not_exists: true
|
131
|
+
|
132
|
+
create_table :banner_ads, if_not_exists: true do |t|
|
133
|
+
t.string :name
|
134
|
+
t.string :location
|
135
|
+
|
136
|
+
t.datetime :published_start_at
|
137
|
+
t.datetime :published_end_at
|
138
|
+
|
139
|
+
t.string :caption
|
140
|
+
t.string :url
|
141
|
+
|
142
|
+
t.string :slug
|
143
|
+
t.integer :tracks_count, default: 0
|
144
|
+
|
145
|
+
t.timestamps
|
146
|
+
end
|
147
|
+
|
148
|
+
add_index :banner_ads, :name, :unique => true
|
149
|
+
add_index :banner_ads, :location, if_not_exists: true
|
150
|
+
add_index :banner_ads, [:published_start_at, :published_end_at], if_not_exists: true
|
131
151
|
end
|
132
152
|
|
133
153
|
end
|
data/lib/effective_pages.rb
CHANGED
@@ -7,19 +7,19 @@ require 'effective_pages/version'
|
|
7
7
|
module EffectivePages
|
8
8
|
def self.config_keys
|
9
9
|
[
|
10
|
-
:pages_table_name, :page_banners_table_name, :page_sections_table_name, :page_segments_table_name,
|
10
|
+
:pages_table_name, :page_banners_table_name, :page_sections_table_name, :page_segments_table_name, :banner_ads_table_name,
|
11
11
|
:alerts_table_name, :carousel_items_table_name, :permalinks_table_name, :tags_table_name, :taggings_table_name,
|
12
12
|
:pages_path, :excluded_pages, :layouts_path, :excluded_layouts,
|
13
13
|
:site_og_image, :site_og_image_width, :site_og_image_height,
|
14
14
|
:site_title, :site_title_suffix, :fallback_meta_description, :google_analytics_code,
|
15
15
|
:silence_missing_page_title_warnings, :silence_missing_meta_description_warnings, :silence_missing_canonical_url_warnings,
|
16
|
-
:use_effective_roles, :layout, :max_menu_depth, :banners_hint_text, :carousels_hint_text, :banners_force_randomize,
|
16
|
+
:use_effective_roles, :layout, :max_menu_depth, :banner_ads_hint_text, :banners_hint_text, :carousels_hint_text, :banners_force_randomize,
|
17
17
|
|
18
18
|
# Booleans
|
19
19
|
:banners, :sidebars,
|
20
20
|
|
21
21
|
# Hashes
|
22
|
-
:menus, :carousels
|
22
|
+
:menus, :carousels, :banner_ads
|
23
23
|
]
|
24
24
|
end
|
25
25
|
|
@@ -60,6 +60,10 @@ module EffectivePages
|
|
60
60
|
!!banners
|
61
61
|
end
|
62
62
|
|
63
|
+
def self.banner_ads?
|
64
|
+
banner_ads.kind_of?(Array) && banner_ads.present?
|
65
|
+
end
|
66
|
+
|
63
67
|
def self.carousels?
|
64
68
|
carousels.kind_of?(Array) && carousels.present?
|
65
69
|
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.
|
4
|
+
version: 3.15.1
|
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: 2025-
|
11
|
+
date: 2025-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -163,6 +163,7 @@ files:
|
|
163
163
|
- app/assets/javascripts/effective_pages.js
|
164
164
|
- app/assets/javascripts/effective_pages/google_analytics.js
|
165
165
|
- app/controllers/admin/alerts_controller.rb
|
166
|
+
- app/controllers/admin/banner_ads_controller.rb
|
166
167
|
- app/controllers/admin/carousel_items_controller.rb
|
167
168
|
- app/controllers/admin/menus_controller.rb
|
168
169
|
- app/controllers/admin/page_banners_controller.rb
|
@@ -171,8 +172,10 @@ files:
|
|
171
172
|
- app/controllers/admin/permalinks_controller.rb
|
172
173
|
- app/controllers/admin/taggings_controller.rb
|
173
174
|
- app/controllers/admin/tags_controller.rb
|
175
|
+
- app/controllers/effective/banner_ads_controller.rb
|
174
176
|
- app/controllers/effective/pages_controller.rb
|
175
177
|
- app/controllers/effective/permalinks_controller.rb
|
178
|
+
- app/datatables/admin/effective_banner_ads_datatable.rb
|
176
179
|
- app/datatables/admin/effective_taggings_datatable.rb
|
177
180
|
- app/datatables/admin/effective_tags_datatable.rb
|
178
181
|
- app/datatables/effective_alerts_datatable.rb
|
@@ -183,6 +186,7 @@ files:
|
|
183
186
|
- app/datatables/effective_pages_menu_datatable.rb
|
184
187
|
- app/datatables/effective_permalinks_datatable.rb
|
185
188
|
- app/helpers/effective_alerts_helper.rb
|
189
|
+
- app/helpers/effective_banner_ads_helper.rb
|
186
190
|
- app/helpers/effective_carousels_helper.rb
|
187
191
|
- app/helpers/effective_menus_helper.rb
|
188
192
|
- app/helpers/effective_page_banners_helper.rb
|
@@ -193,6 +197,7 @@ files:
|
|
193
197
|
- app/helpers/effective_tags_helper.rb
|
194
198
|
- app/models/concerns/acts_as_tagged.rb
|
195
199
|
- app/models/effective/alert.rb
|
200
|
+
- app/models/effective/banner_ad.rb
|
196
201
|
- app/models/effective/carousel_item.rb
|
197
202
|
- app/models/effective/page.rb
|
198
203
|
- app/models/effective/page_banner.rb
|
@@ -203,6 +208,8 @@ files:
|
|
203
208
|
- app/models/effective/tagging.rb
|
204
209
|
- app/views/admin/alerts/_form.html.haml
|
205
210
|
- app/views/admin/alerts/_form_alert.html.haml
|
211
|
+
- app/views/admin/banner_ads/_form.html.haml
|
212
|
+
- app/views/admin/banner_ads/_form_banner_ad.html.haml
|
206
213
|
- app/views/admin/carousel_items/_form.html.haml
|
207
214
|
- app/views/admin/carousel_items/_form_carousel_item.html.haml
|
208
215
|
- app/views/admin/carousel_items/index.html.haml
|
@@ -226,6 +233,7 @@ files:
|
|
226
233
|
- app/views/admin/tags/_form.html.haml
|
227
234
|
- app/views/admin/tags/_form_tag.html.haml
|
228
235
|
- app/views/effective/alerts/_alert.html.haml
|
236
|
+
- app/views/effective/banner_ads/_banner_ad.html.haml
|
229
237
|
- app/views/effective/carousels/_carousel.html.haml
|
230
238
|
- app/views/effective/page_segments/_content.html.haml
|
231
239
|
- app/views/effective/page_segments/_menu.html.haml
|