Skip to content
This repository
Browse code

Added redirects for Drupal posts' URL-aliases

  • Loading branch information...
commit 2ce0eb00e759126be41d905afe3be0ed624b3338 1 parent e8f604b
Pelle Wessman authored August 08, 2011

Showing 1 changed file with 12 additions and 6 deletions. Show diff stats Hide diff stats

  1. 18  lib/jekyll/migrators/drupal.rb
18  lib/jekyll/migrators/drupal.rb
@@ -78,12 +78,18 @@ def self.process(dbname, user, pass, host = 'localhost', prefix = '')
78 78
 
79 79
         # Make a file to redirect from the old Drupal URL
80 80
         if is_published
81  
-          FileUtils.mkdir_p "node/#{node_id}"
82  
-          File.open("node/#{node_id}/index.md", "w") do |f|
83  
-            f.puts "---"
84  
-            f.puts "layout: refresh"
85  
-            f.puts "refresh_to_post_id: /#{time.strftime("%Y/%m/%d/") + slug}"
86  
-            f.puts "---"
  81
+          aliases = db["SELECT dst FROM #{prefix}url_alias WHERE src = ?", "node/#{node_id}"].all
  82
+
  83
+          aliases.push(:dst => "node/#{node_id}")
  84
+
  85
+          aliases.each do |url_alias|
  86
+            FileUtils.mkdir_p url_alias[:dst]
  87
+            File.open("#{url_alias[:dst]}/index.md", "w") do |f|
  88
+              f.puts "---"
  89
+              f.puts "layout: refresh"
  90
+              f.puts "refresh_to_post_id: /#{time.strftime("%Y/%m/%d/") + slug}"
  91
+              f.puts "---"
  92
+            end
87 93
           end
88 94
         end
89 95
       end

0 notes on commit 2ce0eb0

Please sign in to comment.
Something went wrong with that request. Please try again.