jekyll-import 0.4.1 → 0.5.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/importers/blogger.rb +251 -0
- data/lib/jekyll-import/importers/drupal6.rb +0 -6
- data/lib/jekyll-import/importers/drupal7.rb +0 -6
- data/lib/jekyll-import/importers/easyblog.rb +14 -21
- data/lib/jekyll-import/importers/enki.rb +0 -3
- data/lib/jekyll-import/importers/ghost.rb +1 -2
- data/lib/jekyll-import/importers/joomla.rb +0 -7
- data/lib/jekyll-import/importers/jrnl.rb +0 -2
- data/lib/jekyll-import/importers/mephisto.rb +0 -10
- data/lib/jekyll-import/importers/mt.rb +0 -10
- data/lib/jekyll-import/importers/posterous.rb +0 -9
- data/lib/jekyll-import/importers/rss.rb +0 -10
- data/lib/jekyll-import/importers/s9y.rb +0 -7
- data/lib/jekyll-import/importers/textpattern.rb +0 -6
- data/lib/jekyll-import/importers/typo.rb +0 -1
- data/lib/jekyll-import/importers/wordpress.rb +0 -9
- data/lib/jekyll-import/importers/wordpressdotcom.rb +1 -4
- data/lib/jekyll-import/version.rb +1 -1
- data/lib/jekyll/commands/import.rb +9 -6
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b24802c3b5f7734905bef82ba555c97b273b1139
|
4
|
+
data.tar.gz: 6c1da2b13f4727a49144d84f140cc1fe91151d7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 889cf9c39a18ff9c0903ec4e154683fb895315b3cc916a5fb44559f0ef1ef47e31a17086586f72f5a4bfc3ab409825698398577856085a71a8efe0c755181b96
|
7
|
+
data.tar.gz: a4432acb1e4c9ecbb47e53472fa48c7fdb411b5d399c2c91573b953250c87b50fe6817fe7b19ba4311115293e560d68b5aabedb119c01032af04e7fbc71bd73b
|
@@ -0,0 +1,251 @@
|
|
1
|
+
module JekyllImport
|
2
|
+
module Importers
|
3
|
+
class Blogger < Importer
|
4
|
+
def self.specify_options(c)
|
5
|
+
c.option 'source', '--source NAME', 'The XML file (blog-MM-DD-YYYY.xml) path to import'
|
6
|
+
c.option 'no-blogger-info', '--no-blogger-info', 'not to leave blogger-URL info (id and old URL) in the front matter (default: false)'
|
7
|
+
c.option 'replace-internal-link', '--replace-internal-link', 'replace internal links using the post_url liquid tag. (default: false)'
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.validate(options)
|
11
|
+
if options['source'].nil?
|
12
|
+
raise 'Missing mandatory option: --source'
|
13
|
+
elsif not File.exist?(options['source'])
|
14
|
+
raise Errno::ENOENT, "File not found: #{options['source']}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.require_deps
|
19
|
+
JekyllImport.require_with_fallback(%w[
|
20
|
+
rexml/document
|
21
|
+
rexml/streamlistener
|
22
|
+
rexml/parsers/streamparser
|
23
|
+
uri
|
24
|
+
time
|
25
|
+
fileutils
|
26
|
+
safe_yaml
|
27
|
+
])
|
28
|
+
end
|
29
|
+
|
30
|
+
# Process the import.
|
31
|
+
#
|
32
|
+
# source:: a local file String (or IO object for internal use purpose)..
|
33
|
+
# no-blogger-info:: a boolean if not leave blogger info (id and original URL).
|
34
|
+
# replace-internal-link:: a boolean if replace internal link
|
35
|
+
#
|
36
|
+
# Returns nothing.
|
37
|
+
def self.process(options)
|
38
|
+
source = options.fetch('source')
|
39
|
+
|
40
|
+
listener = BloggerAtomStreamListener.new
|
41
|
+
|
42
|
+
listener.leave_blogger_info = ! options.fetch('no-blogger-info', false),
|
43
|
+
|
44
|
+
File.open(source, 'r') do |f|
|
45
|
+
f.flock(File::LOCK_SH)
|
46
|
+
REXML::Parsers::StreamParser.new(f, listener).parse()
|
47
|
+
end
|
48
|
+
|
49
|
+
options['original-url-base'] = listener.original_url_base
|
50
|
+
|
51
|
+
postprocess(options)
|
52
|
+
end
|
53
|
+
|
54
|
+
# Post-process after import.
|
55
|
+
#
|
56
|
+
# replace-internal-link:: a boolean if replace internal link
|
57
|
+
#
|
58
|
+
# Returns nothing.
|
59
|
+
def self.postprocess(options)
|
60
|
+
# Replace internal link URL
|
61
|
+
if options.fetch('replace-internal-link', false)
|
62
|
+
original_url_base = options.fetch('original-url-base', nil)
|
63
|
+
if original_url_base
|
64
|
+
orig_url_pattern = Regexp.new(" href=([\"\'])(?:#{Regexp.escape(original_url_base)})?/([0-9]{4})/([0-9]{2})/([^\"\']+\.html)\\1")
|
65
|
+
|
66
|
+
Dir.glob('_posts/*.*') do |filename|
|
67
|
+
body = nil
|
68
|
+
File.open(filename, 'r') do |f|
|
69
|
+
f.flock(File::LOCK_SH)
|
70
|
+
body = f.read
|
71
|
+
end
|
72
|
+
|
73
|
+
body.gsub!(orig_url_pattern) do
|
74
|
+
# for post_url
|
75
|
+
quote = $1
|
76
|
+
post_file = Dir.glob("_posts/#{$2}-#{$3}-*-#{$4.to_s.tr('/', '-')}").first
|
77
|
+
raise "Could not found: _posts/#{$2}-#{$3}-*-#{$4.to_s.tr('/', '-')}" if post_file.nil?
|
78
|
+
" href=#{quote}{{ site.baseurl }}{% post_url #{File.basename(post_file, '.html')} %}#{quote}"
|
79
|
+
end
|
80
|
+
|
81
|
+
File.open(filename, 'w') do |f|
|
82
|
+
f.flock(File::LOCK_EX)
|
83
|
+
f << body
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
class BloggerAtomStreamListener
|
91
|
+
def initialize
|
92
|
+
# use `extend` instead of `include` to use `require_deps` instead of `require`.
|
93
|
+
extend REXML::StreamListener
|
94
|
+
extend BloggerAtomStreamListenerMethods
|
95
|
+
|
96
|
+
@leave_blogger_info = true
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
module BloggerAtomStreamListenerMethods
|
101
|
+
attr_accessor :leave_blogger_info
|
102
|
+
attr_reader :original_url_base
|
103
|
+
|
104
|
+
def tag_start(tag, attrs)
|
105
|
+
@tag_bread = [] unless @tag_bread
|
106
|
+
@tag_bread.push(tag)
|
107
|
+
|
108
|
+
case tag
|
109
|
+
when 'entry'
|
110
|
+
raise 'nest entry element' if @in_entry_elem
|
111
|
+
@in_entry_elem = {:meta => {}, :body => nil}
|
112
|
+
when 'title'
|
113
|
+
if @in_entry_elem
|
114
|
+
raise 'only <title type="text"></title> is supported' if attrs['type'] != 'text'
|
115
|
+
end
|
116
|
+
when 'category'
|
117
|
+
if @in_entry_elem
|
118
|
+
if attrs['scheme'] == 'http://www.blogger.com/atom/ns#'
|
119
|
+
@in_entry_elem[:meta][:category] = [] unless @in_entry_elem[:meta][:category]
|
120
|
+
@in_entry_elem[:meta][:category] << attrs['term']
|
121
|
+
elsif attrs['scheme'] == 'http://schemas.google.com/g/2005#kind'
|
122
|
+
kind = attrs['term']
|
123
|
+
kind.sub!(Regexp.new("^http://schemas\\.google\\.com/blogger/2008/kind\\#"), '')
|
124
|
+
@in_entry_elem[:meta][:kind] = kind
|
125
|
+
end
|
126
|
+
end
|
127
|
+
when 'content'
|
128
|
+
if @in_entry_elem
|
129
|
+
@in_entry_elem[:meta][:content_type] = attrs['type']
|
130
|
+
end
|
131
|
+
when 'link'
|
132
|
+
if @in_entry_elem
|
133
|
+
if attrs['rel'] == 'alternate' && attrs['type'] == 'text/html'
|
134
|
+
@in_entry_elem[:meta][:original_url] = attrs['href']
|
135
|
+
elsif attrs['rel'] == 'replies' && attrs['type'] == 'text/html'
|
136
|
+
unless @in_entry_elem[:meta][:original_url]
|
137
|
+
@in_entry_elem[:meta][:original_url] = attrs['href'].sub(/\#comment-form$/, '')
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
when 'media:thumbnail'
|
142
|
+
if @in_entry_elem
|
143
|
+
@in_entry_elem[:meta][:thumbnail] = attrs['url']
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
def text(text)
|
149
|
+
if @in_entry_elem
|
150
|
+
case @tag_bread.last
|
151
|
+
when 'id'
|
152
|
+
@in_entry_elem[:meta][:id] = text
|
153
|
+
when 'published'
|
154
|
+
@in_entry_elem[:meta][:published] = text
|
155
|
+
when 'updated'
|
156
|
+
@in_entry_elem[:meta][:updated] = text
|
157
|
+
when 'title'
|
158
|
+
@in_entry_elem[:meta][:title] = text
|
159
|
+
when 'content'
|
160
|
+
@in_entry_elem[:body] = text
|
161
|
+
when 'name'
|
162
|
+
if @tag_bread[-2..-1] == %w[author name]
|
163
|
+
@in_entry_elem[:meta][:author] = text
|
164
|
+
end
|
165
|
+
when 'app:draft'
|
166
|
+
if @tag_bread[-2..-1] == %w[app:control app:draft]
|
167
|
+
@in_entry_elem[:meta][:draft] = true if text == 'yes'
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
def tag_end(tag)
|
174
|
+
case tag
|
175
|
+
when 'entry'
|
176
|
+
raise 'nest entry element' unless @in_entry_elem
|
177
|
+
|
178
|
+
if @in_entry_elem[:meta][:kind] == 'post'
|
179
|
+
post_data = get_post_data_from_in_entry_elem_info
|
180
|
+
|
181
|
+
if post_data
|
182
|
+
target_dir = '_posts'
|
183
|
+
target_dir = '_drafts' if @in_entry_elem[:meta][:draft]
|
184
|
+
|
185
|
+
FileUtils.mkdir_p(target_dir)
|
186
|
+
|
187
|
+
File.open(File.join(target_dir, "#{post_data[:filename]}.html"), 'w') do |f|
|
188
|
+
f.flock(File::LOCK_EX)
|
189
|
+
|
190
|
+
f << post_data[:header].to_yaml
|
191
|
+
f << "---\n\n"
|
192
|
+
f << post_data[:body]
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
@in_entry_elem = nil
|
198
|
+
end
|
199
|
+
|
200
|
+
@tag_bread.pop
|
201
|
+
end
|
202
|
+
|
203
|
+
def get_post_data_from_in_entry_elem_info
|
204
|
+
if (@in_entry_elem.nil? || ! @in_entry_elem.has_key?(:meta) || ! @in_entry_elem[:meta].has_key?(:kind))
|
205
|
+
nil
|
206
|
+
elsif @in_entry_elem[:meta][:kind] == 'post'
|
207
|
+
if @in_entry_elem[:meta][:original_url]
|
208
|
+
original_uri = URI.parse(@in_entry_elem[:meta][:original_url])
|
209
|
+
original_path = original_uri.path.to_s
|
210
|
+
filename = "%s-%s" %
|
211
|
+
[Time.parse(@in_entry_elem[:meta][:published]).strftime('%Y-%m-%d'),
|
212
|
+
File.basename(original_path, File.extname(original_path))]
|
213
|
+
|
214
|
+
@original_url_base = "#{original_uri.scheme}://#{original_uri.host}"
|
215
|
+
else
|
216
|
+
raise 'Original URL is missing'
|
217
|
+
end
|
218
|
+
|
219
|
+
header = {
|
220
|
+
'layout' => 'post',
|
221
|
+
'title' => @in_entry_elem[:meta][:title],
|
222
|
+
'date' => @in_entry_elem[:meta][:published],
|
223
|
+
'author' => @in_entry_elem[:meta][:author],
|
224
|
+
'tags' => @in_entry_elem[:meta][:category],
|
225
|
+
}
|
226
|
+
header['modified_time'] = @in_entry_elem[:meta][:updated] if @in_entry_elem[:meta][:updated] && @in_entry_elem[:meta][:updated] != @in_entry_elem[:meta][:published]
|
227
|
+
header['thumbnail'] = @in_entry_elem[:meta][:thumbnail] if @in_entry_elem[:meta][:thumbnail]
|
228
|
+
header['blogger_id'] = @in_entry_elem[:meta][:id] if @leave_blogger_info
|
229
|
+
header['blogger_orig_url'] = @in_entry_elem[:meta][:original_url] if @leave_blogger_info
|
230
|
+
|
231
|
+
body = @in_entry_elem[:body]
|
232
|
+
|
233
|
+
# body escaping associated with liquid
|
234
|
+
if body =~ /{{/
|
235
|
+
body.gsub!(/{{/, '{{ "{{" }}')
|
236
|
+
end
|
237
|
+
if body =~ /{%/
|
238
|
+
body.gsub!(/{%/, '{{ "{%" }}')
|
239
|
+
end
|
240
|
+
|
241
|
+
{ :filename => filename, :header => header, :body => body }
|
242
|
+
else
|
243
|
+
nil
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
end
|
248
|
+
|
249
|
+
end
|
250
|
+
end
|
251
|
+
end
|
@@ -1,9 +1,3 @@
|
|
1
|
-
# NOTE: This converter requires Sequel and the MySQL gems.
|
2
|
-
# The MySQL gem can be difficult to install on OS X. Once you have MySQL
|
3
|
-
# installed, running the following commands should work:
|
4
|
-
# $ sudo gem install sequel
|
5
|
-
# $ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
|
6
|
-
|
7
1
|
module JekyllImport
|
8
2
|
module Importers
|
9
3
|
class Drupal6 < Importer
|
@@ -1,9 +1,3 @@
|
|
1
|
-
# NOTE: This converter requires Sequel and the MySQL gems.
|
2
|
-
# The MySQL gem can be difficult to install on OS X. Once you have MySQL
|
3
|
-
# installed, running the following commands should work:
|
4
|
-
# $ sudo gem install sequel
|
5
|
-
# $ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
|
6
|
-
|
7
1
|
module JekyllImport
|
8
2
|
module Importers
|
9
3
|
class Drupal7 < Importer
|
@@ -1,10 +1,3 @@
|
|
1
|
-
# NOTE: This migrator is made for Joomla 2.5 database and EasyBlog 3.8.
|
2
|
-
# NOTE: This converter requires Sequel and the MySQL gems.
|
3
|
-
# The MySQL gem can be difficult to install on OS X. Once you have MySQL
|
4
|
-
# installed, running the following commands should work:
|
5
|
-
# $ sudo gem install sequel
|
6
|
-
# $ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
|
7
|
-
|
8
1
|
module JekyllImport
|
9
2
|
module Importers
|
10
3
|
class Easyblog < Importer
|
@@ -15,7 +8,7 @@ module JekyllImport
|
|
15
8
|
end
|
16
9
|
end
|
17
10
|
end
|
18
|
-
|
11
|
+
|
19
12
|
def self.specify_options(c)
|
20
13
|
c.option 'dbname', '--dbname', 'Database name'
|
21
14
|
c.option 'user', '--user', 'Database user name'
|
@@ -24,7 +17,7 @@ module JekyllImport
|
|
24
17
|
c.option 'section', '--section', 'Table prefix name'
|
25
18
|
c.option 'prefix', '--prefix', 'Table prefix name'
|
26
19
|
end
|
27
|
-
|
20
|
+
|
28
21
|
def self.require_deps
|
29
22
|
JekyllImport.require_with_fallback(%w[
|
30
23
|
rubygems
|
@@ -33,7 +26,7 @@ module JekyllImport
|
|
33
26
|
safe_yaml
|
34
27
|
])
|
35
28
|
end
|
36
|
-
|
29
|
+
|
37
30
|
def self.process(options)
|
38
31
|
dbname = options.fetch('dbname')
|
39
32
|
user = options.fetch('user')
|
@@ -41,20 +34,20 @@ module JekyllImport
|
|
41
34
|
host = options.fetch('host', "localhost")
|
42
35
|
section = options.fetch('section', '1')
|
43
36
|
table_prefix = options.fetch('prefix', "jos_")
|
44
|
-
|
37
|
+
|
45
38
|
db = Sequel.mysql(dbname, :user => user, :password => pass, :host => host, :encoding => 'utf8')
|
46
|
-
|
39
|
+
|
47
40
|
FileUtils.mkdir_p("_posts")
|
48
|
-
|
41
|
+
|
49
42
|
# Reads a MySQL database via Sequel and creates a post file for each
|
50
43
|
# post in wp_posts that has post_status = 'publish'. This restriction is
|
51
44
|
# made because 'draft' posts are not guaranteed to have valid dates.
|
52
45
|
|
53
46
|
query = "
|
54
|
-
select
|
47
|
+
select
|
55
48
|
ep.`title`, `permalink` as alias, concat(`intro`, `content`) as content, ep.`created`, ep.`id`, ec.`title` as category, tags
|
56
|
-
from
|
57
|
-
#{table_prefix}easyblog_post ep
|
49
|
+
from
|
50
|
+
#{table_prefix}easyblog_post ep
|
58
51
|
left join #{table_prefix}easyblog_category ec on (ep.category_id = ec.id)
|
59
52
|
left join (
|
60
53
|
select
|
@@ -66,7 +59,7 @@ module JekyllImport
|
|
66
59
|
group by
|
67
60
|
ept.post_id) x on (ep.id = x.post_id);
|
68
61
|
"
|
69
|
-
|
62
|
+
|
70
63
|
db[query].each do |post|
|
71
64
|
# Get required fields and construct Jekyll compatible name.
|
72
65
|
title = post[:title]
|
@@ -74,10 +67,10 @@ module JekyllImport
|
|
74
67
|
date = post[:created]
|
75
68
|
content = post[:content]
|
76
69
|
category = post[:category]
|
77
|
-
tags = post[:tags]
|
70
|
+
tags = post[:tags]
|
78
71
|
name = "%02d-%02d-%02d-%s.markdown" % [date.year, date.month, date.day,
|
79
72
|
slug]
|
80
|
-
|
73
|
+
|
81
74
|
# Get the relevant fields as a hash, delete empty fields and convert
|
82
75
|
# to YAML for the header.
|
83
76
|
data = {
|
@@ -86,10 +79,10 @@ module JekyllImport
|
|
86
79
|
'joomla_id' => post[:id],
|
87
80
|
'joomla_url' => post[:alias],
|
88
81
|
'category' => post[:category],
|
89
|
-
'tags' => post[:tags],
|
82
|
+
'tags' => post[:tags],
|
90
83
|
'date' => date
|
91
84
|
}.delete_if { |k,v| v.nil? || v == '' }.to_yaml
|
92
|
-
|
85
|
+
|
93
86
|
# Write out the data and content to file
|
94
87
|
File.open("_posts/#{name}", "w") do |f|
|
95
88
|
f.puts data
|
@@ -1,4 +1,3 @@
|
|
1
|
-
# NOTE: This migrator is made for Ghost sqlite databases.
|
2
1
|
module JekyllImport
|
3
2
|
module Importers
|
4
3
|
class Ghost < Importer
|
@@ -38,7 +37,7 @@ module JekyllImport
|
|
38
37
|
# detect if the post is a draft
|
39
38
|
draft = post[:status].eql?('draft')
|
40
39
|
|
41
|
-
# Ghost saves the time in an weird format with 3 more numbers.
|
40
|
+
# Ghost saves the time in an weird format with 3 more numbers.
|
42
41
|
# But the time is correct when we remove the last 3 numbers.
|
43
42
|
date = Time.at(post[:created_at].to_i.to_s[0..-4].to_i)
|
44
43
|
|
@@ -1,10 +1,3 @@
|
|
1
|
-
# NOTE: This migrator is made for Joomla 1.5 databases.
|
2
|
-
# NOTE: This converter requires Sequel and the MySQL gems.
|
3
|
-
# The MySQL gem can be difficult to install on OS X. Once you have MySQL
|
4
|
-
# installed, running the following commands should work:
|
5
|
-
# $ sudo gem install sequel
|
6
|
-
# $ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
|
7
|
-
|
8
1
|
module JekyllImport
|
9
2
|
module Importers
|
10
3
|
class Joomla < Importer
|
@@ -1,13 +1,3 @@
|
|
1
|
-
# Quickly hacked together my Michael Ivey
|
2
|
-
# Based on mt.rb by Nick Gerakines, open source and publically
|
3
|
-
# available under the MIT license. Use this module at your own risk.
|
4
|
-
|
5
|
-
# NOTE: This converter requires Sequel and the MySQL gems.
|
6
|
-
# The MySQL gem can be difficult to install on OS X. Once you have MySQL
|
7
|
-
# installed, running the following commands should work:
|
8
|
-
# $ sudo gem install sequel
|
9
|
-
# $ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
|
10
|
-
|
11
1
|
module JekyllImport
|
12
2
|
module Importers
|
13
3
|
class Mephisto < Importer
|
@@ -1,13 +1,3 @@
|
|
1
|
-
# Created by Nick Gerakines, open source and publically available under the
|
2
|
-
# MIT license. Use this module at your own risk.
|
3
|
-
# I'm an Erlang/Perl/C++ guy so please forgive my dirty ruby.
|
4
|
-
|
5
|
-
# NOTE: This converter requires Sequel and the MySQL gems.
|
6
|
-
# The MySQL gem can be difficult to install on OS X. Once you have MySQL
|
7
|
-
# installed, running the following commands should work:
|
8
|
-
# $ sudo gem install sequel
|
9
|
-
# $ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
|
10
|
-
|
11
1
|
module JekyllImport
|
12
2
|
module Importers
|
13
3
|
class MT < Importer
|
@@ -1,12 +1,3 @@
|
|
1
|
-
# ruby -r './lib/jekyll/migrators/posterous.rb' -e 'Jekyll::Posterous.process(email, pass, api_key)'
|
2
|
-
# Other arguments are optional; the default values are:
|
3
|
-
# * :include_imgs => false # should images be downloaded as well?
|
4
|
-
# * :blog => 'primary' # blog, if you have more than one.
|
5
|
-
# * :base_path => '/' # for image, if they will be served from a different host for eg.
|
6
|
-
|
7
|
-
# For example, to download images as well as your posts, use the above command with
|
8
|
-
# ....process(email, pass, api_key, :include_imgs => true)
|
9
|
-
|
10
1
|
module JekyllImport
|
11
2
|
module Importers
|
12
3
|
class Posterous < Importer
|
@@ -1,13 +1,3 @@
|
|
1
|
-
# Created by Kendall Buchanan (https://github.com/kendagriff) on 2011-12-22.
|
2
|
-
# Use at your own risk. The end.
|
3
|
-
#
|
4
|
-
# Usage:
|
5
|
-
# (URL)
|
6
|
-
# ruby -r 'jekyll/jekyll-import/rss' -e "JekyllImport::RSS.process(:source => 'http://yourdomain.com/your-favorite-feed.xml')"
|
7
|
-
#
|
8
|
-
# (Local file)
|
9
|
-
# ruby -r 'jekyll/jekyll-import/rss' -e "JekyllImport::RSS.process(:source => './somefile/on/your/computer.xml')"
|
10
|
-
|
11
1
|
module JekyllImport
|
12
2
|
module Importers
|
13
3
|
class RSS < Importer
|
@@ -1,10 +1,3 @@
|
|
1
|
-
# Migrator to import entries from an Serendipity (S9Y) blog
|
2
|
-
#
|
3
|
-
# Entries can be exported from http://blog.example.com/rss.php?version=2.0&all=1
|
4
|
-
#
|
5
|
-
# Usage:
|
6
|
-
# ruby -r './s9y_rss.rb' -e 'Jekyll::S9Y.process("http://blog.example.com/rss.php?version=2.0&all=1")'
|
7
|
-
|
8
1
|
module JekyllImport
|
9
2
|
module Importers
|
10
3
|
class S9Y < Importer
|
@@ -1,9 +1,3 @@
|
|
1
|
-
# NOTE: This converter requires Sequel and the MySQL gems.
|
2
|
-
# The MySQL gem can be difficult to install on OS X. Once you have MySQL
|
3
|
-
# installed, running the following commands should work:
|
4
|
-
# $ sudo gem install sequel
|
5
|
-
# $ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
|
6
|
-
|
7
1
|
module JekyllImport
|
8
2
|
module Importers
|
9
3
|
class TextPattern < Importer
|
@@ -1,12 +1,3 @@
|
|
1
|
-
# NOTE: This converter requires Sequel and the MySQL gems.
|
2
|
-
# The MySQL gem can be difficult to install on OS X. Once you have MySQL
|
3
|
-
# installed, running the following commands should work:
|
4
|
-
# $ sudo gem install sequel
|
5
|
-
# $ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
|
6
|
-
#
|
7
|
-
# If you are running MacPorts, it the mysql2 gem can be installed like this:
|
8
|
-
# $ gem install mysql2 -- --with-mysql-lib=/opt/local/lib/mysql56/mysql/ --with-mysql-include=/opt/local/include/mysql56/mysql
|
9
|
-
|
10
1
|
module JekyllImport
|
11
2
|
module Importers
|
12
3
|
class WordPress < Importer
|
@@ -1,6 +1,4 @@
|
|
1
|
-
#
|
2
|
-
# This importer takes a wordpress.xml file, which can be exported from your
|
3
|
-
# wordpress.com blog (/wp-admin/export.php).
|
1
|
+
# encoding: UTF-8
|
4
2
|
|
5
3
|
module JekyllImport
|
6
4
|
module Importers
|
@@ -8,7 +6,6 @@ module JekyllImport
|
|
8
6
|
def self.require_deps
|
9
7
|
JekyllImport.require_with_fallback(%w[
|
10
8
|
rubygems
|
11
|
-
sequel
|
12
9
|
fileutils
|
13
10
|
safe_yaml
|
14
11
|
hpricot
|
@@ -7,6 +7,7 @@ module Jekyll
|
|
7
7
|
class Import < Command
|
8
8
|
|
9
9
|
IMPORTERS = {
|
10
|
+
:blogger => 'Blogger',
|
10
11
|
:behance => 'Behance',
|
11
12
|
:csv => 'CSV',
|
12
13
|
:drupal6 => 'Drupal6',
|
@@ -53,7 +54,11 @@ module Jekyll
|
|
53
54
|
if IMPORTERS.keys.include?(migrator.to_sym)
|
54
55
|
if JekyllImport::Importers.const_defined?(IMPORTERS[migrator.to_sym])
|
55
56
|
klass = JekyllImport::Importers.const_get(IMPORTERS[migrator.to_sym])
|
56
|
-
|
57
|
+
if options.respond_to?(:__hash__)
|
58
|
+
klass.run(options.__hash__)
|
59
|
+
else
|
60
|
+
klass.run(options)
|
61
|
+
end
|
57
62
|
end
|
58
63
|
else
|
59
64
|
abort_on_invalid_migrator(migrator)
|
@@ -61,11 +66,9 @@ module Jekyll
|
|
61
66
|
end
|
62
67
|
|
63
68
|
def abort_on_invalid_migrator(migrator)
|
64
|
-
|
65
|
-
IMPORTERS.keys.each
|
66
|
-
|
67
|
-
end
|
68
|
-
abort msg
|
69
|
+
$stderr.puts "Sorry, '#{migrator}' isn't a valid migrator. Valid choices:"
|
70
|
+
IMPORTERS.keys.each { |k| $stderr.puts "* #{k}" }
|
71
|
+
raise RuntimeError.new("'#{migrator}' is not a valid migrator.")
|
69
72
|
end
|
70
73
|
|
71
74
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-import
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Preston-Werner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -304,6 +304,7 @@ files:
|
|
304
304
|
- lib/jekyll-import/importer.rb
|
305
305
|
- lib/jekyll-import/importers.rb
|
306
306
|
- lib/jekyll-import/importers/behance.rb
|
307
|
+
- lib/jekyll-import/importers/blogger.rb
|
307
308
|
- lib/jekyll-import/importers/csv.rb
|
308
309
|
- lib/jekyll-import/importers/drupal6.rb
|
309
310
|
- lib/jekyll-import/importers/drupal7.rb
|