Skip to content

Added About Me #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ GEM
eventmachine (0.12.10)
i18n (0.6.0)
multi_json (1.3.5)
rack (1.4.1)
rack (1.5.2)
rack-protection (1.2.0)
rack
rack-test (0.6.1)
Expand Down
11 changes: 3 additions & 8 deletions theweb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,9 @@
enable :sessions

get '/' do
@title = "Patrick Irwin"
likes = ["Turtles", "Cake", "Puppies", "Ruby", "Archer (The Cartoon)", "PC Games", "Stuff", "Apples", "Programming"]
@random_likes = likes[rand(likes.length)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some ruby coolness. Try

@random_likes = likes.sample

That'll return 1 random item, which is generally what you want. It won't be an array, so you may need to update that in the view.

And, to randomly sort an array, use .shuffle

erb :dashboard
end

post '/number' do
@number_of_randoms = session[:number_of_randoms] || 0
@number_of_randoms += 1
session[:number_of_randoms] = @number_of_randoms
number_as_string = params.fetch('number').to_i
@the_number = rand(number_as_string)
erb :number
end
2 changes: 2 additions & 0 deletions views/about.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<h1>About Me</h1>
<p> Oh Hello!</p>
17 changes: 11 additions & 6 deletions views/dashboard.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<h1>OH HAI THERE</h1>
<form method="POST" action="/number">
<label for="number">Max number for Randomitude</label>
<input type="text" id="number" name="number"/>
<input type="submit" class="btn btn-large btn-primary" value="View Number"/>
</form>
<h1>About Me</h1>
<div>
<p>Hi, I'm Pat!</p>
<p>I like things and stuff, they're pretty awesome!</p>
<p>I like:</p>
<ul>
<li>
<%= @random_likes %>!
</li>
</ul>
</div>
30 changes: 4 additions & 26 deletions views/layout.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
<title>Bootstrap, from Twitter</title>
<title> <%= @title %> </title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
Expand Down Expand Up @@ -42,11 +42,10 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="/">Randomizer</a>
<a class="brand" href="/">Patrick Irwin</a>
<div class="nav-collapse">
<ul class="nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#about">About</a></li>
<li class="active"><a href="/">Home</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</div><!--/.nav-collapse -->
Expand All @@ -61,31 +60,10 @@
<%= yield %>
</div>

<!-- Example row of columns -->
<div class="row">
<div class="span4">
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
<p><a class="btn" href="#">View details &raquo;</a></p>
</div>
<div class="span4">
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
<p><a class="btn" href="#">View details &raquo;</a></p>
</div>
<div class="span4">
<h2>Heading</h2>
<p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
<p><a class="btn" href="#">View details &raquo;</a></p>
</div>
</div>

<hr>

<footer>
<p>Number of Randoms: <%= @number_of_randoms %></p>
OH HAI THERE
<p>&copy; Company 2012</p>
<p>&copy; Patrick Irwin 2014</p>
</footer>

</div> <!-- /container -->
Expand Down