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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d5ad5f27b1543d457921137c6e09b86812171246
4
- data.tar.gz: ca15aea25a07a481732568c7e2bad990fc23a091
3
+ metadata.gz: 968baac908af395098f34b73f1f56655f11945ea
4
+ data.tar.gz: 311a29bbf7af6534dd4f9efe63c0d97c9a9c19c6
5
5
  SHA512:
6
- metadata.gz: fbc7150a88df2446090c1722b16fd409bc94fe93aeec41627c1b97634de89248ae36d7320a2d7c08d6ca0026176bce83c1773a9cc69093215e4fd21a903de899
7
- data.tar.gz: b19049bcf0b88abc1a9268875d28073f42a8eaa05a1bf4c1f86cbf6aa76a854f2af8ad2e9f5842fb9f250f66bea162db5ed9f583dc0235cd3dc0348a8bb00049
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.include? url
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 << url
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
- puts "Posted '#{payload['title']}' to Medium (#{payload['publishStatus']})"
182
- return true
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.7
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 00:00:00.000000000 Z
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