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

All files to Github #3

Open
wants to merge 1 commit 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
55 changes: 52 additions & 3 deletions movies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,64 @@
require 'sinatra/reloader'
require 'typhoeus'
require 'json'
require 'pry'

# A setup step to get rspec tests running.
configure do
root = File.expand_path(File.dirname(__FILE__))
set :views, File.join(root,'views')
set :views, File.join(root, 'views')
end


get '/' do
# redirect to form to get movie

@method = "get"
@action = "/movie"

erb :form
end

get '/movie' do

request = Typhoeus.get(
"http://www.omdbapi.com",
:params => { :s => params[:query]}
)

@movies = JSON.parse(request.body)["Search"]
@movies = @movies.sort_by {|element| element["Year"]}
@movies = @movies.reverse


@movie_info_index = {}
@movies.each do |element|

request2 = Typhoeus.get(
"http://www.omdbapi.com",
:params => { :i => element["imdbID"], :tomatoes => true}
)
request3 = JSON.parse(request2.body)
@movie_info_index[element["imdbID"].to_s] = request3

end
erb :index
end

get "/movie/:id" do
# show a particular movie
@id = params[:captures][0]

request = Typhoeus.get(
"http://www.omdbapi.com",
:params => { :i => @id, :tomatoes => true}
)

@movie_info = JSON.parse(request.body)
#raise @movie_info.inspect
#puts "NEW STRING http://api.rottentomatoes.com/api/public/v1.0/movie_alias.json?apikey=544r4dehy8m4bp5h4xtuzvd6&type=imdb&id=#{@id[2..-1]}"
request_tomatoes = Typhoeus.get("http://api.rottentomatoes.com/api/public/v1.0/movie_alias.json?apikey=544r4dehy8m4bp5h4xtuzvd6&type=imdb&id=#{@id[2..-1]}")
@tomatoes_data = JSON.parse(request_tomatoes.body)

erb :movie_view
end


Binary file added public/.DS_Store
Binary file not shown.
Binary file added public/stylesheets/.DS_Store
Binary file not shown.
129 changes: 129 additions & 0 deletions public/stylesheets/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
body {
text-align: center;
vertical-align: center;
background: white;
background-size: cover;
background-repeat: no-repeat;
opacity: .85;

}

h1 {
text-align: center;
vertical-align: center;
opacity: 1;
background-size: 50px;
font-family: 'Freckle Face', cursive;
font-weight: bold;
font-size: 1000%
}


h2 {
text-align: left;
opacity: 1;
background-size: 50px;
font-family: sans-serif;
font-weight: bold;
font-size: 200%
}

.newspaper-a
{
font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif;
font-size: 12px;
margin: 45px;
width: 600px;
text-align: left;
border-collapse: collapse;
}
#movie_list {
margin-left: auto;
margin-right: auto;
float: left;
border-collapse: none;
}

#movie_list td {
padding: 1em;
border: solid gray thin;
float: left;
}


.letter_1 {
color: blue;
float: left;
}


.letter_2 {
color: red;
float:left;
}


.letter_3 {
color: yellow;
float: left;
}


.letter_4 {
color: blue;
float: left;
}


.letter_5 {
color: green;
float: left;
}


.letter_6 {
color: red;
float: left;
}


.moogle {
margin: 0 auto;
width: 50%;
text-align: center;
}
.form {

margin: 0 auto;
width: 50%;
text-align: center;
font-size: 300%
}
.MoogleSearch {
margin: 0 auto;
width: 50%;
text-align: center;
font-size: 300%
}

button {
width: 300px;
height: 30px;

}

.poster {
text-align: left;
}

.details {
text-align: left;
font-size: 150%;
font-family: sans-serif;
font-weight: bold;
}

.attributes {
text-align: left;
font-family: sans-serif;
}
30 changes: 30 additions & 0 deletions views/form.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<head>

<title>
Moogle
</title>

</head>

<body>

<h1>
<div class = "moogle">
<div class = "letter_1">M</div>
<div class="letter_2">o</div>
<div class="letter_3">o</div>
<div class="letter_4">g</div>
<div class="letter_5">l</div>
<div class="letter_6">e</div>
</div>
</h1>
<br>
<div class = "form">
<form name="myform" method="<%= @method %>" action="<%= @action %>">
<input size = "100" width ="48" height="48" type="text" name="query" placeholder="<movie search>" required focus />
</div>
<div class = "MoogleSearch">
<button size = "100" type="submit">Moogle Search</button>
</form>
</div>
</body>
36 changes: 36 additions & 0 deletions views/index.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<div class = "form">
<form name="myform" method="<%= @method %>" action="<%= @action %>">
<input size = "100" width ="48" height="48" type="text" name="query" placeholder="<movie search>" required focus />
</div>
<div class = "MoogleSearch">
<button size = "100" type="submit">Moogle Search</button>
</form>
</div>

<h2> <%= "#{@movies.length} Results Shown" %> </h2>


<div>
<br>
<% @movies.each do |movie| %>
<div ><table class = .container><thead>
<!-- <td>Year</td>
<td>Title</td>
<td>Plot</td> -->
</thead><tbody>
<tr>
<td>
<%=movie["Year"]%>
</td>
<td>
<a class="list" href="/movie/<%= movie['imdbID'] %>" > <%=movie["Title"]%> </a>
</td>
<td>
<%=@movie_info_index[movie['imdbID']]["Plot"]%>
</td>
</tr>
</tbody>
</table></div>
<% end %>
</div>

4 changes: 3 additions & 1 deletion views/layout.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<!doctype html>
<html>
<head>
<title>Your Title Here</title>
<link href='http://fonts.googleapis.com/css?family=Freckle+Face' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="/stylesheets/styles.css" type="text/css">
<title>Moogle - The Movie Search Engine</title>
</head>
<body>
<%= yield %>
Expand Down
33 changes: 33 additions & 0 deletions views/movie_view.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<div class = "form">
<form name="myform" method="<%= @method %>" action="<%= @action %>">
<input size = "100" width ="48" height="48" type="text" name="query" placeholder="<movie search>" required focus />
</div>
<div class = "MoogleSearch">
<button size = "100" type="submit">Moogle Search</button>
</form>
</div>

<div class="poster">
<% if @movie_info["Poster"] == "N/A" %>
<h1>No Image Available</h1>
<% else %>
<img src="<%= @movie_info["Poster"] %>"
alt="no picture on file"></div>
<% end %>
<div class="details">
<h2><%= @movie_info["Title"] %></h2>
</div>
<div class="attributes">
Year: <%= @movie_info["Year"] %>, Rated: <%= @movie_info["Rated"] %>,
Runtime: <%= @movie_info["Runtime"] %></br>
Genre: <%= @movie_info["Genre"] %></br>
Director: <%= @movie_info["Director"] %></br>
Writer: <%= @movie_info["Writer"] %></br>
Rating: <%= @movie_info["imdbRating"] %></br>
Votes: <%= @movie_info["imdbVotes"] %></br>
Type: <%= @movie_info["Type"] %></br>
Plot: <%= @movie_info["Plot"] %></br>
</div>

<!-- <button onclick="changeBackground()" >Run JS</button> -->