Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Finish layout and routes

  • Loading branch information...
commit 7e3cc23a2ecc7bbff108c7c6f994eb22310e3e78 1 parent d85e0cb
Jason Kim authored
View
4 Gemfile
@@ -1,6 +1,8 @@
source 'https://rubygems.org'
-gem 'rails', '3.2.1'
+gem 'rails', '3.2.2'
+gem 'bootstrap-sass', '2.0.0'
+
group :development, :test do
gem 'sqlite3', '1.3.5'
View
54 Gemfile.lock
@@ -1,12 +1,12 @@
GEM
remote: https://rubygems.org/
specs:
- actionmailer (3.2.1)
- actionpack (= 3.2.1)
+ actionmailer (3.2.2)
+ actionpack (= 3.2.2)
mail (~> 2.4.0)
- actionpack (3.2.1)
- activemodel (= 3.2.1)
- activesupport (= 3.2.1)
+ actionpack (3.2.2)
+ activemodel (= 3.2.2)
+ activesupport (= 3.2.2)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.1)
@@ -14,21 +14,22 @@ GEM
rack-cache (~> 1.1)
rack-test (~> 0.6.1)
sprockets (~> 2.1.2)
- activemodel (3.2.1)
- activesupport (= 3.2.1)
+ activemodel (3.2.2)
+ activesupport (= 3.2.2)
builder (~> 3.0.0)
- activerecord (3.2.1)
- activemodel (= 3.2.1)
- activesupport (= 3.2.1)
- arel (~> 3.0.0)
+ activerecord (3.2.2)
+ activemodel (= 3.2.2)
+ activesupport (= 3.2.2)
+ arel (~> 3.0.2)
tzinfo (~> 0.3.29)
- activeresource (3.2.1)
- activemodel (= 3.2.1)
- activesupport (= 3.2.1)
- activesupport (3.2.1)
+ activeresource (3.2.2)
+ activemodel (= 3.2.2)
+ activesupport (= 3.2.2)
+ activesupport (3.2.2)
i18n (~> 0.6)
multi_json (~> 1.0)
arel (3.0.2)
+ bootstrap-sass (2.0.0)
builder (3.0.0)
capybara (1.1.2)
mime-types (>= 1.16)
@@ -74,17 +75,17 @@ GEM
rack
rack-test (0.6.1)
rack (>= 1.0)
- rails (3.2.1)
- actionmailer (= 3.2.1)
- actionpack (= 3.2.1)
- activerecord (= 3.2.1)
- activeresource (= 3.2.1)
- activesupport (= 3.2.1)
+ rails (3.2.2)
+ actionmailer (= 3.2.2)
+ actionpack (= 3.2.2)
+ activerecord (= 3.2.2)
+ activeresource (= 3.2.2)
+ activesupport (= 3.2.2)
bundler (~> 1.0)
- railties (= 3.2.1)
- railties (3.2.1)
- actionpack (= 3.2.1)
- activesupport (= 3.2.1)
+ railties (= 3.2.2)
+ railties (3.2.2)
+ actionpack (= 3.2.2)
+ activesupport (= 3.2.2)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
@@ -137,11 +138,12 @@ PLATFORMS
ruby
DEPENDENCIES
+ bootstrap-sass (= 2.0.0)
capybara (= 1.1.2)
coffee-rails (= 3.2.2)
jquery-rails (= 2.0.0)
pg (= 0.12.2)
- rails (= 3.2.1)
+ rails (= 3.2.2)
rspec-rails (= 2.8.1)
sass-rails (= 3.2.4)
sqlite3 (= 1.3.5)
View
3  app/assets/javascripts/users.js.coffee
@@ -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://jashkenas.github.com/coffee-script/
View
102 app/assets/stylesheets/custom.css.scss
@@ -0,0 +1,102 @@
+@import "bootstrap";
+
+/* mixins, variables, etc. */
+
+$grayMediumLight: #eaeaea;
+
+/* universal */
+
+html {
+ overflow-y: scroll;
+}
+
+body {
+ padding-top: 60px;
+}
+
+section {
+ overflow: auto;
+}
+
+textarea {
+ resize: vertical;
+}
+
+.center {
+ text-align: 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.7em;
+ letter-spacing: -1px;
+ margin-bottom: 30px;
+ text-align: center;
+ font-weight: normal;
+ color: $grayLight;
+}
+
+p {
+ font-size: 1.1em;
+ line-height: 1.7em;
+}
+
+
+/* header */
+
+#logo {
+ float: left;
+ margin-right: 10px;
+ font-size: 1.7em;
+ color: white;
+ text-transform: uppercase;
+ letter-spacing: -1px;
+ padding-top: 9px;
+ font-weight: bold;
+ line-height: 1;
+ &:hover {
+ color: white;
+ text-decoration: none;
+ }
+}
+
+/* footer */
+
+footer {
+ margin-top: 45px;
+ padding-top: 5px;
+ border-top: 1px solid $grayMediumLight;
+ color: $grayLight;
+ a {
+ color: $gray;
+ &:hover {
+ color: $grayDarker;
+ }
+ }
+ small {
+ float: left;
+ }
+ ul {
+ float: right;
+ list-style: none;
+ li {
+ float: left;
+ margin-left: 10px;
+ }
+ }
+}
View
3  app/assets/stylesheets/users.css.scss
@@ -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/
View
3  app/controllers/static_pages_controller.rb
@@ -7,4 +7,7 @@ def help
def about
end
+
+ def contact
+ end
end
View
4 app/controllers/users_controller.rb
@@ -0,0 +1,4 @@
+class UsersController < ApplicationController
+ def new
+ end
+end
View
8 app/helpers/application_helper.rb
@@ -1,2 +1,10 @@
module ApplicationHelper
+ def full_title(page_title)
+ base_title = "Ruby on Rails Tutorial Sample App"
+ if page_title.empty?
+ return base_title
+ else
+ "#{base_title} | #{page_title}"
+ end
+ end
end
View
2  app/helpers/users_helper.rb
@@ -0,0 +1,2 @@
+module UsersHelper
+end
View
13 app/views/layouts/_footer.html.erb
@@ -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>
View
14 app/views/layouts/_header.html.erb
@@ -0,0 +1,14 @@
+<header class="navbar navbar-fixed-top">
+ <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>
View
3  app/views/layouts/_shim.html.erb
@@ -0,0 +1,3 @@
+<!--[if lt IE 9]>
+<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
+<![endif]-->
View
12 app/views/layouts/application.html.erb
@@ -1,13 +1,17 @@
-
<!DOCTYPE html>
<html>
<head>
- <title>Ruby on Rails Tutorial Sample App | <%= yield(:title) %></title>
- <%= stylesheet_link_tag "application", :media => "all" %>
+ <title><%= full_title(yield(:title)) %></title>
+ <%= stylesheet_link_tag "application", media: "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
+ <%= render 'layouts/shim' %>
</head>
<body>
- <%= yield %>
+ <%= render 'layouts/header' %>
+ <div class="container">
+ <%= yield %>
+ <%= render 'layouts/footer' %>
+ </div>
</body>
</html>
View
2  app/views/static_pages/about.html.erb
@@ -5,4 +5,4 @@
is a project to make a book and screencasts to teach web development
with <a href="http://rubyonrails.org/">Ruby on Rails</a>. This
is the sample application for the tutorial.
-</p>
+</p>
View
6 app/views/static_pages/contact.html.erb
@@ -0,0 +1,6 @@
+<% provide(:title, 'Contact')%>
+<h1>Contact</h1>
+<p>
+ Contact Ruby on Rails Tutorial about the sample app at the
+ <a href="http://railstutorial.org/contact">contact page</a>.
+</p>
View
20 app/views/static_pages/home.html.erb
@@ -1,7 +1,13 @@
-<% provide(:title, 'Home') %>
-<h1>Sample App</h1>
-<p>
- This is the home page for the
- <a href="http://railstutorial.org/">Ruby on Rails Tutorial</a>
- sample application.
-</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.
+ </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/' %>
View
3  app/views/users/new.html.erb
@@ -0,0 +1,3 @@
+<% provide(:title, 'Sign up') %>
+<h1>Sign Up</h1>
+<p>Find me in app/views/users/new.html.erb</p>
View
66 config/routes.rb
@@ -1,63 +1,13 @@
SampleApp::Application.routes.draw do
- get "static_pages/home"
+ get "users/new"
- get "static_pages/help"
- get "static_pages/about"
+ root to: 'static_pages#home'
+ # match '/', to: 'static_pages#home'
+
+ match '/signup', to: 'users#new'
- # The priority is based upon order of creation:
- # first created -> highest priority.
+ match '/help', to: 'static_pages#help'
+ match '/about', to: 'static_pages#about'
+ match '/contact', to: 'static_pages#contact'
- # Sample of regular route:
- # match 'products/:id' => 'catalog#view'
- # Keep in mind you can assign values other than :controller and :action
-
- # Sample of named route:
- # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
- # This route can be invoked with purchase_url(:id => product.id)
-
- # Sample resource route (maps HTTP verbs to controller actions automatically):
- # resources :products
-
- # Sample resource route with options:
- # resources :products do
- # member do
- # get 'short'
- # post 'toggle'
- # end
- #
- # collection do
- # get 'sold'
- # end
- # end
-
- # Sample resource route with sub-resources:
- # resources :products do
- # resources :comments, :sales
- # resource :seller
- # end
-
- # Sample resource route with more complex sub-resources
- # resources :products do
- # resources :comments
- # resources :sales do
- # get 'recent', :on => :collection
- # end
- # end
-
- # Sample resource route within a namespace:
- # namespace :admin do
- # # Directs /admin/products/* to Admin::ProductsController
- # # (app/controllers/admin/products_controller.rb)
- # resources :products
- # end
-
- # You can have the root of your site routed with "root"
- # just remember to delete public/index.html.
- # root :to => 'welcome#index'
-
- # See how all your routes lay out with "rake routes"
-
- # This is a legacy wild controller route that's not recommended for RESTful applications.
- # Note: This route will make all actions in every controller accessible via GET requests.
- # match ':controller(/:action(/:id))(.:format)'
end
View
57 spec/requests/static_pages_spec.rb
@@ -2,45 +2,34 @@
describe "Static pages" do
+ subject { page }
+
describe "Home page" do
+ before { visit root_path }
- it "should have the content 'Sample App'" do
- visit '/static_pages/home'
- page.should have_content('Sample App')
- end
-
- it "should have the title 'home'" do
- visit '/static_pages/home'
- page.should have_selector('title',
- :text => "Ruby on Rails Tutorial Sample App | Home"
- )
- end
+ it { should have_selector('h1', text: 'Sample App') }
+ it { should have_selector('title', text: full_title('')) }
+ it { should_not have_selector 'title', text: '| Home' }
end
-
+
describe "Help page" do
-
- it "should havee the content 'Help'" do
- visit '/static_pages/help'
- page.should have_content('Help')
- end
-
- it "should have the title 'Help'" do
- visit '/static_pages/help'
- page.should have_selector('title',
- :text => "Ruby on Rails Tutorial Sample App | Help")
- end
+ before { visit help_path }
+
+ it { should have_selector('h1', text: 'Help') }
+ it { should have_selector('title', text: full_title('Help')) }
end
-
+
describe "About page" do
- it "should have the content 'About Us'" do
- visit '/static_pages/about'
- page.should have_content('About Us')
- end
-
- it "should have the title 'About Us'" do
- visit '/static_pages/about'
- page.should have_selector('title',
- :text => "Ruby on Rails Tutorial Sample App | About Us")
- end
+ before { visit about_path }
+
+ it { should have_selector('h1', text: 'About') }
+ it { should have_selector('title', text: full_title('About Us')) }
+ end
+
+ describe "Contact page" do
+ before { visit contact_path }
+
+ it { should have_selector('h1', text: 'Contact') }
+ it { should have_selector('title', text: full_title('Contact')) }
end
end
View
12 spec/requests/user_pages_spec.rb
@@ -0,0 +1,12 @@
+require 'spec_helper'
+
+describe "User pages" do
+ subject { page }
+
+ describe "signup page" do
+ before { visit signup_path }
+
+ it { should have_selector('h1', text: 'Sign Up') }
+ it { should have_selector('title', text: full_title('Sign up')) }
+ end
+end
View
8 spec/support/utilities.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.