webflow_sync 2.0.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b00faecbccbfec2e2c8007ef0225d4ca6c5ed0a0988dffb84bb9b5c271514b00
|
4
|
+
data.tar.gz: 5b76e7b85ebbd71059743053275a0d288b0308ac758094cae7efa0bd8d2a87e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c38563161e4684cc4709b07861740ed377c9ed4fa9aacff05fe829534ca684bcf3f04df288577e06acc4fdfd385a19115bd60f290251307bef2a0b0c4b007771
|
7
|
+
data.tar.gz: 9ede89c923844a546c16c015f4a2e5c9f09ab1fdbbafc8d04b0c1a13c033941764f55a8197c83942b0e0c1e2ee00f85ceb271f2bf6f4fff6353da23c588fc010
|
data/README.md
CHANGED
@@ -5,7 +5,9 @@
|
|
5
5
|
|
6
6
|
Keep your Ruby on Rails records in sync with WebFlow.*
|
7
7
|
|
8
|
-
*Currently only one way Rails => WebFlow synchronization
|
8
|
+
*Currently only one way Rails => WebFlow synchronization.
|
9
|
+
|
10
|
+
For the latest changes, check the [CHANGELOG.md](CHANGELOG.md).
|
9
11
|
|
10
12
|
## Installation
|
11
13
|
|
@@ -42,8 +44,9 @@ In `config/initializers/webflow_sync.rb` you can specify configuration options:
|
|
42
44
|
|
43
45
|
1. `api_token`
|
44
46
|
2. `webflow_site_id`
|
45
|
-
3. `skip_webflow_sync` - skip synchronization for different environments
|
46
|
-
4. `
|
47
|
+
3. `skip_webflow_sync` - skip synchronization for different environments.
|
48
|
+
4. `publish_on_sync` - republish all domains after create, update and destroy actions.
|
49
|
+
5. `sync_webflow_slug` - save slug generated on WebFlow to the Rails model, `webflow_slug` column.
|
47
50
|
|
48
51
|
This can be useful if you want to link to WebFlow item directly from your Rails app:
|
49
52
|
|
@@ -56,7 +59,7 @@ In `config/initializers/webflow_sync.rb` you can specify configuration options:
|
|
56
59
|
1. add `webflow_slug` column on the model table, then
|
57
60
|
2. set the `sync_webflow_slug` option to `true`.
|
58
61
|
|
59
|
-
Example:
|
62
|
+
Example:
|
60
63
|
|
61
64
|
```rb
|
62
65
|
WebflowSync.configure do |config|
|
@@ -156,7 +159,7 @@ Or if you already use `#as_json` for some other use-case and cannot modify it, y
|
|
156
159
|
# app/models/article.rb
|
157
160
|
class Article < ApplicationRecord
|
158
161
|
include WebflowSync::ItemSync
|
159
|
-
|
162
|
+
|
160
163
|
def as_webflow_json
|
161
164
|
self.as_json
|
162
165
|
end
|
@@ -37,12 +37,16 @@ module WebflowSync
|
|
37
37
|
make_request(:item, collection['_id'], webflow_item_id)
|
38
38
|
end
|
39
39
|
|
40
|
-
def create_item(record, collection_slug)
|
40
|
+
def create_item(record, collection_slug) # rubocop:disable Metrics/MethodLength
|
41
41
|
collection = find_webflow_collection(collection_slug)
|
42
42
|
response = make_request(:create_item, collection['_id'],
|
43
43
|
record.as_webflow_json.reverse_merge(_archived: false, _draft: false), live: true)
|
44
44
|
|
45
45
|
if update_record_colums(record, response)
|
46
|
+
# When the item is created, sometimes changes are not visible throughout the WebFlow site immediately (probably due to some caching).
|
47
|
+
# To make this change immediately visible from the WebFlow site, we need to publish the site.
|
48
|
+
publish
|
49
|
+
|
46
50
|
puts "Created #{record.inspect} in #{collection_slug}"
|
47
51
|
response
|
48
52
|
else
|
@@ -56,6 +60,10 @@ module WebflowSync
|
|
56
60
|
response = make_request(:update_item, { '_cid' => collection['_id'], '_id' => record.webflow_item_id },
|
57
61
|
record.as_webflow_json.reverse_merge(_archived: false, _draft: false), live: true)
|
58
62
|
|
63
|
+
# When the item is updated, sometimes changes are not visible throughout the WebFlow site immediately (probably due to some caching).
|
64
|
+
# To make this change immediately visible from the WebFlow site, we need to publish the site.
|
65
|
+
publish
|
66
|
+
|
59
67
|
puts "Updated #{record.inspect} in #{collection_slug}"
|
60
68
|
response
|
61
69
|
end
|
@@ -72,6 +80,8 @@ module WebflowSync
|
|
72
80
|
end
|
73
81
|
|
74
82
|
def publish
|
83
|
+
return unless WebflowSync.configuration.publish_on_sync
|
84
|
+
|
75
85
|
response = make_request(:publish, site_id, domain_names: domain_names)
|
76
86
|
|
77
87
|
puts "Publish all domains for Webflow site with id: #{site_id}"
|
@@ -6,10 +6,13 @@ module WebflowSync
|
|
6
6
|
|
7
7
|
def configure
|
8
8
|
self.configuration ||= Configuration.new
|
9
|
+
|
10
|
+
self.configuration.publish_on_sync = true
|
11
|
+
self.configuration.skip_webflow_sync = !Rails.env.production?
|
12
|
+
|
9
13
|
yield(self.configuration)
|
10
14
|
|
11
15
|
self.configuration.api_token ||= ENV.fetch('WEBFLOW_API_TOKEN')
|
12
|
-
defined?(self.configuration.skip_webflow_sync) or self.configuration.skip_webflow_sync = !Rails.env.production?
|
13
16
|
end
|
14
17
|
|
15
18
|
private
|
@@ -18,7 +21,7 @@ module WebflowSync
|
|
18
21
|
end
|
19
22
|
|
20
23
|
class Configuration
|
21
|
-
attr_accessor :skip_webflow_sync, :webflow_site_id, :sync_webflow_slug
|
24
|
+
attr_accessor :skip_webflow_sync, :webflow_site_id, :sync_webflow_slug, :publish_on_sync
|
22
25
|
attr_reader :api_token
|
23
26
|
|
24
27
|
def api_token=(value)
|
data/lib/webflow_sync/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webflow_sync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Viktor
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: dotenv-rails
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: factory_bot_rails
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|