Permalink
Browse files

Added redirects for Drupal posts' URL-aliases

  • Loading branch information...
1 parent e8f604b commit 2ce0eb00e759126be41d905afe3be0ed624b3338 @voxpelli voxpelli committed Aug 8, 2011
Showing with 12 additions and 6 deletions.
  1. +12 −6 lib/jekyll/migrators/drupal.rb
View
18 lib/jekyll/migrators/drupal.rb
@@ -78,12 +78,18 @@ def self.process(dbname, user, pass, host = 'localhost', prefix = '')
# 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

0 comments on commit 2ce0eb0

Please sign in to comment.