Add better support for compact view

master
Guillaume Dott 2015-11-12 12:33:22 +01:00
parent f803a6adfb
commit 0535253c91
5 changed files with 24 additions and 14 deletions

View File

@ -1,6 +1,7 @@
require 'librarix/filter'
require 'librarix/menu'
require 'librarix/the_movie_db'
require 'librarix/helpers'
require 'sinatra/base'
require 'sinatra/content_for'
@ -21,12 +22,10 @@ module Librarix
helpers Librarix::TheMovieDB
helpers Librarix::Menu::Helper
helpers Librarix::Helpers
get '/' do
slim :index, locals: {
compact: params.key?('compact'),
movies: Librarix::Filter.new(params).movies
}
slim :index, locals: {movies: Librarix::Filter.new(params).movies}
end
get '/search' do

View File

@ -0,0 +1,7 @@
module Librarix
module Helpers
def compact?
params.key?('compact')
end
end
end

View File

@ -1,12 +1,16 @@
- content_for(:title) { 'Index' }
form method="get" action="/" id="filter"
div id="search-main"
input type="text" name="title" value="#{params['title']}" autocomplete="off"
input type="submit" value="Filter"
div id="search-more"
select name="view_state"
option value="all" selected=(params['view_state'].nil? || params['view_state'] == '' || params['view_state'] == 'all') All movies
option value="viewed" selected=(params['view_state'] == 'viewed') Only viewed
option value="not_viewed" selected=(params['view_state'] == 'not_viewed') Not viewed
input type="submit" value="Filter"
input type="checkbox" name="compact" id="compact" checked=(params['compact'])
label for="compact" Compact view
== slim :list, locals: {compact: compact, movies: movies}
== slim :list, locals: {movies: movies}

View File

@ -1,4 +1,4 @@
ul#movies
- movies.each do |movie|
li
== slim :movie, locals: {compact: locals.key?('compact') ? compact : false, movie: movie}
== slim :movie, locals: {movie: movie}

View File

@ -1,12 +1,12 @@
.movie data-id="#{movie.id}"
.poster
- if movie.poster_path
img src="#{poster_url(movie.poster_path, compact ? 'w92' : 'w154')}"
img src="#{poster_url(movie.poster_path, compact? ? 'w92' : 'w154')}"
.informations
h2
a href="https://www.themoviedb.org/movie/#{movie.id}" #{movie.original_title}
p = movie.release_date
- unless compact
- unless compact?
p = movie.overview
.actions
- if movie.added?