Skip to content

Commit ffdedcc

Browse files
committed
Finish layout and routes
1 parent 299fcf1 commit ffdedcc

File tree

15 files changed

+179
-6
lines changed

15 files changed

+179
-6
lines changed

Diff for: app/assets/images/rails.png

12.7 KB
Loading

Diff for: app/assets/javascripts/users.coffee

+3
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/

Diff for: app/assets/stylesheets/custom.css.scss

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

Diff for: app/assets/stylesheets/users.scss

+3
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/

Diff for: app/controllers/static_pages_controller.rb

+3
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@ def help
77

88
def about
99
end
10+
11+
def contact
12+
end
1013
end

Diff for: app/controllers/users_controller.rb

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class UsersController < ApplicationController
2+
def new
3+
end
4+
end

Diff for: app/helpers/users_helper.rb

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module UsersHelper
2+
end

Diff for: app/views/static_pages/contact.html.erb

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<% provide(:title, "Contact") %>
2+
<h1>Contact</h1>
3+
<p>Contact me at [email protected] </p>

Diff for: app/views/static_pages/home.html.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
sample application.
88
</h2>
99

10-
<%= link_to "Sign up now!", '#', class: "btn btn-lg btn-primary" %>
10+
<%= link_to "Sign up now!", signup_path, class: "btn btn-lg btn-primary" %>
1111
</div>
1212

1313
<%= link_to image_tag("rails.png", alt: "Rails logo"),

Diff for: app/views/users/new.html.erb

+3
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>

Diff for: config/routes.rb

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
Rails.application.routes.draw do
2-
root 'static_pages#home'
2+
get 'users/new'
33

4-
get 'static_pages/help'
5-
get 'static_pages/about'
6-
get 'static_pages/contact'
4+
root 'static_pages#home'
5+
get 'help' => 'static_pages#help'
6+
get 'about' => 'static_pages#about'
7+
get 'contact' => 'static_pages#contact'
8+
get 'signup' => 'users#new'
79

8-
910
end

Diff for: example_user.rb

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class User
2+
attr_accessor :name, :email
3+
4+
def initialize(attributes = {})
5+
@name = attributes[:name]
6+
@email = attributes[:email]
7+
end
8+
9+
def formatted_email
10+
"#{@name} <#{@email}>"
11+
end
12+
end

Diff for: test/controllers/users_controller_test.rb

+9
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

Diff for: test/integration/site_layout_test.rb

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

Diff for: words.rb

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
words = {}
2+
File.open("/usr/share/dict/words") do |file|
3+
file.each do |line|
4+
words[line.strip] = true
5+
end
6+
end
7+
8+
c = 0.0
9+
count = 100000
10+
for i in 0..count
11+
word = ('a'..'z').to_a.shuffle.join[0..5]
12+
if words[word]
13+
puts word
14+
c = c + 1
15+
end
16+
end
17+
puts c
18+
puts c/count

0 commit comments

Comments
 (0)