jekyll-import 0.12.0 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/lib/jekyll-import.rb +10 -8
  3. data/lib/jekyll-import/importer.rb +1 -1
  4. data/lib/jekyll-import/importers.rb +1 -1
  5. data/lib/jekyll-import/importers/behance.rb +20 -20
  6. data/lib/jekyll-import/importers/blogger.rb +108 -118
  7. data/lib/jekyll-import/importers/csv.rb +7 -7
  8. data/lib/jekyll-import/importers/drupal6.rb +5 -6
  9. data/lib/jekyll-import/importers/drupal7.rb +7 -13
  10. data/lib/jekyll-import/importers/drupal_common.rb +57 -59
  11. data/lib/jekyll-import/importers/easyblog.rb +30 -30
  12. data/lib/jekyll-import/importers/enki.rb +28 -29
  13. data/lib/jekyll-import/importers/ghost.rb +46 -33
  14. data/lib/jekyll-import/importers/google_reader.rb +9 -9
  15. data/lib/jekyll-import/importers/joomla.rb +32 -32
  16. data/lib/jekyll-import/importers/joomla3.rb +41 -39
  17. data/lib/jekyll-import/importers/jrnl.rb +16 -17
  18. data/lib/jekyll-import/importers/marley.rb +25 -26
  19. data/lib/jekyll-import/importers/mephisto.rb +26 -26
  20. data/lib/jekyll-import/importers/mt.rb +76 -75
  21. data/lib/jekyll-import/importers/posterous.rb +30 -29
  22. data/lib/jekyll-import/importers/rss.rb +13 -10
  23. data/lib/jekyll-import/importers/s9y.rb +16 -17
  24. data/lib/jekyll-import/importers/s9y_database.rb +98 -89
  25. data/lib/jekyll-import/importers/textpattern.rb +18 -17
  26. data/lib/jekyll-import/importers/tmp.rb +0 -0
  27. data/lib/jekyll-import/importers/tumblr.rb +146 -143
  28. data/lib/jekyll-import/importers/typo.rb +31 -31
  29. data/lib/jekyll-import/importers/wordpress.rb +100 -100
  30. data/lib/jekyll-import/importers/wordpressdotcom.rb +70 -60
  31. data/lib/jekyll-import/util.rb +24 -24
  32. data/lib/jekyll-import/version.rb +1 -1
  33. data/lib/jekyll/commands/import.rb +32 -35
  34. metadata +14 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 27f5a0ab9d87425b92a6e1a4fbc01c5c87c64626
4
- data.tar.gz: 4c3382d2e508f6fd6571fa45f1a01f1c804cf69d
3
+ metadata.gz: 4e855d9fab183b0627590b601d2773b2c03deab6
4
+ data.tar.gz: f167d6f4b2a76aa9ccb9d03bf8c263c4f3c0d8e4
5
5
  SHA512:
6
- metadata.gz: 5ec278c744142928a3db648710bae5313ad6a7c78dfc948a382c50ed30122e4d0c03324a31ddfc41dd9ad99512ea6879fc7ed9a093779c473ea36703a0743aef
7
- data.tar.gz: b63caa7a81fc42055d663b94b0f9e9e798bdb2459e9782268bbd938288f8b15b633afba6b1719a58c0f349e21e27bec46ea9413a03cb3e8c00af5cdc4048a44f
6
+ metadata.gz: 0de306ccd211d7c972362ba8624ff747f3a73e6c4cac5019cdf0c6c8d3253c1ca0fdcdc077ce2bd7372bac297da0ca8f1f16a927b34c2dd6788893f7cb0fff85
7
+ data.tar.gz: 02fed28e00f8920850e0006d814ad6087a3664332679fd929f38b994bc6bd7941a4319710fcfc478cc98f434161a036d0b2b764259aeb5df88166486a9476ad1
@@ -1,12 +1,14 @@
1
- $:.unshift File.dirname(__FILE__) # For use/testing when no gem is installed
2
- require 'rubygems'
3
- require 'jekyll'
4
- require 'jekyll/commands/import'
5
- require 'colorator'
1
+ # For use/testing when no gem is installed
2
+ $LOAD_PATH.unshift __dir__
6
3
 
7
- require 'jekyll-import/importer'
8
- require 'jekyll-import/importers'
9
- require 'jekyll-import/util'
4
+ require "rubygems"
5
+ require "jekyll"
6
+ require "jekyll/commands/import"
7
+ require "colorator"
8
+
9
+ require "jekyll-import/importer"
10
+ require "jekyll-import/importers"
11
+ require "jekyll-import/util"
10
12
 
11
13
  module JekyllImport
12
14
  # Public: Add the subcommands for each importer
@@ -11,7 +11,7 @@ module JekyllImport
11
11
  def self.stringify_keys(hash)
12
12
  the_hash = hash.clone
13
13
  the_hash.keys.each do |key|
14
- the_hash[(key.to_s rescue key) || key] = the_hash.delete(key)
14
+ the_hash[(key.to_s rescue key) || key] = the_hash.delete(key)
15
15
  end
16
16
  the_hash
17
17
  end
@@ -1,6 +1,6 @@
1
1
  module JekyllImport
2
2
  module Importers
3
- Dir.chdir(File.expand_path(File.join("importers"), File.dirname(__FILE__))) do
3
+ Dir.chdir(File.expand_path(File.join("importers"), __dir__)) do
4
4
  Dir.entries(".").each do |f|
5
5
  next if f[0..0].eql?(".")
6
6
  require "jekyll-import/importers/#{f}"
@@ -2,22 +2,22 @@ module JekyllImport
2
2
  module Importers
3
3
  class Behance < Importer
4
4
  def self.require_deps
5
- JekyllImport.require_with_fallback(%w[
5
+ JekyllImport.require_with_fallback(%w(
6
6
  fileutils
7
7
  safe_yaml
8
8
  date
9
9
  time
10
10
  behance
11
- ])
11
+ ))
12
12
  end
13
13
 
14
14
  def self.specify_options(c)
15
- c.option 'user', '--user NAME', 'The username of the account'
16
- c.option 'api_token', '--api_token TOKEN', 'The API access token for the account'
15
+ c.option "user", "--user NAME", "The username of the account"
16
+ c.option "api_token", "--api_token TOKEN", "The API access token for the account"
17
17
  end
18
18
 
19
19
  def self.validate(options)
20
- %w[user api_token].each do |option|
20
+ %w(user api_token).each do |option|
21
21
  if options[option].nil?
22
22
  abort "Missing mandatory option --#{option}."
23
23
  end
@@ -31,8 +31,8 @@ module JekyllImport
31
31
  #
32
32
  # Returns nothing.
33
33
  def self.process(options)
34
- user = options.fetch('user')
35
- token = options.fetch('api_token')
34
+ user = options.fetch("user")
35
+ token = options.fetch("api_token")
36
36
 
37
37
  client = fetch_behance(token)
38
38
 
@@ -41,21 +41,20 @@ module JekyllImport
41
41
  puts "#{user_projects.length} project(s) found. Importing now..."
42
42
 
43
43
  user_projects.each do |project|
44
-
45
- details = client.project(project['id'])
46
- title = project['name'].to_s
47
- formatted_date = Time.at(project['published_on'].to_i).to_date.to_s
44
+ details = client.project(project["id"])
45
+ title = project["name"].to_s
46
+ formatted_date = Time.at(project["published_on"].to_i).to_date.to_s
48
47
 
49
48
  post_name = title.split(%r{ |!|/|:|&|-|$|,}).map do |character|
50
49
  character.downcase unless character.empty?
51
- end.compact.join('-')
50
+ end.compact.join("-")
52
51
 
53
52
  name = "#{formatted_date}-#{post_name}"
54
53
 
55
54
  header = {
56
- "layout" => "post",
57
- "title" => title,
58
- "details" => details
55
+ "layout" => "post",
56
+ "title" => title,
57
+ "details" => details,
59
58
  }
60
59
 
61
60
  FileUtils.mkdir_p("_posts")
@@ -63,17 +62,18 @@ module JekyllImport
63
62
  File.open("_posts/#{name}.md", "w") do |f|
64
63
  f.puts header.to_yaml
65
64
  f.puts "---\n\n"
66
- f.puts details['description'].to_s
65
+ f.puts details["description"].to_s
67
66
  end
68
67
  end
69
68
 
70
69
  puts "Finished importing."
71
70
  end
72
71
 
73
- private
74
-
75
- def self.fetch_behance(token)
76
- ::Behance::Client.new(access_token: token)
72
+ class << self
73
+ private
74
+ def fetch_behance(token)
75
+ ::Behance::Client.new(:access_token => token)
76
+ end
77
77
  end
78
78
  end
79
79
  end
@@ -2,22 +2,22 @@ module JekyllImport
2
2
  module Importers
3
3
  class Blogger < Importer
4
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
- c.option 'comments', '--comments', 'import comments to _comments collection'
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
+ c.option "comments", "--comments", "import comments to _comments collection"
9
9
  end
10
10
 
11
11
  def self.validate(options)
12
- if options['source'].nil?
13
- raise 'Missing mandatory option: --source'
14
- elsif not File.exist?(options['source'])
15
- raise Errno::ENOENT, "File not found: #{options['source']}"
12
+ if options["source"].nil?
13
+ raise "Missing mandatory option: --source"
14
+ elsif !File.exist?(options["source"])
15
+ raise Errno::ENOENT, "File not found: #{options["source"]}"
16
16
  end
17
17
  end
18
18
 
19
19
  def self.require_deps
20
- JekyllImport.require_with_fallback(%w[
20
+ JekyllImport.require_with_fallback(%w(
21
21
  rexml/document
22
22
  rexml/streamlistener
23
23
  rexml/parsers/streamparser
@@ -26,7 +26,7 @@ module JekyllImport
26
26
  fileutils
27
27
  safe_yaml
28
28
  open-uri
29
- ])
29
+ ))
30
30
  end
31
31
 
32
32
  # Process the import.
@@ -37,19 +37,19 @@ module JekyllImport
37
37
  #
38
38
  # Returns nothing.
39
39
  def self.process(options)
40
- source = options.fetch('source')
40
+ source = options.fetch("source")
41
41
 
42
42
  listener = BloggerAtomStreamListener.new
43
43
 
44
- listener.leave_blogger_info = ! options.fetch('no-blogger-info', false),
45
- listener.comments = options.fetch('comments', false),
44
+ listener.leave_blogger_info = !options.fetch("no-blogger-info", false),
45
+ listener.comments = options.fetch("comments", false),
46
46
 
47
- File.open(source, 'r') do |f|
47
+ File.open(source, "r") do |f|
48
48
  f.flock(File::LOCK_SH)
49
- REXML::Parsers::StreamParser.new(f, listener).parse()
49
+ REXML::Parsers::StreamParser.new(f, listener).parse
50
50
  end
51
51
 
52
- options['original-url-base'] = listener.original_url_base
52
+ options["original-url-base"] = listener.original_url_base
53
53
 
54
54
  postprocess(options)
55
55
  end
@@ -61,27 +61,27 @@ module JekyllImport
61
61
  # Returns nothing.
62
62
  def self.postprocess(options)
63
63
  # Replace internal link URL
64
- if options.fetch('replace-internal-link', false)
65
- original_url_base = options.fetch('original-url-base', nil)
64
+ if options.fetch("replace-internal-link", false)
65
+ original_url_base = options.fetch("original-url-base", nil)
66
66
  if original_url_base
67
67
  orig_url_pattern = Regexp.new(" href=([\"\'])(?:#{Regexp.escape(original_url_base)})?/([0-9]{4})/([0-9]{2})/([^\"\']+\.html)\\1")
68
68
 
69
- Dir.glob('_posts/*.*') do |filename|
69
+ Dir.glob("_posts/*.*") do |filename|
70
70
  body = nil
71
- File.open(filename, 'r') do |f|
71
+ File.open(filename, "r") do |f|
72
72
  f.flock(File::LOCK_SH)
73
73
  body = f.read
74
74
  end
75
75
 
76
76
  body.gsub!(orig_url_pattern) do
77
77
  # for post_url
78
- quote = $1
79
- post_file = Dir.glob("_posts/#{$2}-#{$3}-*-#{$4.to_s.tr('/', '-')}").first
80
- raise "Could not found: _posts/#{$2}-#{$3}-*-#{$4.to_s.tr('/', '-')}" if post_file.nil?
81
- " href=#{quote}{{ site.baseurl }}{% post_url #{File.basename(post_file, '.html')} %}#{quote}"
78
+ quote = Regexp.last_match(1)
79
+ post_file = Dir.glob("_posts/#{Regexp.last_match(2)}-#{Regexp.last_match(3)}-*-#{Regexp.last_match(4).to_s.tr("/", "-")}").first
80
+ raise "Could not found: _posts/#{Regexp.last_match(2)}-#{Regexp.last_match(3)}-*-#{Regexp.last_match(4).to_s.tr("/", "-")}" if post_file.nil?
81
+ " href=#{quote}{{ site.baseurl }}{% post_url #{File.basename(post_file, ".html")} %}#{quote}"
82
82
  end
83
83
 
84
- File.open(filename, 'w') do |f|
84
+ File.open(filename, "w") do |f|
85
85
  f.flock(File::LOCK_EX)
86
86
  f << body
87
87
  end
@@ -110,45 +110,45 @@ module JekyllImport
110
110
  @tag_bread.push(tag)
111
111
 
112
112
  case tag
113
- when 'entry'
114
- raise 'nest entry element' if @in_entry_elem
115
- @in_entry_elem = {:meta => {}, :body => nil}
116
- when 'title'
113
+ when "entry"
114
+ raise "nest entry element" if @in_entry_elem
115
+ @in_entry_elem = { :meta => {}, :body => nil }
116
+ when "title"
117
117
  if @in_entry_elem
118
- raise 'only <title type="text"></title> is supported' if attrs['type'] != 'text'
118
+ raise 'only <title type="text"></title> is supported' if attrs["type"] != "text"
119
119
  end
120
- when 'category'
120
+ when "category"
121
121
  if @in_entry_elem
122
- if attrs['scheme'] == 'http://www.blogger.com/atom/ns#'
122
+ if attrs["scheme"] == "http://www.blogger.com/atom/ns#"
123
123
  @in_entry_elem[:meta][:category] = [] unless @in_entry_elem[:meta][:category]
124
- @in_entry_elem[:meta][:category] << attrs['term']
125
- elsif attrs['scheme'] == 'http://schemas.google.com/g/2005#kind'
126
- kind = attrs['term']
127
- kind.sub!(Regexp.new("^http://schemas\\.google\\.com/blogger/2008/kind\\#"), '')
124
+ @in_entry_elem[:meta][:category] << attrs["term"]
125
+ elsif attrs["scheme"] == "http://schemas.google.com/g/2005#kind"
126
+ kind = attrs["term"]
127
+ kind.sub!(Regexp.new("^http://schemas\\.google\\.com/blogger/2008/kind\\#"), "")
128
128
  @in_entry_elem[:meta][:kind] = kind
129
129
  end
130
130
  end
131
- when 'content'
131
+ when "content"
132
132
  if @in_entry_elem
133
- @in_entry_elem[:meta][:content_type] = attrs['type']
133
+ @in_entry_elem[:meta][:content_type] = attrs["type"]
134
134
  end
135
- when 'link'
135
+ when "link"
136
136
  if @in_entry_elem
137
- if attrs['rel'] == 'alternate' && attrs['type'] == 'text/html'
138
- @in_entry_elem[:meta][:original_url] = attrs['href']
139
- elsif attrs['rel'] == 'replies' && attrs['type'] == 'text/html'
137
+ if attrs["rel"] == "alternate" && attrs["type"] == "text/html"
138
+ @in_entry_elem[:meta][:original_url] = attrs["href"]
139
+ elsif attrs["rel"] == "replies" && attrs["type"] == "text/html"
140
140
  unless @in_entry_elem[:meta][:original_url]
141
- @in_entry_elem[:meta][:original_url] = attrs['href'].sub(/\#comment-form$/, '')
141
+ @in_entry_elem[:meta][:original_url] = attrs["href"].sub(%r!\#comment-form$!, "")
142
142
  end
143
143
  end
144
144
  end
145
- when 'media:thumbnail'
145
+ when "media:thumbnail"
146
146
  if @in_entry_elem
147
- @in_entry_elem[:meta][:thumbnail] = attrs['url']
147
+ @in_entry_elem[:meta][:thumbnail] = attrs["url"]
148
148
  end
149
- when 'thr:in-reply-to'
149
+ when "thr:in-reply-to"
150
150
  if @in_entry_elem
151
- @in_entry_elem[:meta][:post_id] = attrs['ref']
151
+ @in_entry_elem[:meta][:post_id] = attrs["ref"]
152
152
  end
153
153
  end
154
154
  end
@@ -156,23 +156,23 @@ module JekyllImport
156
156
  def text(text)
157
157
  if @in_entry_elem
158
158
  case @tag_bread.last
159
- when 'id'
159
+ when "id"
160
160
  @in_entry_elem[:meta][:id] = text
161
- when 'published'
161
+ when "published"
162
162
  @in_entry_elem[:meta][:published] = text
163
- when 'updated'
163
+ when "updated"
164
164
  @in_entry_elem[:meta][:updated] = text
165
- when 'title'
165
+ when "title"
166
166
  @in_entry_elem[:meta][:title] = text
167
- when 'content'
167
+ when "content"
168
168
  @in_entry_elem[:body] = text
169
- when 'name'
170
- if @tag_bread[-2..-1] == %w[author name]
169
+ when "name"
170
+ if @tag_bread[-2..-1] == %w(author name)
171
171
  @in_entry_elem[:meta][:author] = text
172
172
  end
173
- when 'app:draft'
174
- if @tag_bread[-2..-1] == %w[app:control app:draft]
175
- @in_entry_elem[:meta][:draft] = true if text == 'yes'
173
+ when "app:draft"
174
+ if @tag_bread[-2..-1] == %w(app:control app:draft)
175
+ @in_entry_elem[:meta][:draft] = true if text == "yes"
176
176
  end
177
177
  end
178
178
  end
@@ -180,20 +180,20 @@ module JekyllImport
180
180
 
181
181
  def tag_end(tag)
182
182
  case tag
183
- when 'entry'
184
- raise 'nest entry element' unless @in_entry_elem
183
+ when "entry"
184
+ raise "nest entry element" unless @in_entry_elem
185
185
 
186
- if @in_entry_elem[:meta][:kind] == 'post'
186
+ if @in_entry_elem[:meta][:kind] == "post"
187
187
  post_data = get_post_data_from_in_entry_elem_info
188
188
 
189
189
  if post_data
190
- target_dir = '_posts'
191
- target_dir = '_drafts' if @in_entry_elem[:meta][:draft]
190
+ target_dir = "_posts"
191
+ target_dir = "_drafts" if @in_entry_elem[:meta][:draft]
192
192
 
193
193
  FileUtils.mkdir_p(target_dir)
194
194
 
195
- file_name = URI::decode("#{post_data[:filename]}.html")
196
- File.open(File.join(target_dir, file_name), 'w') do |f|
195
+ file_name = URI.decode("#{post_data[:filename]}.html")
196
+ File.open(File.join(target_dir, file_name), "w") do |f|
197
197
  f.flock(File::LOCK_EX)
198
198
 
199
199
  f << post_data[:header].to_yaml
@@ -201,16 +201,16 @@ module JekyllImport
201
201
  f << post_data[:body]
202
202
  end
203
203
  end
204
- elsif @in_entry_elem[:meta][:kind] == 'comment' and @comments
204
+ elsif @in_entry_elem[:meta][:kind] == "comment" && @comments
205
205
  post_data = get_post_data_from_in_entry_elem_info
206
206
 
207
207
  if post_data
208
- target_dir = '_comments'
208
+ target_dir = "_comments"
209
209
 
210
210
  FileUtils.mkdir_p(target_dir)
211
211
 
212
- file_name = URI::decode("#{post_data[:filename]}.html")
213
- File.open(File.join(target_dir, file_name), 'w') do |f|
212
+ file_name = URI.decode("#{post_data[:filename]}.html")
213
+ File.open(File.join(target_dir, file_name), "w") do |f|
214
214
  f.flock(File::LOCK_EX)
215
215
 
216
216
  f << post_data[:header].to_yaml
@@ -227,104 +227,94 @@ module JekyllImport
227
227
  end
228
228
 
229
229
  def get_post_data_from_in_entry_elem_info
230
- if (@in_entry_elem.nil? || ! @in_entry_elem.has_key?(:meta) || ! @in_entry_elem[:meta].has_key?(:kind))
230
+ if @in_entry_elem.nil? || !@in_entry_elem.key?(:meta) || !@in_entry_elem[:meta].key?(:kind)
231
231
  nil
232
- elsif @in_entry_elem[:meta][:kind] == 'post'
233
- timestamp = Time.parse(@in_entry_elem[:meta][:published]).strftime('%Y-%m-%d')
232
+ elsif @in_entry_elem[:meta][:kind] == "post"
233
+ timestamp = Time.parse(@in_entry_elem[:meta][:published]).strftime("%Y-%m-%d")
234
234
  if @in_entry_elem[:meta][:original_url]
235
235
  original_uri = URI.parse(@in_entry_elem[:meta][:original_url])
236
236
  original_path = original_uri.path.to_s
237
- filename = "%s-%s" %
238
- [timestamp,
239
- File.basename(original_path, File.extname(original_path))]
237
+ filename = format("%s-%s", timestamp, File.basename(original_path, File.extname(original_path)))
240
238
 
241
239
  @original_url_base = "#{original_uri.scheme}://#{original_uri.host}"
242
240
  elsif @in_entry_elem[:meta][:draft]
243
241
  # Drafts don't have published urls
244
242
  name = @in_entry_elem[:meta][:title]
245
- if name.nil?
246
- filename = timestamp
247
- else
248
- filename = "%s-%s" %
249
- [timestamp,
250
- CGI.escape(name.downcase).tr('+','-')]
251
- end
243
+ filename = if name.nil?
244
+ timestamp
245
+ else
246
+ format("%s-%s", timestamp, CGI.escape(name.downcase.tr("+/\\:'\"<>{}?%*|.", "-")))
247
+ end
252
248
  else
253
- raise 'Original URL is missing'
249
+ raise "Original URL is missing"
254
250
  end
255
251
 
256
252
  header = {
257
- 'layout' => 'post',
258
- 'title' => @in_entry_elem[:meta][:title],
259
- 'date' => @in_entry_elem[:meta][:published],
260
- 'author' => @in_entry_elem[:meta][:author],
261
- 'tags' => @in_entry_elem[:meta][:category],
253
+ "layout" => "post",
254
+ "title" => @in_entry_elem[:meta][:title],
255
+ "date" => @in_entry_elem[:meta][:published],
256
+ "author" => @in_entry_elem[:meta][:author],
257
+ "tags" => @in_entry_elem[:meta][:category],
262
258
  }
263
- header['modified_time'] = @in_entry_elem[:meta][:updated] if @in_entry_elem[:meta][:updated] && @in_entry_elem[:meta][:updated] != @in_entry_elem[:meta][:published]
264
- header['thumbnail'] = @in_entry_elem[:meta][:thumbnail] if @in_entry_elem[:meta][:thumbnail]
265
- header['blogger_id'] = @in_entry_elem[:meta][:id] if @leave_blogger_info
266
- header['blogger_orig_url'] = @in_entry_elem[:meta][:original_url] if @leave_blogger_info && @in_entry_elem[:meta][:original_url]
259
+ header["modified_time"] = @in_entry_elem[:meta][:updated] if @in_entry_elem[:meta][:updated] && @in_entry_elem[:meta][:updated] != @in_entry_elem[:meta][:published]
260
+ header["thumbnail"] = @in_entry_elem[:meta][:thumbnail] if @in_entry_elem[:meta][:thumbnail]
261
+ header["blogger_id"] = @in_entry_elem[:meta][:id] if @leave_blogger_info
262
+ header["blogger_orig_url"] = @in_entry_elem[:meta][:original_url] if @leave_blogger_info && @in_entry_elem[:meta][:original_url]
267
263
 
268
264
  body = @in_entry_elem[:body]
269
265
 
270
266
  # body escaping associated with liquid
271
- if body =~ /{{/
272
- body.gsub!(/{{/, '{{ "{{" }}')
267
+ if body =~ %r!{{!
268
+ body.gsub!(%r!{{!, '{{ "{{" }}')
273
269
  end
274
- if body =~ /{%/
275
- body.gsub!(/{%/, '{{ "{%" }}')
270
+ if body =~ %r!{%!
271
+ body.gsub!(%r!{%!, '{{ "{%" }}')
276
272
  end
277
273
 
278
274
  { :filename => filename, :header => header, :body => body }
279
- elsif @in_entry_elem[:meta][:kind] == 'comment'
280
- timestamp = Time.parse(@in_entry_elem[:meta][:published]).strftime('%Y-%m-%d')
275
+ elsif @in_entry_elem[:meta][:kind] == "comment"
276
+ timestamp = Time.parse(@in_entry_elem[:meta][:published]).strftime("%Y-%m-%d")
281
277
  if @in_entry_elem[:meta][:original_url]
282
- if not @comment_seq
278
+ unless @comment_seq
283
279
  @comment_seq = 1
284
280
  end
285
281
 
286
282
  original_uri = URI.parse(@in_entry_elem[:meta][:original_url])
287
283
  original_path = original_uri.path.to_s
288
- filename = "%s-%s-%s" %
289
- [timestamp,
290
- File.basename(original_path, File.extname(original_path)),
291
- @comment_seq]
284
+ filename = format("%s-%s-%s", timestamp, File.basename(original_path, File.extname(original_path)), @comment_seq)
292
285
 
293
- @comment_seq = @comment_seq + 1
286
+ @comment_seq += 1
294
287
 
295
288
  @original_url_base = "#{original_uri.scheme}://#{original_uri.host}"
296
289
  else
297
- raise 'Original URL is missing'
290
+ raise "Original URL is missing"
298
291
  end
299
292
 
300
293
  header = {
301
- 'date' => @in_entry_elem[:meta][:published],
302
- 'author' => @in_entry_elem[:meta][:author],
303
- 'blogger_post_id' => @in_entry_elem[:meta][:post_id],
294
+ "date" => @in_entry_elem[:meta][:published],
295
+ "author" => @in_entry_elem[:meta][:author],
296
+ "blogger_post_id" => @in_entry_elem[:meta][:post_id],
304
297
  }
305
- header['modified_time'] = @in_entry_elem[:meta][:updated] if @in_entry_elem[:meta][:updated] && @in_entry_elem[:meta][:updated] != @in_entry_elem[:meta][:published]
306
- header['thumbnail'] = @in_entry_elem[:meta][:thumbnail] if @in_entry_elem[:meta][:thumbnail]
307
- header['blogger_id'] = @in_entry_elem[:meta][:id] if @leave_blogger_info
308
- header['blogger_orig_url'] = @in_entry_elem[:meta][:original_url] if @leave_blogger_info && @in_entry_elem[:meta][:original_url]
298
+ header["modified_time"] = @in_entry_elem[:meta][:updated] if @in_entry_elem[:meta][:updated] && @in_entry_elem[:meta][:updated] != @in_entry_elem[:meta][:published]
299
+ header["thumbnail"] = @in_entry_elem[:meta][:thumbnail] if @in_entry_elem[:meta][:thumbnail]
300
+ header["blogger_id"] = @in_entry_elem[:meta][:id] if @leave_blogger_info
301
+ header["blogger_orig_url"] = @in_entry_elem[:meta][:original_url] if @leave_blogger_info && @in_entry_elem[:meta][:original_url]
309
302
 
310
303
  body = @in_entry_elem[:body]
311
304
 
312
305
  # body escaping associated with liquid
313
- if body =~ /{{/
314
- body.gsub!(/{{/, '{{ "{{" }}')
306
+ if body =~ %r!{{!
307
+ body.gsub!(%r!{{!, '{{ "{{" }}')
315
308
  end
316
- if body =~ /{%/
317
- body.gsub!(/{%/, '{{ "{%" }}')
309
+ if body =~ %r!{%!
310
+ body.gsub!(%r!{%!, '{{ "{%" }}')
318
311
  end
319
312
 
320
313
  { :filename => filename, :header => header, :body => body }
321
- else
322
- nil
323
314
  end
324
315
  end
325
316
 
326
317
  end
327
-
328
318
  end
329
319
  end
330
320
  end