Skip to content
This repository has been archived by the owner on Mar 22, 2019. It is now read-only.

Commit

Permalink
URL TLC
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanpenner committed Mar 14, 2013
1 parent 0f782c7 commit d98cbe2
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 9 deletions.
20 changes: 18 additions & 2 deletions config.rb
Expand Up @@ -27,7 +27,23 @@
activate :blog do |blog|
blog.prefix = 'blog'
blog.layout = 'layouts/blog'
blog.tag_template = 'blog/tag.html'
blog.tag_template = 'blog/tag'
blog.permalink = '/:year/:month/:day/:title'
blog.taglink = 'tags/:tag'
end

ready do
blog.articles.each do |article|
options = {
locals: {
redirect_to: article.url
},
layout: false,
ignore: true
}

proxy article.path + '.html', 'redirect.html', options
end
end

page '/blog/feed.xml', layout: false
Expand Down Expand Up @@ -75,7 +91,7 @@ def rendered_partial_for(key)

def link_to_page name, url
path = request.path
current = path =~ Regexp.new('^' + url[1..-1] + '.*\.html')
current = path =~ Regexp.new('^' + url[1..-1])

if path == 'index.html' and name == 'about'
current = true
Expand Down
2 changes: 1 addition & 1 deletion lib/api_docs.rb
Expand Up @@ -11,7 +11,7 @@ def registered(app, options={})

@repo_url = options[:repo_url]

app.after_configuration do
app.ready do
ApiClass.data = data.api

page '/api*', directory_index: false, layout: 'layouts/api'
Expand Down
12 changes: 6 additions & 6 deletions source/blog/index.html.erb
Expand Up @@ -5,10 +5,10 @@ title: "Blog"
<% partial_for :head, 'head' %>
<% partial_for :sidebar, 'sidebar' %>
<% blog.articles.each_with_index do |article, i| %>
<article class="blog-post-summary">
<h2><%= link_to article.title, article %> &ndash; <time><%= article.date.strftime('%b %d, %Y') %></time></span></h2>
<%= article.summary %>
<%= link_to "Read more...", article %>
</article>
<% blog.articles.reject(&:proxied_to).each_with_index do |article, i| %>
<article class="blog-post-summary">
<h2><%= link_to article.title, article %> &ndash; <time><%= article.date.strftime('%b %d, %Y') %></time></span></h2>
<%= article.summary %>
<%= link_to "Read more...", article %>
</article>
<% end %>
File renamed without changes.
1 change: 1 addition & 0 deletions source/examples/index.html
@@ -1,3 +1,4 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Refresh" content="0; url=/" />
Expand Down
8 changes: 8 additions & 0 deletions source/redirect.html.erb
@@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Refresh" content="0; url=<%= redirect_to %>" />
</head>
<body>
</body>
</html>

0 comments on commit d98cbe2

Please sign in to comment.