Skip to content

Commit

Permalink
Title attribute changes as per the article.
Browse files Browse the repository at this point in the history
Rbenv specific config file is ignored
  • Loading branch information
kgrz committed May 4, 2013
1 parent 650a7b7 commit ff17c31
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -2,7 +2,7 @@ Gemfile.lock
.sass-cache .sass-cache
.rvmrc .rvmrc
config/database.yml config/database.yml

.ruby-version
bin bin
.bundle .bundle
*.swp *.swp
22 changes: 19 additions & 3 deletions app.rb
Expand Up @@ -33,8 +33,24 @@
end.compact.sort end.compact.sort
end end


before '/p/:topic/:article' do
@title = prepare_title(params[:topic], params[:article])
end

before '/p/:topic' do
@title = prepare_title(params[:topic])
end

helpers do helpers do


def de_underscore(string)
string.gsub('_', ' ').split(" ").map(&:capitalize).join(" ")
end

def prepare_title(*args)
"Sinatra Recipes - #{args.map {|x| de_underscore(x)}.join(' - ')}"
end

def commits_url def commits_url
"https://api.github.com/repos/sinatra/sinatra-recipes/commits" "https://api.github.com/repos/sinatra/sinatra-recipes/commits"
end end
Expand Down Expand Up @@ -129,7 +145,7 @@ def get_activity_by_author
meta charset="utf-8" meta charset="utf-8"
meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible" meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible"
meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no" meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no"
title Sinatra Recipes title #{@title || 'Sinatra Recipes'}
link rel="stylesheet" type="text/css" href="/style.css" link rel="stylesheet" type="text/css" href="/style.css"
link rel="stylesheet" type="text/css" href="/stylesheets/pygment_trac.css" link rel="stylesheet" type="text/css" href="/stylesheets/pygment_trac.css"
link rel="stylesheet" type="text/css" href="/stylesheets/chosen.css" link rel="stylesheet" type="text/css" href="/stylesheets/chosen.css"
Expand Down Expand Up @@ -158,7 +174,7 @@ def get_activity_by_author
select#selectNav.chosen data-placeholder="Select a topic" select#selectNav.chosen data-placeholder="Select a topic"
option option
- @menu.each do |me| - @menu.each do |me|
option value="/p/#{me}?#article" #{me.capitalize.sub('_', ' ')} option value="/p/#{me}?#article" #{de_underscore(me)}
- if @toc and @toc.any? - if @toc and @toc.any?
h2 Chapters h2 Chapters
ol ol
Expand All @@ -174,7 +190,7 @@ def get_activity_by_author
- @children.each do |child| - @children.each do |child|
li li
a href="/p/#{params[:topic]}/#{child}?#article" a href="/p/#{params[:topic]}/#{child}?#article"
== child.capitalize.sub('_', ' ') == de_underscore(child)
- if @activity - if @activity
#activity #activity
- @activity.each do |x| - @activity.each do |x|
Expand Down

0 comments on commit ff17c31

Please sign in to comment.