Skip to content
Browse files

Redirect from old html pages to new Octopress pages

Redirects are handled by the jekyll_alias_generator Octopress plugin
https://github.com/tsmango/jekyll_alias_generator
  • Loading branch information...
1 parent a9076e1 commit 90c56a34f9f63193c2f58c0aa06303301cc28693 @juliepagano juliepagano committed May 4, 2012
View
23 README.markdown
@@ -34,6 +34,29 @@ This will create a new post in the `/source/_posts/` directory. Always edit the
$ rake new_page[policies/index.html]
+### Redirect from another url:
+
+Place the full path of the alias (place to redirect from) inside the
+destination post's YAML Front Matter. One or more aliases may be given.
+
+Example Post Configuration:
+
+ ---
+ layout: post
+ title: "How I Keep Limited Pressing Running"
+ alias: /post/6301645915/how-i-keep-limited-pressing-running/index.html
+ ---
+
+Example Post Configuration:
+
+ ---
+ layout: post
+ title: "How I Keep Limited Pressing Running"
+ alias: [/first-alias/index.html, /second-alias/index.html]
+ ---
+
+Aliases are handled by the [jekyll_alias_generator](https://github.com/tsmango/jekyll_alias_generator) plugin.
+
### Generate and preview:
$ rake generate # Generates posts and pages into the public directory
View
110 plugins/alias_generator.rb
@@ -0,0 +1,110 @@
+# Alias Generator for Posts.
+#
+# Generates redirect pages for posts with aliases set in the YAML Front Matter.
+#
+# Place the full path of the alias (place to redirect from) inside the
+# destination post's YAML Front Matter. One or more aliases may be given.
+#
+# Example Post Configuration:
+#
+# ---
+# layout: post
+# title: "How I Keep Limited Pressing Running"
+# alias: /post/6301645915/how-i-keep-limited-pressing-running/index.html
+# ---
+#
+# Example Post Configuration:
+#
+# ---
+# layout: post
+# title: "How I Keep Limited Pressing Running"
+# alias: [/first-alias/index.html, /second-alias/index.html]
+# ---
+#
+# Author: Thomas Mango
+# Site: http://thomasmango.com
+# Plugin Source: http://github.com/tsmango/jekyll_alias_generator
+# Site Source: http://github.com/tsmango/thomasmango.com
+# PLugin License: MIT
+
+module Jekyll
+
+ class AliasGenerator < Generator
+
+ def generate(site)
+ @site = site
+
+ process_posts
+ process_pages
+ end
+
+ def process_posts
+ @site.posts.each do |post|
+ generate_aliases(post.url, post.data['alias'])
+ end
+ end
+
+ def process_pages
+ @site.pages.each do |page|
+ generate_aliases(page.destination('').gsub(/index\.(html|htm)$/, ''), page.data['alias'])
+ end
+ end
+
+ def generate_aliases(destination_path, aliases)
+ alias_paths ||= Array.new
+ alias_paths << aliases
+ alias_paths.compact!
+
+ alias_paths.flatten.each do |alias_path|
+ # If alias_path has an extension, we'll write the alias file
+ # directly to that path. Otherwise, we'll assume that the
+ # alias_path is a directory, in which case we'll generate an
+ # index.html file.
+ alias_dir = File.extname(alias_path).empty? ? alias_path : File.dirname(alias_path)
+ alias_file = File.extname(alias_path).empty? ? "index.html" : File.basename(alias_path)
+
+ fs_path_to_dir = File.join(@site.dest, alias_dir)
+ alias_index_path = File.join(alias_dir, alias_file)
+
+ FileUtils.mkdir_p(fs_path_to_dir)
+
+ File.open(File.join(fs_path_to_dir, alias_file), 'w') do |file|
+ file.write(alias_template(destination_path))
+ end
+
+ (alias_index_path.split('/').size + 1).times do |sections|
+ @site.static_files << Jekyll::AliasFile.new(@site, @site.dest, alias_index_path.split('/')[0, sections].join('/'), nil)
+ end
+ end
+ end
+
+ def alias_template(destination_path)
+ <<-EOF
+ <!DOCTYPE html>
+ <html>
+ <head>
+ <link rel="canonical" href="#{destination_path}"/>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
+ <meta http-equiv="refresh" content="0;url=#{destination_path}" />
+ </head>
+ </html>
+ EOF
+ end
+ end
+
+ class AliasFile < StaticFile
+ require 'set'
+
+ def destination(dest)
+ File.join(dest, @dir)
+ end
+
+ def modified?
+ return false
+ end
+
+ def write(dest)
+ return true
+ end
+ end
+end
View
2 public/atom.xml
@@ -4,7 +4,7 @@
<title><![CDATA[Steel City Ruby Conf]]></title>
<link href="http://scrc-octopress.heroku.com/atom.xml" rel="self"/>
<link href="http://scrc-octopress.heroku.com/"/>
- <updated>2012-05-03T22:25:51-04:00</updated>
+ <updated>2012-05-04T22:56:01-04:00</updated>
<id>http://scrc-octopress.heroku.com/</id>
<author>
<name><![CDATA[]]></name>
View
2 public/blog/2012/05/03/how-steel-city-ruby-conf-came-to-be/index.html
@@ -188,7 +188,7 @@ <h1 class="entry-title">How Steel City Ruby Conf Came to Be</h1>
</div>
</div>
<footer role="contentinfo"><div id="harassment-notice">
-Steel City Ruby Conference is dedicated to a harassment-free conference experience for everyone. Please read our <a href="policies#antiharassment">anti-harassment policy</a>.
+Steel City Ruby Conference is dedicated to a harassment-free conference experience for everyone. Please read our <a href="/policies#antiharassment">anti-harassment policy</a>.
</div>
<a href="http://twitter.com/#!/steelcityruby">Follow @SteelCityRuby on Twitter</a>
View
2 public/blog/archives/index.html
@@ -120,7 +120,7 @@ <h1 class="entry-title">Blog Archive</h1>
</div>
</div>
<footer role="contentinfo"><div id="harassment-notice">
-Steel City Ruby Conference is dedicated to a harassment-free conference experience for everyone. Please read our <a href="policies#antiharassment">anti-harassment policy</a>.
+Steel City Ruby Conference is dedicated to a harassment-free conference experience for everyone. Please read our <a href="/policies#antiharassment">anti-harassment policy</a>.
</div>
<a href="http://twitter.com/#!/steelcityruby">Follow @SteelCityRuby on Twitter</a>
View
2 public/blog/index.html
@@ -239,7 +239,7 @@ <h1 class="entry-title"><a href="/blog/2012/05/03/how-steel-city-ruby-conf-came-
</div>
</div>
<footer role="contentinfo"><div id="harassment-notice">
-Steel City Ruby Conference is dedicated to a harassment-free conference experience for everyone. Please read our <a href="policies#antiharassment">anti-harassment policy</a>.
+Steel City Ruby Conference is dedicated to a harassment-free conference experience for everyone. Please read our <a href="/policies#antiharassment">anti-harassment policy</a>.
</div>
<a href="http://twitter.com/#!/steelcityruby">Follow @SteelCityRuby on Twitter</a>
View
8 public/city.html
@@ -0,0 +1,8 @@
+ <!DOCTYPE html>
+ <html>
+ <head>
+ <link rel="canonical" href="/city/"/>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
+ <meta http-equiv="refresh" content="0;url=/city/" />
+ </head>
+ </html>
View
2 public/city/index.html
@@ -171,7 +171,7 @@ <h1 class="entry-title">The City</h1>
</div>
</div>
<footer role="contentinfo"><div id="harassment-notice">
-Steel City Ruby Conference is dedicated to a harassment-free conference experience for everyone. Please read our <a href="policies#antiharassment">anti-harassment policy</a>.
+Steel City Ruby Conference is dedicated to a harassment-free conference experience for everyone. Please read our <a href="/policies#antiharassment">anti-harassment policy</a>.
</div>
<a href="http://twitter.com/#!/steelcityruby">Follow @SteelCityRuby on Twitter</a>
View
8 public/conference.html
@@ -0,0 +1,8 @@
+ <!DOCTYPE html>
+ <html>
+ <head>
+ <link rel="canonical" href="/conference/"/>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
+ <meta http-equiv="refresh" content="0;url=/conference/" />
+ </head>
+ </html>
View
4 public/conference/index.html
@@ -102,7 +102,7 @@ <h1 class="entry-title">The Conference</h1>
<img src="/images/scrc/heinz-history-center.jpg" alt="Heinz History Center"
title="Heinz History Center" />
</div>
-
+
<div class="map-frame">
<iframe width="570" height="438" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=john+heinz+history+center&amp;aq=&amp;sll=40.444661,-80.001068&amp;sspn=0.023025,0.045447&amp;ie=UTF8&amp;hq=john+heinz+history+center&amp;hnear=&amp;t=m&amp;cid=5087244111269421195&amp;ll=40.482732,-79.981842&amp;spn=0.104453,0.195351&amp;z=12&amp;iwloc=A&amp;output=embed"></iframe>
</div>
@@ -397,7 +397,7 @@ <h2 class="clear">SPEAKERS</h2>
</div>
</div>
<footer role="contentinfo"><div id="harassment-notice">
-Steel City Ruby Conference is dedicated to a harassment-free conference experience for everyone. Please read our <a href="policies#antiharassment">anti-harassment policy</a>.
+Steel City Ruby Conference is dedicated to a harassment-free conference experience for everyone. Please read our <a href="/policies#antiharassment">anti-harassment policy</a>.
</div>
<a href="http://twitter.com/#!/steelcityruby">Follow @SteelCityRuby on Twitter</a>
View
2 public/index.html
@@ -265,7 +265,7 @@
</div>
</div>
<footer role="contentinfo"><div id="harassment-notice">
-Steel City Ruby Conference is dedicated to a harassment-free conference experience for everyone. Please read our <a href="policies#antiharassment">anti-harassment policy</a>.
+Steel City Ruby Conference is dedicated to a harassment-free conference experience for everyone. Please read our <a href="/policies#antiharassment">anti-harassment policy</a>.
</div>
<a href="http://twitter.com/#!/steelcityruby">Follow @SteelCityRuby on Twitter</a>
View
8 public/policies.html
@@ -0,0 +1,8 @@
+ <!DOCTYPE html>
+ <html>
+ <head>
+ <link rel="canonical" href="/policies/"/>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
+ <meta http-equiv="refresh" content="0;url=/policies/" />
+ </head>
+ </html>
View
2 public/policies/index.html
@@ -216,7 +216,7 @@ <h1 class="entry-title">Policies</h1>
</div>
</div>
<footer role="contentinfo"><div id="harassment-notice">
-Steel City Ruby Conference is dedicated to a harassment-free conference experience for everyone. Please read our <a href="policies#antiharassment">anti-harassment policy</a>.
+Steel City Ruby Conference is dedicated to a harassment-free conference experience for everyone. Please read our <a href="/policies#antiharassment">anti-harassment policy</a>.
</div>
<a href="http://twitter.com/#!/steelcityruby">Follow @SteelCityRuby on Twitter</a>
View
16 public/sitemap.xml
@@ -4,34 +4,34 @@
<loc>
http://scrc-octopress.heroku.com/blog/2012/05/03/how-steel-city-ruby-conf-came-to-be/
</loc>
- <lastmod>2012-05-03T22:25:51-04:00</lastmod>
+ <lastmod>2012-05-04T22:09:29-04:00</lastmod>
</url>
<url>
<loc>http://scrc-octopress.heroku.com/blog/archives/</loc>
- <lastmod>2012-05-03T22:25:51-04:00</lastmod>
+ <lastmod>2012-05-04T22:09:29-04:00</lastmod>
</url>
<url>
<loc>http://scrc-octopress.heroku.com/blog/</loc>
- <lastmod>2012-05-03T22:25:51-04:00</lastmod>
+ <lastmod>2012-05-04T22:09:29-04:00</lastmod>
</url>
<url>
<loc>http://scrc-octopress.heroku.com/city/</loc>
- <lastmod>2012-05-03T22:25:51-04:00</lastmod>
+ <lastmod>2012-05-04T22:54:31-04:00</lastmod>
</url>
<url>
<loc>http://scrc-octopress.heroku.com/conference/</loc>
- <lastmod>2012-05-03T22:25:51-04:00</lastmod>
+ <lastmod>2012-05-04T22:54:31-04:00</lastmod>
</url>
<url>
<loc>http://scrc-octopress.heroku.com/</loc>
- <lastmod>2012-05-03T22:25:51-04:00</lastmod>
+ <lastmod>2012-05-04T22:09:29-04:00</lastmod>
</url>
<url>
<loc>http://scrc-octopress.heroku.com/policies/</loc>
- <lastmod>2012-05-03T22:25:51-04:00</lastmod>
+ <lastmod>2012-05-04T22:54:31-04:00</lastmod>
</url>
<url>
<loc>http://scrc-octopress.heroku.com/sponsors/</loc>
- <lastmod>2012-05-03T22:25:51-04:00</lastmod>
+ <lastmod>2012-05-04T22:54:31-04:00</lastmod>
</url>
</urlset>
View
8 public/sponsors.html
@@ -0,0 +1,8 @@
+ <!DOCTYPE html>
+ <html>
+ <head>
+ <link rel="canonical" href="/sponsors/"/>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
+ <meta http-equiv="refresh" content="0;url=/sponsors/" />
+ </head>
+ </html>
View
2 public/sponsors/index.html
@@ -360,7 +360,7 @@ <h3 class="print-break">Sponsorship Levels</h3>
</div>
</div>
<footer role="contentinfo"><div id="harassment-notice">
-Steel City Ruby Conference is dedicated to a harassment-free conference experience for everyone. Please read our <a href="policies#antiharassment">anti-harassment policy</a>.
+Steel City Ruby Conference is dedicated to a harassment-free conference experience for everyone. Please read our <a href="/policies#antiharassment">anti-harassment policy</a>.
</div>
<a href="http://twitter.com/#!/steelcityruby">Follow @SteelCityRuby on Twitter</a>
View
2 public/stylesheets/screen.css
1 addition, 1 deletion not shown because the diff is too large. Please use a local Git client to view these changes.
View
2 source/_includes/custom/footer.html
@@ -1,5 +1,5 @@
<div id="harassment-notice">
-Steel City Ruby Conference is dedicated to a harassment-free conference experience for everyone. Please read our <a href="policies#antiharassment">anti-harassment policy</a>.
+Steel City Ruby Conference is dedicated to a harassment-free conference experience for everyone. Please read our <a href="/policies#antiharassment">anti-harassment policy</a>.
</div>
<a href="http://twitter.com/#!/steelcityruby">Follow @SteelCityRuby on Twitter</a>
View
1 source/city/index.html
@@ -5,6 +5,7 @@
sharing: false
footer: true
body_id: "city"
+alias: /city.html
---
<h2>PITTSBURGH</h2>
View
3 source/conference/index.html
@@ -5,6 +5,7 @@
sharing: false
footer: true
body_id: "conference"
+alias: /conference.html
---
<h2>VENUE</h2>
@@ -22,7 +23,7 @@
<img src="/images/scrc/heinz-history-center.jpg" alt="Heinz History Center"
title="Heinz History Center" />
</div>
-
+
<div class="map-frame">
<iframe width="570" height="438" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=john+heinz+history+center&amp;aq=&amp;sll=40.444661,-80.001068&amp;sspn=0.023025,0.045447&amp;ie=UTF8&amp;hq=john+heinz+history+center&amp;hnear=&amp;t=m&amp;cid=5087244111269421195&amp;ll=40.482732,-79.981842&amp;spn=0.104453,0.195351&amp;z=12&amp;iwloc=A&amp;output=embed"></iframe>
</div>
View
1 source/policies/index.html
@@ -6,6 +6,7 @@
comments: true
sharing: false
footer: false
+alias: /policies.html
---
<h2>
View
1 source/sponsors/index.html
@@ -5,6 +5,7 @@
sharing: false
footer: true
body_id: "sponsors"
+alias: /sponsors.html
---
<h2>OUR SPONSORS</h2>

0 comments on commit 90c56a3

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