Skip to content

Commit 238921b

Browse files
committed
Finish layout and routes
1 parent b86ef94 commit 238921b

File tree

13 files changed

+205
-53
lines changed

13 files changed

+205
-53
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
source 'http://ruby.taobao.org/'
22

33
gem 'rails', '3.2.6'
4+
gem 'bootstrap-sass'
45

56
# Bundle edge Rails instead:
67
# gem 'rails', :git => 'git://github.com/rails/rails.git'

Gemfile.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ GEM
3030
multi_json (~> 1.0)
3131
addressable (2.2.8)
3232
arel (3.0.2)
33+
bootstrap-sass (2.0.4.0)
3334
builder (3.0.0)
3435
capybara (1.1.2)
3536
mime-types (>= 1.16)
@@ -67,7 +68,9 @@ GEM
6768
treetop (~> 1.4.8)
6869
mime-types (1.19)
6970
multi_json (1.3.6)
71+
nokogiri (1.5.5)
7072
nokogiri (1.5.5-x86-mingw32)
73+
pg (0.14.0)
7174
pg (0.14.0-x86-mingw32)
7275
polyglot (0.3.3)
7376
rack (1.4.1)
@@ -141,6 +144,7 @@ PLATFORMS
141144
x86-mingw32
142145

143146
DEPENDENCIES
147+
bootstrap-sass
144148
capybara
145149
coffee-rails (~> 3.2.1)
146150
jquery-rails
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
@import "bootstrap";
2+
3+
/* mixins, variables, etc. */
4+
5+
$grayMediumLight: #eaeaea;
6+
7+
/* universal */
8+
9+
html {
10+
overflow-y: scroll;
11+
}
12+
13+
body {
14+
padding-top: 60px;
15+
}
16+
17+
section {
18+
overflow: auto;
19+
}
20+
21+
textarea {
22+
resize: vertical;
23+
}
24+
25+
.center {
26+
text-align: center;
27+
h1 {
28+
margin-bottom: 10px;
29+
}
30+
}
31+
32+
/* typography */
33+
34+
h1, h2, h3, h4, h5, h6 {
35+
line-height: 1;
36+
}
37+
38+
h1 {
39+
font-size: 3em;
40+
letter-spacing: -2px;
41+
margin-bottom: 30px;
42+
text-align: center;
43+
}
44+
45+
h2 {
46+
font-size: 1.7em;
47+
letter-spacing: -1px;
48+
margin-bottom: 30px;
49+
text-align: center;
50+
font-weight: normal;
51+
color: $grayLight;
52+
}
53+
54+
p {
55+
font-size: 1.1em;
56+
line-height: 1.7em;
57+
}
58+
59+
60+
/* header */
61+
62+
#logo {
63+
float: left;
64+
margin-right: 10px;
65+
font-size: 1.7em;
66+
color: white;
67+
text-transform: uppercase;
68+
letter-spacing: -1px;
69+
padding-top: 9px;
70+
font-weight: bold;
71+
line-height: 1;
72+
&:hover {
73+
color: white;
74+
text-decoration: none;
75+
}
76+
}
77+
78+
/* footer */
79+
80+
footer {
81+
margin-top: 45px;
82+
padding-top: 5px;
83+
border-top: 1px solid $grayMediumLight;
84+
color: $grayLight;
85+
a {
86+
color: $gray;
87+
&:hover {
88+
color: $grayDarker;
89+
}
90+
}
91+
small {
92+
float: left;
93+
}
94+
ul {
95+
float: right;
96+
list-style: none;
97+
li {
98+
float: left;
99+
margin-left: 10px;
100+
}
101+
}
102+
}

app/controllers/static_pages_controller.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,8 @@ def help
88
def about
99

1010
end
11+
12+
def contact
13+
14+
end
1115
end

app/helpers/application_helper.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
11
module ApplicationHelper
2+
def full_title(page_title)
3+
base_title = "Ruby on Rails Tutorial Sample App"
4+
if page_title.empty?
5+
base_title
6+
else
7+
"#{base_title} | #{page_title}"
8+
end
9+
end
210
end

app/views/layouts/_footer.html.erb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<footer class="footer">
2+
<small>
3+
<a href="http://railstutorial.org/">Rails Tutorial</a>
4+
by Michael Hartl
5+
</small>
6+
<nav>
7+
<ul>
8+
<li><%= link_to "About", about_path %></li>
9+
<li><%= link_to "Contact", contact_path %></li>
10+
<li><a href="http://news.railstutorial.org/">News</a></li>
11+
</ul>
12+
</nav>
13+
</footer>

app/views/layouts/_header.html.erb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<header class="navbar navbar-fixed-top">
2+
<div class="navbar-inner">
3+
<div class="container">
4+
<%= link_to "sample app", root_path, id: "logo" %>
5+
<nav>
6+
<ul class="nav pull-right">
7+
<li><%= link_to "Home", root_path %></li>
8+
<li><%= link_to "Help", help_path %></li>
9+
<li><%= link_to "Sign in", '#' %></li>
10+
</ul>
11+
</nav>
12+
</div>
13+
</div>
14+
</header>

app/views/layouts/_shim.html.erb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<!--[if lt IE 9]>
2+
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
3+
<![endif]-->
Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
<!DOCTYPE html>
22
<html>
3-
<head>
4-
<title>Ruby on Rails Tutorial Sample App | <%= yield(:title) %></title>
5-
<%= stylesheet_link_tag "application", :media => "all" %>
6-
<%= javascript_include_tag "application" %>
7-
<%= csrf_meta_tags %>
8-
</head>
9-
<body>
10-
11-
<%= yield %>
12-
13-
</body>
14-
</html>
3+
<head>
4+
<title><%= full_title(yield(:title)) %></title>
5+
<%= stylesheet_link_tag "application", media: "all" %>
6+
<%= javascript_include_tag "application" %>
7+
<%= csrf_meta_tags %>
8+
<%= render 'layouts/shim' %>
9+
</head>
10+
<body>
11+
<%= render 'layouts/header' %>
12+
<div class="container">
13+
<%= yield %>
14+
<%= render 'layouts/footer' %>
15+
</div>
16+
</body>
17+
</html>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<% provide(:title, 'Contact') %>
2+
<h1>Contact</h1>
3+
<p>
4+
Contact Ruby on Rails Tutorial about the sample app at the
5+
<a href="http://railstutorial.org/contact">contact page</a>.
6+
</p>

0 commit comments

Comments
 (0)