jekyll-import 0.19.2 → 0.20.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/importer.rb +1 -1
- data/lib/jekyll-import/importers/blogger.rb +4 -4
- data/lib/jekyll-import/importers/marley.rb +1 -1
- data/lib/jekyll-import/importers/mt.rb +1 -1
- data/lib/jekyll-import/importers/pluxml.rb +82 -0
- data/lib/jekyll-import/importers/tumblr.rb +2 -2
- data/lib/jekyll-import/importers/typo.rb +3 -3
- data/lib/jekyll-import/importers/wordpressdotcom.rb +12 -2
- data/lib/jekyll-import/version.rb +1 -1
- data/lib/jekyll/commands/import.rb +1 -1
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 334724ebd0dbdc9774dd2e4799dea04dc5adaacc911d05cfc26f2a5daf23bbfa
|
4
|
+
data.tar.gz: 79a4f8c6de087aebca9f726275ebb3c234361b7341a01ce10c544ff65a0b6bac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d716d81c1e596e1004a65eadaa6c4df3e130d134d0b3db0fef7e06151350a90525f59db50aefd6f771950b0698f174fe19311dca7134c3488be970b85e76737a
|
7
|
+
data.tar.gz: f5ee7ba0c29bfad8267482789e2f571ee2d6ccafd343d173c9e9408b1c6c9c25941f28476386c3076310ec630fc5ff84c7ef12aaac2bc934aa1b8ee8e11010f5
|
@@ -258,8 +258,8 @@ module JekyllImport
|
|
258
258
|
body = @in_entry_elem[:body]
|
259
259
|
|
260
260
|
# body escaping associated with liquid
|
261
|
-
body.gsub!(%r!{{!, '{{ "{{" }}') if
|
262
|
-
body.gsub!(%r!{%!, '{{ "{%" }}') if
|
261
|
+
body.gsub!(%r!{{!, '{{ "{{" }}') if %r!{{!.match?(body)
|
262
|
+
body.gsub!(%r!{%!, '{{ "{%" }}') if %r!{%!.match?(body)
|
263
263
|
|
264
264
|
{ :filename => filename, :header => header, :body => body }
|
265
265
|
elsif @in_entry_elem[:meta][:kind] == "comment"
|
@@ -291,8 +291,8 @@ module JekyllImport
|
|
291
291
|
body = @in_entry_elem[:body]
|
292
292
|
|
293
293
|
# body escaping associated with liquid
|
294
|
-
body.gsub!(%r!{{!, '{{ "{{" }}') if
|
295
|
-
body.gsub!(%r!{%!, '{{ "{%" }}') if
|
294
|
+
body.gsub!(%r!{{!, '{{ "{{" }}') if %r!{{!.match?(body)
|
295
|
+
body.gsub!(%r!{%!, '{{ "{%" }}') if %r!{%!.match?(body)
|
296
296
|
|
297
297
|
{ :filename => filename, :header => header, :body => body }
|
298
298
|
end
|
@@ -48,7 +48,7 @@ module JekyllImport
|
|
48
48
|
title = file_content.scan(regexp[:title]).first.to_s.strip
|
49
49
|
prerex = file_content.scan(regexp[:perex]).first.to_s.strip
|
50
50
|
published_on = DateTime.parse(post[:published_on]) rescue File.mtime(File.dirname(f))
|
51
|
-
meta
|
51
|
+
meta = meta_content ? YAML.safe_load(meta_content.scan(regexp[:meta]).to_s) : {}
|
52
52
|
meta["title"] = title
|
53
53
|
meta["layout"] = "post"
|
54
54
|
|
@@ -69,7 +69,7 @@ module JekyllImport
|
|
69
69
|
# comments:: If true, output comments in _comments directory, like the one
|
70
70
|
# mentioned at https://github.com/mpalmer/jekyll-static-comments/
|
71
71
|
def self.process(options)
|
72
|
-
options
|
72
|
+
options = default_options.merge(options)
|
73
73
|
|
74
74
|
comments = options.fetch("comments")
|
75
75
|
posts_name_by_id = {} if comments
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module JekyllImport
|
4
|
+
module Importers
|
5
|
+
class Pluxml < Importer
|
6
|
+
def self.require_deps
|
7
|
+
JekyllImport.require_with_fallback(%w(
|
8
|
+
nokogiri
|
9
|
+
fileutils
|
10
|
+
safe_yaml
|
11
|
+
))
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.specify_options(c)
|
15
|
+
c.option "source", "--source NAME", "The PluXML data directory to import"
|
16
|
+
c.option "layout", "--layout NAME", "The layout to apply"
|
17
|
+
c.option "avoid_liquid", "--avoid_liquid true", "Will add render_with_liquid: false in frontmatter"
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.validate(options)
|
21
|
+
abort "Missing mandatory option --source." if options["source"].nil?
|
22
|
+
# no layout option, layout by default is post
|
23
|
+
options["layout"] = "post" if options["layout"].nil?
|
24
|
+
# no avoid_liquid option, avoid_liquid by default is false
|
25
|
+
options["avoid_liquid"] = false if options["avoid_liquid"].nil?
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.process(options)
|
29
|
+
source = options.fetch("source")
|
30
|
+
layout = options.fetch("layout")
|
31
|
+
avoid_liquid = options.fetch("avoid_liquid")
|
32
|
+
|
33
|
+
FileUtils.mkdir_p("_posts")
|
34
|
+
FileUtils.mkdir_p("_drafts")
|
35
|
+
|
36
|
+
# for each XML file in source location
|
37
|
+
Dir.glob("*.xml", :base => source).each do |df|
|
38
|
+
df = File.join(source, df)
|
39
|
+
filename = File.basename(df, ".*")
|
40
|
+
|
41
|
+
# prepare post file name in Jekyll format
|
42
|
+
a_filename = filename.split(".")
|
43
|
+
post_name = a_filename.pop
|
44
|
+
file_date = a_filename.pop
|
45
|
+
post_date = file_date[0..3] + "-" + file_date[4..5] + "-" + file_date[6..7]
|
46
|
+
|
47
|
+
# if draft, only take post name
|
48
|
+
if filename.split(".")[1].split(",")[0] == "draft"
|
49
|
+
directory = "_drafts"
|
50
|
+
name = post_name.to_s
|
51
|
+
# if post, post date precede post name
|
52
|
+
else
|
53
|
+
directory = "_posts"
|
54
|
+
name = "#{post_date}-#{post_name}"
|
55
|
+
end
|
56
|
+
|
57
|
+
xml = File.open(df) { |f| Nokogiri::XML(f) }
|
58
|
+
raise "There doesn't appear to be any XML items at the source (#{df}) provided." unless xml
|
59
|
+
|
60
|
+
doc = xml.xpath("document")
|
61
|
+
header = {
|
62
|
+
"layout" => layout,
|
63
|
+
"title" => doc.xpath("title").text,
|
64
|
+
"tags" => doc.xpath("tags").text.split(", "),
|
65
|
+
}
|
66
|
+
header["render_with_liquid"] = false if avoid_liquid
|
67
|
+
|
68
|
+
path = File.join(directory, "#{name}.html")
|
69
|
+
File.open(path, "w") do |f|
|
70
|
+
f.puts header.to_yaml
|
71
|
+
f.puts "---\n\n"
|
72
|
+
f.puts doc.xpath("chapo").text
|
73
|
+
f.puts doc.xpath("content").text
|
74
|
+
end
|
75
|
+
|
76
|
+
Jekyll.logger.info "Wrote file #{path} successfully!"
|
77
|
+
end
|
78
|
+
nil
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -266,7 +266,7 @@ module JekyllImport
|
|
266
266
|
lang = "python"
|
267
267
|
start = i
|
268
268
|
elsif block
|
269
|
-
lang = "javascript" if
|
269
|
+
lang = "javascript" if %r!;$!.match?(line)
|
270
270
|
block = line =~ indent && i < lines.size - 1 # Also handle EOF
|
271
271
|
unless block
|
272
272
|
lines[start] = "{% highlight #{lang} %}"
|
@@ -283,7 +283,7 @@ module JekyllImport
|
|
283
283
|
return url unless @grab_images
|
284
284
|
|
285
285
|
path = "tumblr_files/#{url.split("/").last}"
|
286
|
-
path += ext unless
|
286
|
+
path += ext unless %r!#{ext}$!.match?(path)
|
287
287
|
FileUtils.mkdir_p "tumblr_files"
|
288
288
|
|
289
289
|
# Don't fetch if we've already cached this file
|
@@ -55,7 +55,7 @@ module JekyllImport
|
|
55
55
|
raise "Unknown database server '#{server}'"
|
56
56
|
end
|
57
57
|
db[SQL].each do |post|
|
58
|
-
next unless
|
58
|
+
next unless %r!published!i.match?(post[:state])
|
59
59
|
|
60
60
|
post[:slug] = "no slug" if post[:slug].nil?
|
61
61
|
|
@@ -77,8 +77,8 @@ module JekyllImport
|
|
77
77
|
|
78
78
|
File.open("_posts/#{name}", "w") do |f|
|
79
79
|
f.puts({ "layout" => "post",
|
80
|
-
"title" =>
|
81
|
-
"tags" =>
|
80
|
+
"title" => post[:title]&.to_s&.force_encoding("UTF-8"),
|
81
|
+
"tags" => post[:keywords]&.to_s&.force_encoding("UTF-8"),
|
82
82
|
"typo_id" => post[:id], }.delete_if { |_k, v| v.nil? || v == "" }.to_yaml)
|
83
83
|
f.puts "---"
|
84
84
|
f.puts post[:body].delete("\r")
|
@@ -30,14 +30,15 @@ module JekyllImport
|
|
30
30
|
images.each do |i|
|
31
31
|
uri = i["src"]
|
32
32
|
|
33
|
-
i["src"] = format("{{ site.baseurl }}/%s/%s", assets_folder, File.basename(uri))
|
34
33
|
dst = File.join(assets_folder, File.basename(uri))
|
34
|
+
i["src"] = File.join("{{ site.baseurl }}", dst)
|
35
35
|
Jekyll.logger.info uri
|
36
36
|
if File.exist?(dst)
|
37
37
|
Jekyll.logger.info "Already in cache. Clean assets folder if you want a redownload."
|
38
38
|
next
|
39
39
|
end
|
40
40
|
begin
|
41
|
+
FileUtils.mkdir_p assets_folder
|
41
42
|
OpenURI.open_uri(uri, :allow_redirections => :safe) do |f|
|
42
43
|
File.open(dst, "wb") do |out|
|
43
44
|
out.puts f.read
|
@@ -191,7 +192,16 @@ module JekyllImport
|
|
191
192
|
content = Hpricot(item.text_for("content:encoded"))
|
192
193
|
header["excerpt"] = item.excerpt if item.excerpt
|
193
194
|
|
194
|
-
|
195
|
+
if fetch
|
196
|
+
# Put the images into a /yyyy/mm/ subfolder to reduce clashes
|
197
|
+
assets_dir_path = if item.published_at
|
198
|
+
File.join(assets_folder, item.published_at.strftime("/%Y/%m"))
|
199
|
+
else
|
200
|
+
assets_folder
|
201
|
+
end
|
202
|
+
|
203
|
+
download_images(item.title, content, assets_dir_path)
|
204
|
+
end
|
195
205
|
|
196
206
|
FileUtils.mkdir_p item.directory_name
|
197
207
|
File.open(File.join(item.directory_name, item.file_name), "w") do |f|
|
@@ -64,7 +64,7 @@ module Jekyll
|
|
64
64
|
|
65
65
|
def abort_on_invalid_migrator(migrator)
|
66
66
|
warn "Sorry, '#{migrator}' isn't a valid migrator. Valid choices:"
|
67
|
-
IMPORTERS.
|
67
|
+
IMPORTERS.each_key { |k| warn "* #{k}" }
|
68
68
|
raise "'#{migrator}' is not a valid migrator."
|
69
69
|
end
|
70
70
|
end
|
metadata
CHANGED
@@ -1,16 +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.20.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Preston-Werner
|
8
8
|
- Parker Moore
|
9
9
|
- Matt Rogers
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2020-
|
13
|
+
date: 2020-09-08 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: jekyll
|
@@ -150,14 +150,14 @@ dependencies:
|
|
150
150
|
requirements:
|
151
151
|
- - "~>"
|
152
152
|
- !ruby/object:Gem::Version
|
153
|
-
version:
|
153
|
+
version: 0.11.0
|
154
154
|
type: :development
|
155
155
|
prerelease: false
|
156
156
|
version_requirements: !ruby/object:Gem::Requirement
|
157
157
|
requirements:
|
158
158
|
- - "~>"
|
159
159
|
- !ruby/object:Gem::Version
|
160
|
-
version:
|
160
|
+
version: 0.11.0
|
161
161
|
- !ruby/object:Gem::Dependency
|
162
162
|
name: shoulda
|
163
163
|
requirement: !ruby/object:Gem::Requirement
|
@@ -370,6 +370,7 @@ files:
|
|
370
370
|
- lib/jekyll-import/importers/marley.rb
|
371
371
|
- lib/jekyll-import/importers/mephisto.rb
|
372
372
|
- lib/jekyll-import/importers/mt.rb
|
373
|
+
- lib/jekyll-import/importers/pluxml.rb
|
373
374
|
- lib/jekyll-import/importers/posterous.rb
|
374
375
|
- lib/jekyll-import/importers/roller.rb
|
375
376
|
- lib/jekyll-import/importers/rss.rb
|
@@ -387,7 +388,7 @@ homepage: http://github.com/jekyll/jekyll-import
|
|
387
388
|
licenses:
|
388
389
|
- MIT
|
389
390
|
metadata: {}
|
390
|
-
post_install_message:
|
391
|
+
post_install_message:
|
391
392
|
rdoc_options:
|
392
393
|
- "--charset=UTF-8"
|
393
394
|
require_paths:
|
@@ -396,7 +397,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
396
397
|
requirements:
|
397
398
|
- - ">="
|
398
399
|
- !ruby/object:Gem::Version
|
399
|
-
version: 2.
|
400
|
+
version: 2.4.0
|
400
401
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
401
402
|
requirements:
|
402
403
|
- - ">="
|
@@ -404,7 +405,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
404
405
|
version: '0'
|
405
406
|
requirements: []
|
406
407
|
rubygems_version: 3.0.3
|
407
|
-
signing_key:
|
408
|
+
signing_key:
|
408
409
|
specification_version: 4
|
409
410
|
summary: Import command for Jekyll (static site generator).
|
410
411
|
test_files: []
|