Skip to content

Commit

Permalink
Merge pull request jekyll#384 from voxpelli/drupal-alias-redirect
Browse files Browse the repository at this point in the history
Added redirects for Drupal posts' URL-aliases
  • Loading branch information
mojombo committed Jan 22, 2012
2 parents 6e921c5 + 2ce0eb0 commit 1292c02
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions lib/jekyll/migrators/drupal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1292c02

Please sign in to comment.