jekyll-import 0.22.0 → 0.23.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ba591570a71e1a96e2a064ba583010d114d8051d9cb4fa810ff45a7e382b621e
4
- data.tar.gz: ac515c173bc2bb258d75da253cbdd83aa5f3a9074a97ba8c68a02193b4d15449
3
+ metadata.gz: 6fcccee7603179ae5818e0ba75bb5ad0f0abafdedd2f9f214347d02634683ed1
4
+ data.tar.gz: 8a1852ed040f027a25cc97c318445b6782aa1134917dc4823f72e073c86fdbcc
5
5
  SHA512:
6
- metadata.gz: 716d363903258758c63a266d81a865bee73e174816d9cdd854f8d8079511ec3b75fccb1576aa82700b3212c8fa4fe59144196f0e4010084489c7e7c0f8127268
7
- data.tar.gz: 65a01c5fbf3b3d69d2a2808ea2e4233b6a7034e056e91950487cdef84d03d9048ea95fefd52eb8b48cd3e0608bfb269b6ef35d347ab59e94a698779088d57069
6
+ metadata.gz: c52bfbe4d79d920dadcceccc0cfae985c85219befd093cda8d63f6e8604e99da9823604413814d286061c7a5b14da74b17f92ed27211e4e4cd51c15385e5fdcd
7
+ data.tar.gz: 3c5f1a75535b1e3ffdb274641ab17724e8b5587a1e266a02dd9b3a334954fe45e2dd8f99a69712e942ac86a9f987fa73a481248a3cba907ad42dc55ef0a8fecd
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 import IMPORTER [options]`
15
+ 2. Run `jekyll-import IMPORTER [options]`
16
16
 
17
17
  ### Jekyll v1.x
18
18
 
data/exe/jekyll-import ADDED
@@ -0,0 +1,33 @@
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/commands/import'
10
+ require 'mercenary'
11
+
12
+ Mercenary.program(:jekyll_import) do |p|
13
+ p.version JekyllImport::VERSION
14
+ p.description "Import from various blogs to Jekyll format."
15
+ p.syntax "jekyll-import <blog_engine> [options]"
16
+
17
+ # Create all the subcommands for the importers.
18
+ JekyllImport.add_importer_commands(p)
19
+
20
+ p.action do |args, _|
21
+ if args.empty?
22
+ Jekyll.logger.error "An importer subcommand is required."
23
+ puts p
24
+ abort
25
+ else
26
+ subcommand = args.first
27
+ unless p.has_command? subcommand
28
+ Jekyll.logger.abort_with "fatal: 'jekyll-import #{args.first}'" \
29
+ " could not be found."
30
+ end
31
+ end
32
+ end
33
+ 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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JekyllImport
4
- VERSION = "0.22.0"
4
+ VERSION = "0.23.0"
5
5
  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.22.0
4
+ version: 0.23.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: bin
11
+ bindir: exe
12
12
  cert_chain: []
13
- date: 2023-03-29 00:00:00.000000000 Z
13
+ date: 2024-01-17 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