diff --git a/.gitignore b/.gitignore index 6c78296..17091f5 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,6 @@ # Ignore Byebug command history file. .byebug_history - + /config/locales/database.yml.example /config/locales/secrets.yml diff --git a/Gemfile b/Gemfile index b5fbf94..fcc13a0 100644 --- a/Gemfile +++ b/Gemfile @@ -1,53 +1,30 @@ -source 'https://rubygems.org' +source "https://rubygems.org" git_source(:github) do |repo_name| repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") "https://github.com/#{repo_name}.git" end - -# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem 'rails', '~> 5.0.2' -# Use sqlite3 as the database for Active Record -gem 'sqlite3' -# Use Puma as the app server -gem 'puma', '~> 3.0' -# Use SCSS for stylesheets -gem 'sass-rails', '~> 5.0' -# Use Uglifier as compressor for JavaScript assets -gem 'uglifier', '>= 1.3.0' -# Use CoffeeScript for .coffee assets and views -gem 'coffee-rails', '~> 4.2' -# See https://github.com/rails/execjs#readme for more supported runtimes -# gem 'therubyracer', platforms: :ruby - -# Use jquery as the JavaScript library -gem 'jquery-rails' -# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks -gem 'turbolinks', '~> 5' -# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder -gem 'jbuilder', '~> 2.5' -# Use Redis adapter to run Action Cable in production -# gem 'redis', '~> 3.0' -# Use ActiveModel has_secure_password -# gem 'bcrypt', '~> 3.1.7' - -# Use Capistrano for deployment -# gem 'capistrano-rails', group: :development +gem "rails", "~> 5.0.2" +gem "sqlite3" +gem "bootstrap-sass", "3.3.6" +gem "puma", "~> 3.0" +gem "sass-rails", "~> 5.0" +gem "uglifier", ">= 1.3.0" +gem "coffee-rails", "~> 4.2" +gem "jquery-rails" +gem "turbolinks", "~> 5" +gem "jbuilder", "~> 2.5" group :development, :test do - # Call 'byebug' anywhere in the code to stop execution and get a debugger console - gem 'byebug', platform: :mri + gem "byebug", platform: :mri end group :development do - # Access an IRB console on exception pages or by using <%= console %> anywhere in the code. - gem 'web-console', '>= 3.3.0' - gem 'listen', '~> 3.0.5' - # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring - gem 'spring' - gem 'spring-watcher-listen', '~> 2.0.0' + gem "web-console", ">= 3.3.0" + gem "listen", "~> 3.0.5" + gem "spring" + gem "spring-watcher-listen", "~> 2.0.0" end -# Windows does not include zoneinfo files, so bundle the tzinfo-data gem -gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] +gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby] diff --git a/Gemfile.lock b/Gemfile.lock index 559a447..239bcdb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -39,6 +39,11 @@ GEM minitest (~> 5.1) tzinfo (~> 1.1) arel (7.1.4) + autoprefixer-rails (6.7.7) + execjs + bootstrap-sass (3.3.6) + autoprefixer-rails (>= 5.2.1) + sass (>= 3.3.4) builder (3.2.3) byebug (9.0.6) coffee-rails (4.2.1) @@ -154,6 +159,7 @@ PLATFORMS ruby DEPENDENCIES + bootstrap-sass (= 3.3.6) byebug coffee-rails (~> 4.2) jbuilder (~> 2.5) diff --git a/app/assets/images/rails.png b/app/assets/images/rails.png new file mode 100644 index 0000000..f9fa0a0 Binary files /dev/null and b/app/assets/images/rails.png differ diff --git a/app/assets/stylesheets/custom.scss b/app/assets/stylesheets/custom.scss new file mode 100644 index 0000000..11f634f --- /dev/null +++ b/app/assets/stylesheets/custom.scss @@ -0,0 +1,42 @@ +@import "bootstrap-sprockets"; +@import "bootstrap"; + +/* universal */ + +body { + padding-top: 60px; +} + +section { + overflow: auto; +} + +textarea { + resize: vertical; +} + +.center { + text-align: center; +} + +.center h1 { + margin-bottom: 10px; +} + +/* header */ + +#logo { + float: left; + margin-right: 10px; + font-size: 1.7em; + color: #fff; + text-transform: uppercase; + letter-spacing: -1px; + padding-top: 9px; + font-weight: bold; +} + +#logo:hover { + color: #fff; + text-decoration: none; +} diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb deleted file mode 100644 index 1c07694..0000000 --- a/app/controllers/application_controller.rb +++ /dev/null @@ -1,3 +0,0 @@ -class ApplicationController < ActionController::Base - protect_from_forgery with: :exception -end diff --git a/app/controllers/static_pages_controller.rb b/app/controllers/static_pages_controller.rb new file mode 100644 index 0000000..953e2d7 --- /dev/null +++ b/app/controllers/static_pages_controller.rb @@ -0,0 +1,11 @@ +class StaticPagesController < ApplicationController + def home + end + + def help + end + + def about + end + +end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index de6be79..937a5de 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,2 +1,11 @@ module ApplicationHelper + + def full_title page_title = "" + base_title = "Ruby on Rails Tutorial Sample App" + if page_title.empty? + base_title + else + page_title + " | " + base_title + end + end end diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb new file mode 100644 index 0000000..faff04d --- /dev/null +++ b/app/views/layouts/_header.html.erb @@ -0,0 +1,12 @@ + diff --git a/app/views/layouts/_shim.html.erb b/app/views/layouts/_shim.html.erb new file mode 100644 index 0000000..ecfd51d --- /dev/null +++ b/app/views/layouts/_shim.html.erb @@ -0,0 +1,4 @@ + diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index c2501a3..9a079d1 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,14 +1,31 @@ - RubyK59 + <%= full_title(yield(:title)) %> <%= csrf_meta_tags %> - - <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> - <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> + <%= stylesheet_link_tag "application", media: "all", + "data-turbolinks-track": "reload" %> + <%= javascript_include_tag "application", "data-turbolinks-track": "reload" %> + - - <%= yield %> + +
+ <%= yield %> +
diff --git a/app/views/static_pages/about.html.erb b/app/views/static_pages/about.html.erb new file mode 100644 index 0000000..32e755e --- /dev/null +++ b/app/views/static_pages/about.html.erb @@ -0,0 +1,11 @@ +<% provide:title, "About" %> +

About

+

+ The Ruby on Rails + Tutorial is a + book and + screencast series + to teach web development with + Ruby on Rails. + This is the sample application for the tutorial. +

diff --git a/app/views/static_pages/help.html.erb b/app/views/static_pages/help.html.erb new file mode 100644 index 0000000..e975234 --- /dev/null +++ b/app/views/static_pages/help.html.erb @@ -0,0 +1,9 @@ +<% provide:title, "Help" %> +

Help

+

+ Get help on the Ruby on Rails Tutorial at the + Rails Tutorial help section. + To get help on this sample app, see the + Ruby on Rails Tutorial + book. +

diff --git a/app/views/static_pages/home.html.erb b/app/views/static_pages/home.html.erb new file mode 100644 index 0000000..c17a234 --- /dev/null +++ b/app/views/static_pages/home.html.erb @@ -0,0 +1,14 @@ +
+

Welcome to the Sample App

+ +

+ This is the home page for the + Ruby on Rails Tutorial + sample application. +

+ + <%= link_to "Sign up now!", "#", class: "btn btn-lg btn-primary" %> +
+ +<%= link_to image_tag("rails.png", alt: "Rails logo"), + "http://rubyonrails.org/" %> diff --git a/config/routes.rb b/config/routes.rb index 787824f..d336c91 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,3 +1,6 @@ Rails.application.routes.draw do - # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html + root "static_pages#home" + get "static_pages/home" + get "static_pages/help" + get "static_pages/about" end diff --git a/test/controllers/static_pages_controller_test.rb b/test/controllers/static_pages_controller_test.rb new file mode 100644 index 0000000..e9a0692 --- /dev/null +++ b/test/controllers/static_pages_controller_test.rb @@ -0,0 +1,14 @@ +require 'test_helper' + +class StaticPagesControllerTest < ActionDispatch::IntegrationTest + test "should get home" do + get static_pages_home_url + assert_response :success + end + + test "should get help" do + get static_pages_help_url + assert_response :success + end + +end