jekyll-import 0.22.0 → 0.24.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +17 -0
- data/README.markdown +1 -1
- data/exe/jekyll-import +34 -0
- data/lib/jekyll-import/importers/pebble.rb +97 -0
- data/lib/jekyll-import/importers/wordpressdotcom.rb +1 -1
- data/lib/jekyll-import/version.rb +1 -1
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9ffb136ba16d1bf4cbeff1c00dcb67375a0ac318ee586a629606f8a153c4d38
|
4
|
+
data.tar.gz: 3025eb441d0034c8b74aac6d4350f82b4f2262575acdb863378027f7cea6cd39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e36c60d548abd7c55eaefbb1bdd8dd11d96896ecbadb747f92009d4383e4f1e6595a4e8112549cef82e117966f84addc8818e31bc8d011a8cae752d3b7ce5af0
|
7
|
+
data.tar.gz: 7852a939368f86a5d8fa977f2ced12b2090ea4cd2582925b4375706a592c06ca8559696d5e3cb1fb4529cc7d0fb4cc5fbb517aa23adb70d3d2ccbe41580712e5
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
2
|
+
|
3
|
+
require: rubocop-jekyll
|
4
|
+
inherit_gem:
|
5
|
+
rubocop-jekyll: .rubocop.yml
|
6
|
+
|
7
|
+
AllCops:
|
8
|
+
TargetRubyVersion: 2.4
|
9
|
+
Exclude:
|
10
|
+
- docs/**/*
|
11
|
+
- script/**/*
|
12
|
+
- test/**/*
|
13
|
+
- vendor/**/*
|
14
|
+
- Rakefile
|
15
|
+
Style/MutableConstant:
|
16
|
+
Exclude:
|
17
|
+
- lib/jekyll-import/importers/typo.rb
|
data/README.markdown
CHANGED
@@ -12,7 +12,7 @@ The new __Jekyll__ command for importing from various blogs to Jekyll format.
|
|
12
12
|
### Jekyll v2.x and higher
|
13
13
|
|
14
14
|
1. Install the _rubygem_ with `gem install jekyll-import`.
|
15
|
-
2. Run `jekyll
|
15
|
+
2. Run `jekyll-import IMPORTER [options]`
|
16
16
|
|
17
17
|
### Jekyll v1.x
|
18
18
|
|
data/exe/jekyll-import
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
STDOUT.sync = true
|
5
|
+
|
6
|
+
$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
|
7
|
+
|
8
|
+
require "jekyll-import"
|
9
|
+
require "jekyll-import/version"
|
10
|
+
require "jekyll/commands/import"
|
11
|
+
require "mercenary"
|
12
|
+
|
13
|
+
Mercenary.program(:jekyll_import) do |p|
|
14
|
+
p.version JekyllImport::VERSION
|
15
|
+
p.description "Import from various blogs to Jekyll format."
|
16
|
+
p.syntax "jekyll-import <blog_engine> [options]"
|
17
|
+
|
18
|
+
# Create all the subcommands for the importers.
|
19
|
+
JekyllImport.add_importer_commands(p)
|
20
|
+
|
21
|
+
p.action do |args, _|
|
22
|
+
if args.empty?
|
23
|
+
Jekyll.logger.error "An importer subcommand is required."
|
24
|
+
puts p
|
25
|
+
abort
|
26
|
+
else
|
27
|
+
subcommand = args.first
|
28
|
+
unless p.has_command? subcommand
|
29
|
+
Jekyll.logger.abort_with "fatal: 'jekyll-import #{args.first}'" \
|
30
|
+
" could not be found."
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
module JekyllImport
|
2
|
+
module Importers
|
3
|
+
class Pebble < Importer
|
4
|
+
def self.require_deps
|
5
|
+
JekyllImport.require_with_fallback(%w(
|
6
|
+
nokogiri
|
7
|
+
safe_yaml
|
8
|
+
))
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.specify_options(c)
|
12
|
+
c.option "directory", "--directory PATH", "Pebble source directory"
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.process(opts)
|
16
|
+
options = {
|
17
|
+
directory: opts.fetch("directory", "")
|
18
|
+
}
|
19
|
+
|
20
|
+
FileUtils.mkdir_p("_posts")
|
21
|
+
FileUtils.mkdir_p("_drafts")
|
22
|
+
|
23
|
+
traverse_posts_within(options[:directory]) do |file|
|
24
|
+
next if file.end_with?('categories.xml')
|
25
|
+
process_file(file)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.traverse_posts_within(directory, &block)
|
30
|
+
Dir.foreach(directory) do |fd|
|
31
|
+
path = File.join(directory, fd)
|
32
|
+
if fd == '.' || fd == '..'
|
33
|
+
next
|
34
|
+
elsif File.directory?(path)
|
35
|
+
traverse_posts_within(path, &block)
|
36
|
+
elsif path.end_with?('xml')
|
37
|
+
yield(path) if block_given?
|
38
|
+
else
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.process_file(file)
|
44
|
+
xml = File.open(file) { |f| Nokogiri::XML(f) }
|
45
|
+
raise "There doesn't appear to be any XML items at the source (#{file}) provided." unless xml
|
46
|
+
|
47
|
+
doc = xml.xpath("blogEntry")
|
48
|
+
|
49
|
+
title = kebabize(doc.xpath('title').text).gsub('_', '-')
|
50
|
+
date = Date.parse(doc.xpath('date').text)
|
51
|
+
|
52
|
+
directory = "_posts"
|
53
|
+
name = "#{date.strftime('%Y-%m-%d')}-#{title}"
|
54
|
+
|
55
|
+
header = {
|
56
|
+
"layout" => 'post',
|
57
|
+
"title" => doc.xpath("title").text,
|
58
|
+
"tags" => doc.xpath("tags").text.split(", "),
|
59
|
+
"categories" => doc.xpath('category').text.split(', ')
|
60
|
+
}
|
61
|
+
header["render_with_liquid"] = false
|
62
|
+
|
63
|
+
path = File.join(directory, "#{name}.html")
|
64
|
+
File.open(path, "w") do |f|
|
65
|
+
f.puts header.to_yaml
|
66
|
+
f.puts "---\n\n"
|
67
|
+
f.puts doc.xpath("body").text
|
68
|
+
end
|
69
|
+
|
70
|
+
Jekyll.logger.info "Wrote file #{path} successfully!"
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.kebabize(string)
|
74
|
+
kebab = '-'.freeze
|
75
|
+
string.gsub!(/[^\w\-_]+/, kebab)
|
76
|
+
|
77
|
+
unless kebab.nil? || kebab.empty?
|
78
|
+
if kebab == "-".freeze
|
79
|
+
re_duplicate_kebab = /-{2,}/
|
80
|
+
re_leading_trailing_kebab = /^-|-$/
|
81
|
+
else
|
82
|
+
re_sep = Regexp.escape(kebab)
|
83
|
+
re_duplicate_kebab = /#{re_sep}{2,}/
|
84
|
+
re_leading_trailing_kebab = /^#{re_sep}|#{re_sep}$/
|
85
|
+
end
|
86
|
+
# No more than one of the kebab in a row.
|
87
|
+
string.gsub!(re_duplicate_kebab, kebab)
|
88
|
+
# Remove leading/trailing kebab.
|
89
|
+
string.gsub!(re_leading_trailing_kebab, "".freeze)
|
90
|
+
end
|
91
|
+
|
92
|
+
string.downcase!
|
93
|
+
string
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -28,7 +28,7 @@ module JekyllImport
|
|
28
28
|
|
29
29
|
Jekyll.logger.info "Downloading images for ", title
|
30
30
|
images.each do |i|
|
31
|
-
uri = i["src"]
|
31
|
+
uri = URI::DEFAULT_PARSER.escape(i["src"])
|
32
32
|
|
33
33
|
dst = File.join(assets_folder, File.basename(uri))
|
34
34
|
i["src"] = File.join("{{ site.baseurl }}", dst)
|
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.24.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Preston-Werner
|
8
8
|
- Parker Moore
|
9
9
|
- Matt Rogers
|
10
10
|
autorequire:
|
11
|
-
bindir:
|
11
|
+
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2024-02-19 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: jekyll
|
@@ -328,14 +328,17 @@ dependencies:
|
|
328
328
|
version: '2.4'
|
329
329
|
description: Provides the Import command for Jekyll.
|
330
330
|
email: maintainers@jekyllrb.com
|
331
|
-
executables:
|
331
|
+
executables:
|
332
|
+
- jekyll-import
|
332
333
|
extensions: []
|
333
334
|
extra_rdoc_files:
|
334
335
|
- README.markdown
|
335
336
|
- LICENSE
|
336
337
|
files:
|
338
|
+
- ".rubocop.yml"
|
337
339
|
- LICENSE
|
338
340
|
- README.markdown
|
341
|
+
- exe/jekyll-import
|
339
342
|
- lib/jekyll-import.rb
|
340
343
|
- lib/jekyll-import/importer.rb
|
341
344
|
- lib/jekyll-import/importers.rb
|
@@ -358,6 +361,7 @@ files:
|
|
358
361
|
- lib/jekyll-import/importers/medium.rb
|
359
362
|
- lib/jekyll-import/importers/mephisto.rb
|
360
363
|
- lib/jekyll-import/importers/mt.rb
|
364
|
+
- lib/jekyll-import/importers/pebble.rb
|
361
365
|
- lib/jekyll-import/importers/pluxml.rb
|
362
366
|
- lib/jekyll-import/importers/posterous.rb
|
363
367
|
- lib/jekyll-import/importers/roller.rb
|