From 2ce0eb00e759126be41d905afe3be0ed624b3338 Mon Sep 17 00:00:00 2001 From: Pelle Wessman Date: Mon, 8 Aug 2011 16:19:02 +0200 Subject: [PATCH] Added redirects for Drupal posts' URL-aliases --- lib/jekyll/migrators/drupal.rb | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/jekyll/migrators/drupal.rb b/lib/jekyll/migrators/drupal.rb index 2301b0e5..7fd16aef 100644 --- a/lib/jekyll/migrators/drupal.rb +++ b/lib/jekyll/migrators/drupal.rb @@ -78,12 +78,18 @@ EOF # Make a file to redirect from the old Drupal URL if is_published - FileUtils.mkdir_p "node/#{node_id}" - File.open("node/#{node_id}/index.md", "w") do |f| - f.puts "---" - f.puts "layout: refresh" - f.puts "refresh_to_post_id: /#{time.strftime("%Y/%m/%d/") + slug}" - f.puts "---" + aliases = db["SELECT dst FROM #{prefix}url_alias WHERE src = ?", "node/#{node_id}"].all + + aliases.push(:dst => "node/#{node_id}") + + aliases.each do |url_alias| + FileUtils.mkdir_p url_alias[:dst] + File.open("#{url_alias[:dst]}/index.md", "w") do |f| + f.puts "---" + f.puts "layout: refresh" + f.puts "refresh_to_post_id: /#{time.strftime("%Y/%m/%d/") + slug}" + f.puts "---" + end end end end