jekyll-import 0.1.0.beta1 → 0.1.0.beta2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/History.markdown +21 -0
- data/README.markdown +7 -0
- data/jekyll-import.gemspec +9 -7
- data/lib/jekyll/commands/import.rb +7 -6
- data/lib/jekyll/jekyll-import/csv.rb +6 -2
- data/lib/jekyll/jekyll-import/drupal6.rb +14 -6
- data/lib/jekyll/jekyll-import/posterous.rb +26 -15
- data/lib/jekyll/jekyll-import/rss.rb +2 -2
- data/lib/jekyll/jekyll-import/s9y.rb +12 -2
- data/lib/jekyll/jekyll-import/tumblr.rb +69 -25
- data/lib/jekyll/jekyll-import/typo.rb +4 -2
- data/lib/jekyll/jekyll-import/wordpress.rb +8 -5
- data/lib/jekyll/jekyll-import/wordpressdotcom.rb +2 -2
- data/lib/jekyll-import.rb +1 -1
- data/test/helper.rb +6 -0
- data/test/test_mt_importer.rb +2 -2
- metadata +28 -48
- data/History.txt +0 -7
- data/README.md +0 -4
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
YzhiN2U2ZDMwNjA0NTM4ODYxYjViM2E0ZWJkZTMyYzA2MmQxN2E3Mw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
OThkMzY2ZjhhYzZiMjQ5MmUyMDU1NTI3ODg3NTFhMTNkMDAxMzFhYg==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YWY0NWEyOTM2OTRiOTYzNmY2Y2I0ZTMxNWMzMGRhODdlMTg1MWU0OTNmM2Qz
|
10
|
+
MGU2NDRlMzI2ZDc1MWZmNWU1ZDE1YWJjOTVmYzQ2MWE5ZDlkMDdmOGUxZGUx
|
11
|
+
YjAxNjg4OTRiYTk5OTUxZmIzMzdjNzVkNzBmMWJmNDI4ODlhM2Y=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MGQwODAyZjgwNDBjOTExNjU5NDNlNTFiYmVkMGQzNTc2YmY2MjAyNzQ1Yzli
|
14
|
+
MTM3MmNkNWU3ZWY4ZjVlMWVlNmFjYjE1YjZjN2UyZjBkMjg1NGVmY2QwY2Mz
|
15
|
+
ZWY2NGYwY2I5YjMxMjc3ZDMyYmUzY2I1ZjI1OWZlNDkwNThmOGE=
|
data/History.markdown
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
## HEAD
|
2
|
+
|
3
|
+
### Major Enhancements
|
4
|
+
* Add the optional ability to include images in a posterous migration (#5)
|
5
|
+
* Posterous archive (unzipped directory) importer added (#12)
|
6
|
+
* Improve MovableType importer (#13)
|
7
|
+
### Minor Enhancements
|
8
|
+
* Various Tumblr Enhancements (#27)
|
9
|
+
* Adding tags to Typo and forcing their encoding to UTF-8 (#11)
|
10
|
+
* S9Y Importer: specify data source using --source option (#18)
|
11
|
+
* Add taxonomy (`tags`) to Drupal6 migration (#15)
|
12
|
+
### Bug Fixes
|
13
|
+
* Remove usage of `Hash#at` in Tumblr importer (#14)
|
14
|
+
* Force encoding of Drupal 6.x titles to UTF-8 (#22)
|
15
|
+
* Update wordpressdotcom.rb to use its method parameter correctly (#24)
|
16
|
+
* Use MySQL2 adapter for WordPress importer to fix broken front-matter (#20)
|
17
|
+
* Fix WordPress import initialize parameters due to new Jekyll setup (#19)
|
18
|
+
* Fixed misspelling in method name (#17)
|
19
|
+
### Site Enhancements
|
20
|
+
### Development Fixes
|
21
|
+
* Update usage docs in RSS importer (#35)
|
data/README.markdown
ADDED
data/jekyll-import.gemspec
CHANGED
@@ -2,10 +2,11 @@ Gem::Specification.new do |s|
|
|
2
2
|
s.specification_version = 2 if s.respond_to? :specification_version=
|
3
3
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
4
4
|
s.rubygems_version = '1.3.5'
|
5
|
+
s.required_ruby_version = '>= 1.9.2'
|
5
6
|
|
6
7
|
s.name = 'jekyll-import'
|
7
|
-
s.version = '0.1.0.
|
8
|
-
s.date = '2013-
|
8
|
+
s.version = '0.1.0.beta2'
|
9
|
+
s.date = '2013-07-01'
|
9
10
|
s.rubyforge_project = 'jekyll-import'
|
10
11
|
|
11
12
|
s.summary = "Import command for Jekyll (static site generator)."
|
@@ -18,16 +19,17 @@ Gem::Specification.new do |s|
|
|
18
19
|
s.require_paths = %w[lib]
|
19
20
|
|
20
21
|
s.rdoc_options = ["--charset=UTF-8"]
|
21
|
-
s.extra_rdoc_files = %w[README.
|
22
|
+
s.extra_rdoc_files = %w[README.markdown LICENSE]
|
22
23
|
|
23
|
-
s.add_runtime_dependency('jekyll')
|
24
|
+
s.add_runtime_dependency('jekyll', '~> 1.0')
|
24
25
|
s.add_runtime_dependency('fastercsv')
|
25
26
|
s.add_runtime_dependency('nokogiri')
|
26
|
-
s.add_runtime_dependency('safe_yaml', '~> 0.7')
|
27
|
+
s.add_runtime_dependency('safe_yaml', '~> 0.7.0')
|
27
28
|
|
28
29
|
# development dependencies
|
29
30
|
s.add_development_dependency('rake', "~> 10.0.3")
|
30
31
|
s.add_development_dependency('rdoc', "~> 4.0.0")
|
32
|
+
s.add_development_dependency('activesupport', '~> 3.2')
|
31
33
|
|
32
34
|
# test dependencies:
|
33
35
|
s.add_development_dependency('redgreen', "~> 1.2")
|
@@ -46,9 +48,9 @@ Gem::Specification.new do |s|
|
|
46
48
|
# = MANIFEST =
|
47
49
|
s.files = %w[
|
48
50
|
Gemfile
|
49
|
-
History.
|
51
|
+
History.markdown
|
50
52
|
LICENSE
|
51
|
-
README.
|
53
|
+
README.markdown
|
52
54
|
Rakefile
|
53
55
|
jekyll-import.gemspec
|
54
56
|
lib/jekyll-import.rb
|
@@ -23,8 +23,8 @@ module Jekyll
|
|
23
23
|
:wordpressdotcom => 'WordpressDotCom'
|
24
24
|
}
|
25
25
|
|
26
|
-
def self.
|
27
|
-
msg = "
|
26
|
+
def self.abort_on_invalid_migrator(migrator)
|
27
|
+
msg = "Sorry, '#{migrator}' isn't a valid migrator. Valid choices:\n"
|
28
28
|
IMPORTERS.keys.each do |k, v|
|
29
29
|
msg += "* #{k}\n"
|
30
30
|
end
|
@@ -32,18 +32,19 @@ module Jekyll
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def self.process(migrator, options)
|
35
|
-
if IMPORTERS.keys.include?(migrator.to_sym)
|
36
|
-
migrator = migrator.downcase
|
35
|
+
if IMPORTERS.keys.include?(migrator.to_s.to_sym)
|
36
|
+
migrator = migrator.to_s.downcase
|
37
37
|
|
38
38
|
require File.join(File.dirname(__FILE__), "..", "jekyll-import", "#{migrator}.rb")
|
39
39
|
|
40
40
|
if JekyllImport.const_defined?(IMPORTERS[migrator.to_sym])
|
41
|
-
puts 'Importing...'
|
42
41
|
klass = JekyllImport.const_get(IMPORTERS[migrator.to_sym])
|
42
|
+
klass.validate(options.__hash__) if klass.respond_to?(:validate)
|
43
|
+
puts 'Importing...'
|
43
44
|
klass.process(options.__hash__)
|
44
45
|
end
|
45
46
|
else
|
46
|
-
|
47
|
+
abort_on_invalid_migrator(migrator)
|
47
48
|
end
|
48
49
|
end
|
49
50
|
end
|
@@ -1,11 +1,15 @@
|
|
1
|
+
require "csv"
|
2
|
+
|
1
3
|
module JekyllImport
|
2
4
|
module CSV
|
3
5
|
# Reads a csv with title, permalink, body, published_at, and filter.
|
4
6
|
# It creates a post file for each row in the csv
|
5
|
-
def self.process(
|
7
|
+
def self.process(options)
|
8
|
+
file = options[:file] || "posts.csv"
|
6
9
|
FileUtils.mkdir_p "_posts"
|
7
10
|
posts = 0
|
8
|
-
|
11
|
+
abort "Cannot find the file '#{file}'. Aborting." unless File.file?(file)
|
12
|
+
::CSV.foreach(file) do |row|
|
9
13
|
next if row[0] == "title"
|
10
14
|
posts += 1
|
11
15
|
name = row[3].split(" ")[0]+"-"+row[1]+(row[4] =~ /markdown/ ? ".markdown" : ".textile")
|
@@ -17,11 +17,15 @@ module JekyllImport
|
|
17
17
|
n.title, \
|
18
18
|
nr.body, \
|
19
19
|
n.created, \
|
20
|
-
n.status \
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
n.status, \
|
21
|
+
GROUP_CONCAT( td.name SEPARATOR ' ' ) AS 'tags' \
|
22
|
+
FROM node_revisions AS nr, \
|
23
|
+
node AS n \
|
24
|
+
JOIN term_node AS tn ON tn.nid = n.nid \
|
25
|
+
JOIN term_data AS td ON tn.tid = td.tid \
|
26
|
+
WHERE (n.type = 'blog' OR n.type = 'story') \
|
27
|
+
AND n.vid = nr.vid \
|
28
|
+
GROUP BY n.nid"
|
25
29
|
|
26
30
|
def self.process(dbname, user, pass, host = 'localhost', prefix = '')
|
27
31
|
db = Sequel.mysql(dbname, :user => user, :password => pass, :host => host, :encoding => 'utf8')
|
@@ -53,6 +57,7 @@ EOF
|
|
53
57
|
node_id = post[:nid]
|
54
58
|
title = post[:title]
|
55
59
|
content = post[:body]
|
60
|
+
tags = post[:tags].downcase.strip
|
56
61
|
created = post[:created]
|
57
62
|
time = Time.at(created)
|
58
63
|
is_published = post[:status] == 1
|
@@ -66,7 +71,10 @@ EOF
|
|
66
71
|
'layout' => 'post',
|
67
72
|
'title' => title.to_s,
|
68
73
|
'created' => created,
|
69
|
-
|
74
|
+
'categories' => tags
|
75
|
+
}.delete_if { |k,v| v.nil? || v == ''}.each_pair {
|
76
|
+
|k,v| ((v.is_a? String) ? v.force_encoding("UTF-8") : v)
|
77
|
+
}.to_yaml
|
70
78
|
|
71
79
|
# Write out the data and content to file
|
72
80
|
File.open("#{dir}/#{name}", "w") do |f|
|
@@ -5,7 +5,14 @@ require 'net/http'
|
|
5
5
|
require 'uri'
|
6
6
|
require "json"
|
7
7
|
|
8
|
-
# ruby -r './lib/jekyll/migrators/posterous.rb' -e 'Jekyll::Posterous.process(email, pass, api_key
|
8
|
+
# ruby -r './lib/jekyll/migrators/posterous.rb' -e 'Jekyll::Posterous.process(email, pass, api_key)'
|
9
|
+
# Other arguments are optional; the default values are:
|
10
|
+
# * :include_imgs => false # should images be downloaded as well?
|
11
|
+
# * :blog => 'primary' # blog, if you have more than one.
|
12
|
+
# * :base_path => '/' # for image, if they will be served from a different host for eg.
|
13
|
+
|
14
|
+
# For example, to download images as well as your posts, use the above command with
|
15
|
+
# ....process(email, pass, api_key, :include_imgs => true)
|
9
16
|
|
10
17
|
module JekyllImport
|
11
18
|
module Posterous
|
@@ -55,11 +62,13 @@ module JekyllImport
|
|
55
62
|
return urls
|
56
63
|
end
|
57
64
|
|
58
|
-
def self.process(email, pass, api_token,
|
65
|
+
def self.process(email, pass, api_token, opts={})
|
59
66
|
@email, @pass, @api_token = email, pass, api_token
|
67
|
+
defaults = { :include_imgs => false, :blog => 'primary', :base_path => '/' }
|
68
|
+
opts = defaults.merge(opts)
|
60
69
|
FileUtils.mkdir_p "_posts"
|
61
70
|
|
62
|
-
posts = JSON.parse(self.fetch("/api/v2/users/me/sites/#{blog}/posts?api_token=#{@api_token}").body)
|
71
|
+
posts = JSON.parse(self.fetch("/api/v2/users/me/sites/#{opts[:blog]}/posts?api_token=#{@api_token}").body)
|
63
72
|
page = 1
|
64
73
|
|
65
74
|
while posts.any?
|
@@ -73,18 +82,20 @@ module JekyllImport
|
|
73
82
|
name = basename + '.html'
|
74
83
|
|
75
84
|
# Images:
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
85
|
+
if opts[:include_imgs]
|
86
|
+
post_imgs = post["media"]["images"]
|
87
|
+
if post_imgs.any?
|
88
|
+
img_dir = "imgs/%s" % basename
|
89
|
+
img_urls = self.fetch_images(img_dir, post_imgs)
|
90
|
+
|
91
|
+
img_urls.map! do |url|
|
92
|
+
'<li><img src="' + opts[:base_path] + url + '"></li>'
|
93
|
+
end
|
94
|
+
imgcontent = "<ol>\n" + img_urls.join("\n") + "</ol>\n"
|
95
|
+
|
96
|
+
# filter out "posterous-content", replacing with imgs:
|
97
|
+
content = content.sub(/\<p\>\[\[posterous-content:[^\]]+\]\]\<\/p\>/, imgcontent)
|
83
98
|
end
|
84
|
-
imgcontent = "<ol>\n" + img_urls.join("\n") + "</ol>\n"
|
85
|
-
|
86
|
-
# filter out "posterous-content", replacing with imgs:
|
87
|
-
content = content.sub(/\<p\>\[\[posterous-content:[^\]]+\]\]\<\/p\>/, imgcontent)
|
88
99
|
end
|
89
100
|
|
90
101
|
# Get the relevant fields as a hash, delete empty fields and convert
|
@@ -104,7 +115,7 @@ module JekyllImport
|
|
104
115
|
end
|
105
116
|
|
106
117
|
page += 1
|
107
|
-
posts = JSON.parse(self.fetch("/api/v2/users/me/sites/#{blog}/posts?api_token=#{@api_token}&page=#{page}").body)
|
118
|
+
posts = JSON.parse(self.fetch("/api/v2/users/me/sites/#{opts[:blog]}/posts?api_token=#{@api_token}&page=#{page}").body)
|
108
119
|
end
|
109
120
|
end
|
110
121
|
end
|
@@ -3,10 +3,10 @@
|
|
3
3
|
#
|
4
4
|
# Usage:
|
5
5
|
# (URL)
|
6
|
-
# ruby -r '
|
6
|
+
# ruby -r 'jekyll/jekyll-import/rss' -e "JekyllImport::RSS.process(:source => 'http://yourdomain.com/your-favorite-feed.xml')"
|
7
7
|
#
|
8
8
|
# (Local file)
|
9
|
-
# ruby -r '
|
9
|
+
# ruby -r 'jekyll/jekyll-import/rss' -e "JekyllImport::RSS.process(:source => './somefile/on/your/computer.xml')"
|
10
10
|
|
11
11
|
require 'rss/1.0'
|
12
12
|
require 'rss/2.0'
|
@@ -12,11 +12,21 @@ require 'yaml'
|
|
12
12
|
|
13
13
|
module JekyllImport
|
14
14
|
module S9Y
|
15
|
-
def self.
|
15
|
+
def self.validate(options)
|
16
|
+
if !options[:source]
|
17
|
+
abort "Missing mandatory option --source, e.g. --source \"http://blog.example.com/rss.php?version=2.0&all=1\""
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.process(options)
|
22
|
+
validate(options)
|
23
|
+
|
16
24
|
FileUtils.mkdir_p("_posts")
|
17
25
|
|
26
|
+
source = options[:source]
|
27
|
+
|
18
28
|
text = ''
|
19
|
-
open(
|
29
|
+
open(source) { |line| text = line.read }
|
20
30
|
rss = RSS::Parser.parse(text)
|
21
31
|
|
22
32
|
rss.items.each do |item|
|
@@ -20,28 +20,46 @@ module JekyllImport
|
|
20
20
|
# First pass builds up an array of each post as a hash.
|
21
21
|
begin
|
22
22
|
current_page = (current_page || -1) + 1
|
23
|
-
|
23
|
+
feed_url = url + "?num=#{per_page}&start=#{current_page * per_page}"
|
24
|
+
puts "Fetching #{feed_url}"
|
25
|
+
feed = open(feed_url)
|
24
26
|
json = feed.readlines.join("\n")[21...-2] # Strip Tumblr's JSONP chars.
|
25
27
|
blog = JSON.parse(json)
|
26
28
|
puts "Page: #{current_page + 1} - Posts: #{blog["posts"].size}"
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
post
|
35
|
-
post[:content] = add_syntax_highlights post[:content] if add_highlights
|
36
|
-
end
|
37
|
-
File.open("_posts/tumblr/#{post[:name]}", "w") do |f|
|
38
|
-
f.puts post[:header].to_yaml + "---\n" + post[:content]
|
29
|
+
batch = blog["posts"].map { |post| post_to_hash(post, format) }
|
30
|
+
|
31
|
+
# If we're rewriting, save the posts for later. Otherwise, go ahead and
|
32
|
+
# dump these to disk now
|
33
|
+
if rewrite_urls
|
34
|
+
posts += batch
|
35
|
+
else
|
36
|
+
batch.each {|post| write_post(post, format == "md", add_highlights)}
|
39
37
|
end
|
38
|
+
|
39
|
+
end until blog["posts"].size < per_page
|
40
|
+
|
41
|
+
# Rewrite URLs, create redirects and write out out posts if necessary
|
42
|
+
if rewrite_urls
|
43
|
+
posts = rewrite_urls_and_redirects posts
|
44
|
+
posts.each {|post| write_post(post, format == "md", add_highlights)}
|
40
45
|
end
|
41
46
|
end
|
42
47
|
|
43
48
|
private
|
44
49
|
|
50
|
+
# Writes a post out to disk
|
51
|
+
def self.write_post(post, use_markdown, add_highlights)
|
52
|
+
content = post[:content]
|
53
|
+
if use_markdown
|
54
|
+
content = html_to_markdown content
|
55
|
+
content = add_syntax_highlights content if add_highlights
|
56
|
+
end
|
57
|
+
|
58
|
+
File.open("_posts/tumblr/#{post[:name]}", "w") do |f|
|
59
|
+
f.puts post[:header].to_yaml + "---\n" + content
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
45
63
|
# Converts each type of Tumblr post to a hash with all required
|
46
64
|
# data for Jekyll.
|
47
65
|
def self.post_to_hash(post, format)
|
@@ -57,22 +75,18 @@ module JekyllImport
|
|
57
75
|
end
|
58
76
|
when "photo"
|
59
77
|
title = post["photo-caption"]
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
}.first].split(".").last
|
65
|
-
content = "<img src=\"#{save_file(url, ext)}\"/>"
|
66
|
-
unless post["photo-link-url"].nil?
|
67
|
-
content = "<a href=\"#{post["photo-link-url"]}\">#{content}</a>"
|
78
|
+
content = if post["photo-link-url"].nil?
|
79
|
+
"<a href=\"#{post["photo-link-url"]}\">#{content}</a>"
|
80
|
+
else
|
81
|
+
fetch_photo post
|
68
82
|
end
|
69
83
|
when "audio"
|
70
84
|
if !post["id3-title"].nil?
|
71
85
|
title = post["id3-title"]
|
72
|
-
content = post
|
86
|
+
content = post["audio-player"] + "<br/>" + post["audio-caption"]
|
73
87
|
else
|
74
88
|
title = post["audio-caption"]
|
75
|
-
content = post
|
89
|
+
content = post["audio-player"]
|
76
90
|
end
|
77
91
|
when "quote"
|
78
92
|
title = post["quote-text"]
|
@@ -111,6 +125,31 @@ module JekyllImport
|
|
111
125
|
}
|
112
126
|
end
|
113
127
|
|
128
|
+
# Attempts to fetch the largest version of a photo available for a post.
|
129
|
+
# If that file fails, it tries the next smaller size until all available
|
130
|
+
# photo URLs are exhausted. If they all fail, the import is aborted.
|
131
|
+
def self.fetch_photo(post)
|
132
|
+
sizes = post.keys.map {|k| k.gsub("photo-url-", "").to_i}
|
133
|
+
sizes.sort! {|a,b| b <=> a}
|
134
|
+
|
135
|
+
ext_key, ext_val = post.find do |k,v|
|
136
|
+
k =~ /^photo-url-/ && v.split("/").last =~ /\./
|
137
|
+
end
|
138
|
+
ext = "." + ext_val.split(".").last
|
139
|
+
|
140
|
+
sizes.each do |size|
|
141
|
+
url = post["photo-url"] || post["photo-url-#{size}"]
|
142
|
+
next if url.nil?
|
143
|
+
begin
|
144
|
+
return "<img src=\"#{save_photo(url, ext)}\"/>"
|
145
|
+
rescue OpenURI::HTTPError => err
|
146
|
+
puts "Failed to grab photo"
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
abort "Failed to fetch photo for post #{post['url']}"
|
151
|
+
end
|
152
|
+
|
114
153
|
# Create a Hash of old urls => new urls, for rewriting and
|
115
154
|
# redirects, and replace urls in each post. Instantiate Jekyll
|
116
155
|
# site/posts to get the correct permalink format.
|
@@ -181,12 +220,17 @@ module JekyllImport
|
|
181
220
|
lines.join("\n")
|
182
221
|
end
|
183
222
|
|
184
|
-
def self.
|
223
|
+
def self.save_photo(url, ext)
|
185
224
|
if @grab_images
|
186
225
|
path = "tumblr_files/#{url.split('/').last}"
|
187
226
|
path += ext unless path =~ /#{ext}$/
|
188
227
|
FileUtils.mkdir_p "tumblr_files"
|
189
|
-
|
228
|
+
|
229
|
+
# Don't fetch if we've already cached this file
|
230
|
+
unless File.size? path
|
231
|
+
puts "Fetching photo #{url}"
|
232
|
+
File.open(path, "w") { |f| f.write(open(url).read) }
|
233
|
+
end
|
190
234
|
url = "/" + path
|
191
235
|
end
|
192
236
|
url
|
@@ -15,6 +15,7 @@ module JekyllImport
|
|
15
15
|
c.extended extended,
|
16
16
|
c.published_at date,
|
17
17
|
c.state state,
|
18
|
+
c.keywords keywords,
|
18
19
|
COALESCE(tf.name, 'html') filter
|
19
20
|
FROM contents c
|
20
21
|
LEFT OUTER JOIN text_filters tf
|
@@ -32,7 +33,7 @@ module JekyllImport
|
|
32
33
|
raise "Unknown database server '#{server}'"
|
33
34
|
end
|
34
35
|
db[SQL].each do |post|
|
35
|
-
next unless post[:state] =~ /published/
|
36
|
+
next unless post[:state] =~ /published/i
|
36
37
|
|
37
38
|
if post[:slug] == nil
|
38
39
|
post[:slug] = "no slug"
|
@@ -54,7 +55,8 @@ module JekyllImport
|
|
54
55
|
|
55
56
|
File.open("_posts/#{name}", 'w') do |f|
|
56
57
|
f.puts({ 'layout' => 'post',
|
57
|
-
'title' => post[:title].to_s,
|
58
|
+
'title' => (post[:title] and post[:title].to_s.force_encoding('UTF-8')),
|
59
|
+
'tags' => (post[:keywords] and post[:keywords].to_s.force_encoding('UTF-8')),
|
58
60
|
'typo_id' => post[:id]
|
59
61
|
}.delete_if { |k, v| v.nil? || v == '' }.to_yaml)
|
60
62
|
f.puts '---'
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'sequel'
|
3
3
|
require 'fileutils'
|
4
|
-
require 'psych'
|
5
4
|
require 'safe_yaml'
|
6
5
|
|
7
6
|
# NOTE: This converter requires Sequel and the MySQL gems.
|
@@ -50,9 +49,13 @@ module JekyllImport
|
|
50
49
|
# and :revision. If this is nil or an empty
|
51
50
|
# array, all posts are migrated regardless of
|
52
51
|
# status. Default: [:publish].
|
53
|
-
#
|
54
|
-
def self.process(
|
52
|
+
#
|
53
|
+
def self.process(options={})
|
55
54
|
options = {
|
55
|
+
:user => '',
|
56
|
+
:pass => '',
|
57
|
+
:host => 'localhost',
|
58
|
+
:dbname => '',
|
56
59
|
:table_prefix => 'wp_',
|
57
60
|
:clean_entities => true,
|
58
61
|
:comments => true,
|
@@ -75,8 +78,8 @@ module JekyllImport
|
|
75
78
|
|
76
79
|
FileUtils.mkdir_p("_posts")
|
77
80
|
|
78
|
-
db = Sequel.
|
79
|
-
:host => host, :encoding => 'utf8')
|
81
|
+
db = Sequel.mysql2(options[:dbname], :user => options[:user], :password => options[:pass],
|
82
|
+
:host => options[:host], :encoding => 'utf8')
|
80
83
|
|
81
84
|
px = options[:table_prefix]
|
82
85
|
|
@@ -10,9 +10,9 @@ module JekyllImport
|
|
10
10
|
# This importer takes a wordpress.xml file, which can be exported from your
|
11
11
|
# wordpress.com blog (/wp-admin/export.php).
|
12
12
|
module WordpressDotCom
|
13
|
-
def self.process(filename = "wordpress.xml")
|
13
|
+
def self.process(filename = {:source => "wordpress.xml"})
|
14
14
|
import_count = Hash.new(0)
|
15
|
-
doc = Hpricot::XML(File.read(filename))
|
15
|
+
doc = Hpricot::XML(File.read(filename[:source]))
|
16
16
|
|
17
17
|
(doc/:channel/:item).each do |item|
|
18
18
|
title = item.at(:title).inner_text.strip
|
data/lib/jekyll-import.rb
CHANGED
data/test/helper.rb
CHANGED
@@ -9,6 +9,12 @@ require 'redgreen' if RUBY_VERSION < '1.9'
|
|
9
9
|
require 'shoulda'
|
10
10
|
require 'rr'
|
11
11
|
|
12
|
+
unless defined?(Test::Unit::AssertionFailedError)
|
13
|
+
require 'active_support'
|
14
|
+
class Test::Unit::AssertionFailedError < ActiveSupport::TestCase::Assertion
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
12
18
|
Dir.glob(File.expand_path('../../lib/jekyll/jekyll-import/*', __FILE__)).each do |f|
|
13
19
|
require f
|
14
20
|
end
|
data/test/test_mt_importer.rb
CHANGED
@@ -89,11 +89,11 @@ class TestMTMigrator < Test::Unit::TestCase
|
|
89
89
|
|
90
90
|
should "not include a <!--MORE--> separator when there is no entry_text_more" do
|
91
91
|
post = stub_entry_row(:entry_text_more => "")
|
92
|
-
|
92
|
+
assert !JekyllImport::MT.post_content(post).include?(JekyllImport::MT::MORE_CONTENT_SEPARATOR)
|
93
93
|
end
|
94
94
|
|
95
95
|
should "include the entry_authored_on date in the file name" do
|
96
|
-
post = stub_entry_row(:entry_authored_on => Time.parse("2013-01-02 00:00:00").utc)
|
96
|
+
post = stub_entry_row(:entry_authored_on => Time.parse("2013-01-02 00:00:00 -00:00").utc)
|
97
97
|
assert JekyllImport::MT.post_file_name(post).include?("2013-01-02")
|
98
98
|
end
|
99
99
|
|
metadata
CHANGED
@@ -1,36 +1,32 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-import
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.
|
5
|
-
prerelease: 6
|
4
|
+
version: 0.1.0.beta2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Tom Preston-Werner
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-07-01 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: jekyll
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: '0'
|
19
|
+
version: '1.0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: '0'
|
26
|
+
version: '1.0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: fastercsv
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ! '>='
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,7 +34,6 @@ dependencies:
|
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ! '>='
|
44
39
|
- !ruby/object:Gem::Version
|
@@ -46,7 +41,6 @@ dependencies:
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: nokogiri
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
45
|
- - ! '>='
|
52
46
|
- !ruby/object:Gem::Version
|
@@ -54,7 +48,6 @@ dependencies:
|
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
52
|
- - ! '>='
|
60
53
|
- !ruby/object:Gem::Version
|
@@ -62,23 +55,20 @@ dependencies:
|
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: safe_yaml
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
59
|
- - ~>
|
68
60
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
61
|
+
version: 0.7.0
|
70
62
|
type: :runtime
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
66
|
- - ~>
|
76
67
|
- !ruby/object:Gem::Version
|
77
|
-
version:
|
68
|
+
version: 0.7.0
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: rake
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
73
|
- - ~>
|
84
74
|
- !ruby/object:Gem::Version
|
@@ -86,7 +76,6 @@ dependencies:
|
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
80
|
- - ~>
|
92
81
|
- !ruby/object:Gem::Version
|
@@ -94,7 +83,6 @@ dependencies:
|
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: rdoc
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
87
|
- - ~>
|
100
88
|
- !ruby/object:Gem::Version
|
@@ -102,15 +90,27 @@ dependencies:
|
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
94
|
- - ~>
|
108
95
|
- !ruby/object:Gem::Version
|
109
96
|
version: 4.0.0
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: activesupport
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ~>
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '3.2'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ~>
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3.2'
|
110
111
|
- !ruby/object:Gem::Dependency
|
111
112
|
name: redgreen
|
112
113
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
114
|
requirements:
|
115
115
|
- - ~>
|
116
116
|
- !ruby/object:Gem::Version
|
@@ -118,7 +118,6 @@ dependencies:
|
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
121
|
requirements:
|
123
122
|
- - ~>
|
124
123
|
- !ruby/object:Gem::Version
|
@@ -126,7 +125,6 @@ dependencies:
|
|
126
125
|
- !ruby/object:Gem::Dependency
|
127
126
|
name: shoulda
|
128
127
|
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
128
|
requirements:
|
131
129
|
- - ~>
|
132
130
|
- !ruby/object:Gem::Version
|
@@ -134,7 +132,6 @@ dependencies:
|
|
134
132
|
type: :development
|
135
133
|
prerelease: false
|
136
134
|
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
135
|
requirements:
|
139
136
|
- - ~>
|
140
137
|
- !ruby/object:Gem::Version
|
@@ -142,7 +139,6 @@ dependencies:
|
|
142
139
|
- !ruby/object:Gem::Dependency
|
143
140
|
name: rr
|
144
141
|
requirement: !ruby/object:Gem::Requirement
|
145
|
-
none: false
|
146
142
|
requirements:
|
147
143
|
- - ~>
|
148
144
|
- !ruby/object:Gem::Version
|
@@ -150,7 +146,6 @@ dependencies:
|
|
150
146
|
type: :development
|
151
147
|
prerelease: false
|
152
148
|
version_requirements: !ruby/object:Gem::Requirement
|
153
|
-
none: false
|
154
149
|
requirements:
|
155
150
|
- - ~>
|
156
151
|
- !ruby/object:Gem::Version
|
@@ -158,7 +153,6 @@ dependencies:
|
|
158
153
|
- !ruby/object:Gem::Dependency
|
159
154
|
name: simplecov
|
160
155
|
requirement: !ruby/object:Gem::Requirement
|
161
|
-
none: false
|
162
156
|
requirements:
|
163
157
|
- - ~>
|
164
158
|
- !ruby/object:Gem::Version
|
@@ -166,7 +160,6 @@ dependencies:
|
|
166
160
|
type: :development
|
167
161
|
prerelease: false
|
168
162
|
version_requirements: !ruby/object:Gem::Requirement
|
169
|
-
none: false
|
170
163
|
requirements:
|
171
164
|
- - ~>
|
172
165
|
- !ruby/object:Gem::Version
|
@@ -174,7 +167,6 @@ dependencies:
|
|
174
167
|
- !ruby/object:Gem::Dependency
|
175
168
|
name: simplecov-gem-adapter
|
176
169
|
requirement: !ruby/object:Gem::Requirement
|
177
|
-
none: false
|
178
170
|
requirements:
|
179
171
|
- - ~>
|
180
172
|
- !ruby/object:Gem::Version
|
@@ -182,7 +174,6 @@ dependencies:
|
|
182
174
|
type: :development
|
183
175
|
prerelease: false
|
184
176
|
version_requirements: !ruby/object:Gem::Requirement
|
185
|
-
none: false
|
186
177
|
requirements:
|
187
178
|
- - ~>
|
188
179
|
- !ruby/object:Gem::Version
|
@@ -190,7 +181,6 @@ dependencies:
|
|
190
181
|
- !ruby/object:Gem::Dependency
|
191
182
|
name: sequel
|
192
183
|
requirement: !ruby/object:Gem::Requirement
|
193
|
-
none: false
|
194
184
|
requirements:
|
195
185
|
- - ~>
|
196
186
|
- !ruby/object:Gem::Version
|
@@ -198,7 +188,6 @@ dependencies:
|
|
198
188
|
type: :development
|
199
189
|
prerelease: false
|
200
190
|
version_requirements: !ruby/object:Gem::Requirement
|
201
|
-
none: false
|
202
191
|
requirements:
|
203
192
|
- - ~>
|
204
193
|
- !ruby/object:Gem::Version
|
@@ -206,7 +195,6 @@ dependencies:
|
|
206
195
|
- !ruby/object:Gem::Dependency
|
207
196
|
name: htmlentities
|
208
197
|
requirement: !ruby/object:Gem::Requirement
|
209
|
-
none: false
|
210
198
|
requirements:
|
211
199
|
- - ~>
|
212
200
|
- !ruby/object:Gem::Version
|
@@ -214,7 +202,6 @@ dependencies:
|
|
214
202
|
type: :development
|
215
203
|
prerelease: false
|
216
204
|
version_requirements: !ruby/object:Gem::Requirement
|
217
|
-
none: false
|
218
205
|
requirements:
|
219
206
|
- - ~>
|
220
207
|
- !ruby/object:Gem::Version
|
@@ -222,7 +209,6 @@ dependencies:
|
|
222
209
|
- !ruby/object:Gem::Dependency
|
223
210
|
name: hpricot
|
224
211
|
requirement: !ruby/object:Gem::Requirement
|
225
|
-
none: false
|
226
212
|
requirements:
|
227
213
|
- - ~>
|
228
214
|
- !ruby/object:Gem::Version
|
@@ -230,7 +216,6 @@ dependencies:
|
|
230
216
|
type: :development
|
231
217
|
prerelease: false
|
232
218
|
version_requirements: !ruby/object:Gem::Requirement
|
233
|
-
none: false
|
234
219
|
requirements:
|
235
220
|
- - ~>
|
236
221
|
- !ruby/object:Gem::Version
|
@@ -238,7 +223,6 @@ dependencies:
|
|
238
223
|
- !ruby/object:Gem::Dependency
|
239
224
|
name: mysql
|
240
225
|
requirement: !ruby/object:Gem::Requirement
|
241
|
-
none: false
|
242
226
|
requirements:
|
243
227
|
- - ~>
|
244
228
|
- !ruby/object:Gem::Version
|
@@ -246,7 +230,6 @@ dependencies:
|
|
246
230
|
type: :development
|
247
231
|
prerelease: false
|
248
232
|
version_requirements: !ruby/object:Gem::Requirement
|
249
|
-
none: false
|
250
233
|
requirements:
|
251
234
|
- - ~>
|
252
235
|
- !ruby/object:Gem::Version
|
@@ -254,7 +237,6 @@ dependencies:
|
|
254
237
|
- !ruby/object:Gem::Dependency
|
255
238
|
name: pg
|
256
239
|
requirement: !ruby/object:Gem::Requirement
|
257
|
-
none: false
|
258
240
|
requirements:
|
259
241
|
- - ~>
|
260
242
|
- !ruby/object:Gem::Version
|
@@ -262,7 +244,6 @@ dependencies:
|
|
262
244
|
type: :development
|
263
245
|
prerelease: false
|
264
246
|
version_requirements: !ruby/object:Gem::Requirement
|
265
|
-
none: false
|
266
247
|
requirements:
|
267
248
|
- - ~>
|
268
249
|
- !ruby/object:Gem::Version
|
@@ -272,13 +253,13 @@ email: tom@mojombo.com
|
|
272
253
|
executables: []
|
273
254
|
extensions: []
|
274
255
|
extra_rdoc_files:
|
275
|
-
- README.
|
256
|
+
- README.markdown
|
276
257
|
- LICENSE
|
277
258
|
files:
|
278
259
|
- Gemfile
|
279
|
-
- History.
|
260
|
+
- History.markdown
|
280
261
|
- LICENSE
|
281
|
-
- README.
|
262
|
+
- README.markdown
|
282
263
|
- Rakefile
|
283
264
|
- jekyll-import.gemspec
|
284
265
|
- lib/jekyll-import.rb
|
@@ -305,26 +286,25 @@ files:
|
|
305
286
|
- test/test_wordpressdotcom_importer.rb
|
306
287
|
homepage: http://github.com/mojombo/jekyll-import
|
307
288
|
licenses: []
|
289
|
+
metadata: {}
|
308
290
|
post_install_message:
|
309
291
|
rdoc_options:
|
310
292
|
- --charset=UTF-8
|
311
293
|
require_paths:
|
312
294
|
- lib
|
313
295
|
required_ruby_version: !ruby/object:Gem::Requirement
|
314
|
-
none: false
|
315
296
|
requirements:
|
316
297
|
- - ! '>='
|
317
298
|
- !ruby/object:Gem::Version
|
318
|
-
version:
|
299
|
+
version: 1.9.2
|
319
300
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
320
|
-
none: false
|
321
301
|
requirements:
|
322
302
|
- - ! '>'
|
323
303
|
- !ruby/object:Gem::Version
|
324
304
|
version: 1.3.1
|
325
305
|
requirements: []
|
326
306
|
rubyforge_project: jekyll-import
|
327
|
-
rubygems_version:
|
307
|
+
rubygems_version: 2.0.3
|
328
308
|
signing_key:
|
329
309
|
specification_version: 2
|
330
310
|
summary: Import command for Jekyll (static site generator).
|
data/History.txt
DELETED
data/README.md
DELETED