jekyll-import 0.12.0 → 0.13.0

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.
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
@@ -1,56 +1,55 @@
1
1
  module JekyllImport
2
2
  module Importers
3
3
  class Posterous < Importer
4
-
5
4
  def self.specify_options(c)
6
- c.option 'email', '--email EMAIL', 'Posterous email address'
7
- c.option 'password', '--password PW', 'Posterous password'
8
- c.option 'api_token', '--token TOKEN', 'Posterous API Token'
5
+ c.option "email", "--email EMAIL", "Posterous email address"
6
+ c.option "password", "--password PW", "Posterous password"
7
+ c.option "api_token", "--token TOKEN", "Posterous API Token"
9
8
  end
10
9
 
11
10
  def self.require_deps
12
- JekyllImport.require_with_fallback(%w[
11
+ JekyllImport.require_with_fallback(%w(
13
12
  rubygems
14
13
  jekyll
15
14
  fileutils
16
15
  uri
17
16
  json
18
17
  net/http
19
- ])
18
+ ))
20
19
  end
21
20
 
22
21
  def self.fetch(uri_str, limit = 10)
23
22
  # You should choose better exception.
24
- raise ArgumentError, 'Stuck in a redirect loop. Please double check your email and password' if limit == 0
23
+ raise ArgumentError, "Stuck in a redirect loop. Please double check your email and password" if limit.zero?
25
24
 
26
25
  response = nil
27
- Net::HTTP.start('posterous.com') do |http|
26
+ Net::HTTP.start("posterous.com") do |http|
28
27
  req = Net::HTTP::Get.new(uri_str)
29
28
  req.basic_auth @email, @pass
30
29
  response = http.request(req)
31
30
  end
32
31
 
33
32
  case response
34
- when Net::HTTPSuccess then response
35
- when Net::HTTPRedirection then fetch(response['location'], limit - 1)
36
- else response.error!
33
+ when Net::HTTPSuccess then response
34
+ when Net::HTTPRedirection then fetch(response["location"], limit - 1)
35
+ else response.error!
37
36
  end
38
37
  end
39
38
 
40
39
  def self.fetch_images(directory, imgs)
41
40
  def self.fetch_one(url, limit = 10)
42
- raise ArgumentError, 'HTTP redirect too deep' if limit == 0
41
+ raise ArgumentError, "HTTP redirect too deep" if limit.zero?
43
42
  response = Net::HTTP.get_response(URI.parse(url))
44
43
  case response
45
44
  when Net::HTTPSuccess then response.body
46
- when Net::HTTPRedirection then self.fetch_one(response['location'], limit - 1)
45
+ when Net::HTTPRedirection then self.fetch_one(response["location"], limit - 1)
47
46
  else
48
47
  response.error!
49
48
  end
50
49
  end
51
50
 
52
51
  FileUtils.mkdir_p directory
53
- urls = Array.new
52
+ urls = []
54
53
  imgs.each do |img|
55
54
  fullurl = img["full"]["url"]
56
55
  uri = URI.parse(fullurl)
@@ -66,12 +65,14 @@ module JekyllImport
66
65
  end
67
66
 
68
67
  def self.process(options)
69
- email = options.fetch('email')
70
- pass = options.fetch('password')
71
- api_token = options.fetch('api_token')
72
-
73
- @email, @pass, @api_token = email, pass, api_token
74
- defaults = { :include_imgs => false, :blog => 'primary', :base_path => '/' }
68
+ email = options.fetch("email")
69
+ pass = options.fetch("password")
70
+ api_token = options.fetch("api_token")
71
+
72
+ @email = email
73
+ @pass = pass
74
+ @api_token = api_token
75
+ defaults = { :include_imgs => false, :blog => "primary", :base_path => "/" }
75
76
  opts = defaults.merge(opts)
76
77
  FileUtils.mkdir_p "_posts"
77
78
 
@@ -81,18 +82,18 @@ module JekyllImport
81
82
  while posts.any?
82
83
  posts.each do |post|
83
84
  title = post["title"]
84
- slug = title.gsub(/[^[:alnum:]]+/, '-').downcase
85
+ slug = title.gsub(%r![^[:alnum:]]+!, "-").downcase
85
86
  date = Date.parse(post["display_date"])
86
87
  content = post["body_html"]
87
88
  published = !post["is_private"]
88
- basename = "%02d-%02d-%02d-%s" % [date.year, date.month, date.day, slug]
89
- name = basename + '.html'
89
+ basename = format("%02d-%02d-%02d-%s", date.year, date.month, date.day, slug)
90
+ name = basename + ".html"
90
91
 
91
92
  # Images:
92
93
  if opts[:include_imgs]
93
94
  post_imgs = post["media"]["images"]
94
95
  if post_imgs.any?
95
- img_dir = "imgs/%s" % basename
96
+ img_dir = format("imgs/%s", basename)
96
97
  img_urls = self.fetch_images(img_dir, post_imgs)
97
98
 
98
99
  img_urls.map! do |url|
@@ -101,17 +102,17 @@ module JekyllImport
101
102
  imgcontent = "<ol>\n" + img_urls.join("\n") + "</ol>\n"
102
103
 
103
104
  # filter out "posterous-content", replacing with imgs:
104
- content = content.sub(/\<p\>\[\[posterous-content:[^\]]+\]\]\<\/p\>/, imgcontent)
105
+ content = content.sub(%r!\<p\>\[\[posterous-content:[^\]]+\]\]\<\/p\>!, imgcontent)
105
106
  end
106
107
  end
107
108
 
108
109
  # Get the relevant fields as a hash, delete empty fields and convert
109
110
  # to YAML for the header
110
111
  data = {
111
- 'layout' => 'post',
112
- 'title' => title.to_s,
113
- 'published' => published
114
- }.delete_if { |k,v| v.nil? || v == ''}.to_yaml
112
+ "layout" => "post",
113
+ "title" => title.to_s,
114
+ "published" => published,
115
+ }.delete_if { |_k, v| v.nil? || v == "" }.to_yaml
115
116
 
116
117
  # Write out the data and content to file
117
118
  File.open("_posts/#{name}", "w") do |f|
@@ -2,24 +2,25 @@ module JekyllImport
2
2
  module Importers
3
3
  class RSS < Importer
4
4
  def self.specify_options(c)
5
- c.option 'source', '--source NAME', 'The RSS file or URL to import'
5
+ c.option "source", "--source NAME", "The RSS file or URL to import"
6
+ c.option "tag", "--tag NAME", "Add a tag to posts"
6
7
  end
7
8
 
8
9
  def self.validate(options)
9
- if options['source'].nil?
10
+ if options["source"].nil?
10
11
  abort "Missing mandatory option --source."
11
12
  end
12
13
  end
13
14
 
14
15
  def self.require_deps
15
- JekyllImport.require_with_fallback(%w[
16
+ JekyllImport.require_with_fallback(%w(
16
17
  rss
17
18
  rss/1.0
18
19
  rss/2.0
19
20
  open-uri
20
21
  fileutils
21
22
  safe_yaml
22
- ])
23
+ ))
23
24
  end
24
25
 
25
26
  # Process the import.
@@ -28,7 +29,7 @@ module JekyllImport
28
29
  #
29
30
  # Returns nothing.
30
31
  def self.process(options)
31
- source = options.fetch('source')
32
+ source = options.fetch("source")
32
33
 
33
34
  content = ""
34
35
  open(source) { |s| content = s.read }
@@ -37,17 +38,19 @@ module JekyllImport
37
38
  raise "There doesn't appear to be any RSS items at the source (#{source}) provided." unless rss
38
39
 
39
40
  rss.items.each do |item|
40
- formatted_date = item.date.strftime('%Y-%m-%d')
41
+ formatted_date = item.date.strftime("%Y-%m-%d")
41
42
  post_name = item.title.split(%r{ |!|/|:|&|-|$|,}).map do |i|
42
- i.downcase if i != ''
43
- end.compact.join('-')
43
+ i.downcase if i != ""
44
+ end.compact.join("-")
44
45
  name = "#{formatted_date}-#{post_name}"
45
46
 
46
47
  header = {
47
- 'layout' => 'post',
48
- 'title' => item.title
48
+ "layout" => "post",
49
+ "title" => item.title,
49
50
  }
50
51
 
52
+ header["tag"] = options["tag"] if !options.to_s.empty?
53
+
51
54
  FileUtils.mkdir_p("_posts")
52
55
 
53
56
  File.open("_posts/#{name}.html", "w") do |f|
@@ -2,50 +2,49 @@ module JekyllImport
2
2
  module Importers
3
3
  class S9Y < Importer
4
4
  def self.specify_options(c)
5
- c.option 'source', '--source SOURCE', 'The URL of the S9Y RSS feed'
5
+ c.option "source", "--source SOURCE", "The URL of the S9Y RSS feed"
6
6
  end
7
7
 
8
8
  def self.validate(options)
9
- if options['source'].nil?
9
+ if options["source"].nil?
10
10
  abort "Missing mandatory option --source, e.g. --source \"http://blog.example.com/rss.php?version=2.0&all=1\""
11
11
  end
12
12
  end
13
13
 
14
14
  def self.require_deps
15
- JekyllImport.require_with_fallback(%w[
15
+ JekyllImport.require_with_fallback(%w(
16
16
  open-uri
17
17
  rss
18
18
  fileutils
19
19
  safe_yaml
20
- ])
20
+ ))
21
21
  end
22
22
 
23
23
  def self.process(options)
24
- source = options.fetch('source')
24
+ source = options.fetch("source")
25
25
 
26
26
  FileUtils.mkdir_p("_posts")
27
27
 
28
- text = ''
28
+ text = ""
29
29
  open(source) { |line| text = line.read }
30
30
  rss = ::RSS::Parser.parse(text)
31
31
 
32
32
  rss.items.each do |item|
33
- post_url = item.link.match('.*(/archives/.*)')[1]
34
- categories = item.categories.collect { |c| c.content }
33
+ post_url = item.link.match(".*(/archives/.*)")[1]
34
+ categories = item.categories.collect(&:content)
35
35
  content = item.content_encoded.strip
36
36
  date = item.date
37
37
  slug = item.link.match('.*/archives/[0-9]+-(.*)\.html')[1]
38
- name = "%02d-%02d-%02d-%s.markdown" % [date.year, date.month, date.day,
39
- slug]
38
+ name = format("%02d-%02d-%02d-%s.markdown", date.year, date.month, date.day, slug)
40
39
 
41
40
  data = {
42
- 'layout' => 'post',
43
- 'title' => item.title,
44
- 'categories' => categories,
45
- 'permalink' => post_url,
46
- 's9y_link' => item.link,
47
- 'date' => item.date,
48
- }.delete_if { |k,v| v.nil? || v == '' }.to_yaml
41
+ "layout" => "post",
42
+ "title" => item.title,
43
+ "categories" => categories,
44
+ "permalink" => post_url,
45
+ "s9y_link" => item.link,
46
+ "date" => item.date,
47
+ }.delete_if { |_k, v| v.nil? || v == "" }.to_yaml
49
48
 
50
49
  # Write out the data and content to file
51
50
  File.open("_posts/#{name}", "w") do |f|
@@ -1,32 +1,33 @@
1
1
  module JekyllImport
2
2
  module Importers
3
3
  class S9YDatabase < Importer
4
-
5
4
  def self.require_deps
6
5
  JekyllImport.require_with_fallback(
7
- %w[
8
- rubygems
6
+ %w(
7
+ rubygems
9
8
  sequel
10
9
  fileutils
11
10
  safe_yaml
12
11
  unidecode
13
- ])
12
+ )
13
+ )
14
14
  end
15
15
 
16
16
  def self.specify_options(c)
17
- c.option 'dbname', '--dbname DB', 'Database name (default: "")'
18
- c.option 'socket', '--socket SOCKET', 'Database socket (default: "")'
19
- c.option 'user', '--user USER', 'Database user name (default: "")'
20
- c.option 'password', '--password PW', "Database user's password (default: "")"
21
- c.option 'host', '--host HOST', 'Database host name (default: "localhost")'
22
- c.option 'table_prefix', '--table_prefix PREFIX', 'Table prefix name (default: "serendipity_")'
23
- c.option 'clean_entities', '--clean_entities', 'Whether to clean entities (default: true)'
24
- c.option 'comments', '--comments', 'Whether to import comments (default: true)'
25
- c.option 'categories', '--categories', 'Whether to import categories (default: true)'
26
- c.option 'tags', '--tags', 'Whether to import tags (default: true)'
27
- c.option 'drafts', '--drafts', 'Whether to export drafts as well'
28
- c.option 'markdown', '--markdown', 'convert into markdown format (default: false)'
29
- c.option 'permalinks', '--permalinks', 'preserve S9Y permalinks (default: false)'
17
+ c.option "dbname", "--dbname DB", "Database name (default: '')"
18
+ c.option "socket", "--socket SOCKET", "Database socket (default: '')"
19
+ c.option "user", "--user USER", "Database user name (default: '')"
20
+ c.option "password", "--password PW", "Database user's password (default: '')"
21
+ c.option "host", "--host HOST", "Database host name (default: 'localhost')"
22
+ c.option "port", "--port PORT", "Custom database port connect to (default: 3306)"
23
+ c.option "table_prefix", "--table_prefix PREFIX", "Table prefix name (default: 'serendipity_')"
24
+ c.option "clean_entities", "--clean_entities", "Whether to clean entities (default: true)"
25
+ c.option "comments", "--comments", "Whether to import comments (default: true)"
26
+ c.option "categories", "--categories", "Whether to import categories (default: true)"
27
+ c.option "tags", "--tags", "Whether to import tags (default: true)"
28
+ c.option "drafts", "--drafts", "Whether to export drafts as well"
29
+ c.option "markdown", "--markdown", "convert into markdown format (default: false)"
30
+ c.option "permalinks", "--permalinks", "preserve S9Y permalinks (default: false)"
30
31
  end
31
32
 
32
33
  # Main migrator function. Call this to perform the migration.
@@ -35,6 +36,7 @@ module JekyllImport
35
36
  # user:: The database user name
36
37
  # pass:: The database user's password
37
38
  # host:: The address of the MySQL database host. Default: 'localhost'
39
+ # port:: The port of the MySQL database server. Default: 3306
38
40
  # socket:: The database socket's path
39
41
  # options:: A hash table of configuration options.
40
42
  #
@@ -54,7 +56,7 @@ module JekyllImport
54
56
  # :tags:: If true, save the post's tags in its
55
57
  # YAML front matter. Default: true.
56
58
  # :extension:: Set the post extension. Default: "html"
57
- # :drafts:: If true, export drafts as well
59
+ # :drafts:: If true, export drafts as well
58
60
  # Default: true.
59
61
  # :markdown:: If true, convert the content to markdown
60
62
  # Default: false
@@ -63,35 +65,42 @@ module JekyllImport
63
65
  #
64
66
  def self.process(opts)
65
67
  options = {
66
- :user => opts.fetch('user', ''),
67
- :pass => opts.fetch('password', ''),
68
- :host => opts.fetch('host', 'localhost'),
69
- :socket => opts.fetch('socket', nil),
70
- :dbname => opts.fetch('dbname', ''),
71
- :table_prefix => opts.fetch('table_prefix', 'serendipity_'),
72
- :clean_entities => opts.fetch('clean_entities', true),
73
- :comments => opts.fetch('comments', true),
74
- :categories => opts.fetch('categories', true),
75
- :tags => opts.fetch('tags', true),
76
- :extension => opts.fetch('extension', 'html'),
77
- :drafts => opts.fetch('drafts', true),
78
- :markdown => opts.fetch('markdown', false),
79
- :permalinks => opts.fetch('permalinks', false),
68
+ :user => opts.fetch("user", ""),
69
+ :pass => opts.fetch("password", ""),
70
+ :host => opts.fetch("host", "localhost"),
71
+ :port => opts.fetch("port", 3306),
72
+ :socket => opts.fetch("socket", nil),
73
+ :dbname => opts.fetch("dbname", ""),
74
+ :table_prefix => opts.fetch("table_prefix", "serendipity_"),
75
+ :clean_entities => opts.fetch("clean_entities", true),
76
+ :comments => opts.fetch("comments", true),
77
+ :categories => opts.fetch("categories", true),
78
+ :tags => opts.fetch("tags", true),
79
+ :extension => opts.fetch("extension", "html"),
80
+ :drafts => opts.fetch("drafts", true),
81
+ :markdown => opts.fetch("markdown", false),
82
+ :permalinks => opts.fetch("permalinks", false),
80
83
  }
81
84
 
82
85
  if options[:clean_entities]
83
- options[:clean_entities] = require_if_available('htmlentities', 'clean_entities')
86
+ options[:clean_entities] = require_if_available("htmlentities", "clean_entities")
84
87
  end
85
88
 
86
89
  if options[:markdown]
87
- options[:markdown] = require_if_available('reverse_markdown', 'markdown')
90
+ options[:markdown] = require_if_available("reverse_markdown", "markdown")
88
91
  end
89
92
 
90
93
  FileUtils.mkdir_p("_posts")
91
94
  FileUtils.mkdir_p("_drafts") if options[:drafts]
92
95
 
93
- db = Sequel.mysql2(options[:dbname], :user => options[:user], :password => options[:pass],
94
- :socket => options[:socket], :host => options[:host], :encoding => 'utf8')
96
+ db = Sequel.mysql2(options[:dbname],
97
+ :user => options[:user],
98
+ :password => options[:pass],
99
+ :socket => options[:socket],
100
+ :host => options[:host],
101
+ :port => options[:port],
102
+ :encoding => "utf8"
103
+ )
95
104
 
96
105
  px = options[:table_prefix]
97
106
 
@@ -108,7 +117,7 @@ module JekyllImport
108
117
  page[:slug] = sluggify(page[:title])
109
118
 
110
119
  page_name_list[ page[:id] ] = {
111
- :slug => page[:slug]
120
+ :slug => page[:slug],
112
121
  }
113
122
  end
114
123
 
@@ -119,6 +128,7 @@ module JekyllImport
119
128
  entries.title AS `title`,
120
129
  entries.timestamp AS `timestamp`,
121
130
  entries.body AS `body`,
131
+ entries.extended AS `body_extended`,
122
132
  authors.realname AS `author`,
123
133
  authors.username AS `author_login`,
124
134
  authors.email AS `author_email`
@@ -148,11 +158,14 @@ module JekyllImport
148
158
  slug = sluggify(title)
149
159
  end
150
160
 
151
- status = post[:isdraft] == 'true' ? 'draft' : 'published'
161
+ status = post[:isdraft] == "true" ? "draft" : "published"
152
162
  date = Time.at(post[:timestamp]).utc || Time.now.utc
153
- name = "%02d-%02d-%02d-%s.%s" % [date.year, date.month, date.day, slug, extension]
163
+ name = format("%02d-%02d-%02d-%s.%s", date.year, date.month, date.day, slug, extension)
154
164
 
155
165
  content = post[:body].to_s
166
+ unless post[:body_extended].to_s.empty?
167
+ content += "\n\n" + post[:body_extended].to_s
168
+ end
156
169
 
157
170
  if options[:clean_entities]
158
171
  content = clean_entities(content)
@@ -170,28 +183,28 @@ module JekyllImport
170
183
  # Get the relevant fields as a hash, delete empty fields and
171
184
  # convert to YAML for the header.
172
185
  data = {
173
- 'layout' => post[:type].to_s,
174
- 'status' => status.to_s,
175
- 'published' => status.to_s == 'draft' ? nil : (status.to_s == 'published'),
176
- 'title' => title.to_s,
177
- 'author' => {
178
- 'display_name'=> post[:author].to_s,
179
- 'login' => post[:author_login].to_s,
180
- 'email' => post[:author_email].to_s
186
+ "layout" => post[:type].to_s,
187
+ "status" => status.to_s,
188
+ "published" => status.to_s == "draft" ? nil : (status.to_s == "published"),
189
+ "title" => title.to_s,
190
+ "author" => {
191
+ "display_name" => post[:author].to_s,
192
+ "login" => post[:author_login].to_s,
193
+ "email" => post[:author_email].to_s,
181
194
  },
182
- 'author_login' => post[:author_login].to_s,
183
- 'author_email' => post[:author_email].to_s,
184
- 'date' => date.to_s,
185
- 'permalink' => options[:permalinks] ? permalink : nil,
186
- 'categories' => options[:categories] ? categories : nil,
187
- 'tags' => options[:tags] ? tags : nil,
188
- 'comments' => options[:comments] ? comments : nil,
189
- }.delete_if { |k,v| v.nil? || v == '' }.to_yaml
190
-
191
- if post[:type] == 'page'
195
+ "author_login" => post[:author_login].to_s,
196
+ "author_email" => post[:author_email].to_s,
197
+ "date" => date.to_s,
198
+ "permalink" => options[:permalinks] ? permalink : nil,
199
+ "categories" => options[:categories] ? categories : nil,
200
+ "tags" => options[:tags] ? tags : nil,
201
+ "comments" => options[:comments] ? comments : nil,
202
+ }.delete_if { |_k, v| v.nil? || v == "" }.to_yaml
203
+
204
+ if post[:type] == "page"
192
205
  filename = page_path(post[:id], page_name_list) + "index.#{extension}"
193
206
  FileUtils.mkdir_p(File.dirname(filename))
194
- elsif status == 'draft'
207
+ elsif status == "draft"
195
208
  filename = "_drafts/#{slug}.#{extension}"
196
209
  else
197
210
  filename = "_posts/#{name}"
@@ -206,13 +219,11 @@ module JekyllImport
206
219
  end
207
220
 
208
221
  def self.require_if_available(gem_name, option_name)
209
- begin
210
- require gem_name
211
- return true
212
- rescue LoadError
213
- STDERR.puts "Could not require '#{gem_name}', so the :#{option_name} option is now disabled."
214
- return true
215
- end
222
+ require gem_name
223
+ return true
224
+ rescue LoadError
225
+ STDERR.puts "Could not require '#{gem_name}', so the :#{option_name} option is now disabled."
226
+ return true
216
227
  end
217
228
 
218
229
  def self.process_categories(db, options, post)
@@ -232,11 +243,11 @@ module JekyllImport
232
243
  )
233
244
 
234
245
  db[cquery].each_with_object([]) do |category, categories|
235
- if options[:clean_entities]
236
- categories << clean_entities(category[:name])
237
- else
238
- categories << category[:name]
239
- end
246
+ categories << if options[:clean_entities]
247
+ clean_entities(category[:name])
248
+ else
249
+ category[:name]
250
+ end
240
251
  end
241
252
  end
242
253
 
@@ -273,14 +284,14 @@ module JekyllImport
273
284
  end
274
285
 
275
286
  comments << {
276
- 'id' => comment[:id].to_i,
277
- 'author' => comauthor,
278
- 'author_email' => comment[:author_email].to_s,
279
- 'author_url' => comment[:author_url].to_s,
280
- 'date' => comment[:date].to_s,
281
- 'content' => comcontent,
287
+ "id" => comment[:id].to_i,
288
+ "author" => comauthor,
289
+ "author_email" => comment[:author_email].to_s,
290
+ "author_url" => comment[:author_url].to_s,
291
+ "date" => comment[:date].to_s,
292
+ "content" => comcontent,
282
293
  }
283
- end.sort!{ |a,b| a['id'] <=> b['id'] }
294
+ end.sort! { |a, b| a["id"] <=> b["id"] }
284
295
  end
285
296
 
286
297
  def self.process_tags(db, options, post)
@@ -298,11 +309,11 @@ module JekyllImport
298
309
  )
299
310
 
300
311
  db[cquery].each_with_object([]) do |tag, tags|
301
- if options[:clean_entities]
302
- tags << clean_entities(tag[:name])
303
- else
304
- tags << tag[:name]
305
- end
312
+ tags << if options[:clean_entities]
313
+ clean_entities(tag[:name])
314
+ else
315
+ tag[:name]
316
+ end
306
317
  end
307
318
  end
308
319
 
@@ -326,7 +337,7 @@ module JekyllImport
326
337
  end
327
338
  end
328
339
 
329
- def self.clean_entities( text )
340
+ def self.clean_entities(text)
330
341
  if text.respond_to?(:force_encoding)
331
342
  text.force_encoding("UTF-8")
332
343
  end
@@ -342,22 +353,20 @@ module JekyllImport
342
353
  text
343
354
  end
344
355
 
345
- def self.sluggify( title )
346
- title.to_ascii.downcase.gsub(/[^0-9A-Za-z]+/, " ").strip.gsub(" ", "-")
356
+ def self.sluggify(title)
357
+ title.to_ascii.downcase.gsub(%r![^0-9A-Za-z]+!, " ").strip.tr(" ", "-")
347
358
  end
348
359
 
349
- def self.page_path( page_id, page_name_list )
360
+ def self.page_path(page_id, page_name_list)
350
361
  if page_name_list.key?(page_id)
351
362
  [
352
363
  page_name_list[page_id][:slug],
353
- '/'
364
+ "/",
354
365
  ].join("")
355
366
  else
356
367
  ""
357
368
  end
358
369
  end
359
-
360
370
  end
361
371
  end
362
372
  end
363
-