Permalink
Browse files

Truncate post slugs when importing from Tumblr.

Fixes #481.
  • Loading branch information...
1 parent 4499df8 commit 5fb801474e6949751d0a7ac8bb8dea2ebeddd7fe dunsmoreb committed Feb 1, 2012
Showing with 6 additions and 0 deletions.
  1. +6 −0 lib/jekyll/migrators/tumblr.rb
@@ -34,6 +34,7 @@ def self.process(url, format = "html", grab_images = false,
post[:content] = html_to_markdown post[:content]
post[:content] = add_syntax_highlights post[:content] if add_highlights
end
+ post[:name] = truncate_post_name post[:name] if post[:name].size > 255
File.open("_posts/tumblr/#{post[:name]}", "w") do |f|
f.puts post[:header].to_yaml + "---\n" + post[:content]
end
@@ -42,6 +43,11 @@ def self.process(url, format = "html", grab_images = false,
private
+ def self.truncate_post_name name
+ post = name.match(/^(.+)\.(.+)$/).captures
+ post[0][0..(-1 - post[1].size)] + post[1].size
+ end
+
# Converts each type of Tumblr post to a hash with all required
# data for Jekyll.
def self.post_to_hash(post, format)

0 comments on commit 5fb8014

Please sign in to comment.