jekyll-crosspost-to-medium 0.1.7 → 0.1.8
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/lib/jekyll-crosspost-to-medium.rb +16 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 968baac908af395098f34b73f1f56655f11945ea
|
4
|
+
data.tar.gz: 311a29bbf7af6534dd4f9efe63c0d97c9a9c19c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e62910c38fa2ae6741f322f701733f14e3f8d5c6a78deabd2f2f4b42cb7faeff24c364b9bea2fa2e1396f99b141fdc9ca3f169938f3bb83334d29e3e950bc6e4
|
7
|
+
data.tar.gz: 1cefbeff75e197d628441370c394a3f21067fe477c41e74421fa695602b19f72a198600440811879fc940d875a6dcb2f7c94ee01adf55d0f621220b644c70c5a
|
@@ -51,8 +51,17 @@ module Jekyll
|
|
51
51
|
|
52
52
|
if File.exists?(@crossposted_file)
|
53
53
|
crossposted = open(@crossposted_file) { |f| YAML.load(f) }
|
54
|
+
# convert from an array to a hash (upgrading older versions of this plugin)
|
55
|
+
if crossposted.kind_of?(Array)
|
56
|
+
new_crossposted = {}
|
57
|
+
crossposted.each do |url|
|
58
|
+
new_crossposted[url] = 'unknown'
|
59
|
+
end
|
60
|
+
crossposted = new_crossposted
|
61
|
+
end
|
62
|
+
# end upgrade
|
54
63
|
else
|
55
|
-
crossposted =
|
64
|
+
crossposted = {}
|
56
65
|
end
|
57
66
|
|
58
67
|
# If Jekyll 3.0, use hooks
|
@@ -135,7 +144,7 @@ module Jekyll
|
|
135
144
|
end
|
136
145
|
|
137
146
|
# Only cross-post if content has not already been cross-posted
|
138
|
-
if url and ! crossposted.
|
147
|
+
if url and ! crossposted.has_key? url
|
139
148
|
payload = {
|
140
149
|
'title' => title,
|
141
150
|
'contentFormat' => "html",
|
@@ -146,8 +155,8 @@ module Jekyll
|
|
146
155
|
'canonicalUrl' => canonical_url
|
147
156
|
}
|
148
157
|
|
149
|
-
if crosspost_to_medium(payload)
|
150
|
-
crossposted
|
158
|
+
if medium_url = crosspost_to_medium(payload)
|
159
|
+
crossposted[url] = medium_url
|
151
160
|
# Update cache
|
152
161
|
File.open(@crossposted_file, 'w') { |f| YAML.dump(crossposted, f) }
|
153
162
|
end
|
@@ -178,8 +187,9 @@ module Jekyll
|
|
178
187
|
response = https.request(request)
|
179
188
|
|
180
189
|
if response.code == '201'
|
181
|
-
|
182
|
-
|
190
|
+
medium_response = JSON.parse(response.body)
|
191
|
+
puts "Posted '#{payload['title']}' to Medium as #{payload['publishStatus']} (#{medium_response['data']['url']})"
|
192
|
+
return medium_response['data']['url']
|
183
193
|
else
|
184
194
|
puts "Attempted to post '#{payload['title']}' to Medium. They responded #{response.body}"
|
185
195
|
return false
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-crosspost-to-medium
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Gustafson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: " This generator cross-posts entries to Medium. To work, this script
|
14
14
|
requires\n a MEDIUM_USER_ID environment variable and a MEDIUM_INTEGRATION_TOKEN.\n\n
|