Added redirects for Drupal posts' URL-aliases

This commit is contained in:
Pelle Wessman 2011-08-08 16:19:02 +02:00
parent e8f604b5ae
commit 2ce0eb00e7
1 changed files with 12 additions and 6 deletions

View File

@ -78,8 +78,13 @@ 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|
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}"
@ -87,6 +92,7 @@ EOF
end
end
end
end
# TODO: Make dirs & files for nodes of type 'page'
# Make refresh pages for these as well