trusty-cms 7.0.3 → 7.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +61 -61
- data/README.md +107 -4
- data/app/assets/javascripts/admin/validations/scheduled_status_validation.js +60 -0
- data/app/assets/stylesheets/admin/main.scss +2 -1
- data/app/assets/stylesheets/admin/partials/_datetime_input.scss +5 -0
- data/app/assets/stylesheets/admin/partials/_messages.scss +4 -0
- data/app/controllers/page_status_controller.rb +61 -0
- data/app/controllers/site_controller.rb +0 -15
- data/app/helpers/admin/pages_helper.rb +0 -5
- data/app/helpers/application_helper.rb +2 -1
- data/app/models/page.rb +3 -10
- data/app/models/status.rb +1 -5
- data/app/views/admin/pages/_fields.html.haml +12 -4
- data/config/initializers/devise.rb +1 -1
- data/config/locales/en.yml +1 -1
- data/config/routes.rb +1 -0
- data/lib/trusty_cms/version.rb +1 -1
- metadata +6 -3
- /data/app/assets/stylesheets/admin/partials/{_dateinput.scss → _date_input.scss} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '05933f41895532d7fe76ff1dfef0d58a2ca32616cc65d1371de837b8205fb038'
|
4
|
+
data.tar.gz: b0fb2ed52eba017ff08af74846e4e299fd21307f740954004002097a9279dbfd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 863fe6620bddab68ac18164ba50a1b60e785f00efdfd8a16f907045d2f5fe5fa372b30352c3a7ea4e13bf89200823f3fc181ee4937a49e7f9d3d70bcf9338740
|
7
|
+
data.tar.gz: 16f1007d43c8ab0f8c52f36d1d90dae8d9652caaa0ad1f7e55b7a6d6699b1cdff6ab1e6f5ec059270e434bdb9d119449351f608dbd3a115c49b0c3d786a1f7f1
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -39,69 +39,69 @@ GEM
|
|
39
39
|
remote: https://rubygems.org/
|
40
40
|
specs:
|
41
41
|
RedCloth (4.3.3)
|
42
|
-
actioncable (7.0.8.
|
43
|
-
actionpack (= 7.0.8.
|
44
|
-
activesupport (= 7.0.8.
|
42
|
+
actioncable (7.0.8.7)
|
43
|
+
actionpack (= 7.0.8.7)
|
44
|
+
activesupport (= 7.0.8.7)
|
45
45
|
nio4r (~> 2.0)
|
46
46
|
websocket-driver (>= 0.6.1)
|
47
|
-
actionmailbox (7.0.8.
|
48
|
-
actionpack (= 7.0.8.
|
49
|
-
activejob (= 7.0.8.
|
50
|
-
activerecord (= 7.0.8.
|
51
|
-
activestorage (= 7.0.8.
|
52
|
-
activesupport (= 7.0.8.
|
47
|
+
actionmailbox (7.0.8.7)
|
48
|
+
actionpack (= 7.0.8.7)
|
49
|
+
activejob (= 7.0.8.7)
|
50
|
+
activerecord (= 7.0.8.7)
|
51
|
+
activestorage (= 7.0.8.7)
|
52
|
+
activesupport (= 7.0.8.7)
|
53
53
|
mail (>= 2.7.1)
|
54
54
|
net-imap
|
55
55
|
net-pop
|
56
56
|
net-smtp
|
57
|
-
actionmailer (7.0.8.
|
58
|
-
actionpack (= 7.0.8.
|
59
|
-
actionview (= 7.0.8.
|
60
|
-
activejob (= 7.0.8.
|
61
|
-
activesupport (= 7.0.8.
|
57
|
+
actionmailer (7.0.8.7)
|
58
|
+
actionpack (= 7.0.8.7)
|
59
|
+
actionview (= 7.0.8.7)
|
60
|
+
activejob (= 7.0.8.7)
|
61
|
+
activesupport (= 7.0.8.7)
|
62
62
|
mail (~> 2.5, >= 2.5.4)
|
63
63
|
net-imap
|
64
64
|
net-pop
|
65
65
|
net-smtp
|
66
66
|
rails-dom-testing (~> 2.0)
|
67
|
-
actionpack (7.0.8.
|
68
|
-
actionview (= 7.0.8.
|
69
|
-
activesupport (= 7.0.8.
|
67
|
+
actionpack (7.0.8.7)
|
68
|
+
actionview (= 7.0.8.7)
|
69
|
+
activesupport (= 7.0.8.7)
|
70
70
|
rack (~> 2.0, >= 2.2.4)
|
71
71
|
rack-test (>= 0.6.3)
|
72
72
|
rails-dom-testing (~> 2.0)
|
73
73
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
74
|
-
actiontext (7.0.8.
|
75
|
-
actionpack (= 7.0.8.
|
76
|
-
activerecord (= 7.0.8.
|
77
|
-
activestorage (= 7.0.8.
|
78
|
-
activesupport (= 7.0.8.
|
74
|
+
actiontext (7.0.8.7)
|
75
|
+
actionpack (= 7.0.8.7)
|
76
|
+
activerecord (= 7.0.8.7)
|
77
|
+
activestorage (= 7.0.8.7)
|
78
|
+
activesupport (= 7.0.8.7)
|
79
79
|
globalid (>= 0.6.0)
|
80
80
|
nokogiri (>= 1.8.5)
|
81
|
-
actionview (7.0.8.
|
82
|
-
activesupport (= 7.0.8.
|
81
|
+
actionview (7.0.8.7)
|
82
|
+
activesupport (= 7.0.8.7)
|
83
83
|
builder (~> 3.1)
|
84
84
|
erubi (~> 1.4)
|
85
85
|
rails-dom-testing (~> 2.0)
|
86
86
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
87
|
-
activejob (7.0.8.
|
88
|
-
activesupport (= 7.0.8.
|
87
|
+
activejob (7.0.8.7)
|
88
|
+
activesupport (= 7.0.8.7)
|
89
89
|
globalid (>= 0.3.6)
|
90
|
-
activemodel (7.0.8.
|
91
|
-
activesupport (= 7.0.8.
|
92
|
-
activerecord (7.0.8.
|
93
|
-
activemodel (= 7.0.8.
|
94
|
-
activesupport (= 7.0.8.
|
95
|
-
activestorage (7.0.8.
|
96
|
-
actionpack (= 7.0.8.
|
97
|
-
activejob (= 7.0.8.
|
98
|
-
activerecord (= 7.0.8.
|
99
|
-
activesupport (= 7.0.8.
|
90
|
+
activemodel (7.0.8.7)
|
91
|
+
activesupport (= 7.0.8.7)
|
92
|
+
activerecord (7.0.8.7)
|
93
|
+
activemodel (= 7.0.8.7)
|
94
|
+
activesupport (= 7.0.8.7)
|
95
|
+
activestorage (7.0.8.7)
|
96
|
+
actionpack (= 7.0.8.7)
|
97
|
+
activejob (= 7.0.8.7)
|
98
|
+
activerecord (= 7.0.8.7)
|
99
|
+
activesupport (= 7.0.8.7)
|
100
100
|
marcel (~> 1.0)
|
101
101
|
mini_mime (>= 1.1.0)
|
102
102
|
activestorage-validator (0.4.0)
|
103
103
|
rails (>= 6.1.0)
|
104
|
-
activesupport (7.0.8.
|
104
|
+
activesupport (7.0.8.7)
|
105
105
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
106
106
|
i18n (>= 1.6, < 2)
|
107
107
|
minitest (>= 5.1)
|
@@ -227,7 +227,7 @@ GEM
|
|
227
227
|
mini_mime (1.1.5)
|
228
228
|
mini_racer (0.16.0)
|
229
229
|
libv8-node (~> 18.19.0.0)
|
230
|
-
minitest (5.25.
|
230
|
+
minitest (5.25.4)
|
231
231
|
multi_xml (0.7.1)
|
232
232
|
bigdecimal (~> 3.1)
|
233
233
|
multipart-post (2.4.1)
|
@@ -243,17 +243,17 @@ GEM
|
|
243
243
|
net-smtp (0.5.0)
|
244
244
|
net-protocol
|
245
245
|
nio4r (2.7.3)
|
246
|
-
nokogiri (1.
|
246
|
+
nokogiri (1.17.2-aarch64-linux)
|
247
247
|
racc (~> 1.4)
|
248
|
-
nokogiri (1.
|
248
|
+
nokogiri (1.17.2-arm-linux)
|
249
249
|
racc (~> 1.4)
|
250
|
-
nokogiri (1.
|
250
|
+
nokogiri (1.17.2-arm64-darwin)
|
251
251
|
racc (~> 1.4)
|
252
|
-
nokogiri (1.
|
252
|
+
nokogiri (1.17.2-x86-linux)
|
253
253
|
racc (~> 1.4)
|
254
|
-
nokogiri (1.
|
254
|
+
nokogiri (1.17.2-x86_64-darwin)
|
255
255
|
racc (~> 1.4)
|
256
|
-
nokogiri (1.
|
256
|
+
nokogiri (1.17.2-x86_64-linux)
|
257
257
|
racc (~> 1.4)
|
258
258
|
orm_adapter (0.5.0)
|
259
259
|
poltergeist (1.18.1)
|
@@ -276,32 +276,32 @@ GEM
|
|
276
276
|
rack-test (2.1.0)
|
277
277
|
rack (>= 1.3)
|
278
278
|
radius (0.7.5)
|
279
|
-
rails (7.0.8.
|
280
|
-
actioncable (= 7.0.8.
|
281
|
-
actionmailbox (= 7.0.8.
|
282
|
-
actionmailer (= 7.0.8.
|
283
|
-
actionpack (= 7.0.8.
|
284
|
-
actiontext (= 7.0.8.
|
285
|
-
actionview (= 7.0.8.
|
286
|
-
activejob (= 7.0.8.
|
287
|
-
activemodel (= 7.0.8.
|
288
|
-
activerecord (= 7.0.8.
|
289
|
-
activestorage (= 7.0.8.
|
290
|
-
activesupport (= 7.0.8.
|
279
|
+
rails (7.0.8.7)
|
280
|
+
actioncable (= 7.0.8.7)
|
281
|
+
actionmailbox (= 7.0.8.7)
|
282
|
+
actionmailer (= 7.0.8.7)
|
283
|
+
actionpack (= 7.0.8.7)
|
284
|
+
actiontext (= 7.0.8.7)
|
285
|
+
actionview (= 7.0.8.7)
|
286
|
+
activejob (= 7.0.8.7)
|
287
|
+
activemodel (= 7.0.8.7)
|
288
|
+
activerecord (= 7.0.8.7)
|
289
|
+
activestorage (= 7.0.8.7)
|
290
|
+
activesupport (= 7.0.8.7)
|
291
291
|
bundler (>= 1.15.0)
|
292
|
-
railties (= 7.0.8.
|
292
|
+
railties (= 7.0.8.7)
|
293
293
|
rails-dom-testing (2.2.0)
|
294
294
|
activesupport (>= 5.0.0)
|
295
295
|
minitest
|
296
296
|
nokogiri (>= 1.6)
|
297
|
-
rails-html-sanitizer (1.6.
|
297
|
+
rails-html-sanitizer (1.6.2)
|
298
298
|
loofah (~> 2.21)
|
299
299
|
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
|
300
300
|
rails-observers (0.1.5)
|
301
301
|
activemodel (>= 4.0)
|
302
|
-
railties (7.0.8.
|
303
|
-
actionpack (= 7.0.8.
|
304
|
-
activesupport (= 7.0.8.
|
302
|
+
railties (7.0.8.7)
|
303
|
+
actionpack (= 7.0.8.7)
|
304
|
+
activesupport (= 7.0.8.7)
|
305
305
|
method_source
|
306
306
|
rake (>= 12.2)
|
307
307
|
thor (~> 1.0)
|
data/README.md
CHANGED
@@ -40,16 +40,14 @@ codebase are copyright (c) John W. Long and Sean Cribbs; anything after the
|
|
40
40
|
fork is copyright (c) Pittsburgh Cultural Trust. A copy of the MIT license can
|
41
41
|
be found in the LICENSE file.
|
42
42
|
|
43
|
-
## Installation and Setup
|
43
|
+
## Installation and Setup
|
44
44
|
|
45
45
|
TrustyCMS is a traditional Ruby on Rails engine, meaning that you can
|
46
46
|
configure and run it the way you would a normal gem, like [Devise](https://github.com/plataformatec/devise).
|
47
47
|
|
48
48
|
See the INSTALL.md file for more instructions.
|
49
49
|
|
50
|
-
### Installation
|
51
|
-
|
52
|
-
#### Setup
|
50
|
+
### Installation
|
53
51
|
|
54
52
|
Prerequisites:
|
55
53
|
|
@@ -79,6 +77,111 @@ Steps:
|
|
79
77
|
|
80
78
|
rspec
|
81
79
|
|
80
|
+
|
81
|
+
### Page Status Refresh Setup
|
82
|
+
|
83
|
+
To ensure **Scheduled Pages** automatically update their status to **Published** after their designated **Publish Date & Time**, follow these steps to set up an automated refresh using **AWS Lambda** and **EventBridge**.
|
84
|
+
|
85
|
+
**1. Generate a Bearer Token**
|
86
|
+
Open a Rails console and run the following command:
|
87
|
+
```bash
|
88
|
+
rails c
|
89
|
+
```
|
90
|
+
Then generate a token:
|
91
|
+
```ruby
|
92
|
+
SecureRandom.base58(24)
|
93
|
+
```
|
94
|
+
|
95
|
+
**2. Store the Token in Rails Credentials**
|
96
|
+
Run the following command to edit your credentials:
|
97
|
+
```bash
|
98
|
+
bin/rails encrypted:edit config/credentials.yml.enc
|
99
|
+
```
|
100
|
+
Add the token to your credentials:
|
101
|
+
```yaml
|
102
|
+
trusty_cms:
|
103
|
+
page_status_bearer_token: '<your bearer token>'
|
104
|
+
```
|
105
|
+
|
106
|
+
**3. Create a Ruby Lambda Function in AWS**
|
107
|
+
- Log into **AWS Lambda** and create a **new Ruby Lambda function**.
|
108
|
+
- Note the **Ruby version** used, as you'll need it locally.
|
109
|
+
- Use [rbenv](https://github.com/rbenv/rbenv) to manage the Ruby version locally:
|
110
|
+
```bash
|
111
|
+
rbenv install 3.3.0
|
112
|
+
rbenv local 3.3.0
|
113
|
+
```
|
114
|
+
|
115
|
+
**4. Write the Lambda Function Code**
|
116
|
+
In your local development environment:
|
117
|
+
- Create a new folder and open it in your IDE.
|
118
|
+
- Save the following code in a file named `lambda_handler.rb`:
|
119
|
+
|
120
|
+
```ruby
|
121
|
+
require 'httparty'
|
122
|
+
|
123
|
+
def lambda_handler(event:, context:)
|
124
|
+
uri = ENV['API_ENDPOINT']
|
125
|
+
token = ENV['BEARER_TOKEN']
|
126
|
+
|
127
|
+
response = HTTParty.post(
|
128
|
+
uri,
|
129
|
+
headers: {
|
130
|
+
'Content-Type': 'application/json',
|
131
|
+
'Authorization': "Bearer #{token}"
|
132
|
+
}
|
133
|
+
)
|
134
|
+
|
135
|
+
if response.success?
|
136
|
+
puts "Success: #{response.body}"
|
137
|
+
else
|
138
|
+
puts "Error: #{response.code} - #{response.message}"
|
139
|
+
end
|
140
|
+
end
|
141
|
+
```
|
142
|
+
|
143
|
+
**5. Install Dependencies**
|
144
|
+
Run the following commands in your terminal:
|
145
|
+
```bash
|
146
|
+
gem install bundler
|
147
|
+
bundle init
|
148
|
+
```
|
149
|
+
Add the dependency to your `Gemfile`:
|
150
|
+
```ruby
|
151
|
+
gem 'httparty'
|
152
|
+
```
|
153
|
+
Install dependencies locally:
|
154
|
+
```bash
|
155
|
+
bundle config set --local path 'vendor/bundle'
|
156
|
+
bundle install
|
157
|
+
```
|
158
|
+
|
159
|
+
**6. Package the Lambda Function**
|
160
|
+
Archive your function and dependencies:
|
161
|
+
```bash
|
162
|
+
zip -r lambda_package.zip .
|
163
|
+
```
|
164
|
+
|
165
|
+
**7. Upload to AWS Lambda**
|
166
|
+
- In **AWS Lambda**, open your function.
|
167
|
+
- Select **Upload From > .zip file**.
|
168
|
+
- Upload the `lambda_package.zip` file.
|
169
|
+
|
170
|
+
**8. Configure Environment Variables**
|
171
|
+
In the AWS Lambda Configuration:
|
172
|
+
- Go to **Environment Variables** > **Edit**.
|
173
|
+
- Add the following:
|
174
|
+
- `API_ENDPOINT`: `<your-url>/page-status/refresh`
|
175
|
+
- `BEARER_TOKEN`: `<your bearer token>`
|
176
|
+
|
177
|
+
**9. Set Up EventBridge Trigger**
|
178
|
+
- In **Configuration Settings > Triggers**, create a **new EventBridge Trigger**.
|
179
|
+
- Set the **Schedule** to match your desired **page status refresh frequency**.
|
180
|
+
|
181
|
+
Your setup is now complete, and **Scheduled Pages** will automatically update their status via the AWS Lambda and EventBridge integration.
|
182
|
+
|
183
|
+
### Contributing to TrustyCMS
|
184
|
+
|
82
185
|
When you're ready to make a change:
|
83
186
|
|
84
187
|
1. Add the pgharts fork as a git remote called "upstream":
|
@@ -0,0 +1,60 @@
|
|
1
|
+
$(document).ready(function() {
|
2
|
+
function isValidDateTime(value) {
|
3
|
+
return !isNaN(new Date(value).getTime());
|
4
|
+
}
|
5
|
+
|
6
|
+
function showError(message) {
|
7
|
+
$('#published-at-error').text(message);
|
8
|
+
$('.error').removeClass('hidden');
|
9
|
+
}
|
10
|
+
|
11
|
+
function hideError() {
|
12
|
+
$('.error').addClass('hidden');
|
13
|
+
}
|
14
|
+
|
15
|
+
function validateScheduledStatus(publishedTime, currentTime) {
|
16
|
+
if (!isValidDateTime(publishedTime)) {
|
17
|
+
showError('Select a valid Date & Time.');
|
18
|
+
return false;
|
19
|
+
}
|
20
|
+
if (publishedTime < currentTime) {
|
21
|
+
showError('Scheduled Date & Time cannot be in the past.');
|
22
|
+
return false;
|
23
|
+
}
|
24
|
+
|
25
|
+
hideError();
|
26
|
+
return true;
|
27
|
+
}
|
28
|
+
|
29
|
+
function validatePublishedStatus(publishedTime, currentTime) {
|
30
|
+
if (publishedTime > currentTime) {
|
31
|
+
showError('Published Date & Time cannot be in the future. Clear the date and time to publish now, or set the status to Scheduled.');
|
32
|
+
return false;
|
33
|
+
}
|
34
|
+
|
35
|
+
hideError();
|
36
|
+
return true;
|
37
|
+
}
|
38
|
+
|
39
|
+
function validateDateTime() {
|
40
|
+
const publishedAt = $('#page_published_at').val();
|
41
|
+
const status = $('#page_status_id').val();
|
42
|
+
const publishedTime = new Date(publishedAt);
|
43
|
+
const currentTime = new Date();
|
44
|
+
|
45
|
+
if (status === '90') {
|
46
|
+
return validateScheduledStatus(publishedTime, currentTime);
|
47
|
+
}
|
48
|
+
|
49
|
+
if (status === '100') {
|
50
|
+
return validatePublishedStatus(publishedTime, currentTime);
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
54
|
+
$('#save-button, #save-and-continue-button').on('click', function(event) {
|
55
|
+
if (!validateDateTime()) {
|
56
|
+
event.preventDefault();
|
57
|
+
event.stopImmediatePropagation();
|
58
|
+
}
|
59
|
+
});
|
60
|
+
});
|
@@ -20,7 +20,8 @@
|
|
20
20
|
@import "partials/footer";
|
21
21
|
@import "partials/popup";
|
22
22
|
@import "partials/tabcontrol";
|
23
|
-
@import "partials/
|
23
|
+
@import "partials/date_input";
|
24
|
+
@import "partials/datetime_input";
|
24
25
|
@import "partials/toolbar";
|
25
26
|
@import "partials/validations";
|
26
27
|
@import "partials/preferences";
|
@@ -0,0 +1,61 @@
|
|
1
|
+
class PageStatusController < ApplicationController
|
2
|
+
skip_before_action :verify_authenticity_token, only: [:refresh]
|
3
|
+
skip_before_action :authenticate_user!, only: [:refresh]
|
4
|
+
before_action :authenticate_bearer_token
|
5
|
+
|
6
|
+
def refresh
|
7
|
+
pages = Page.where(status_id: Status[:scheduled].id)
|
8
|
+
|
9
|
+
updated_pages, remaining_pages = process_pages(pages)
|
10
|
+
|
11
|
+
render json: refresh_response(updated_pages, remaining_pages), status: :ok
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def authenticate_bearer_token
|
17
|
+
provided_token = request.headers['Authorization']&.split(' ')&.last
|
18
|
+
expected_token = Rails.application.credentials[:trusty_cms][:page_status_bearer_token]
|
19
|
+
|
20
|
+
if provided_token.blank?
|
21
|
+
render json: { error: 'Missing Bearer Token' }, status: :unauthorized and return
|
22
|
+
end
|
23
|
+
|
24
|
+
unless ActiveSupport::SecurityUtils.secure_compare(provided_token, expected_token)
|
25
|
+
render json: { error: 'Invalid Bearer Token' }, status: :unauthorized
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def process_pages(pages)
|
30
|
+
updated_pages = []
|
31
|
+
remaining_pages = []
|
32
|
+
|
33
|
+
pages.each do |page|
|
34
|
+
page_id = page.id
|
35
|
+
if page.published_at <= Time.now
|
36
|
+
page.update(status_id: Status[:published].id)
|
37
|
+
updated_pages << page_id
|
38
|
+
else
|
39
|
+
remaining_pages << page_id
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
[updated_pages, remaining_pages]
|
44
|
+
end
|
45
|
+
|
46
|
+
def refresh_response(updated_pages, remaining_pages)
|
47
|
+
if updated_pages.any?
|
48
|
+
updated_pages_count = updated_pages.count
|
49
|
+
{
|
50
|
+
message: "Successfully updated status of #{updated_pages_count} #{'page'.pluralize(updated_pages_count)}.",
|
51
|
+
updated_page_ids: updated_pages,
|
52
|
+
remaining_scheduled_page_ids: remaining_pages,
|
53
|
+
}
|
54
|
+
else
|
55
|
+
{
|
56
|
+
message: 'No scheduled pages matched the criteria for status refresh.',
|
57
|
+
remaining_scheduled_page_ids: remaining_pages,
|
58
|
+
}
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -23,7 +23,6 @@ class SiteController < ApplicationController
|
|
23
23
|
url.to_s
|
24
24
|
end
|
25
25
|
if @page = find_page(url)
|
26
|
-
batch_page_status_refresh if url == '/' || url == ''
|
27
26
|
# This is a bit of a hack to get Vanity URL pages working in another extension
|
28
27
|
# In Rails 2, redirect_to halted execution, so process_page could be aliased and
|
29
28
|
# a redirect could be used. This no longer works. There's a better fix for this,
|
@@ -61,20 +60,6 @@ class SiteController < ApplicationController
|
|
61
60
|
|
62
61
|
private
|
63
62
|
|
64
|
-
def batch_page_status_refresh
|
65
|
-
@changed_pages = []
|
66
|
-
@pages = Page.where({ status_id: Status[:scheduled].id })
|
67
|
-
@pages.each do |page|
|
68
|
-
if page.published_at <= Time.now
|
69
|
-
page.status_id = Status[:published].id
|
70
|
-
page.save
|
71
|
-
@changed_pages << page.id
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
expires_in nil, :private => true, 'no-cache' => true if @changed_pages.length > 0
|
76
|
-
end
|
77
|
-
|
78
63
|
def set_cache_control
|
79
64
|
response_cache_director(@page).set_cache_control
|
80
65
|
end
|
@@ -14,11 +14,6 @@ module Admin::PagesHelper
|
|
14
14
|
!!(@page.errors[:slug] or @page.errors[:breadcrumb])
|
15
15
|
end
|
16
16
|
|
17
|
-
def status_to_display
|
18
|
-
@page.status_id = 100 if @page.status_id == 90
|
19
|
-
@display_status = Status.selectable.map { |s| [I18n.translate(s.name.downcase), s.id] }
|
20
|
-
end
|
21
|
-
|
22
17
|
def clean_page_description(page)
|
23
18
|
page.description.to_s.strip.gsub(/\t/, '').gsub(/\s+/, ' ')
|
24
19
|
end
|
@@ -33,11 +33,12 @@ module ApplicationHelper
|
|
33
33
|
t('buttons.save_changes', default: 'Save Changes')
|
34
34
|
options[:class] ||= 'button'
|
35
35
|
options[:accesskey] ||= 'S'
|
36
|
+
options[:id] ||= 'save-button'
|
36
37
|
submit_tag options.delete(:label), options
|
37
38
|
end
|
38
39
|
|
39
40
|
def save_model_and_continue_editing_button(_model)
|
40
|
-
submit_tag t('buttons.save_and_continue'), name: 'continue', class: 'button', accesskey: 's'
|
41
|
+
submit_tag t('buttons.save_and_continue'), name: 'continue', class: 'button', accesskey: 's', id: 'save-and-continue-button'
|
41
42
|
end
|
42
43
|
|
43
44
|
def current_item?(item)
|
data/app/models/page.rb
CHANGED
@@ -8,7 +8,7 @@ class Page < ActiveRecord::Base
|
|
8
8
|
end
|
9
9
|
|
10
10
|
# Callbacks
|
11
|
-
before_save :update_virtual, :
|
11
|
+
before_save :update_virtual, :update_published_datetime, :set_allowed_children_cache
|
12
12
|
|
13
13
|
# Associations
|
14
14
|
acts_as_tree order: 'position ASC'
|
@@ -220,15 +220,8 @@ class Page < ActiveRecord::Base
|
|
220
220
|
slug_child
|
221
221
|
end
|
222
222
|
|
223
|
-
def
|
224
|
-
self.published_at = Time.zone.now if published? && published_at
|
225
|
-
|
226
|
-
if !published_at.nil? && (published? || scheduled?)
|
227
|
-
self[:status_id] = Status[:scheduled].id if published_at > Time.zone.now
|
228
|
-
self[:status_id] = Status[:published].id if published_at <= Time.zone.now
|
229
|
-
end
|
230
|
-
|
231
|
-
true
|
223
|
+
def update_published_datetime
|
224
|
+
self.published_at = Time.zone.now if published? && published_at.blank?
|
232
225
|
end
|
233
226
|
|
234
227
|
def default_child
|
data/app/models/status.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
= javascript_include_tag 'admin/validations/scheduled_status_validation'
|
2
|
+
|
1
3
|
= fields.hidden_field :lock_version
|
2
4
|
= fields.hidden_field :parent_id
|
3
5
|
= fields.hidden_field :class_name
|
@@ -44,14 +46,20 @@
|
|
44
46
|
- if current_user.admin? || current_user.editor?
|
45
47
|
.status
|
46
48
|
= fields.label :status_id, t('status')
|
47
|
-
= fields.select :status_id,
|
49
|
+
= fields.select :status_id, Status.selectable.map { |s| [s.name, s.id] }
|
48
50
|
- layout.edit_published_at do
|
49
51
|
.published-date
|
50
|
-
#published_at{:class => (@page.published? ?
|
51
|
-
= fields.label :published_at, t('
|
52
|
-
= fields.text_field :published_at,
|
52
|
+
#published_at{:class => (@page.published? ? '' : 'hidden')}
|
53
|
+
= fields.label :published_at, t('publish_datetime')
|
54
|
+
= fields.text_field :published_at,
|
55
|
+
class: 'datetime',
|
56
|
+
type: 'datetime-local',
|
57
|
+
value: (@page.published_at? ? @page.published_at.strftime('%Y-%m-%dT%H:%M') : nil)
|
53
58
|
= render_region :layout_row, :locals => {:f => fields}
|
54
59
|
|
60
|
+
.error.hidden
|
61
|
+
%span#published-at-error
|
62
|
+
|
55
63
|
- render_region :form_bottom, :locals => {:f => fields} do |form_bottom|
|
56
64
|
- form_bottom.edit_buttons do
|
57
65
|
- @buttons_partials.each do |partial|
|
@@ -187,7 +187,7 @@ Devise.setup do |config|
|
|
187
187
|
# ==> Configuration for :timeoutable
|
188
188
|
# The time you want to timeout the user session without activity. After this
|
189
189
|
# time the user will be asked for credentials again. Default is 30 minutes.
|
190
|
-
|
190
|
+
config.timeout_in = 8.hours
|
191
191
|
|
192
192
|
# ==> Configuration for :lockable
|
193
193
|
# Defines which strategy will be used to lock an account.
|
data/config/locales/en.yml
CHANGED
@@ -243,7 +243,7 @@ en:
|
|
243
243
|
preview: 'Preview'
|
244
244
|
published: 'Published'
|
245
245
|
published_at: 'Published at'
|
246
|
-
|
246
|
+
publish_datetime: 'Publish Date & Time'
|
247
247
|
reference: 'Reference'
|
248
248
|
remember_me: 'Remember me'
|
249
249
|
remember_me_in_this_browser: 'Remember me in this browser'
|
data/config/routes.rb
CHANGED
@@ -4,6 +4,7 @@ TrustyCms::Application.routes.draw do
|
|
4
4
|
as :user do
|
5
5
|
post 'authenticate', to: 'devise/sessions#create', as: :authenticate
|
6
6
|
end
|
7
|
+
post '/page-status/refresh' => 'page_status#refresh'
|
7
8
|
get '/rad_social/mail' => 'social_mailer#social_mail_form', as: :rad_social_mail_form
|
8
9
|
post '/rad_social/mail' => 'social_mailer#create_social_mail', as: :rad_create_social_mail
|
9
10
|
TrustyCms::Application.config.enabled_extensions.each do |ext|
|
data/lib/trusty_cms/version.rb
CHANGED
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.
|
4
|
+
version: 7.0.4
|
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:
|
11
|
+
date: 2025-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activestorage-validator
|
@@ -653,6 +653,7 @@ files:
|
|
653
653
|
- app/assets/javascripts/admin/treetable.js
|
654
654
|
- app/assets/javascripts/admin/utilities.js
|
655
655
|
- app/assets/javascripts/admin/validation.js
|
656
|
+
- app/assets/javascripts/admin/validations/scheduled_status_validation.js
|
656
657
|
- app/assets/javascripts/admin/validations/user_validations.js
|
657
658
|
- app/assets/javascripts/ckeditor/config.js
|
658
659
|
- app/assets/javascripts/ckeditor/contents.css
|
@@ -673,7 +674,8 @@ files:
|
|
673
674
|
- app/assets/stylesheets/admin/modules/_links.scss
|
674
675
|
- app/assets/stylesheets/admin/partials/_actions.scss
|
675
676
|
- app/assets/stylesheets/admin/partials/_content.scss
|
676
|
-
- app/assets/stylesheets/admin/partials/
|
677
|
+
- app/assets/stylesheets/admin/partials/_date_input.scss
|
678
|
+
- app/assets/stylesheets/admin/partials/_datetime_input.scss
|
677
679
|
- app/assets/stylesheets/admin/partials/_drawer.scss
|
678
680
|
- app/assets/stylesheets/admin/partials/_dropdown.scss
|
679
681
|
- app/assets/stylesheets/admin/partials/_footer.scss
|
@@ -707,6 +709,7 @@ files:
|
|
707
709
|
- app/controllers/admin/snippets_controller.rb
|
708
710
|
- app/controllers/admin/users_controller.rb
|
709
711
|
- app/controllers/application_controller.rb
|
712
|
+
- app/controllers/page_status_controller.rb
|
710
713
|
- app/controllers/site_controller.rb
|
711
714
|
- app/controllers/social_mailer_controller.rb
|
712
715
|
- app/helpers/admin/configuration_helper.rb
|
File without changes
|