jekyll-crosspost-to-medium 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jekyll-crosspost-to-medium.rb +23 -7
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a0f490503ddf56ac2a057e31a78a7a9e243ad26
|
4
|
+
data.tar.gz: 83cb0f961dc4f5235efcf133ed8e6d0567465dd9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6e4cc7f4f6a951fd6c52828763a9abbddf595710305b88afa757f485dba78e22e7d3a8bc14a1dfc72a1d322d6535f50049d460b028f51c39789178e1655197b
|
7
|
+
data.tar.gz: 4c72b3fdd1b7ab077625ff8f45b91148842cbc6d533d15c039639b731d005aba2c8a229124adc961ad393c62a357818b41c468c0d7e6af52ac27da8f13c264f8
|
@@ -107,13 +107,24 @@ module Jekyll
|
|
107
107
|
content = content.gsub /href=(["'])\//, "href=\"\1#{@site.config['url']}/"
|
108
108
|
content = content.gsub /src=(["'])\//, "src=\"\1#{@site.config['url']}/"
|
109
109
|
|
110
|
-
# Prepend the title and add a link back to originating site
|
111
|
-
content.prepend("<h1>#{title}</h1>")
|
112
|
-
content << "<p><i>This article was originally posted <a href=\"#{url}\" rel=\"canonical\">on my own site</a>.</i></p>"
|
113
|
-
|
114
110
|
# Save canonical URL
|
115
111
|
canonical_url = url
|
116
112
|
|
113
|
+
# Prepend the title and add a link back to originating site
|
114
|
+
content.prepend("<h1>#{title}</h1>")
|
115
|
+
# Append a canonical link and text
|
116
|
+
# TODO Accept a position option, e.g., top, bottom.
|
117
|
+
#
|
118
|
+
# User the user's config if it exists
|
119
|
+
if @settings['text']
|
120
|
+
canonical_text = "#{@settings['text']}"
|
121
|
+
canonical_text = canonical_text.gsub /{{ url }}/, canonical_url
|
122
|
+
# Otherwise, use boilerplate
|
123
|
+
else
|
124
|
+
canonical_text = "<p><i>This article was originally posted <a href=\"#{url}\" rel=\"canonical\">on my own site</a>.</i></p>"
|
125
|
+
end
|
126
|
+
content << canonical_text
|
127
|
+
|
117
128
|
# Strip domain name from the URL we check against
|
118
129
|
url = url.sub(/^#{@site.config['url']}?/,'')
|
119
130
|
|
@@ -139,8 +150,6 @@ module Jekyll
|
|
139
150
|
|
140
151
|
|
141
152
|
def crosspost_to_medium(payload)
|
142
|
-
puts "Cross-posting “#{payload['title']}” to Medium"
|
143
|
-
|
144
153
|
user_id = ENV['MEDIUM_USER_ID'] or false
|
145
154
|
token = ENV['MEDIUM_INTEGRATION_TOKEN'] or false
|
146
155
|
medium_api = URI.parse("https://api.medium.com/v1/users/#{user_id}/posts")
|
@@ -161,7 +170,14 @@ module Jekyll
|
|
161
170
|
|
162
171
|
# Post it
|
163
172
|
response = https.request(request)
|
173
|
+
|
174
|
+
puts response.inspect
|
175
|
+
if response.code == '201'
|
176
|
+
puts "Posted '#{payload['title']}' to Medium (#{payload['publishStatus']})"
|
177
|
+
else
|
178
|
+
puts "Attempted to post '#{payload['title']}' to Medium. They responded #{response.body}"
|
179
|
+
end
|
164
180
|
end
|
165
181
|
|
166
182
|
end
|
167
|
-
end
|
183
|
+
end
|
metadata
CHANGED
@@ -1,16 +1,22 @@
|
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Gustafson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
13
|
+
description: " This generator cross-posts entries to Medium. To work, this script
|
14
|
+
requires\n a MEDIUM_USER_ID environment variable and a MEDIUM_INTEGRATION_TOKEN.\n\n
|
15
|
+
\ The generator will only pick up posts with the following front matter:\n\n `crosspost_to_medium:
|
16
|
+
true`\n\n You can control crossposting globally by setting `enabled: true` under
|
17
|
+
the \n `jekyll-crosspost_to_medium` variable in your Jekyll configuration file.\n
|
18
|
+
\ Setting it to false will skip the processing loop entirely which can be\n useful
|
19
|
+
for local preview builds.\n"
|
14
20
|
email: aaron@easy-designs.net
|
15
21
|
executables: []
|
16
22
|
extensions: []
|