Skip to content
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

submission #22

Open
wants to merge 4 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
Binary file added .DS_Store
Binary file not shown.
21 changes: 21 additions & 0 deletions app.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require 'sinatra'
require 'sinatra/reloader'
require 'typhoeus'
require 'json'
require 'pry'

get '/' do
erb :index
end

get '/show' do
search = Typhoeus.get("www.omdbapi.com/", :params => {:s => params[:movie]})
@result = JSON.parse(search.body)["Search"]
erb :show
end

get '/movie_info/:imdbID' do
search = Typhoeus.get("www.omdbapi.com/", :params => {:i => params["imdbID"]})
@result2 = JSON.parse(search.body)
erb :movie_info
end
Binary file added public/.DS_Store
Binary file not shown.
Binary file added public/img/.DS_Store
Binary file not shown.
Binary file added public/img/bg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/indexbg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions public/index.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<h1>ENTER YOUR SEARCH HERE!</h1>
<form action="/results" method="get">
<input type="text" name="movie" >
<button>Submit</button>
</form>
Binary file added public/movie-theater.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 71 additions & 0 deletions public/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added spec/.DS_Store
Binary file not shown.
8 changes: 8 additions & 0 deletions spec/movies_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,13 @@ def app
end
end

describe "Show Page" do
it "should allow access to the show page" do
get '/show'
last_response.should be_ok
end
end
end


end
4 changes: 4 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#poster {
color: red;
text-align: center;
}
17 changes: 17 additions & 0 deletions test
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

<trailers>
<trailer>
<title>The Fault in Our Stars: Trailer</title>
<link>
http://www.traileraddict.com/the-fault-in-our-stars/trailer
</link>
<pubDate>Wed, 29 Jan 2014 10:11:53 -0800</pubDate>
<trailer_id>86052</trailer_id>
<imdb>2582846</imdb>
<embed>
<![CDATA[
<iframe width="480" height="270" src="http://v.traileraddict.com/86052" allowfullscreen="true" webkitallowfullscreen="true" mozallowfullscreen="true" scrolling="no" frameborder="0"></iframe>
]]>
</embed>
</trailer>
</trailers>
17 changes: 17 additions & 0 deletions test.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

<trailers>
<trailer>
<title>The Fault in Our Stars: Trailer</title>
<link>
http://www.traileraddict.com/the-fault-in-our-stars/trailer
</link>
<pubDate>Wed, 29 Jan 2014 10:11:53 -0800</pubDate>
<trailer_id>86052</trailer_id>
<imdb>2582846</imdb>
<embed>
<![CDATA[
<iframe width="480" height="270" src="http://v.traileraddict.com/86052" allowfullscreen="true" webkitallowfullscreen="true" mozallowfullscreen="true" scrolling="no" frameborder="0"></iframe>
]]>
</embed>
</trailer>
</trailers>
17 changes: 17 additions & 0 deletions test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

<trailers>
<trailer>
<title>The Fault in Our Stars: Trailer</title>
<link>
http://www.traileraddict.com/the-fault-in-our-stars/trailer
</link>
<pubDate>Wed, 29 Jan 2014 10:11:53 -0800</pubDate>
<trailer_id>86052</trailer_id>
<imdb>2582846</imdb>
<embed>
<![CDATA[
<iframe width="480" height="270" src="http://v.traileraddict.com/86052" allowfullscreen="true" webkitallowfullscreen="true" mozallowfullscreen="true" scrolling="no" frameborder="0"></iframe>
]]>
</embed>
</trailer>
</trailers>
Binary file added views/.DS_Store
Binary file not shown.
19 changes: 19 additions & 0 deletions views/index.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<head>
<link type="text/css" rel="stylesheet" href="style.css" />
<title>index</title>
</head>
<body>
<div class="container">
<div id="index_bg"
<div class="form">
<h1>ENTER YOUR SEARCH HERE!</h1>
<form action="/show" method="get">
<input type="text" name="movie" >
<button>Submit</button>
</div>
</div>
</div>
</form>
</body>


3 changes: 2 additions & 1 deletion views/layout.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<!doctype html>
<html>
<head>
<title>Your Title Here</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Mahoo</title>
</head>
<body>
<%= yield %>
Expand Down
35 changes: 35 additions & 0 deletions views/movie_info.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<head>
<link type="text/css" rel="stylesheet" href="style.css" />
<title>Movie Info</title>
</head>
<body>
<div class="container"
<div onload="changeBackground()" >
<div id="poster">
<% if @result2["Poster"] == "N/A" %>
<h1>No Image Available</h1>
<% else %>
<img src="<%= @result2["Poster"] %>"
alt="no picture on file"></div>
<% end %>
<div id="details">
<h2><%= @result2["Title"] %></h2>
<ul>
<li>Year: <%= @result2["Year"] %>, Rated: <%= @result2["Rated"] %></li>
<li>Runtime: <%= @result2["Runtime"] %></li>
<li>Genre: <%= @result2["Genre"] %></li>
<li>Director: <%= @result2["Director"] %></li>
<li>Writer: <%= @result2["Writer"] %></li>
<li>Rating: <%= @result2["imdbRating"] %></li>
<li>Votes: <%= @result2["imdbVotes"] %></li>
<li>Type: <%= @result2["Type"] %></li>
<li>Plot: <%= @result2["Plot"] %></li>
</ul>
</div>
<div>
</br>
<a href="/"><button >Movie Search</button></a>
</div>
</div>
</div>
</body>
33 changes: 33 additions & 0 deletions views/show.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<head>
<link type="text/css" rel="stylesheet" href="style.css" />
<title>Results</title>
</head>
<body>
<div class="container"
<div id="no_result">
<% if @result == nil %>
<h2> No Results </h2>
<div class="search">
</br>
<a href="/"><button >Movie Search</button></a>
</div>
<% else %>
</div>
<div id="result">
<h2>Select a Movie</h2>
<% @result.each do |movie| %>
<ul>
<li>
<a class="list" href="/movie_info/<%= movie['imdbID'] %>" >
<%= movie["Title"] %>
</a>
</li>
</ul>
<% end %>
<div>
<a href="/"><button>Movie Search</button></a>
</div>
</div>
<% end %>
</div>
</body>