jekyll-import 0.24.0 → 0.25.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/jekyll-import +1 -1
- data/lib/jekyll-import/importers/drupal7.rb +4 -0
- data/lib/jekyll-import/importers/drupal8.rb +4 -0
- data/lib/jekyll-import/importers/drupal_common.rb +2 -0
- data/lib/jekyll-import/importers/pebble.rb +23 -25
- data/lib/jekyll-import/importers/wordpressdotcom.rb +34 -34
- data/lib/jekyll-import/util.rb +8 -0
- data/lib/jekyll-import/version.rb +1 -1
- metadata +15 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80f8102721c858cbbcd1b8498202ba404b3b9a89a50818cf15e4bae04f3183ed
|
4
|
+
data.tar.gz: c848cf68868c1cc84564a5edca0a42c88df3858c4eb31d17a45cdfd97262a401
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0fcb41bcdcdc69cb4c5fbe12e3870c9d64622e1ba3c404da8407e43f8367abdb22bd4c71abf1fe80d88787eb468e8aed6579353f3ec97a6af8b20a7e83ed88f9
|
7
|
+
data.tar.gz: eb56348a76059323380fd3e8823433837f2575fd43ba7b6da6769eb31627c6fc258b8110f970ddb22d05af7700cb3de2af346adc81584e1c98d98f3a53fb4d1a
|
data/exe/jekyll-import
CHANGED
@@ -34,10 +34,14 @@ SQL
|
|
34
34
|
n.created,
|
35
35
|
n.status,
|
36
36
|
n.type,
|
37
|
+
u.name,
|
38
|
+
u.mail,
|
37
39
|
#{tag_group}
|
38
40
|
FROM #{prefix}node AS n
|
39
41
|
LEFT JOIN #{prefix}field_data_body AS fdb
|
40
42
|
ON fdb.entity_id = n.nid AND fdb.entity_type = 'node'
|
43
|
+
RIGHT JOIN #{prefix}users AS u
|
44
|
+
ON u.uid = n.uid
|
41
45
|
WHERE (#{types})
|
42
46
|
QUERY
|
43
47
|
|
@@ -34,10 +34,14 @@ SQL
|
|
34
34
|
n.created,
|
35
35
|
n.status,
|
36
36
|
n.type,
|
37
|
+
u.name,
|
38
|
+
u.mail,
|
37
39
|
#{tag_group}
|
38
40
|
FROM #{prefix}node_field_data AS n
|
39
41
|
LEFT JOIN #{prefix}node__body AS nb
|
40
42
|
ON nb.entity_id = n.nid
|
43
|
+
RIGHT JOIN #{prefix}users AS u
|
44
|
+
ON u.uid = n.uid
|
41
45
|
WHERE (#{types})
|
42
46
|
QUERY
|
43
47
|
|
@@ -98,6 +98,8 @@ module JekyllImport
|
|
98
98
|
data, content = post_data(post)
|
99
99
|
|
100
100
|
data["layout"] = post[:type]
|
101
|
+
data["name"] = post[:name]
|
102
|
+
data["mail"] = post[:mail]
|
101
103
|
title = data["title"] = post[:title].strip.force_encoding("UTF-8")
|
102
104
|
time = data["created"] = post[:created]
|
103
105
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
|
1
3
|
module JekyllImport
|
2
4
|
module Importers
|
3
5
|
class Pebble < Importer
|
@@ -8,34 +10,30 @@ module JekyllImport
|
|
8
10
|
))
|
9
11
|
end
|
10
12
|
|
11
|
-
def self.specify_options(c)
|
13
|
+
def self.specify_options(c)
|
12
14
|
c.option "directory", "--directory PATH", "Pebble source directory"
|
13
15
|
end
|
14
16
|
|
15
17
|
def self.process(opts)
|
16
|
-
options = {
|
17
|
-
directory: opts.fetch("directory", "")
|
18
|
-
}
|
18
|
+
options = { :directory => opts.fetch("directory", "") }
|
19
19
|
|
20
20
|
FileUtils.mkdir_p("_posts")
|
21
21
|
FileUtils.mkdir_p("_drafts")
|
22
22
|
|
23
23
|
traverse_posts_within(options[:directory]) do |file|
|
24
|
-
next if file.end_with?(
|
24
|
+
next if file.end_with?("categories.xml")
|
25
|
+
|
25
26
|
process_file(file)
|
26
27
|
end
|
27
28
|
end
|
28
29
|
|
29
|
-
def self.traverse_posts_within(directory, &block)
|
30
|
-
Dir.
|
30
|
+
def self.traverse_posts_within(directory, &block)
|
31
|
+
Dir.each_child(directory) do |fd|
|
31
32
|
path = File.join(directory, fd)
|
32
|
-
if
|
33
|
-
next
|
34
|
-
elsif File.directory?(path)
|
33
|
+
if File.directory?(path)
|
35
34
|
traverse_posts_within(path, &block)
|
36
|
-
elsif path.end_with?(
|
35
|
+
elsif path.end_with?("xml")
|
37
36
|
yield(path) if block_given?
|
38
|
-
else
|
39
37
|
end
|
40
38
|
end
|
41
39
|
end
|
@@ -46,17 +44,17 @@ module JekyllImport
|
|
46
44
|
|
47
45
|
doc = xml.xpath("blogEntry")
|
48
46
|
|
49
|
-
title = kebabize(doc.xpath(
|
50
|
-
date = Date.parse(doc.xpath(
|
47
|
+
title = kebabize(doc.xpath("title").text).tr("_", "-")
|
48
|
+
date = Date.parse(doc.xpath("date").text)
|
51
49
|
|
52
50
|
directory = "_posts"
|
53
|
-
name = "#{date.strftime(
|
51
|
+
name = "#{date.strftime("%Y-%m-%d")}-#{title}"
|
54
52
|
|
55
53
|
header = {
|
56
|
-
"layout"
|
57
|
-
"title"
|
58
|
-
"tags"
|
59
|
-
"categories" => doc.xpath(
|
54
|
+
"layout" => "post",
|
55
|
+
"title" => doc.xpath("title").text,
|
56
|
+
"tags" => doc.xpath("tags").text.split(", "),
|
57
|
+
"categories" => doc.xpath("category").text.split(", "),
|
60
58
|
}
|
61
59
|
header["render_with_liquid"] = false
|
62
60
|
|
@@ -71,17 +69,17 @@ module JekyllImport
|
|
71
69
|
end
|
72
70
|
|
73
71
|
def self.kebabize(string)
|
74
|
-
kebab =
|
75
|
-
string.gsub!(
|
72
|
+
kebab = "-".freeze
|
73
|
+
string.gsub!(%r![^\w\-_]+!, kebab)
|
76
74
|
|
77
75
|
unless kebab.nil? || kebab.empty?
|
78
76
|
if kebab == "-".freeze
|
79
|
-
re_duplicate_kebab =
|
80
|
-
re_leading_trailing_kebab =
|
77
|
+
re_duplicate_kebab = %r!-{2,}!
|
78
|
+
re_leading_trailing_kebab = %r!^-|-$!
|
81
79
|
else
|
82
80
|
re_sep = Regexp.escape(kebab)
|
83
|
-
re_duplicate_kebab
|
84
|
-
re_leading_trailing_kebab =
|
81
|
+
re_duplicate_kebab = %r!#{re_sep}{2,}!
|
82
|
+
re_leading_trailing_kebab = %r!^#{re_sep}|#{re_sep}$!
|
85
83
|
end
|
86
84
|
# No more than one of the kebab in a row.
|
87
85
|
string.gsub!(re_duplicate_kebab, kebab)
|
@@ -8,7 +8,7 @@ module JekyllImport
|
|
8
8
|
rubygems
|
9
9
|
fileutils
|
10
10
|
safe_yaml
|
11
|
-
|
11
|
+
nokogiri
|
12
12
|
time
|
13
13
|
open-uri
|
14
14
|
open_uri_redirections
|
@@ -22,16 +22,16 @@ module JekyllImport
|
|
22
22
|
end
|
23
23
|
|
24
24
|
# Will modify post DOM tree
|
25
|
-
def self.download_images(title,
|
26
|
-
images = (
|
25
|
+
def self.download_images(title, post_doc, assets_folder)
|
26
|
+
images = post_doc.css("img")
|
27
27
|
return if images.empty?
|
28
28
|
|
29
|
-
Jekyll.logger.info "Downloading images for "
|
29
|
+
Jekyll.logger.info "Downloading:", "images for #{title}"
|
30
30
|
images.each do |i|
|
31
31
|
uri = URI::DEFAULT_PARSER.escape(i["src"])
|
32
32
|
|
33
33
|
dst = File.join(assets_folder, File.basename(uri))
|
34
|
-
i["src"] = File.join("{{
|
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."
|
@@ -54,15 +54,18 @@ module JekyllImport
|
|
54
54
|
|
55
55
|
class Item
|
56
56
|
def initialize(node)
|
57
|
+
raise "Node is nil" if node.nil?
|
58
|
+
|
57
59
|
@node = node
|
58
60
|
end
|
59
61
|
|
60
62
|
def text_for(path)
|
61
|
-
@node.at(path).
|
63
|
+
subnode = @node.at_xpath("./#{path}") || @node.at(path) || @node.children.find { |child| child.name == path }
|
64
|
+
subnode.text
|
62
65
|
end
|
63
66
|
|
64
67
|
def title
|
65
|
-
@title ||= text_for(
|
68
|
+
@title ||= text_for("title").strip
|
66
69
|
end
|
67
70
|
|
68
71
|
def permalink_title
|
@@ -76,12 +79,10 @@ module JekyllImport
|
|
76
79
|
end
|
77
80
|
|
78
81
|
def permalink
|
79
|
-
# Hpricot thinks "link" is a self closing tag so it puts the text of the link after the tag
|
80
|
-
# but sometimes it works right! I think it's the xml declaration
|
81
82
|
@permalink ||= begin
|
82
83
|
uri = text_for("link")
|
83
|
-
uri = @node.at("link").
|
84
|
-
URI(uri.to_s).path
|
84
|
+
uri = @node.at("link").next_sibling.text if uri.empty?
|
85
|
+
URI(uri.to_s.strip).path
|
85
86
|
end
|
86
87
|
end
|
87
88
|
|
@@ -127,12 +128,8 @@ module JekyllImport
|
|
127
128
|
|
128
129
|
def excerpt
|
129
130
|
@excerpt ||= begin
|
130
|
-
text =
|
131
|
-
|
132
|
-
nil
|
133
|
-
else
|
134
|
-
text
|
135
|
-
end
|
131
|
+
text = Nokogiri::HTML(text_for("excerpt:encoded")).text
|
132
|
+
text.empty? ? nil : text
|
136
133
|
end
|
137
134
|
end
|
138
135
|
end
|
@@ -144,29 +141,32 @@ module JekyllImport
|
|
144
141
|
FileUtils.mkdir_p(assets_folder)
|
145
142
|
|
146
143
|
import_count = Hash.new(0)
|
147
|
-
doc =
|
144
|
+
doc = Nokogiri::XML(File.read(source))
|
148
145
|
# Fetch authors data from header
|
149
146
|
authors = Hash[
|
150
|
-
(
|
151
|
-
[
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
147
|
+
doc.xpath("//channel/wp:author").map do |author|
|
148
|
+
[
|
149
|
+
author.xpath("./wp:author_login").text.strip,
|
150
|
+
{
|
151
|
+
"login" => author.xpath("./wp:author_login").text.strip,
|
152
|
+
"email" => author.xpath("./wp:author_email").text,
|
153
|
+
"display_name" => author.xpath("./wp:author_display_name").text,
|
154
|
+
"first_name" => author.xpath("./wp:author_first_name").text,
|
155
|
+
"last_name" => author.xpath("./wp:author_last_name").text,
|
156
|
+
},
|
157
|
+
]
|
158
158
|
end
|
159
159
|
] rescue {}
|
160
160
|
|
161
|
-
(
|
161
|
+
doc.css("channel > item").each do |node|
|
162
162
|
item = Item.new(node)
|
163
|
-
categories = node.
|
164
|
-
tags = node.
|
163
|
+
categories = node.css('category[domain="category"]').map(&:text).reject { |c| c == "Uncategorized" }.uniq
|
164
|
+
tags = node.css('category[domain="post_tag"]').map(&:text).uniq
|
165
165
|
|
166
166
|
metas = {}
|
167
|
-
node.
|
168
|
-
key = meta.
|
169
|
-
value = meta.
|
167
|
+
node.xpath("./wp:postmeta").each do |meta|
|
168
|
+
key = meta.at_xpath("./wp:meta_key").text
|
169
|
+
value = meta.at_xpath("./wp:meta_value").text
|
170
170
|
metas[key] = value
|
171
171
|
end
|
172
172
|
|
@@ -189,7 +189,7 @@ module JekyllImport
|
|
189
189
|
}
|
190
190
|
|
191
191
|
begin
|
192
|
-
content =
|
192
|
+
content = Nokogiri::HTML(item.text_for("content:encoded"))
|
193
193
|
header["excerpt"] = item.excerpt if item.excerpt
|
194
194
|
|
195
195
|
if fetch
|
@@ -221,7 +221,7 @@ module JekyllImport
|
|
221
221
|
end
|
222
222
|
|
223
223
|
import_count.each do |key, value|
|
224
|
-
Jekyll.logger.info "Imported #{value} #{key}
|
224
|
+
Jekyll.logger.info "Imported", "#{value} #{Util.pluralize(key, value)}"
|
225
225
|
end
|
226
226
|
end
|
227
227
|
|
data/lib/jekyll-import/util.rb
CHANGED
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.25.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: exe
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2025-01-21 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: jekyll
|
@@ -50,16 +50,22 @@ dependencies:
|
|
50
50
|
name: reverse_markdown
|
51
51
|
requirement: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- - "
|
53
|
+
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '2.1'
|
56
|
+
- - "<"
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '4.0'
|
56
59
|
type: :runtime
|
57
60
|
prerelease: false
|
58
61
|
version_requirements: !ruby/object:Gem::Requirement
|
59
62
|
requirements:
|
60
|
-
- - "
|
63
|
+
- - ">="
|
61
64
|
- !ruby/object:Gem::Version
|
62
65
|
version: '2.1'
|
66
|
+
- - "<"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '4.0'
|
63
69
|
- !ruby/object:Gem::Dependency
|
64
70
|
name: bundler
|
65
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -186,20 +192,6 @@ dependencies:
|
|
186
192
|
- - "~>"
|
187
193
|
- !ruby/object:Gem::Version
|
188
194
|
version: '1.0'
|
189
|
-
- !ruby/object:Gem::Dependency
|
190
|
-
name: hpricot
|
191
|
-
requirement: !ruby/object:Gem::Requirement
|
192
|
-
requirements:
|
193
|
-
- - "~>"
|
194
|
-
- !ruby/object:Gem::Version
|
195
|
-
version: '0.8'
|
196
|
-
type: :development
|
197
|
-
prerelease: false
|
198
|
-
version_requirements: !ruby/object:Gem::Requirement
|
199
|
-
requirements:
|
200
|
-
- - "~>"
|
201
|
-
- !ruby/object:Gem::Version
|
202
|
-
version: '0.8'
|
203
195
|
- !ruby/object:Gem::Dependency
|
204
196
|
name: htmlentities
|
205
197
|
requirement: !ruby/object:Gem::Requirement
|
@@ -318,14 +310,14 @@ dependencies:
|
|
318
310
|
requirements:
|
319
311
|
- - "~>"
|
320
312
|
- !ruby/object:Gem::Version
|
321
|
-
version: '
|
313
|
+
version: '3.0'
|
322
314
|
type: :development
|
323
315
|
prerelease: false
|
324
316
|
version_requirements: !ruby/object:Gem::Requirement
|
325
317
|
requirements:
|
326
318
|
- - "~>"
|
327
319
|
- !ruby/object:Gem::Version
|
328
|
-
version: '
|
320
|
+
version: '3.0'
|
329
321
|
description: Provides the Import command for Jekyll.
|
330
322
|
email: maintainers@jekyllrb.com
|
331
323
|
executables:
|
@@ -380,7 +372,7 @@ homepage: http://github.com/jekyll/jekyll-import
|
|
380
372
|
licenses:
|
381
373
|
- MIT
|
382
374
|
metadata: {}
|
383
|
-
post_install_message:
|
375
|
+
post_install_message:
|
384
376
|
rdoc_options:
|
385
377
|
- "--charset=UTF-8"
|
386
378
|
require_paths:
|
@@ -397,7 +389,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
397
389
|
version: '0'
|
398
390
|
requirements: []
|
399
391
|
rubygems_version: 3.1.6
|
400
|
-
signing_key:
|
392
|
+
signing_key:
|
401
393
|
specification_version: 4
|
402
394
|
summary: Import command for Jekyll (static site generator).
|
403
395
|
test_files: []
|