Created
February 9, 2012 19:59
Revisions
-
maxim revised this gist
Feb 9, 2012 . 1 changed file with 11 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title><%= redirect[:title] %></title> <meta http-equiv="refresh" content="0;URL='<%= redirect[:url] %>'" /> </head> <body> <p>This page has moved to <a href="<%= redirect[:url] %>"><%= redirect[:url] %></a>.</p> </body> </html> -
maxim revised this gist
Feb 9, 2012 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,4 +6,8 @@ preprocess do RedirectGenerator.generate(config[:redirects], items) end route '/old_posts/*' do item.identifier.sub('old_posts/', '') + 'index.html' end # ... -
maxim created this gist
Feb 9, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ #!/usr/bin/env ruby # ... preprocess do RedirectGenerator.generate(config[:redirects], items) end # ... This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ redirects: - /avoiding-nested-blocks: - /2009/07/15/avoiding-nested-blocks - /better-memory-associations-inverseof: - /2009/05/04/better-memory-associations-inverseof This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ class RedirectGenerator def self.generate(redirects, items) redirect_template = ERB.new(File.read('redirect.html.erb')) redirects.each do |pairs| pairs.each_pair do |url, aliases| if aliased_item = items.find{|item| item.identifier == "/old_posts#{url}/" } aliases.each do |alias_url| redirect = {:url => url, :title => aliased_item[:title]} items << Nanoc3::Item.new(redirect_template.result(binding), { :redirect => true }, alias_url) end end end end end end