Skip to content

Commit cdf7b55

Browse files
unknownunknown
unknown
authored and
unknown
committed
Made links skip 'dumb' search page and go straight to movies, adjusted styling for filter controls, made movies display title with article in front, added title to a few search buttons, fixed bug with sort filters disappearing, changed jqueryui font to AftasansRegular instead of Candara
1 parent 03efe02 commit cdf7b55

17 files changed

+51
-58
lines changed

app/assets/javascripts/home.js.coffee

+4-3
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ jQuery ->
4343
for actor in dataactors
4444
data.push(
4545
label: actor.firstname + " " + actor.lastname
46-
value: "actors/" + actor.id
46+
value: "movies?actor=" + actor.firstname + " " + actor.lastname
4747
category: "Actor"
4848
)
4949
for genre in datagenres
5050
data.push(
5151
label: genre.name
52-
value: "genres/" + genre.id
52+
value: "movies?genre=" + genre.name
5353
category: "Genre"
5454
)
5555
console.log(datamovies)
@@ -60,5 +60,6 @@ jQuery ->
6060
event.preventDefault()
6161
$(this).catcomplete("close")
6262
$(this).val(ui.item.label)
63-
location.pathname = ui.item.value
63+
console.log(ui.item.value)
64+
location.assign(ui.item.value)
6465
)

app/assets/javascripts/movies.js.coffee

-6
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@ jQuery ->
99
noneSelectedText: "Select actors",
1010
selectedText: "# actors selected"
1111
).multiselectfilter()
12-
$("select#genre").multiselect(
13-
multiple: false,
14-
selectedList: 1,
15-
header: "Select a genre",
16-
noneSelectedText: "Select a genre"
17-
)
1812
$("#filters-toggle").click( ->
1913
$("#new-filters").toggle("blind")
2014
)

app/assets/stylesheets/home.css.scss

+10
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,16 @@ p.info {
241241
#filters-toggle {
242242
text-align: center;
243243
cursor: pointer;
244+
font-size: 16px;
245+
padding: 0;
246+
}
247+
#new-filters {
248+
padding: 5px;
249+
}
250+
#filters-toggle > span:first-child {
251+
display: inline-block;
252+
margin-right: 16px;
253+
margin-top: 0.2em;
244254
}
245255

246256
@media screen and (max-width: 650px) {

app/assets/stylesheets/jquery-ui-1.10.1.custom.css

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*! jQuery UI - v1.10.1 - 2013-02-18
22
* http://jqueryui.com
33
* Includes: jquery.ui.core.css, jquery.ui.resizable.css, jquery.ui.selectable.css, jquery.ui.accordion.css, jquery.ui.autocomplete.css, jquery.ui.button.css, jquery.ui.datepicker.css, jquery.ui.dialog.css, jquery.ui.menu.css, jquery.ui.progressbar.css, jquery.ui.slider.css, jquery.ui.spinner.css, jquery.ui.tabs.css, jquery.ui.tooltip.css
4-
* To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=Candara%2CArial%2Csans-serif&fwDefault=normal&fsDefault=14px&cornerRadius=5px&bgColorHeader=%230a7694&bgTextureHeader=highlight_soft&bgImgOpacityHeader=75&borderColorHeader=%2300bff3&fcHeader=%23eaf5f7&iconColorHeader=%23d8e7f3&bgColorContent=%23fcfcfc&bgTextureContent=highlight_soft&bgImgOpacityContent=100&borderColorContent=%23a6c9e2&fcContent=%23222222&iconColorContent=%23008fae&bgColorDefault=%2300bff3&bgTextureDefault=highlight_soft&bgImgOpacityDefault=45&borderColorDefault=%2300bff3&fcDefault=%23ffffff&iconColorDefault=%23e0fdff&bgColorHover=%2375e2ff&bgTextureHover=highlight_soft&bgImgOpacityHover=75&borderColorHover=%231496b3&fcHover=%230f6080&iconColorHover=%23116a8d&bgColorActive=%2336e935&bgTextureActive=highlight_soft&bgImgOpacityActive=50&borderColorActive=%230f7b0e&fcActive=%23ffffff&iconColorActive=%23f5e175&bgColorHighlight=%23fef1b9&bgTextureHighlight=flat&bgImgOpacityHighlight=55&borderColorHighlight=%23fc9013&fcHighlight=%23000000&iconColorHighlight=%231296c4&bgColorError=%23f73640&bgTextureError=flat&bgImgOpacityError=45&borderColorError=%23700505&fcError=%23ffffff&iconColorError=%23fcd113&bgColorOverlay=%23a0a0a0&bgTextureOverlay=flat&bgImgOpacityOverlay=75&opacityOverlay=30&bgColorShadow=%23999999&bgTextureShadow=flat&bgImgOpacityShadow=55&opacityShadow=45&thicknessShadow=0px&offsetTopShadow=5px&offsetLeftShadow=5px&cornerRadiusShadow=5px
4+
* To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=AftasansRegular%2CArial%2Csans-serif&fwDefault=normal&fsDefault=14px&cornerRadius=5px&bgColorHeader=%230a7694&bgTextureHeader=highlight_soft&bgImgOpacityHeader=75&borderColorHeader=%2300bff3&fcHeader=%23eaf5f7&iconColorHeader=%23d8e7f3&bgColorContent=%23fcfcfc&bgTextureContent=highlight_soft&bgImgOpacityContent=100&borderColorContent=%23a6c9e2&fcContent=%23222222&iconColorContent=%23008fae&bgColorDefault=%2300bff3&bgTextureDefault=highlight_soft&bgImgOpacityDefault=45&borderColorDefault=%2300bff3&fcDefault=%23ffffff&iconColorDefault=%23e0fdff&bgColorHover=%2375e2ff&bgTextureHover=highlight_soft&bgImgOpacityHover=75&borderColorHover=%231496b3&fcHover=%230f6080&iconColorHover=%23116a8d&bgColorActive=%2336e935&bgTextureActive=highlight_soft&bgImgOpacityActive=50&borderColorActive=%230f7b0e&fcActive=%23ffffff&iconColorActive=%23f5e175&bgColorHighlight=%23fef1b9&bgTextureHighlight=flat&bgImgOpacityHighlight=55&borderColorHighlight=%23fc9013&fcHighlight=%23000000&iconColorHighlight=%231296c4&bgColorError=%23f73640&bgTextureError=flat&bgImgOpacityError=45&borderColorError=%23700505&fcError=%23ffffff&iconColorError=%23fcd113&bgColorOverlay=%23a0a0a0&bgTextureOverlay=flat&bgImgOpacityOverlay=75&opacityOverlay=30&bgColorShadow=%23999999&bgTextureShadow=flat&bgImgOpacityShadow=55&opacityShadow=45&thicknessShadow=0px&offsetTopShadow=5px&offsetLeftShadow=5px&cornerRadiusShadow=5px
55
* Copyright (c) 2013 jQuery Foundation and other contributors Licensed MIT */
66

77
/* Layout helpers
@@ -784,7 +784,7 @@ body .ui-tooltip {
784784
/* Component containers
785785
----------------------------------*/
786786
.ui-widget {
787-
font-family: Candara,Arial,sans-serif;
787+
font-family: "AftasansRegular",Arial,sans-serif;
788788
font-size: 14px;
789789
}
790790
.ui-widget .ui-widget {
@@ -794,7 +794,7 @@ body .ui-tooltip {
794794
.ui-widget select,
795795
.ui-widget textarea,
796796
.ui-widget button {
797-
font-family: Candara,Arial,sans-serif;
797+
font-family: "AftasansRegular",Arial,sans-serif;
798798
font-size: 1em;
799799
}
800800
.ui-widget-content {

app/controllers/actors_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ class ActorsController < ApplicationController
22
# GET /actors
33
# GET /actors.json
44
def index
5-
@actors = Actor.order(:lastname)
5+
@actors = Actor.order(:lastname, :firstname)
66

77
if params[:q]
88
@actors.keep_if {|actor| actor.name =~ Regexp.new(Regexp.escape(params[:q]))}

app/controllers/movies_controller.rb

+2-17
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,6 @@ class MoviesController < ApplicationController
22
# GET /movies
33
# GET /movies.json
44
def index
5-
# if params[:sort]
6-
# if params[:sort] == "alphabetical"
7-
# @movies = Movie.order(:title)
8-
# elsif params[:sort] == "date"
9-
# @movies = Movie.order('lastWatched DESC')
10-
# elsif params[:sort] == "type"
11-
# @movies = Movie.order(:dvd)
12-
# elsif params[:sort] == "duration"
13-
# @movies = Movie.order(:duration)
14-
# elsif params[:sort] == "year"
15-
# @movies = Movie.order(:year)
16-
# end
17-
# else
18-
# @movies = Movie.order(:title)
19-
# end
205
@filters = []
216
params.each do |key, value|
227
if key != "q" and key != "sort" and key != "action" and key != "controller" and value != ""
@@ -29,10 +14,10 @@ def index
2914
end
3015

3116
@actors = []
32-
Actor.all().each {|actor| @actors.push(actor.name)}
17+
Actor.order(:lastname, :firstname).each {|actor| @actors.push(actor.name)}
3318

3419
@genres = [""]
35-
Genre.all().each {|genre| @genres.push(genre.name)}
20+
Genre.order(:name).each {|genre| @genres.push(genre.name)}
3621

3722
@movies = Movie.search(params[:q], params[:sort], @filters)
3823

app/controllers/search_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class SearchController < ApplicationController
33
# GET /search.json
44
def index
55
@movies = Movie.order(:title)
6-
@actors = Actor.order(:lastname)
6+
@actors = Actor.order(:lastname, :firstname)
77
@genres = Genre.order(:name)
88

99
if params[:q]

app/helpers/movies_helper.rb

-5
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ def setupURL(url)
99
@url.gsub! "%20", " "
1010
@url.gsub! "+", " "
1111
end
12-
puts @url
13-
puts "<-----------------------------"
1412
@has_querystring = @url["?"] == "?"
1513
end
1614
def searchURL(category, value)
@@ -25,7 +23,6 @@ def cleanURL(url)
2523
def removeFilter(category, value)
2624
filter = Regexp.new "#{category}(\\[\\d?\\])?=#{value}"
2725
newurl = @url.sub filter, ""
28-
puts newurl
2926
return cleanURL newurl
3027
end
3128
def addFilter(category, value, update=false)
@@ -52,8 +49,6 @@ def filterValue(category)
5249
if match
5350
match = match[:value]
5451
end
55-
puts "match for #{category}"
56-
puts match
5752
return match == "" ? "" : match
5853
end
5954
end

app/models/movie.rb

+8-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ def yearstring
1515
end
1616
end
1717

18+
def display_name
19+
r = Regexp.new(", ([Tt]he|[Aa]n|[Aa])$")
20+
if title[r]
21+
return r.match(title)[1] + " " + title.sub(r, "")
22+
end
23+
return title
24+
end
25+
1826
def self.search(q, sort, filters)
1927
if sort == "alphabetical"
2028
movies = Movie.order(:title)
@@ -67,7 +75,6 @@ def self.search(q, sort, filters)
6775
nmovies.keep_if {|movie| times[value].include? movie.duration }
6876
end
6977
end
70-
puts nmovies
7178
if q
7279
nmovies.keep_if {|movie| movie.title.downcase =~ Regexp.new(Regexp.escape(q.downcase))}
7380
end

app/views/actors/index.html.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<form action="" method="GET" role="search" onsubmit="return q.value != ''">
1010
<input id="searchbar" type="text" name="q" placeholder="Search..." <% if defined? @search %>value="<%= @search %>"<% end %> />
11-
<button id="searchbtn" type="submit" class="ui-button-icon-only"><span style="display: inline-block" class="ui-icon ui-icon-search"></span></button>
11+
<button title="Search" id="searchbtn" type="submit" class="ui-button-icon-only"><span style="display: inline-block" class="ui-icon ui-icon-search"></span></button>
1212
</form>
1313
<% @actors.each do |actor| %>
1414
<article class="person">

app/views/actors/show.html.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<% @actor.movies.sort! { |a,b| a.title.downcase <=> b.title.downcase } %>
1717
<% @actor.movies.each do |movie| %>
1818
<article class="<%= movie.dvd == 1 ? "dvd" : "video" %>">
19-
<a href="<%= url_for movie %>"><h2><%= movie.title %> <%= movie.yearstring %></h2></a>
19+
<a href="<%= url_for movie %>"><h2><%= movie.display_name %> <%= movie.yearstring %></h2></a>
2020
<%= link_to 'Edit', edit_movie_path(movie), :class => "btn-edit ui-icon ui-icon-pencil", :title => 'Edit' %>
2121
<%= link_to 'Delete', movie, method: :delete, data: { confirm: 'Are you sure?' }, :class => "btn-delete ui-icon ui-icon-closethick", :title => 'Delete' %>
2222
<% if movie.lastWatched %>

app/views/genres/index.html.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<form action="" method="GET" role="search" onsubmit="return q.value != ''">
1010
<input id="searchbar" type="text" name="q" placeholder="Search..." <% if defined? @search %>value="<%= @search %>"<% end %> />
11-
<button id="searchbtn" type="submit" class="ui-button-icon-only"><span style="display: inline-block" class="ui-icon ui-icon-search"></span></button>
11+
<button title="Search" id="searchbtn" type="submit" class="ui-button-icon-only"><span style="display: inline-block" class="ui-icon ui-icon-search"></span></button>
1212
</form>
1313

1414
<% @genres.each do |genre| %>

app/views/genres/show.html.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<% @genre.movies.sort! { |a,b| a.title.downcase <=> b.title.downcase } %>
1717
<% @genre.movies.each do |movie| %>
1818
<article class="<%= movie.dvd == 1 ? "dvd" : "video" %>">
19-
<a href="<%= url_for movie %>"><h2><%= movie.title %> <%= movie.yearstring %></h2></a>
19+
<a href="<%= url_for movie %>"><h2><%= movie.display_name %> <%= movie.yearstring %></h2></a>
2020
<%= link_to 'Edit', edit_movie_path(movie), :class => "btn-edit ui-icon ui-icon-pencil", :title => 'Edit' %>
2121
<%= link_to 'Delete', movie, method: :delete, data: { confirm: 'Are you sure?' }, :class => "btn-delete ui-icon ui-icon-closethick", :title => 'Delete' %>
2222
<% if movie.lastWatched %>

app/views/home/index.html.erb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<h1>Search</h1>
22

3-
<form action="/search" method="GET" role="search" onsubmit="return q.value != ''">
3+
<form action="/movies" method="GET" role="search" onsubmit="return q.value != ''">
44
<input id="searchbar" type="text" name="q" placeholder="Search..." />
5-
<button id="searchbtn" type="submit" class="ui-button-icon-only"><span style="display: inline-block" class="ui-icon ui-icon-search"></span></button>
5+
<button title="Search" id="searchbtn" type="submit" class="ui-button-icon-only"><span style="display: inline-block" class="ui-icon ui-icon-search"></span></button>
66
</form>
77

88
<p class="info">Recent movies:

app/views/movies/index.html.erb

+13-12
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
<% setupURL request.original_fullpath[/\?.+$/] %>
1111
<form action="" method="GET" role="search">
1212
<input id="searchbar" type="text" name="q" placeholder="Search..." <% if defined? @search %>value="<%= @search %>"<% end %> />
13-
<button id="searchbtn" type="submit" class="ui-button-icon-only"><span style="display: inline-block" class="ui-icon ui-icon-search"></span></button>
13+
<button title="Search" id="searchbtn" type="submit" class="ui-button-icon-only"><span style="display: inline-block" class="ui-icon ui-icon-search"></span></button>
14+
<div class="ui-widget ui-helper-reset">
1415
<div id="new-filters" class="ui-accordion-content ui-helper-reset ui-widget-content ui-corner-all ui-accordion-content-active" style="display: none">
1516
<div class="field">
1617
<%= label_tag 'Actor' %>
@@ -40,8 +41,17 @@
4041
<%= label_tag 'DVD' %>
4142
<%= select_tag 'dvd', options_for_select([["",""], ["DVD", 1], ["Video", 0]], filterValue("dvd")) %>
4243
</div>
44+
<div class="field">
45+
<%= label_tag 'Sort' %>
46+
<%= select_tag 'sort', options_for_select([["Date Watched","date"],["Alphabetical", "alphabetical"], ["Video/DVD", "dvd"], ["Duration", "duration"], ["Year", "year"]], filterValue('sort') || 'alphabetical') %>
47+
</div>
48+
<p class="info" style="text-align: center;">Click search for changes to take effect</p>
49+
</div>
50+
<h3 id="filters-toggle" class="ui-accordion-icons ui-accordion-header ui-state-default ui-corner-all ui-helper-reset">
51+
<span class="ui-icon ui-icon-circle-plus">&nbsp;</span>
52+
<span>Filters</span>
53+
</h3>
4354
</div>
44-
<h3 id="filters-toggle" class="ui-accordion-header ui-state-default ui-corner-all ui-helper-reset">Filters</h3>
4555
<div class="sort-options">
4656
<p>Sort by:
4757
<%= link_to "Date Viewed", addFilter('sort', 'date', true), :class => "sort" %>
@@ -50,15 +60,6 @@
5060
<%= link_to "Running Time", addFilter('sort', 'duration', true), :class => "sort" %>
5161
<%= link_to "Year", addFilter('sort', 'year', true), :class => "sort" %></p>
5262
</div>
53-
<!--<% @filters.each do |filter| %>
54-
<% if filter[:value].kind_of? Hash %>
55-
<% filter[:value].each do |i,subvalue| %>
56-
<%= hidden_field_tag "#{filter[:name]}[#{i}]", subvalue %>
57-
<% end %>
58-
<% else %>
59-
<%= hidden_field_tag filter[:name], filter[:value] %>
60-
<% end %>
61-
<% end %>-->
6263
</form>
6364
<% @filters.each do |filter| %>
6465
<% if filter[:value].kind_of? Hash %>
@@ -75,7 +76,7 @@
7576
<% end %>
7677
<% @movies.each do |movie| %>
7778
<article class="<%= movie.dvd == 1 ? "dvd" : "video" %>">
78-
<a href="<%= url_for movie %>"><h2><%= movie.title %> <%= movie.yearstring %></h2></a>
79+
<a href="<%= url_for movie %>"><h2><%= movie.display_name %> <%= movie.yearstring %></h2></a>
7980
<%= link_to 'Edit', edit_movie_path(movie), :class => "btn-edit ui-icon ui-icon-pencil", :title => 'Edit' %>
8081
<%= link_to 'Delete', movie, method: :delete, data: { confirm: 'Are you sure?' }, :class => "btn-delete ui-icon ui-icon-closethick", :title => 'Delete' %>
8182
<% if movie.lastWatched %>

app/views/movies/show.html.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<% end %>
1717

1818
<article class="<%= @movie.dvd == 1 ? "dvd" : "video"%>">
19-
<h2><%= @movie.title %> <%= @movie.yearstring %></h2>
19+
<h2><%= @movie.display_name %> <%= @movie.yearstring %></h2>
2020
<% if @movie.lastWatched %>
2121
<p>Last Watched: <span class="lastwatched"><%= @movie.lastWatched %></span></p>
2222
<% end %>

app/views/search/index.html.erb

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010

1111
<form action="" method="GET" role="search" onsubmit="return q.value != ''">
1212
<input id="searchbar" type="text" name="q" placeholder="Search..." <% if defined? @search %>value="<%= @search %>"<% end %> />
13-
<button id="searchbtn" type="submit" class="ui-button-icon-only"><span style="display: inline-block" class="ui-icon ui-icon-search"></span></button>
13+
<button title="Search" id="searchbtn" type="submit" class="ui-button-icon-only"><span style="display: inline-block" class="ui-icon ui-icon-search"></span></button>
1414
</form>
1515

1616
<% @movies.each do |movie| %>
1717
<article class="<%= movie.dvd == 1 ? "dvd" : "video" %>">
18-
<a href="<%= url_for movie %>"><h2><%= movie.title %> <%= movie.yearstring %></h2></a>
18+
<a href="<%= url_for movie %>"><h2><%= movie.display_name %> <%= movie.yearstring %></h2></a>
1919
<%= link_to 'Edit', edit_movie_path(movie), :class => "btn-edit ui-icon ui-icon-pencil", :title => 'Edit' %>
2020
<%= link_to 'Delete', movie, method: :delete, data: { confirm: 'Are you sure?' }, :class => "btn-delete ui-icon ui-icon-closethick", :title => 'Delete' %>
2121
<% if movie.lastWatched %>

0 commit comments

Comments
 (0)