lib/jekyll-import/importers/tumblr.rb in jekyll-import-0.8.0 vs lib/jekyll-import/importers/tumblr.rb in jekyll-import-0.9.0
- old
+ new
@@ -150,13 +150,15 @@
date = Date.parse(post['date']).to_s
title = Nokogiri::HTML(title).text
title = "no title" if title.empty?
slug = if post["slug"] && post["slug"].strip != ""
post["slug"]
- else
- slug = title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
+ elsif title && title.downcase.gsub(/[^a-z0-9\-]/, '') != '' && title != 'no title'
+ slug = title.downcase.strip.gsub(' ', '-').gsub(/[^a-z0-9\-]/, '')
slug.length > 200 ? slug.slice(0..200) : slug
+ else
+ slug = post['id']
end
{
:name => "#{date}-#{slug}.#{format}",
:header => {
"layout" => "post",
@@ -203,10 +205,10 @@
site = Jekyll::Site.new(Jekyll.configuration({}))
urls = Hash[posts.map { |post|
# Create an initial empty file for the post so that
# we can instantiate a post object.
File.open("_posts/tumblr/#{post[:name]}", "w")
- tumblr_url = URI.parse(post[:slug]).path
+ tumblr_url = URI.parse(URI.encode(post[:slug])).path
jekyll_url = Jekyll::Post.new(site, Dir.pwd, "", "tumblr/" + post[:name]).url
redirect_dir = tumblr_url.sub(/\//, "") + "/"
FileUtils.mkdir_p redirect_dir
File.open(redirect_dir + "index.html", "w") do |f|
f.puts "<html><head><link rel=\"canonical\" href=\"" +