trusty-cms 7.0.10 → 7.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c63368c558d26f890749954b24ddf5d6802059d20c0785d9bc593e44816ec0cb
4
- data.tar.gz: 80ffc339a2e63778cad2e73f9a8fc6cf0601afdf6208766c4614fe220c8e1746
3
+ metadata.gz: c6268c67cd5f36d603ddb9ce023b0fea8f265520abe38a8493314df631c928a8
4
+ data.tar.gz: 31a91b7d8043ea76ffeb81dfc16bf78bd637227ac6236a355eade3a7f120b4d7
5
5
  SHA512:
6
- metadata.gz: 241df4d13c4d4d1edd897492450bfc611c703d738ee9064bab79772ee2fba4aedbbb74829672f29d8026c164357097b4f461a5d1474c263a092f17173f9e262c
7
- data.tar.gz: a7224d0f909fd5edd57f96755e036c8fb82e90956d564387252ee7d078324a08813828664d556a539c91efba772922ee2f25819da941c33cffbc9e8b97e5655b
6
+ metadata.gz: 866984c6c322c001d7602acf0773850d44846a5155efc27fb2ff525d380a2c2deee855dd295b7ee73be72a1e05dbfd4056b10d1ecd618fe86d6361a96cdb7ed0
7
+ data.tar.gz: 228b95c7d50664d8bd202aad0f0a97d74b39bf1594fa8ad745cf58d245f47ba44a86ca1faf4f37ac74511d266cfa4aeeb4adfcd814ffe0cc5e1f1384de7a700c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- trusty-cms (7.0.9)
4
+ trusty-cms (7.0.12)
5
5
  RedCloth (= 4.3.3)
6
6
  activestorage-validator
7
7
  acts_as_list (>= 0.9.5, < 1.3.0)
data/README.md CHANGED
@@ -93,17 +93,25 @@ SecureRandom.base58(24)
93
93
  ```
94
94
 
95
95
  **2. Store the Token in Rails Credentials**
96
- Run the following command to edit your credentials:
96
+ To store your token securely, edit your Rails credentials by running the following command:
97
97
  ```bash
98
98
  bin/rails encrypted:edit config/credentials.yml.enc
99
- ```
100
- Add the token to your credentials:
99
+ ```
100
+ Then, add the token to your credentials file under the `trusty_cms` namespace:
101
101
  ```yaml
102
102
  trusty_cms:
103
103
  page_status_bearer_token: '<your bearer token>'
104
- ```
104
+ ```
105
+
106
+ **3. Add Google Tag Manager Container ID (Optional)**
107
+ If you'd like to enable trusty-cms to submit Google Tag Manager data for tracking admin page activity (this does not include public-facing pages), add your Google Tag Manager Container ID to the `trusty_cms` section of your `credentials.yml.enc` file:
108
+ ```yaml
109
+ trusty_cms:
110
+ page_status_bearer_token: '<your bearer token>'
111
+ gtm_container_id: 'GTM-xxxxxx'
112
+ ```
105
113
 
106
- **3. Create a Ruby Lambda Function in AWS**
114
+ **4. Create a Ruby Lambda Function in AWS**
107
115
  - Log into **AWS Lambda** and create a **new Ruby Lambda function**.
108
116
  - Note the **Ruby version** used, as you'll need it locally.
109
117
  - Use [rbenv](https://github.com/rbenv/rbenv) to manage the Ruby version locally:
@@ -112,7 +120,7 @@ trusty_cms:
112
120
  rbenv local 3.3.0
113
121
  ```
114
122
 
115
- **4. Write the Lambda Function Code**
123
+ **5. Write the Lambda Function Code**
116
124
  In your local development environment:
117
125
  - Create a new folder and open it in your IDE.
118
126
  - Save the following code in a file named `lambda_handler.rb`:
@@ -140,7 +148,7 @@ def lambda_handler(event:, context:)
140
148
  end
141
149
  ```
142
150
 
143
- **5. Install Dependencies**
151
+ **6. Install Dependencies**
144
152
  Run the following commands in your terminal:
145
153
  ```bash
146
154
  gem install bundler
@@ -156,25 +164,25 @@ bundle config set --local path 'vendor/bundle'
156
164
  bundle install
157
165
  ```
158
166
 
159
- **6. Package the Lambda Function**
167
+ **7. Package the Lambda Function**
160
168
  Archive your function and dependencies:
161
169
  ```bash
162
170
  zip -r lambda_package.zip .
163
171
  ```
164
172
 
165
- **7. Upload to AWS Lambda**
173
+ **8. Upload to AWS Lambda**
166
174
  - In **AWS Lambda**, open your function.
167
175
  - Select **Upload From > .zip file**.
168
176
  - Upload the `lambda_package.zip` file.
169
177
 
170
- **8. Configure Environment Variables**
178
+ **9. Configure Environment Variables**
171
179
  In the AWS Lambda Configuration:
172
180
  - Go to **Environment Variables** > **Edit**.
173
181
  - Add the following:
174
182
  - `API_ENDPOINT`: `<your-url>/page-status/refresh`
175
183
  - `BEARER_TOKEN`: `<your bearer token>`
176
184
 
177
- **9. Set Up EventBridge Trigger**
185
+ **10. Set Up EventBridge Trigger**
178
186
  - In **Configuration Settings > Triggers**, create a **new EventBridge Trigger**.
179
187
  - Set the **Schedule** to match your desired **page status refresh frequency**.
180
188
 
@@ -15,7 +15,7 @@ class PageStatusController < ApplicationController
15
15
 
16
16
  def authenticate_bearer_token
17
17
  provided_token = request.headers['Authorization']&.split(' ')&.last
18
- expected_token = Rails.application.credentials[:trusty_cms][:page_status_bearer_token]
18
+ expected_token = Rails.application.credentials&.dig(:trusty_cms, :page_status_bearer_token)
19
19
 
20
20
  if provided_token.blank?
21
21
  render json: { error: 'Missing Bearer Token' }, status: :unauthorized and return
@@ -32,7 +32,8 @@ class PageStatusController < ApplicationController
32
32
 
33
33
  pages.each do |page|
34
34
  page_id = page.id
35
- if page.published_at <= Time.now
35
+ published_at = page.published_at
36
+ if published_at && published_at <= Time.now
36
37
  page.update(status_id: Status[:published].id)
37
38
  updated_pages << page_id
38
39
  else
@@ -1,3 +1,4 @@
1
+ - gtm_container_id = Rails.application.credentials&.dig(:trusty_cms, :gtm_container_id)
1
2
  <!DOCTYPE html>
2
3
  %html{ :xmlns => "http://www.w3.org/1999/xhtml", "xml:lang" => "en", :lang => "en", :class => "tablesaw-enhanced fontawesome-i2svg-active fontawesome-i2svg-complete" }
3
4
  %head
@@ -8,6 +9,19 @@
8
9
  - @stylesheets.uniq.each do |stylesheet|
9
10
  = stylesheet_link_tag stylesheet, media: "all"
10
11
 
12
+ - if gtm_container_id
13
+ %script{:type=>"text/javascript"}
14
+ :plain
15
+ (function(w, d, s, l, i) {
16
+ w[l] = w[l] || [];
17
+ w[l].push({ 'gtm.start': new Date().getTime(), event: 'gtm.js' });
18
+ var f = d.getElementsByTagName(s)[0],
19
+ j = d.createElement(s),
20
+ dl = l != 'dataLayer' ? '&l=' + l : '';
21
+ j.async = true;
22
+ j.src = 'https://www.googletagmanager.com/gtm.js?id=' + i + dl;
23
+ f.parentNode.insertBefore(j, f);
24
+ })(window, document, 'script', 'dataLayer', "#{gtm_container_id}");
11
25
  %script{:type=>"text/javascript"}
12
26
  var relative_url_root = "#{ActionController::Base.relative_url_root}";
13
27
 
@@ -30,6 +44,9 @@
30
44
  = csrf_meta_tags
31
45
 
32
46
  %body{:class=>body_classes.join(" ")}
47
+ - if gtm_container_id
48
+ %noscript
49
+ %iframe{src: "https://www.googletagmanager.com/ns.html?id=#{gtm_container_id}", height: "0", width: "0", style: "display:none;visibility:hidden"}
33
50
  #page.trusty-container
34
51
  %header
35
52
  - if logged_in?
@@ -1,4 +1,4 @@
1
1
  module TrustyCms
2
- VERSION = '7.0.10'.freeze
2
+ VERSION = '7.0.12'.freeze
3
3
  end
4
4
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trusty-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.10
4
+ version: 7.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - TrustyCms CMS dev team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-01-17 00:00:00.000000000 Z
11
+ date: 2025-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activestorage-validator