For today's drill, we're going to be creating a site like Emergency Compliment, except it will be WDI themed.
When a user visits the site, they'll be greeted with a WDI pick me up that will hopefully cheer them up.
Create a basic Sinatra app inside your drills
folder called pick_me_up
Create your main.rb
file and a views
folder. In your views
folder, you'll have a layout.erb
file and a compliment.erb
file.
When I visit the root "/"
of your app, it should display a greeting and a randomly chosen compliment. The background color of the app should be random as well.
Here is what my layout.erb
file looks like. Notice for the background color, I am taking advantage of the embedded Ruby to pass in the color and make it dynamic. Also, you should not need to link an external stylesheet for this exercise.
<!doctype html>
<html lang='en'>
<head>
<meta charset='utf-8'>
<title>PICK ME UP</title>
<style>
.wrapper {
background-color: <%= @color %>;
font-family: "Helvetica", "Arial", sans-serif;
color: white;
width: 960px;
margin: 0 auto;
}
div {
font-weight: bold;
font-size: 72px;
margin-top: 50px;
}
</style>
</head>
<body>
<h1>Emergency WDI Pickmeup</h1>
<%= yield %>
</body>
</html>
Here are some compliments and colors. Feel free to substitute your own:
compliments = [
"Your instructors love you",
"That's a really nice e-cigarette",
"Is it Ruby Tuesday yet?",
"You are awesome.upcase",
"Cardigan mumblecore Etsy, YOLO Marfa kogi art party",
"(1..1_000_000).to_a.include?(you) == true"
]
colors = ["#FFBF00", "#0080FF","#01DF3A","#FF0080"]
##Phase 2
When I visit "/:name"
ie "/sammy"
, the greeting should say hello to me. There should still be a random compliment and random background color.