contentful-scheduler-custom 1.5.6999 → 1.6
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/.gitignore +2 -0
- data/.travis.yml +2 -2
- data/CHANGELOG.md +6 -10
- data/README.md +89 -9
- data/contentful-scheduler.gemspec +3 -3
- data/example/Dockerfile +25 -0
- data/example/Gemfile +3 -2
- data/example/Procfile +2 -2
- data/example/Rakefile +7 -8
- data/example/config.ru +3 -3
- data/lib/contentful/scheduler/queue.rb +10 -10
- data/lib/contentful/scheduler/version.rb +1 -1
- data/spec/contentful/scheduler/tasks/unpublish_spec.rb +1 -1
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24c8e76a7bb0e793768f797eb6b2252796328df7
|
4
|
+
data.tar.gz: ec6d9c83ff444867914d62efaa43a221f7701c51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47aa3a11c0e51b5166fde9ab1816e167c659c0959b39fe462f1fc8441645b9f483b21f213c75b87d0b951ebf1db685496e4930b544bb119d14e9354b5946c834
|
7
|
+
data.tar.gz: 887d473720281c0c31cd066697f65ed0af986713a3f487dad55c459dafb914ff10c6c595358bccf6b9a760a032f73dd71e85618ce0d64e0a4ff8a2443176549e
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,21 +2,17 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
-
##
|
6
|
-
### Added
|
7
|
-
* Added support for scheduled unpublishing. [#10](https://github.com/contentful/contentful-scheduler.rb/issues/10)
|
5
|
+
## 1.6
|
8
6
|
|
9
|
-
|
10
|
-
### Fixed
|
7
|
+
* Added support for scheduled unpublishing. [#10](https://github.com/contentful/contentful-scheduler.rb/issues/10)
|
11
8
|
* Fixed User Agent Header to comply with specification.
|
12
|
-
|
13
|
-
### Added
|
14
9
|
* Added authentication mechanisms. [#9](https://github.com/contentful/contentful-scheduler.rb/issues/9)
|
15
|
-
|
16
|
-
## 0.3.0
|
17
|
-
### Added
|
18
10
|
* Added possibility to republish already published content. [#5](https://github.com/contentful/contentful-scheduler.rb/issues/5)
|
19
11
|
|
12
|
+
## 1.4.0
|
13
|
+
* Contentful Scheduler now supports future publishing for any existing enteries and
|
14
|
+
publishing ContentBlocks first before publishing the page.
|
15
|
+
|
20
16
|
## 0.2.1
|
21
17
|
|
22
18
|
### Fixed
|
data/README.md
CHANGED
@@ -15,12 +15,14 @@ entries for scheduled publishing and unpublishing.
|
|
15
15
|
Every time the endpoint recieves a call it looks for the value of the field defined in the configuration.
|
16
16
|
If the value is a time in the future it will schedule the entry for publishing or unpublishing at the specified time.
|
17
17
|
|
18
|
-
A background worker based on the popular `resque` gem will then proceed to actually make the publish call
|
19
|
-
against the Content Management API at the due time. For this the Entries you wish to publish
|
20
|
-
customizable Date field, which we advice to call `publishDate
|
21
|
-
|
18
|
+
A background worker based on the popular `resque` gem will then proceed to actually make the publish or unpublish call
|
19
|
+
against the Content Management API at the due time. For this the Entries you wish to publish/unpublish require a
|
20
|
+
customizable Date field, which we advice to call `publishDate`/`unpublishDate`, this field can be configured inside your
|
21
|
+
`Rakefile` and is specific per-space(supports multiple spaces), also please make sure contentBlocks are valid
|
22
|
+
as per logic contentBlocks are published/unpublished first then the page is published, so if there is any contentBlocks with errors those won't be
|
23
|
+
published/unpublished.
|
22
24
|
|
23
|
-
You can add multiple spaces to your configuration, making it useful if you have a
|
25
|
+
You can add multiple spaces to your configuration, making it useful if you have a multi-space setup.
|
24
26
|
|
25
27
|
## Requirements
|
26
28
|
|
@@ -31,7 +33,7 @@ You can add multiple spaces to your configuration, making it useful if you have
|
|
31
33
|
Add this line to your application's Gemfile:
|
32
34
|
|
33
35
|
```ruby
|
34
|
-
gem 'contentful-scheduler'
|
36
|
+
gem 'contentful-scheduler-custom'
|
35
37
|
```
|
36
38
|
|
37
39
|
And then execute:
|
@@ -40,7 +42,7 @@ And then execute:
|
|
40
42
|
|
41
43
|
Or install it yourself as:
|
42
44
|
|
43
|
-
$ gem install contentful-scheduler
|
45
|
+
$ gem install contentful-scheduler-custom
|
44
46
|
|
45
47
|
## Usage
|
46
48
|
|
@@ -56,7 +58,7 @@ If you want to roll out your own, you need to follow the next steps:
|
|
56
58
|
```ruby
|
57
59
|
source 'https://rubygems.org'
|
58
60
|
|
59
|
-
gem 'contentful-scheduler', '~>
|
61
|
+
gem 'contentful-scheduler-custom', '~>1.6'
|
60
62
|
gem 'contentful-management', '~> 1.0'
|
61
63
|
gem 'resque', '~> 1.0'
|
62
64
|
gem 'resque-scheduler', '~> 4.0'
|
@@ -89,13 +91,30 @@ config = {
|
|
89
91
|
password: 'YOUR_REDIS_PASSWORD'
|
90
92
|
},
|
91
93
|
spaces: {
|
94
|
+
'YOUR_SPACE_ID' => {
|
95
|
+
publish_field: 'publishDate', # It specifies the field ID for your Publish Date in your Content Type
|
96
|
+
auth: { # This is optional
|
97
|
+
# ... content in this section will be explained in a separate section ...
|
98
|
+
https://github.devcloud.elisa.fi/contentful-cms/scheduler/pull/2/conflict?name=README.md&ancestor_oid=091876b7c593e3c9ec6ffb1ccd405dcd03fcae1e&base_oid=02b7b6fbfcfa15c1f257beb63ac6b578da282205&head_oid=16b4e23acd70062e83d9bf5930590183234a6c1b }
|
99
|
+
management_token: 'YOUR_TOKEN'
|
100
|
+
},
|
101
|
+
management_token: 'YOUR_TOKEN'
|
102
|
+
},
|
103
|
+
'YOUR_SPACE_ID' => {
|
104
|
+
publish_field: 'publishDate', # It specifies the field ID for your Publish Date in your Content Type
|
105
|
+
unpublish_field: 'unpublishDate', # Optional - It specifies the field ID for your Unpublish Date in your Content Type
|
106
|
+
auth: { # This is optional
|
107
|
+
# ... content in this section will be explained in a separate section ...
|
108
|
+
}
|
109
|
+
management_token: 'YOUR_TOKEN'
|
110
|
+
},
|
92
111
|
'YOUR_SPACE_ID' => {
|
93
112
|
publish_field: 'publishDate', # It specifies the field ID for your Publish Date in your Content Type
|
94
113
|
unpublish_field: 'unpublishDate', # Optional - It specifies the field ID for your Unpublish Date in your Content Type
|
95
|
-
management_token: 'YOUR_TOKEN',
|
96
114
|
auth: { # This is optional
|
97
115
|
# ... content in this section will be explained in a separate section ...
|
98
116
|
}
|
117
|
+
management_token: 'YOUR_TOKEN'
|
99
118
|
}
|
100
119
|
},
|
101
120
|
}
|
@@ -265,6 +284,67 @@ That will allow Heroku to set it's own Port according to their policy.
|
|
265
284
|
|
266
285
|
The URL for the webhook then will be on port 80, so you should change it to: `http://YOUR_APPLICATION/scheduler`.
|
267
286
|
|
287
|
+
## Running in Production Mode
|
288
|
+
|
289
|
+
After verifying that application is working fine in development mode(run "foreman start" for development mode)
|
290
|
+
|
291
|
+
Run the following commands
|
292
|
+
|
293
|
+
1. sudo foreman export -p5000 --app stp --user username_to_start_from systemd /etc/systemd/system/
|
294
|
+
|
295
|
+
Output will be like this:
|
296
|
+
|
297
|
+
[foreman export] cleaning up directory: /etc/systemd/system//graphical.target.wants
|
298
|
+
[foreman export] writing: stp-web@.service
|
299
|
+
[foreman export] creating: stp-web.target.wants
|
300
|
+
[foreman export] symlinking: stp-web.target.wants/stp-web@5000.service -> ../stp-web@.service
|
301
|
+
[foreman export] writing: stp-web.target
|
302
|
+
[foreman export] writing: stp-celery@.service
|
303
|
+
[foreman export] creating: stp-celery.target.wants
|
304
|
+
[foreman export] symlinking: stp-celery.target.wants/stp-celery@5100.service -> ../stp-celery@.service
|
305
|
+
[foreman export] writing: stp-celery.target
|
306
|
+
[foreman export] writing: stp.target
|
307
|
+
|
308
|
+
2. cat /etc/systemd/system/stp-web@.service | head -n 10
|
309
|
+
|
310
|
+
Output will be like this:
|
311
|
+
|
312
|
+
[Unit]
|
313
|
+
PartOf=stp-web.target
|
314
|
+
|
315
|
+
[Service]
|
316
|
+
User=username_to_start_from
|
317
|
+
WorkingDirectory=/srv/stp/
|
318
|
+
Environment=PORT=%i
|
319
|
+
... HERE OTHER DIRICTIVES FROM YOUR .env file ...
|
320
|
+
Environment=DEBUG=0
|
321
|
+
...
|
322
|
+
|
323
|
+
|
324
|
+
3. Start only gunicorn on port 5700:
|
325
|
+
|
326
|
+
systemctl start stp-web@5700.service
|
327
|
+
|
328
|
+
4. Start whole target:
|
329
|
+
|
330
|
+
systemctl start stp.target
|
331
|
+
|
332
|
+
5. Enable whole target (start on OS boot):
|
333
|
+
|
334
|
+
systemctl enable stp.target
|
335
|
+
|
336
|
+
6. Restarting daemon
|
337
|
+
|
338
|
+
sudo systemctl daemon-reload
|
339
|
+
|
340
|
+
sudo systemctl restart stp.target
|
341
|
+
|
342
|
+
7. Optional
|
343
|
+
|
344
|
+
You can also simply define port when call foreman export -pXXXX, but it should be multiple of 1000,
|
345
|
+
e.g. 1000, 2000, 3000, 45000 etc.
|
346
|
+
|
347
|
+
|
268
348
|
## Contributing
|
269
349
|
|
270
350
|
Bug reports and pull requests are welcome on GitHub at https://github.com/contentful/contentful-scheduler.rb. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
@@ -21,9 +21,9 @@ Gem::Specification.new do |spec|
|
|
21
21
|
|
22
22
|
spec.add_runtime_dependency "contentful-webhook-listener", "~> 0.2"
|
23
23
|
spec.add_runtime_dependency "contentful-management", "~> 1.8"
|
24
|
-
spec.add_runtime_dependency "resque", "~> 1.
|
25
|
-
spec.add_runtime_dependency "resque-scheduler", "~> 4.
|
26
|
-
spec.add_runtime_dependency "redis", "~>
|
24
|
+
spec.add_runtime_dependency "resque", "~> 1.27.4"
|
25
|
+
spec.add_runtime_dependency "resque-scheduler", "~> 4.3.1"
|
26
|
+
spec.add_runtime_dependency "redis", "~> 4.0.1"
|
27
27
|
spec.add_runtime_dependency "chronic", "~> 0.10"
|
28
28
|
|
29
29
|
spec.add_development_dependency "bundler", "~> 1.10"
|
data/example/Dockerfile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
FROM ruby:2.5
|
2
|
+
MAINTAINER Bugs Bunny <bbunny@rubyplus.com>
|
3
|
+
|
4
|
+
|
5
|
+
|
6
|
+
# Install gems
|
7
|
+
ENV APP_HOME /app
|
8
|
+
ENV HOME /root
|
9
|
+
RUN mkdir $APP_HOME
|
10
|
+
RUN chmod -R 777 /app
|
11
|
+
RUN chmod -R 777 /root
|
12
|
+
|
13
|
+
|
14
|
+
WORKDIR $APP_HOME
|
15
|
+
COPY Gemfile* $APP_HOME/
|
16
|
+
RUN bundle install
|
17
|
+
|
18
|
+
# Upload source
|
19
|
+
COPY . $APP_HOME
|
20
|
+
|
21
|
+
# Start server
|
22
|
+
ENV PORT 8080
|
23
|
+
EXPOSE 8080
|
24
|
+
USER 1001
|
25
|
+
CMD ["foreman", "start"]
|
data/example/Gemfile
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
gem 'contentful-scheduler', '~>
|
3
|
+
gem 'contentful-scheduler-custom', '~>1.4'
|
4
4
|
gem 'contentful-management', '~> 1.0'
|
5
5
|
gem 'resque', '~> 1.0'
|
6
|
-
gem 'resque-scheduler', '
|
6
|
+
gem 'resque-scheduler', '4.2.1'
|
7
7
|
gem 'rake'
|
8
|
+
gem 'foreman', '~> 0.84.0'
|
data/example/Procfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
web:
|
1
|
+
web: PORT=$PORT bundle exec env rake contentful:scheduler
|
2
2
|
monitor: env bundle exec rackup
|
3
3
|
resque: env bundle exec rake resque:work
|
4
|
-
resque_scheduler: env bundle exec rake resque:scheduler
|
4
|
+
resque_scheduler: env bundle exec rake resque:scheduler
|
data/example/Rakefile
CHANGED
@@ -1,23 +1,22 @@
|
|
1
1
|
require 'contentful/scheduler'
|
2
|
-
require 'logger' # Optional
|
3
2
|
|
4
3
|
$stdout.sync = true
|
5
4
|
|
6
5
|
config = {
|
7
6
|
logger: Logger.new(STDOUT), # Defaults to NullLogger
|
8
|
-
port:
|
7
|
+
port: 8080, # Defaults to 8081
|
9
8
|
endpoint: '/scheduler', # Defaults to /scheduler
|
10
9
|
redis: {
|
11
|
-
host: '
|
12
|
-
port: '
|
13
|
-
password: '
|
10
|
+
host: 'scheduler-redis-db',
|
11
|
+
port: '6379',
|
12
|
+
password: 'password'
|
14
13
|
},
|
15
14
|
spaces: {
|
16
|
-
'
|
15
|
+
'qbra4qai2ti2' => {
|
17
16
|
publish_field: 'publishDate', # It specifies the field ID for your Publish Date in your Content Type
|
18
|
-
management_token: '
|
17
|
+
management_token: 'CFPAT-45f0c4258aa9b32e8a8b6ccebf64136386b31f3ec435cc17f540368d5416de02'
|
19
18
|
}
|
20
|
-
}
|
19
|
+
},
|
21
20
|
}
|
22
21
|
|
23
22
|
namespace :contentful do
|
data/example/config.ru
CHANGED
@@ -3,9 +3,9 @@ require 'resque/server'
|
|
3
3
|
require 'resque/scheduler/server'
|
4
4
|
|
5
5
|
config = {
|
6
|
-
host: '
|
7
|
-
port: '
|
8
|
-
password: '
|
6
|
+
host: 'scheduler-redis-db',
|
7
|
+
port: '6379',
|
8
|
+
password: 'password'
|
9
9
|
}
|
10
10
|
Resque.redis = config
|
11
11
|
|
@@ -1,6 +1,7 @@
|
|
1
|
+
require_relative "tasks"
|
2
|
+
require_relative "tasks"
|
1
3
|
require 'chronic'
|
2
4
|
require 'contentful/webhook/listener'
|
3
|
-
require_relative "tasks"
|
4
5
|
|
5
6
|
module Contentful
|
6
7
|
module Scheduler
|
@@ -39,7 +40,7 @@ module Contentful
|
|
39
40
|
::Contentful::Scheduler.config[:spaces][webhook.space_id][:management_token]
|
40
41
|
)
|
41
42
|
end
|
42
|
-
|
43
|
+
|
43
44
|
def update_or_create_for_unpublish(webhook)
|
44
45
|
remove_unpublish(webhook) if in_unpublish_queue?(webhook)
|
45
46
|
return false unless unpublish_is_future?(webhook)
|
@@ -54,8 +55,8 @@ module Contentful
|
|
54
55
|
end
|
55
56
|
|
56
57
|
def remove(webhook)
|
57
|
-
remove_unpublish(webhook)
|
58
58
|
remove_publish(webhook)
|
59
|
+
remove_unpublish(webhook)
|
59
60
|
end
|
60
61
|
|
61
62
|
def remove_publish(webhook)
|
@@ -98,6 +99,10 @@ module Contentful
|
|
98
99
|
end
|
99
100
|
end
|
100
101
|
|
102
|
+
def isContentBlockAvailable(webhook)
|
103
|
+
return !webhook.fields['contentBlocks'].nil?
|
104
|
+
end
|
105
|
+
|
101
106
|
def publishable?(webhook)
|
102
107
|
return false unless spaces.key?(webhook.space_id)
|
103
108
|
|
@@ -114,7 +119,6 @@ module Contentful
|
|
114
119
|
if webhook_unpublish_field?(webhook)
|
115
120
|
return !webhook_unpublish_field(webhook).nil? && unpublish_is_future?(webhook)
|
116
121
|
end
|
117
|
-
|
118
122
|
false
|
119
123
|
end
|
120
124
|
|
@@ -187,10 +191,6 @@ module Contentful
|
|
187
191
|
end
|
188
192
|
end
|
189
193
|
|
190
|
-
def isContentBlockAvailable(webhook)
|
191
|
-
return !webhook.fields['contentBlocks'].nil?
|
192
|
-
end
|
193
|
-
|
194
194
|
def getScheduleType(type)
|
195
195
|
if type == 'publish'
|
196
196
|
::Contentful::Scheduler::Tasks::Publish
|
@@ -212,11 +212,11 @@ module Contentful
|
|
212
212
|
end
|
213
213
|
|
214
214
|
def webhook_publish_field?(webhook)
|
215
|
-
webhook.fields.key?(spaces.fetch(webhook.space_id, {})[:publish_field])
|
215
|
+
webhook.fields.key?(spaces.fetch(webhook.space_id, {})[:publish_field]) if webhook.respond_to?(:fields)
|
216
216
|
end
|
217
217
|
|
218
218
|
def webhook_unpublish_field?(webhook)
|
219
|
-
webhook.fields.key?(spaces.fetch(webhook.space_id, {})[:unpublish_field])
|
219
|
+
webhook.fields.key?(spaces.fetch(webhook.space_id, {})[:unpublish_field]) if webhook.respond_to?(:fields)
|
220
220
|
end
|
221
221
|
|
222
222
|
def webhook_publish_field(webhook)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contentful-scheduler-custom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: '1.6'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Contentful GmbH (David Litvak Bruno0
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: contentful-webhook-listener
|
@@ -44,42 +44,42 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 1.27.4
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 1.27.4
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: resque-scheduler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 4.3.1
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 4.3.1
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: redis
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 4.0.1
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 4.0.1
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: chronic
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -196,6 +196,7 @@ files:
|
|
196
196
|
- README.md
|
197
197
|
- Rakefile
|
198
198
|
- contentful-scheduler.gemspec
|
199
|
+
- example/Dockerfile
|
199
200
|
- example/Gemfile
|
200
201
|
- example/Procfile
|
201
202
|
- example/Rakefile
|