Skip to content

Commit cd8b18f

Browse files
committed
Finish layout and routes
1 parent bf54f6f commit cd8b18f

File tree

18 files changed

+184
-30
lines changed

18 files changed

+184
-30
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ source 'https://rubygems.org'
33

44
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
55
gem 'rails', '4.2.6'
6+
gem 'bootstrap-sass', '3.2.0.0'
67
# Use sqlite3 as the database for Active Record
78
gem 'sqlite3'
89
# Use SCSS for stylesheets

Gemfile.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ GEM
3939
arel (6.0.3)
4040
binding_of_caller (0.7.2)
4141
debug_inspector (>= 0.0.1)
42+
bootstrap-sass (3.2.0.0)
43+
sass (~> 3.2)
4244
builder (3.2.2)
4345
byebug (9.0.5)
4446
coffee-rails (4.1.1)
@@ -146,6 +148,7 @@ PLATFORMS
146148
ruby
147149

148150
DEPENDENCIES
151+
bootstrap-sass (= 3.2.0.0)
149152
byebug
150153
coffee-rails (~> 4.1.0)
151154
jbuilder (~> 2.0)

app/assets/images/rails.png

12.7 KB
Loading

app/assets/javascripts/users.coffee

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Place all the behaviors and hooks related to the matching controller here.
2+
# All this logic will automatically be available in application.js.
3+
# You can use CoffeeScript in this file: http://coffeescript.org/
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
@import "bootstrap-sprockets";
2+
@import "bootstrap";
3+
4+
body {
5+
padding-top: 60px;
6+
}
7+
section {
8+
overflow: auto;
9+
}
10+
textare {
11+
resize: vertical;
12+
}
13+
.center {
14+
text-align: center;
15+
h1 {
16+
margin-bottom: 10px;
17+
}
18+
}
19+
20+
h1, h2, h3, h4, h5, h6 {
21+
line-height: 1;
22+
}
23+
24+
h1 {
25+
font-size: 3em;
26+
letter-spacing: -2px;
27+
margin-bottom: 30px;
28+
text-align: center;
29+
}
30+
31+
h2 {
32+
font-size: 1.2em;
33+
letter-spacing: -1px;
34+
margin-bottom: 30px;
35+
text-align: center;
36+
font-weight: normal;
37+
color: #777;
38+
}
39+
40+
p {
41+
font-size: 1.1em;
42+
line-height: 1.7em;
43+
}
44+
#logo {
45+
float: left;
46+
margin-right: 10px;
47+
font-size: 1.7em;
48+
color: #fff;
49+
text-transform: uppercase;
50+
letter-spacing: -1px;
51+
padding-top: 9px;
52+
font-weight: bold;
53+
& :hover {
54+
color: #fff;
55+
text-decoration: none;
56+
}
57+
}
58+
59+
/* footer */
60+
61+
footer {
62+
margin-top: 45px;
63+
padding-top: 5px;
64+
border-top: 1px solid #eaeaea;
65+
color: #777;
66+
a {
67+
color: #555;
68+
&:hover {
69+
color: #222;
70+
}
71+
}
72+
small {
73+
float: left;
74+
}
75+
ul {
76+
float: right;
77+
list-style: none;
78+
}
79+
ul li {
80+
float: left;
81+
margin-left: 15px;
82+
}
83+
}
84+
85+

app/assets/stylesheets/users.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Place all the styles related to the Users controller here.
2+
// They will automatically be included in application.css.
3+
// You can use Sass (SCSS) here: http://sass-lang.com/

app/controllers/users_controller.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class UsersController < ApplicationController
2+
def new
3+
end
4+
end

app/helpers/users_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module UsersHelper
2+
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+
The <a href="http://www.railstutorial.org/">Ruby on Rails Tutorial</a>
4+
by <a href="http://www.michaelhartl.com/">Michael Hartl</a>
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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<header class="navbar navbar-fixed-top navbar-inverse">
2+
<div class="container">
3+
<%= link_to "sample app", '#', id: "logo" %>
4+
<nav>
5+
<ul class="nav navbar-nav navbar-right">
6+
<li><%= link_to "Home", root_path %></li>
7+
<li><%= link_to "Help", help_path %></li>
8+
<li><%= link_to "Log in", '#' %></li>
9+
</ul>
10+
</nav>
11+
</div>
12+
</header>

app/views/layouts/_shim.html.erb

Whitespace-only changes.
Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
<!DOCTYPE html>
22
<html>
3-
<head>
4-
<title><%= full_title(yield(:title))%> </title>
5-
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6-
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
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+
'data-turbolinks-track' => true %>
7+
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
8+
<%= csrf_meta_tags %>
9+
<%= render 'layouts/shim' %>
10+
</head>
11+
<body>
12+
<%= render 'layouts/header' %>
13+
<div class="container">
14+
<%= yield %>
15+
<%= render 'layouts/footer' %>
16+
</div>
17+
</body>
18+
</html>

app/views/static_pages/home.html.erb

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1+
<div class="center jumbotron">
2+
<h1>Welcome to the Sample App</h1>
13

2-
<h1>Sample App</h1>
3-
<p>
4-
This is the home page for the
5-
<a href="http://www.railstutorial.org/">Ruby on Rails Tutorial</a>
6-
sample application.
7-
</p>
4+
<h2>
5+
This is the home page for the
6+
<a href="http://www.railstutorial.org/">Ruby on Rails Tutorial</a>
7+
sample application.
8+
</h2>
89

10+
<%= link_to "Sign up now!", signup_path, class: "btn btn-lg btn-primary" %>
11+
</div>
12+
13+
<%= link_to image_tag("rails.png", alt: "Rails logo"),
14+
'http://rubyonrails.org/' %>

app/views/users/new.html.erb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<%provide(:title, 'Sign up')%>
2+
<h1>Sign up</h1>
3+
<p>This will be a signup page for new users.</p>

config/routes.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
Rails.application.routes.draw do
2+
get 'users/new'
3+
24
root 'static_pages#home'
3-
get 'static_pages/help'
4-
get 'static_pages/about'
5-
get 'static_pages/contact'
5+
get 'help' => 'static_pages#help'
6+
get 'about' => 'static_pages#about'
7+
get 'contact' => 'static_pages#contact'
8+
get 'signup' => 'users#new'
69

710

811
# The priority is based upon order of creation: first created -> highest priority.

test/controllers/static_pages_controller_test.rb

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22

33
class StaticPagesControllerTest < ActionController::TestCase
44

5-
#def setup
6-
# @base_title = "Ruby on Rails Tutorial Sample App"
7-
8-
# end
95
test "should get home" do
106
get :home
117
assert_response :success
@@ -30,9 +26,4 @@ class StaticPagesControllerTest < ActionController::TestCase
3026
assert_select "title", "About | Ruby on Rails Tutorial Sample App"
3127
end
3228

33-
#test "shout get about" do
34-
# get :static_pages_help_url
35-
# assert_response :success
36-
#end
37-
3829
end
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
require 'test_helper'
2+
3+
class UsersControllerTest < ActionController::TestCase
4+
test "should get new" do
5+
get :new
6+
assert_response :success
7+
end
8+
9+
end

test/integration/site_layout_test.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
require 'test_helper'
2+
3+
class SiteLayoutTest < ActionDispatch::IntegrationTest
4+
test "layout links" do
5+
get root_path
6+
assert_template 'static_pages/home'
7+
assert_select "a[href=?]", root_path, count: 2
8+
assert_select "a[href=?]", help_path
9+
assert_select "a[href=?]", about_path
10+
assert_select "a[href=?]", contact_path
11+
end
12+
end

0 commit comments

Comments
 (0)