Skip to content

Instantly share code, notes, and snippets.

@adriancuadros
Last active August 29, 2015 14:21
Show Gist options
  • Save adriancuadros/2a221d2b0ea9a2fc5da8 to your computer and use it in GitHub Desktop.
Save adriancuadros/2a221d2b0ea9a2fc5da8 to your computer and use it in GitHub Desktop.
HackerSchool 1-7 Solution (Rack)
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="./read.css">
<title>Best gags</title>
</head>
<body>
<h1>Best gags</h1>
<div class='best-gag'>
<span>Joke with most points</span>
<h3><%= @reader.loved_gag.title %></h3>
<img src="<%= @reader.loved_gag.image_url %>" />
</div>
<div class='commented-gag'>
<span>Joke with most comments</span>
<h3><%= @reader.commented_gag.title %></h3>
<img src="<%= @reader.commented_gag.image_url %>" />
</div>
</body>
</html>
## nine_app.rb
class NineApp
def initialize
@reader = GagReader.new
end
def render
ERB.new(File.read('./practice/practice.erb')).result(binding)
end
end
nineapp = -> (env) { [ '200', {'Content-Type' => 'text-html'}, [NineApp.new.render] ] }
Rack::Handler::WEBrick.run nineapp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment