effective_pages 3.4.10 → 3.4.12
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/README.md +13 -5
- data/app/assets/config/effective_pages_manifest.js +1 -0
- data/app/assets/javascripts/effective_pages/google_analytics.js +13 -0
- data/app/assets/javascripts/effective_pages.js +1 -0
- data/app/models/effective/page.rb +8 -3
- data/app/views/admin/pages/_form_menu.html.haml +3 -0
- data/app/views/layouts/_google_analytics.html.erb +1 -3
- data/lib/effective_pages/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec9b9faa01d5d460d0064fd18152e8b6c06ce910f86fe5a5384c39aebcfbc212
|
4
|
+
data.tar.gz: e5fe292060f189cf864eee702a305e513f28c596cbbbc7ac01a5b302cc0fe40c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae3a89c63ba34122f61061a4695e8b24ffb173a8637adf457dd12f5a50cb343724733d0d28e44fe14458877daa79791210153739334ed8bf1d3ca177cdfc0962
|
7
|
+
data.tar.gz: a28500dcfabd62b961894c57d523b7df6420ee51ab89558c9b7d097346b0ffb86bd49eb8c0c62e008510380ae2fa90561c1f197fdd487f40dac067254cec8c96
|
data/README.md
CHANGED
@@ -159,14 +159,20 @@ This helper is entirely optional and in no way required for effective_pages to w
|
|
159
159
|
|
160
160
|
### Google Analytics GTag Script Helper
|
161
161
|
|
162
|
-
|
162
|
+
Only works with Turbolinks.
|
163
|
+
|
164
|
+
Include the effective_pages.js javascript file in your asset pipeline.
|
163
165
|
|
164
|
-
```
|
165
|
-
|
166
|
-
= effective_pages_google_analytics
|
166
|
+
```
|
167
|
+
//= require effective_pages
|
167
168
|
```
|
168
169
|
|
169
|
-
|
170
|
+
Add the following inside your `<head>` tag:
|
171
|
+
|
172
|
+
```haml
|
173
|
+
%head
|
174
|
+
= effective_pages_google_analytics
|
175
|
+
```
|
170
176
|
|
171
177
|
Set the GA4 code in your `config/initializers/effective_pages.rb` as so:
|
172
178
|
|
@@ -174,6 +180,8 @@ Set the GA4 code in your `config/initializers/effective_pages.rb` as so:
|
|
174
180
|
config.google_analytics_code = 'G-1234567890'
|
175
181
|
```
|
176
182
|
|
183
|
+
This will render the google analytics script tags when running in production mode.
|
184
|
+
|
177
185
|
### Permissions
|
178
186
|
|
179
187
|
When creating a Page, if you've also installed the [effective_roles](https://github.com/code-and-effect/effective_roles) gem, you will be able to configure user access on a per-page basis.
|
@@ -0,0 +1 @@
|
|
1
|
+
//= link_directory ../javascripts .js
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// Add Google Analytics Code
|
2
|
+
// Supports Turbolinks and Turbo
|
3
|
+
document.addEventListener('turbolinks:load', function(event){
|
4
|
+
if(typeof(gtag) != 'function') { return }
|
5
|
+
|
6
|
+
var code = $('head').find('script[data-gtag-code]').first().data('gtag-code');
|
7
|
+
if(typeof(code) == undefined) { return }
|
8
|
+
|
9
|
+
gtag('config', code, {
|
10
|
+
'page_title': document.title,
|
11
|
+
'page_path': location.href.replace(location.origin, "")
|
12
|
+
});
|
13
|
+
})
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require_tree ./effective_pages
|
@@ -59,8 +59,9 @@ module Effective
|
|
59
59
|
scope :on_menu, -> { where(menu: true) }
|
60
60
|
scope :except_home, -> { where.not(title: 'Home') }
|
61
61
|
|
62
|
-
scope :menuable, -> { published.where(menu: true).
|
62
|
+
scope :menuable, -> { published.where(menu: true).menu_sorted }
|
63
63
|
scope :menu_deep, -> { includes(:menu_parent, :menu_children) }
|
64
|
+
scope :menu_sorted, -> { order(:menu_position) }
|
64
65
|
|
65
66
|
scope :for_menu, -> (name) { menuable.where(menu_name: name) }
|
66
67
|
scope :for_menu_root, -> (name) { for_menu(name).menu_deep.root_level }
|
@@ -68,8 +69,8 @@ module Effective
|
|
68
69
|
|
69
70
|
scope :menu_root_with_children, -> { menu_parents.where(menu_parent_id: nil) }
|
70
71
|
scope :menu_roots, -> { where(menu: true).where(menu_parent_id: nil) }
|
71
|
-
scope :menu_parents, -> { where(menu: true).where(id: Effective::Page.select('menu_parent_id')) }
|
72
|
-
scope :menu_children, -> { where(menu: true).where.not(menu_parent_id: nil) }
|
72
|
+
scope :menu_parents, -> { where(menu: true).where(id: Effective::Page.select('menu_parent_id')).menu_sorted }
|
73
|
+
scope :menu_children, -> { where(menu: true).where.not(menu_parent_id: nil).menu_sorted }
|
73
74
|
|
74
75
|
scope :for_sitemap, -> {
|
75
76
|
published.where(menu: false).or(published.where(menu: true).where.not(id: menu_root_with_children))
|
@@ -142,6 +143,10 @@ module Effective
|
|
142
143
|
duplicate.tap { |page| page.save! }
|
143
144
|
end
|
144
145
|
|
146
|
+
def menu_group
|
147
|
+
(menu_group ||= '')
|
148
|
+
end
|
149
|
+
|
145
150
|
# When true, this should not appear in sitemap.xml and should return 404 if visited
|
146
151
|
def menu_root_with_children?
|
147
152
|
menu_root? && menu_parent?
|
@@ -1,9 +1,7 @@
|
|
1
1
|
<!-- Google tag (gtag.js) -->
|
2
2
|
<script async src="https://www.googletagmanager.com/gtag/js?id=<%= code %>"></script>
|
3
|
-
<script>
|
3
|
+
<script data-gtag-code="<%= code %>">
|
4
4
|
window.dataLayer = window.dataLayer || [];
|
5
5
|
function gtag(){dataLayer.push(arguments);}
|
6
6
|
gtag('js', new Date());
|
7
|
-
|
8
|
-
gtag('config', '<%= code %>');
|
9
7
|
</script>
|
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.
|
4
|
+
version: 3.4.12
|
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: 2023-
|
11
|
+
date: 2023-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -75,6 +75,9 @@ extra_rdoc_files: []
|
|
75
75
|
files:
|
76
76
|
- MIT-LICENSE
|
77
77
|
- README.md
|
78
|
+
- app/assets/config/effective_pages_manifest.js
|
79
|
+
- app/assets/javascripts/effective_pages.js
|
80
|
+
- app/assets/javascripts/effective_pages/google_analytics.js
|
78
81
|
- app/controllers/admin/carousel_items_controller.rb
|
79
82
|
- app/controllers/admin/menus_controller.rb
|
80
83
|
- app/controllers/admin/page_banners_controller.rb
|