Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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...
commit 90c56a34f9f63193c2f58c0aa06303301cc28693 1 parent a9076e1
Julie Pagano juliepagano authored
23 README.markdown
Source Rendered
@@ -34,6 +34,29 @@ This will create a new post in the `/source/_posts/` directory. Always edit the
34 34
35 35 $ rake new_page[policies/index.html]
36 36
  37 +### Redirect from another url:
  38 +
  39 +Place the full path of the alias (place to redirect from) inside the
  40 +destination post's YAML Front Matter. One or more aliases may be given.
  41 +
  42 +Example Post Configuration:
  43 +
  44 + ---
  45 + layout: post
  46 + title: "How I Keep Limited Pressing Running"
  47 + alias: /post/6301645915/how-i-keep-limited-pressing-running/index.html
  48 + ---
  49 +
  50 +Example Post Configuration:
  51 +
  52 + ---
  53 + layout: post
  54 + title: "How I Keep Limited Pressing Running"
  55 + alias: [/first-alias/index.html, /second-alias/index.html]
  56 + ---
  57 +
  58 +Aliases are handled by the [jekyll_alias_generator](https://github.com/tsmango/jekyll_alias_generator) plugin.
  59 +
37 60 ### Generate and preview:
38 61
39 62 $ rake generate # Generates posts and pages into the public directory
110 plugins/alias_generator.rb
... ... @@ -0,0 +1,110 @@
  1 +# Alias Generator for Posts.
  2 +#
  3 +# Generates redirect pages for posts with aliases set in the YAML Front Matter.
  4 +#
  5 +# Place the full path of the alias (place to redirect from) inside the
  6 +# destination post's YAML Front Matter. One or more aliases may be given.
  7 +#
  8 +# Example Post Configuration:
  9 +#
  10 +# ---
  11 +# layout: post
  12 +# title: "How I Keep Limited Pressing Running"
  13 +# alias: /post/6301645915/how-i-keep-limited-pressing-running/index.html
  14 +# ---
  15 +#
  16 +# Example Post Configuration:
  17 +#
  18 +# ---
  19 +# layout: post
  20 +# title: "How I Keep Limited Pressing Running"
  21 +# alias: [/first-alias/index.html, /second-alias/index.html]
  22 +# ---
  23 +#
  24 +# Author: Thomas Mango
  25 +# Site: http://thomasmango.com
  26 +# Plugin Source: http://github.com/tsmango/jekyll_alias_generator
  27 +# Site Source: http://github.com/tsmango/thomasmango.com
  28 +# PLugin License: MIT
  29 +
  30 +module Jekyll
  31 +
  32 + class AliasGenerator < Generator
  33 +
  34 + def generate(site)
  35 + @site = site
  36 +
  37 + process_posts
  38 + process_pages
  39 + end
  40 +
  41 + def process_posts
  42 + @site.posts.each do |post|
  43 + generate_aliases(post.url, post.data['alias'])
  44 + end
  45 + end
  46 +
  47 + def process_pages
  48 + @site.pages.each do |page|
  49 + generate_aliases(page.destination('').gsub(/index\.(html|htm)$/, ''), page.data['alias'])
  50 + end
  51 + end
  52 +
  53 + def generate_aliases(destination_path, aliases)
  54 + alias_paths ||= Array.new
  55 + alias_paths << aliases
  56 + alias_paths.compact!
  57 +
  58 + alias_paths.flatten.each do |alias_path|
  59 + # If alias_path has an extension, we'll write the alias file
  60 + # directly to that path. Otherwise, we'll assume that the
  61 + # alias_path is a directory, in which case we'll generate an
  62 + # index.html file.
  63 + alias_dir = File.extname(alias_path).empty? ? alias_path : File.dirname(alias_path)
  64 + alias_file = File.extname(alias_path).empty? ? "index.html" : File.basename(alias_path)
  65 +
  66 + fs_path_to_dir = File.join(@site.dest, alias_dir)
  67 + alias_index_path = File.join(alias_dir, alias_file)
  68 +
  69 + FileUtils.mkdir_p(fs_path_to_dir)
  70 +
  71 + File.open(File.join(fs_path_to_dir, alias_file), 'w') do |file|
  72 + file.write(alias_template(destination_path))
  73 + end
  74 +
  75 + (alias_index_path.split('/').size + 1).times do |sections|
  76 + @site.static_files << Jekyll::AliasFile.new(@site, @site.dest, alias_index_path.split('/')[0, sections].join('/'), nil)
  77 + end
  78 + end
  79 + end
  80 +
  81 + def alias_template(destination_path)
  82 + <<-EOF
  83 + <!DOCTYPE html>
  84 + <html>
  85 + <head>
  86 + <link rel="canonical" href="#{destination_path}"/>
  87 + <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  88 + <meta http-equiv="refresh" content="0;url=#{destination_path}" />
  89 + </head>
  90 + </html>
  91 + EOF
  92 + end
  93 + end
  94 +
  95 + class AliasFile < StaticFile
  96 + require 'set'
  97 +
  98 + def destination(dest)
  99 + File.join(dest, @dir)
  100 + end
  101 +
  102 + def modified?
  103 + return false
  104 + end
  105 +
  106 + def write(dest)
  107 + return true
  108 + end
  109 + end
  110 +end
2  public/atom.xml
@@ -4,7 +4,7 @@
4 4 <title><![CDATA[Steel City Ruby Conf]]></title>
5 5 <link href="http://scrc-octopress.heroku.com/atom.xml" rel="self"/>
6 6 <link href="http://scrc-octopress.heroku.com/"/>
7   - <updated>2012-05-03T22:25:51-04:00</updated>
  7 + <updated>2012-05-04T22:56:01-04:00</updated>
8 8 <id>http://scrc-octopress.heroku.com/</id>
9 9 <author>
10 10 <name><![CDATA[]]></name>
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>
188 188 </div>
189 189 </div>
190 190 <footer role="contentinfo"><div id="harassment-notice">
191   -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>.
  191 +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>.
192 192 </div>
193 193
194 194 <a href="http://twitter.com/#!/steelcityruby">Follow @SteelCityRuby on Twitter</a>
2  public/blog/archives/index.html
@@ -120,7 +120,7 @@ <h1 class="entry-title">Blog Archive</h1>
120 120 </div>
121 121 </div>
122 122 <footer role="contentinfo"><div id="harassment-notice">
123   -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>.
  123 +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>.
124 124 </div>
125 125
126 126 <a href="http://twitter.com/#!/steelcityruby">Follow @SteelCityRuby on Twitter</a>
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-
239 239 </div>
240 240 </div>
241 241 <footer role="contentinfo"><div id="harassment-notice">
242   -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>.
  242 +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>.
243 243 </div>
244 244
245 245 <a href="http://twitter.com/#!/steelcityruby">Follow @SteelCityRuby on Twitter</a>
8 public/city.html
... ... @@ -0,0 +1,8 @@
  1 + <!DOCTYPE html>
  2 + <html>
  3 + <head>
  4 + <link rel="canonical" href="/city/"/>
  5 + <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  6 + <meta http-equiv="refresh" content="0;url=/city/" />
  7 + </head>
  8 + </html>
2  public/city/index.html
@@ -171,7 +171,7 @@ <h1 class="entry-title">The City</h1>
171 171 </div>
172 172 </div>
173 173 <footer role="contentinfo"><div id="harassment-notice">
174   -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>.
  174 +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>.
175 175 </div>
176 176
177 177 <a href="http://twitter.com/#!/steelcityruby">Follow @SteelCityRuby on Twitter</a>
8 public/conference.html
... ... @@ -0,0 +1,8 @@
  1 + <!DOCTYPE html>
  2 + <html>
  3 + <head>
  4 + <link rel="canonical" href="/conference/"/>
  5 + <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  6 + <meta http-equiv="refresh" content="0;url=/conference/" />
  7 + </head>
  8 + </html>
4 public/conference/index.html
@@ -102,7 +102,7 @@ <h1 class="entry-title">The Conference</h1>
102 102 <img src="/images/scrc/heinz-history-center.jpg" alt="Heinz History Center"
103 103 title="Heinz History Center" />
104 104 </div>
105   -
  105 +
106 106 <div class="map-frame">
107 107 <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>
108 108 </div>
@@ -397,7 +397,7 @@ <h2 class="clear">SPEAKERS</h2>
397 397 </div>
398 398 </div>
399 399 <footer role="contentinfo"><div id="harassment-notice">
400   -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>.
  400 +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>.
401 401 </div>
402 402
403 403 <a href="http://twitter.com/#!/steelcityruby">Follow @SteelCityRuby on Twitter</a>
2  public/index.html
@@ -265,7 +265,7 @@
265 265 </div>
266 266 </div>
267 267 <footer role="contentinfo"><div id="harassment-notice">
268   -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>.
  268 +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>.
269 269 </div>
270 270
271 271 <a href="http://twitter.com/#!/steelcityruby">Follow @SteelCityRuby on Twitter</a>
8 public/policies.html
... ... @@ -0,0 +1,8 @@
  1 + <!DOCTYPE html>
  2 + <html>
  3 + <head>
  4 + <link rel="canonical" href="/policies/"/>
  5 + <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  6 + <meta http-equiv="refresh" content="0;url=/policies/" />
  7 + </head>
  8 + </html>
2  public/policies/index.html
@@ -216,7 +216,7 @@ <h1 class="entry-title">Policies</h1>
216 216 </div>
217 217 </div>
218 218 <footer role="contentinfo"><div id="harassment-notice">
219   -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>.
  219 +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>.
220 220 </div>
221 221
222 222 <a href="http://twitter.com/#!/steelcityruby">Follow @SteelCityRuby on Twitter</a>
16 public/sitemap.xml
@@ -4,34 +4,34 @@
4 4 <loc>
5 5 http://scrc-octopress.heroku.com/blog/2012/05/03/how-steel-city-ruby-conf-came-to-be/
6 6 </loc>
7   - <lastmod>2012-05-03T22:25:51-04:00</lastmod>
  7 + <lastmod>2012-05-04T22:09:29-04:00</lastmod>
8 8 </url>
9 9 <url>
10 10 <loc>http://scrc-octopress.heroku.com/blog/archives/</loc>
11   - <lastmod>2012-05-03T22:25:51-04:00</lastmod>
  11 + <lastmod>2012-05-04T22:09:29-04:00</lastmod>
12 12 </url>
13 13 <url>
14 14 <loc>http://scrc-octopress.heroku.com/blog/</loc>
15   - <lastmod>2012-05-03T22:25:51-04:00</lastmod>
  15 + <lastmod>2012-05-04T22:09:29-04:00</lastmod>
16 16 </url>
17 17 <url>
18 18 <loc>http://scrc-octopress.heroku.com/city/</loc>
19   - <lastmod>2012-05-03T22:25:51-04:00</lastmod>
  19 + <lastmod>2012-05-04T22:54:31-04:00</lastmod>
20 20 </url>
21 21 <url>
22 22 <loc>http://scrc-octopress.heroku.com/conference/</loc>
23   - <lastmod>2012-05-03T22:25:51-04:00</lastmod>
  23 + <lastmod>2012-05-04T22:54:31-04:00</lastmod>
24 24 </url>
25 25 <url>
26 26 <loc>http://scrc-octopress.heroku.com/</loc>
27   - <lastmod>2012-05-03T22:25:51-04:00</lastmod>
  27 + <lastmod>2012-05-04T22:09:29-04:00</lastmod>
28 28 </url>
29 29 <url>
30 30 <loc>http://scrc-octopress.heroku.com/policies/</loc>
31   - <lastmod>2012-05-03T22:25:51-04:00</lastmod>
  31 + <lastmod>2012-05-04T22:54:31-04:00</lastmod>
32 32 </url>
33 33 <url>
34 34 <loc>http://scrc-octopress.heroku.com/sponsors/</loc>
35   - <lastmod>2012-05-03T22:25:51-04:00</lastmod>
  35 + <lastmod>2012-05-04T22:54:31-04:00</lastmod>
36 36 </url>
37 37 </urlset>
8 public/sponsors.html
... ... @@ -0,0 +1,8 @@
  1 + <!DOCTYPE html>
  2 + <html>
  3 + <head>
  4 + <link rel="canonical" href="/sponsors/"/>
  5 + <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  6 + <meta http-equiv="refresh" content="0;url=/sponsors/" />
  7 + </head>
  8 + </html>
2  public/sponsors/index.html
@@ -360,7 +360,7 @@ <h3 class="print-break">Sponsorship Levels</h3>
360 360 </div>
361 361 </div>
362 362 <footer role="contentinfo"><div id="harassment-notice">
363   -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>.
  363 +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>.
364 364 </div>
365 365
366 366 <a href="http://twitter.com/#!/steelcityruby">Follow @SteelCityRuby on Twitter</a>
2  public/stylesheets/screen.css
1 addition, 1 deletion not shown
2  source/_includes/custom/footer.html
... ... @@ -1,5 +1,5 @@
1  source/city/index.html
@@ -5,6 +5,7 @@
5 5 sharing: false
6 6 footer: true
7 7 body_id: "city"
  8 +alias: /city.html
8 9 ---
9 10
10 11 <h2>PITTSBURGH</h2>
3  source/conference/index.html
@@ -5,6 +5,7 @@
5 5 sharing: false
6 6 footer: true
7 7 body_id: "conference"
  8 +alias: /conference.html
8 9 ---
9 10
10 11 <h2>VENUE</h2>
@@ -22,7 +23,7 @@
22 23 <img src="/images/scrc/heinz-history-center.jpg" alt="Heinz History Center"
23 24 title="Heinz History Center" />
24 25 </div>
25   -
  26 +
26 27 <div class="map-frame">
27 28 <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>
28 29 </div>
1  source/policies/index.html
@@ -6,6 +6,7 @@
6 6 comments: true
7 7 sharing: false
8 8 footer: false
  9 +alias: /policies.html
9 10 ---
10 11
11 12 <h2>
1  source/sponsors/index.html
@@ -5,6 +5,7 @@
5 5 sharing: false
6 6 footer: true
7 7 body_id: "sponsors"
  8 +alias: /sponsors.html
8 9 ---
9 10
10 11 <h2>OUR SPONSORS</h2>

0 comments on commit 90c56a3

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