Skip to content

Commit

Permalink
serving up movies in browse section with jquery. fixed nav
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgraffeocohen committed May 5, 2014
1 parent 6d5bf25 commit 6debf6c
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 14 deletions.
7 changes: 7 additions & 0 deletions app/assets/javascripts/movies.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
$(document).ready(function(){
$('#browse-button').click(function(){
if($('.row').length > 1) {
$('.row').last().remove();
}
});
});
1 change: 0 additions & 1 deletion app/assets/stylesheets/movie.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
}

#movie-options {
width: 1000px;
.poster-thumbnail {
position: absolute;
height: 292px;
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/movies_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def find_choices_for(range, genre)
max = range.max
min = range.min

Movie.joins(:genre_movies).where("genre_id = #{Genre.first.id} AND filmetric >= #{min} AND filmetric <= #{max}")
Movie.joins(:genre_movies).where("genre_id = #{genre.id} AND filmetric >= #{min} AND filmetric <= #{max}")
end

def quality_of(movie)
Expand Down
4 changes: 3 additions & 1 deletion app/views/layouts/_nav.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
<%= link_to_unless_current "Home", root_path do %>
<p>Home</p>
<% end %>
<%= link_to "Browse", browse_path %>
<%= link_to_unless_current "Browse", browse_path do %>
<p>Browse</p>
<% end %>
<%= link_to_unless_current "What the Hell Is This?", about_path do %>
<p>What the Hell Is This?</p>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<div class="row">
<div id="movie-options">
<% i = 0 %>
<% unless @choices.nil? || @choices.empty? %>
<% @choices.each do |movie| %>
<% unless choices.nil? || choices.empty? %>
<% choices.each do |movie| %>
<a href="<%= movie_path(movie) %>"><img class="poster-thumbnail" src="<%= movie.poster_link %>"
style="left: <%= 17 + i %>px;"></a>
<% i += 250 %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/movies/browse.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<%= render 'layouts/nav' %>
<div id="search-container">
<div class="form-group" id="search-box">
<%= form_tag discover_path, { :method => :get, :class => "form-inline" } do %>
<%= form_tag discover_path, { :method => :get, :class => "form-inline", :remote => true } do %>
<p class="browse-form"> I want a </p>

<%= label_tag :genre, "Genre", :class => "sr-only" %>
Expand All @@ -13,7 +13,7 @@
<%= label_tag :filmetric_eval, "Flimetric", :class => "sr-only" %>
<%= select_tag :filmetric_eval, options_from_collection_for_select(@filmetric_evals, "first", "second"), :class => "form-control input-lg", :id => "categories" %><br><br>

<%= submit_tag "Search", :class => "btn btn-lg btn-primary", :id => "search-button" %>
<%= submit_tag "Search", :class => "btn btn-lg btn-primary", :id => "browse-button" %>
<% end %>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions app/views/movies/discover.js.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$("body").append("<%= j render(:partial => 'options', locals: {choices: @choices}) %>")
7 changes: 0 additions & 7 deletions spec/models/imdb_scraper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@
expect(scraper.ids.length).to_not eq(0)
end

xit 'can scrape a specific figure\'s movies' do
url = IMDBScraper.find_page("Tom Cruise")
scraper.scrape

expect(scraper.ids).to include('0259711')
end

it 'can generate valid urls' do
new_url = scraper.generate_url(5)
scraper.nokogiri_query(new_url)
Expand Down

0 comments on commit 6debf6c

Please sign in to comment.