Skip to content

Commit

Permalink
Finish layout and routes
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaslorenz committed Jun 28, 2014
1 parent b85c3db commit 6936e90
Show file tree
Hide file tree
Showing 19 changed files with 236 additions and 55 deletions.
19 changes: 18 additions & 1 deletion .idea/sample_app.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added app/assets/images/rails.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions app/assets/javascripts/users.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
98 changes: 98 additions & 0 deletions app/assets/stylesheets/custom.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
@import "bootstrap";
$lightgray: #999;
/* universal */

html {
overflow-y: scroll;
}

body {
padding-top: 60px;
}

section {
overflow: auto;
}

textarea {
resize: vertical;
}

.center {
text-align: center;
}

.center h1 {
margin-bottom: 10px;
}

/* typography */

h1, h2, h3, h4, h5, h6 {
line-height: 1;
}

h1 {
font-size: 3em;
letter-spacing: -2px;
margin-bottom: 30px;
text-align: center;
}
h2 {
font-size: 1.2em;
letter-spacing: -1px;
margin-bottom: 30px;
text-align: center;
font-weight: normal;
color: $lightgray;
}

p {
font-size: 1.1em;
line-height: 1.7em;
}

/* header */

#logo {
float: left;
margin-left: 10px;
font-size: 1.7em;
color: #fff;
text-transform: uppercase;
letter-spacing: -1px;
padding-top: 9px;
font-weight: bold;
line-height: 1;
&:hover {
color: #fff;
text-decoration: none;
}
}


/* footer */

footer {
margin-top: 45px;
padding-top: 5px;
border-top: 1px solid #eaeaea;
color: $lightgray;
a {
color: #555;
&:hover{
color: #222;
}
}
small {
float: left;
}
ul {
float: right;
list-style: none;
li {
float: left;
margin-left: 10px;
}
}
}
3 changes: 3 additions & 0 deletions app/assets/stylesheets/users.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the Users controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
4 changes: 4 additions & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class UsersController < ApplicationController
def new
end
end
2 changes: 2 additions & 0 deletions app/helpers/users_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module UsersHelper
end
13 changes: 13 additions & 0 deletions app/views/layouts/_footer.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<footer class="footer">
<small>
<a href="http://railstutorial.org/">Rails Tutorial</a>
by Michael Hartl
</small>
<nav>
<ul>
<li><%= link_to "About", about_path %></li>
<li><%= link_to "Contact", contact_path %></li>
<li><a href="http://news.railstutorial.org/">News</a></li>
</ul>
</nav>
</footer>
14 changes: 14 additions & 0 deletions app/views/layouts/_header.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<header class="navbar navbar-fixed-top navbar-inverse">
<div class="navbar-inner">
<div class="container">
<%= link_to "sample app", root_path, id: "logo" %>
<nav>
<ul class="nav pull-right">
<li><%= link_to "Home", root_path %></li>
<li><%= link_to "Help", help_path %></li>
<li><%= link_to "Sign in", '#' %></li>
</ul>
</nav>
</div>
</div>
</header>
3 changes: 3 additions & 0 deletions app/views/layouts/_shim.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
13 changes: 9 additions & 4 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@
<html>
<head>
<title><%= full_title(yield(:title)) %></title>
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
<%= stylesheet_link_tag "application", media: "all",
"data-turbolinks-track" => true %>
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
<%= csrf_meta_tags %>
<%= render 'layouts/shim' %>
</head>
<body>

<%= yield %>
<%= render 'layouts/header' %>
<div class="container">
<%= yield %>
<%= render 'layouts/footer' %>
</div>

</body>
</html>
</html>
14 changes: 10 additions & 4 deletions app/views/static_pages/home.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
<h1>Sample App</h1>
<p>
<div class="center hero-unit">
<h1>Welcome to the Sample App</h1>

<h2>
This is the home page for the
<a href="http://railstutorial.org/">Ruby on Rails Tutorial</a>
sample application
</p>
sample application.
</h2>

<%= link_to "Sign up now!", signup_path, class: "btn btn-large btn-primary" %>
</div>

<%= link_to image_tag("rails.png", alt: "Rails"), 'http://rubyonrails.org/' %>
3 changes: 3 additions & 0 deletions app/views/users/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<% provide(:title, 'Sign up') %>
<h1>Sign up</h1>
<p>Find me in app/views/users/new.html.erb</p>
1 change: 1 addition & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ class Application < Rails::Application
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif)
end
end
12 changes: 8 additions & 4 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
SampleApp::Application.routes.draw do
get "static_pages/home"
get "static_pages/help"
get "static_pages/about"
get "static_pages/contact"
get "users/new"

root 'static_pages#home'
match '/signup', to: 'users#new', via: 'get'
match '/help', to: 'static_pages#help', via: 'get'
match '/about', to: 'static_pages#about', via: 'get'
match '/contact', to: 'static_pages#contact', via: 'get'

# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".

Expand Down
12 changes: 12 additions & 0 deletions spec/controllers/users_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require 'spec_helper'

describe UsersController do

describe "GET 'new'" do
it "returns http success" do
get 'new'
response.should be_success
end
end

end
56 changes: 14 additions & 42 deletions spec/requests/static_pages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,57 +3,29 @@
describe "Static pages" do

let(:base_title) {"Ruby on Rails Tutorial Sample App"}
subject { page }
describe "Home page" do

it "should have the content 'Sample App'" do
visit '/static_pages/home'
expect(page).to have_content('Sample App')
end
it "should have the right title" do
visit '/static_pages/home'
expect(page).to have_title("#{base_title}")
end
it "should not have custom title" do
visit '/static_pages/home'
expect(page).not_to have_title('| Home')
end

before { visit root_path }
it {should have_content('Sample App')}
it {should have_title(full_title(''))}
it {should_not have_title('| Home')}
end

describe "Help page" do

it "should have the content 'Help'" do
visit '/static_pages/help'
expect(page).to have_content('Help')
end

it "should have the right title" do
visit '/static_pages/help'
expect(page).to have_title("#{base_title} | Help")
end
before { visit help_path }
it {should have_content('Help')}
it {should have_title(full_title('Help'))}
end

describe "About page" do

it "should have the content 'About'" do
visit '/static_pages/about'
expect(page).to have_content('About Us')
end
it "should have the right title" do
visit '/static_pages/about'
expect(page).to have_title("#{base_title} | About")
end
before { visit about_path }
it {should have_content('About Us')}
it {should have_title('About')}
end

describe "Contact page" do
it "should have the content 'Contact'" do
visit '/static_pages/contact'
expect(page).to have_content('Contact')
end
it "should have the right title" do
visit '/static_pages/contact'
expect(page).to have_title("#{base_title} | Contact")
end
before { visit contact_path }
it {should have_content('Contact')}
it {should have_title('Contact')}
end

end
13 changes: 13 additions & 0 deletions spec/requests/user_pages_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require 'spec_helper'

describe "User pages" do

subject { page }

describe "signup page" do
before { visit signup_path }

it { should have_content('Sign up') }
it { should have_title(full_title('Sign up')) }
end
end
8 changes: 8 additions & 0 deletions spec/support/utilities.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
def full_title(page_title)
base_title = 'Ruby on Rails Tutorial Sample App'
if page_title.empty?
base_title
else
"#{base_title} | #{page_title}"
end
end

0 comments on commit 6936e90

Please sign in to comment.