jekyll-import 0.16.0 → 0.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jekyll-import/importers/blogger.rb +1 -1
- data/lib/jekyll-import/importers/joomla3.rb +1 -1
- data/lib/jekyll-import/importers/s9y_database.rb +1 -1
- data/lib/jekyll-import/importers/tumblr.rb +66 -57
- data/lib/jekyll-import/importers/typo.rb +1 -1
- data/lib/jekyll-import/importers/wordpress.rb +3 -3
- data/lib/jekyll-import/version.rb +1 -1
- metadata +25 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0dcc7e31eb1aa2846478a51d98137a9ea5531a4bf47aa053a3b413a9e6fd0e9
|
4
|
+
data.tar.gz: fc5cff2462128b3906d7047a2e7c6a39b3553cedfc58afc429cc6d352f055be3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3ad1ab0288e1ed20c7c423283bdc0eafb2871ac6db2af684fdc30026172c90042f8b3fa2bea564ff98aa183181ad40e46c6d6174927d5a3649b29f52ed8f950
|
7
|
+
data.tar.gz: 8d2d819c2724f4150b07f7ca0718fcd46e61deecc2579335911180163dd236711a9f6cdfaa72a59765e97ed42356426b8f2854932be18034de89de2e2952de7b
|
@@ -1,73 +1,73 @@
|
|
1
|
-
# frozen_string_literal:
|
1
|
+
# frozen_string_literal: false
|
2
2
|
|
3
3
|
module JekyllImport
|
4
4
|
module Importers
|
5
5
|
class Tumblr < Importer
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
6
|
+
class << self
|
7
|
+
def require_deps
|
8
|
+
JekyllImport.require_with_fallback(%w(
|
9
|
+
rubygems
|
10
|
+
fileutils
|
11
|
+
open-uri
|
12
|
+
nokogiri
|
13
|
+
json
|
14
|
+
uri
|
15
|
+
time
|
16
|
+
jekyll
|
17
|
+
reverse_markdown
|
18
|
+
))
|
19
|
+
end
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
def specify_options(c)
|
22
|
+
c.option "url", "--url URL", "Tumblr URL"
|
23
|
+
c.option "format", "--format FORMAT", 'Output format (default: "html")'
|
24
|
+
c.option "grab_images", "--grab_images", "Whether to grab images (default: false)"
|
25
|
+
c.option "add_highlights", "--add_highlights", "Whether to add highlights (default: false)"
|
26
|
+
c.option "rewrite_urls", "--rewrite_urls", "Whether to rewrite URLs (default: false)"
|
27
|
+
end
|
28
|
+
|
29
|
+
def process(options)
|
30
|
+
url = options.fetch("url")
|
31
|
+
format = options.fetch("format", "html")
|
32
|
+
grab_images = options.fetch("grab_images", false)
|
33
|
+
add_highlights = options.fetch("add_highlights", false)
|
34
|
+
rewrite_urls = options.fetch("rewrite_urls", false)
|
26
35
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
add_highlights = options.fetch("add_highlights", false)
|
32
|
-
rewrite_urls = options.fetch("rewrite_urls", false)
|
36
|
+
@grab_images = grab_images
|
37
|
+
FileUtils.mkdir_p "_posts/tumblr"
|
38
|
+
per_page = 50
|
39
|
+
posts = []
|
33
40
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
41
|
+
# Two passes are required so that we can rewrite URLs.
|
42
|
+
# First pass builds up an array of each post as a hash.
|
43
|
+
begin
|
44
|
+
current_page = (current_page || -1) + 1
|
45
|
+
feed_url = api_feed_url(url, current_page, per_page)
|
46
|
+
Jekyll.logger.info "Fetching #{feed_url}"
|
39
47
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
feed_url = "#{url}?num=#{per_page}&start=#{current_page * per_page}"
|
45
|
-
Jekyll.logger.info "Fetching #{feed_url}"
|
48
|
+
feed = URI.parse(feed_url).open
|
49
|
+
contents = feed.readlines.join("\n")
|
50
|
+
blog = extract_json(contents)
|
51
|
+
Jekyll.logger.info "Page: #{current_page + 1} - Posts: #{blog["posts"].size}"
|
46
52
|
|
47
|
-
|
48
|
-
contents = feed.readlines.join("\n")
|
49
|
-
blog = extract_json(contents)
|
50
|
-
Jekyll.logger.info "Page: #{current_page + 1} - Posts: #{blog["posts"].size}"
|
53
|
+
batch = blog["posts"].map { |post| post_to_hash(post, format) }
|
51
54
|
|
52
|
-
|
55
|
+
# If we're rewriting, save the posts for later. Otherwise, go ahead and dump these to
|
56
|
+
# disk now
|
57
|
+
if rewrite_urls
|
58
|
+
posts += batch
|
59
|
+
else
|
60
|
+
batch.each { |post| write_post(post, format == "md", add_highlights) }
|
61
|
+
end
|
62
|
+
end until blog["posts"].size < per_page
|
53
63
|
|
54
|
-
#
|
55
|
-
# disk now
|
64
|
+
# Rewrite URLs, create redirects and write out out posts if necessary
|
56
65
|
if rewrite_urls
|
57
|
-
posts
|
58
|
-
|
59
|
-
batch.each { |post| write_post(post, format == "md", add_highlights) }
|
66
|
+
posts = rewrite_urls_and_redirects posts
|
67
|
+
posts.each { |post| write_post(post, format == "md", add_highlights) }
|
60
68
|
end
|
61
|
-
end until blog["posts"].size < per_page
|
62
|
-
|
63
|
-
# Rewrite URLs, create redirects and write out out posts if necessary
|
64
|
-
if rewrite_urls
|
65
|
-
posts = rewrite_urls_and_redirects posts
|
66
|
-
posts.each { |post| write_post(post, format == "md", add_highlights) }
|
67
69
|
end
|
68
|
-
end
|
69
70
|
|
70
|
-
class << self
|
71
71
|
def extract_json(contents)
|
72
72
|
beginning = contents.index("{")
|
73
73
|
ending = contents.rindex("}") + 1
|
@@ -237,9 +237,11 @@ module JekyllImport
|
|
237
237
|
preserve = %w(table tr th td)
|
238
238
|
preserve.each do |tag|
|
239
239
|
content.gsub!(%r!<#{tag}!i, "$$#{tag}")
|
240
|
-
content.gsub!(%r
|
240
|
+
content.gsub!(%r!</#{tag}!i, "||#{tag}")
|
241
241
|
end
|
242
|
-
|
242
|
+
|
243
|
+
content = ReverseMarkdown.convert(content)
|
244
|
+
|
243
245
|
preserve.each do |tag|
|
244
246
|
content.gsub!("$$#{tag}", "<#{tag}")
|
245
247
|
content.gsub!("||#{tag}", "</#{tag}")
|
@@ -291,6 +293,13 @@ module JekyllImport
|
|
291
293
|
end
|
292
294
|
"/#{path}"
|
293
295
|
end
|
296
|
+
|
297
|
+
private
|
298
|
+
|
299
|
+
def api_feed_url(url, page, per_page = 50)
|
300
|
+
url = File.join(url, "/api/read/json/")
|
301
|
+
"#{url}?num=#{per_page}&start=#{page * per_page}"
|
302
|
+
end
|
294
303
|
end
|
295
304
|
end
|
296
305
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# frozen_string_literal:
|
1
|
+
# frozen_string_literal: false
|
2
2
|
|
3
3
|
module JekyllImport
|
4
4
|
module Importers
|
@@ -163,10 +163,10 @@ module JekyllImport
|
|
163
163
|
|
164
164
|
if options[:status] && !options[:status].empty?
|
165
165
|
status = options[:status][0]
|
166
|
-
|
166
|
+
posts_query << "
|
167
167
|
WHERE posts.post_status = '#{status}'"
|
168
168
|
options[:status][1..-1].each do |post_status|
|
169
|
-
|
169
|
+
posts_query << " OR
|
170
170
|
posts.post_status = '#{post_status}'"
|
171
171
|
end
|
172
172
|
end
|
metadata
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-import
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.17.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Preston-Werner
|
8
|
+
- Parker Moore
|
9
|
+
- Matt Rogers
|
8
10
|
autorequire:
|
9
11
|
bindir: bin
|
10
12
|
cert_chain: []
|
11
|
-
date: 2018-
|
13
|
+
date: 2018-12-21 00:00:00.000000000 Z
|
12
14
|
dependencies:
|
13
15
|
- !ruby/object:Gem::Dependency
|
14
16
|
name: fastercsv
|
@@ -52,6 +54,20 @@ dependencies:
|
|
52
54
|
- - "~>"
|
53
55
|
- !ruby/object:Gem::Version
|
54
56
|
version: '1.0'
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: reverse_markdown
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - "~>"
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '1.0'
|
64
|
+
type: :runtime
|
65
|
+
prerelease: false
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - "~>"
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '1.0'
|
55
71
|
- !ruby/object:Gem::Dependency
|
56
72
|
name: activesupport
|
57
73
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,14 +102,14 @@ dependencies:
|
|
86
102
|
requirements:
|
87
103
|
- - "~>"
|
88
104
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
105
|
+
version: '6.0'
|
90
106
|
type: :development
|
91
107
|
prerelease: false
|
92
108
|
version_requirements: !ruby/object:Gem::Requirement
|
93
109
|
requirements:
|
94
110
|
- - "~>"
|
95
111
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
112
|
+
version: '6.0'
|
97
113
|
- !ruby/object:Gem::Dependency
|
98
114
|
name: redgreen
|
99
115
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,14 +144,14 @@ dependencies:
|
|
128
144
|
requirements:
|
129
145
|
- - "~>"
|
130
146
|
- !ruby/object:Gem::Version
|
131
|
-
version: '0.
|
147
|
+
version: '0.4'
|
132
148
|
type: :development
|
133
149
|
prerelease: false
|
134
150
|
version_requirements: !ruby/object:Gem::Requirement
|
135
151
|
requirements:
|
136
152
|
- - "~>"
|
137
153
|
- !ruby/object:Gem::Version
|
138
|
-
version: '0.
|
154
|
+
version: '0.4'
|
139
155
|
- !ruby/object:Gem::Dependency
|
140
156
|
name: shoulda
|
141
157
|
requirement: !ruby/object:Gem::Requirement
|
@@ -262,20 +278,6 @@ dependencies:
|
|
262
278
|
- - "~>"
|
263
279
|
- !ruby/object:Gem::Version
|
264
280
|
version: '0.12'
|
265
|
-
- !ruby/object:Gem::Dependency
|
266
|
-
name: reverse_markdown
|
267
|
-
requirement: !ruby/object:Gem::Requirement
|
268
|
-
requirements:
|
269
|
-
- - "~>"
|
270
|
-
- !ruby/object:Gem::Version
|
271
|
-
version: '1.0'
|
272
|
-
type: :development
|
273
|
-
prerelease: false
|
274
|
-
version_requirements: !ruby/object:Gem::Requirement
|
275
|
-
requirements:
|
276
|
-
- - "~>"
|
277
|
-
- !ruby/object:Gem::Version
|
278
|
-
version: '1.0'
|
279
281
|
- !ruby/object:Gem::Dependency
|
280
282
|
name: sequel
|
281
283
|
requirement: !ruby/object:Gem::Requirement
|
@@ -333,7 +335,7 @@ dependencies:
|
|
333
335
|
- !ruby/object:Gem::Version
|
334
336
|
version: '2.4'
|
335
337
|
description: Provides the Import command for Jekyll.
|
336
|
-
email:
|
338
|
+
email: maintainers@jekyllrb.com
|
337
339
|
executables: []
|
338
340
|
extensions: []
|
339
341
|
extra_rdoc_files:
|
@@ -394,9 +396,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
394
396
|
- !ruby/object:Gem::Version
|
395
397
|
version: '0'
|
396
398
|
requirements: []
|
397
|
-
|
398
|
-
rubygems_version: 2.7.7
|
399
|
+
rubygems_version: 3.0.0
|
399
400
|
signing_key:
|
400
|
-
specification_version:
|
401
|
+
specification_version: 4
|
401
402
|
summary: Import command for Jekyll (static site generator).
|
402
403
|
test_files: []
|