Packages grid/list view are different controller actions now

This commit is contained in:
Christoph Haas 2014-11-30 19:25:21 +01:00
parent 1c59a5ac74
commit f940e96014
6 changed files with 32 additions and 31 deletions

View file

@ -19,17 +19,18 @@ class PackagesController < ApplicationController
@packages = @packages.without_screenshots @packages = @packages.without_screenshots
logger.debug 'Limiting packages to those without screenshots' logger.debug 'Limiting packages to those without screenshots'
end end
end
# Show packages as list or grid def list
if params['view']=='list' index
# List view @packages = @packages.paginate(page: params[:page], per_page: 12)
@packages = @packages.paginate(page: params[:page], per_page: 12) render 'packages/index-list.slim'
render 'packages/index-list.slim' end
else
# Grid view def grid
@packages = @packages.paginate(page: params[:page], per_page: 24) index
render 'packages/index-grid.slim' @packages = @packages.paginate(page: params[:page], per_page: 24)
end render 'packages/index-grid.slim'
end end
def details def details

View file

@ -1,50 +1,49 @@
- raise
// Navigation sidebar // Navigation sidebar
#sidebar #sidebar
.caption View .caption View
- if params['view'] == 'list' - if current_page? packages_list_path
.item .item
// Switch to grid view // Switch to grid view
//a href=url(:package, :index) //a href=url(:package, :index)
a href=url_for(view: 'grid') = link_to packages_grid_path
img src="images/sidebar/grid0.svg" width=40 height=40 img src="/images/sidebar/grid0.svg" width=40 height=40
.item.space .item.space
img src="images/sidebar/list1.svg" width=40 height=40 img src="/images/sidebar/list1.svg" width=40 height=40
- else - else
.item .item
img src="images/sidebar/grid1.svg" width=40 height=40 img src="/images/sidebar/grid1.svg" width=40 height=40
.item.space .item.space
// Switch to list view // Switch to list view
//a href=url(:package, :index, view: 'list') //a href=url(:package, :index, view: 'list')
a href=url_for(view: 'list') = link_to packages_list_path
img src="images/sidebar/list0.svg" width=40 height=40 img src="/images/sidebar/list0.svg" width=40 height=40
// Cycling between with/without/any packages filter // Cycling between with/without/any packages filter
.caption Screenshots .caption Screenshots
- if params['show'] == 'with' - if params['show'] == 'with'
.item .item
a href=url_for(show: 'without') a href=url_for(show: 'without')
img src="images/sidebar/show-without0.svg" width=40 height=40 img src="/images/sidebar/show-without0.svg" width=40 height=40
.item .item
img src="images/sidebar/show-with1.svg" width=40 height=40 img src="/images/sidebar/show-with1.svg" width=40 height=40
.item.space .item.space
a href=url_for(show: 'any') a href=url_for(show: 'any')
img src="images/sidebar/show-any0.svg" width=40 height=40 img src="/images/sidebar/show-any0.svg" width=40 height=40
- elsif params['show'] == 'without' - elsif params['show'] == 'without'
.item .item
img src="images/sidebar/show-without1.svg" width=40 height=40 img src="/images/sidebar/show-without1.svg" width=40 height=40
.item .item
a href=url_for(show: 'with') a href=url_for(show: 'with')
img src="images/sidebar/show-with0.svg" width=40 height=40 img src="/images/sidebar/show-with0.svg" width=40 height=40
.item.space .item.space
a href=url_for(show: 'any') a href=url_for(show: 'any')
img src="images/sidebar/show-any0.svg" width=40 height=40 img src="/images/sidebar/show-any0.svg" width=40 height=40
- else # any - else # any
.item .item
a href=url_for(show: 'without') a href=url_for(show: 'without')
img src="images/sidebar/show-without0.svg" width=40 height=40 img src="/images/sidebar/show-without0.svg" width=40 height=40
.item .item
a href=url_for(show: 'with') a href=url_for(show: 'with')
img src="images/sidebar/show-with0.svg" width=40 height=40 img src="/images/sidebar/show-with0.svg" width=40 height=40
.item.space .item.space
img src="images/sidebar/show-any1.svg" width=40 height=40 img src="/images/sidebar/show-any1.svg" width=40 height=40

View file

@ -6,7 +6,7 @@
.small-6.medium-4.large-3.columns .small-6.medium-4.large-3.columns
// Search form // Search form
= form_tag packages_path, :method=>'GET' = form_tag url_for, :method=>'GET'
= text_field_tag('search', params[:search], placeholder: "Search...") = text_field_tag('search', params[:search], placeholder: "Search...")
// Grid view // Grid view

View file

@ -6,7 +6,7 @@
.small-6.medium-4.large-3.columns .small-6.medium-4.large-3.columns
// Search form // Search form
= form_tag packages_path, :method=>'GET' = form_tag url_for, :method=>'GET'
= text_field_tag(:search, params[:search], placeholder: "Search...") = text_field_tag(:search, params[:search], placeholder: "Search...")
// Package list // Package list

View file

@ -15,7 +15,7 @@
' Debian and other Linux distributions. And of course you are encouraged to upload ' Debian and other Linux distributions. And of course you are encouraged to upload
' your own screenshots for others to explore. ' your own screenshots for others to explore.
p p
= form_tag(packages_path, method: 'GET') = form_tag(packages_grid_path, method: 'GET')
div.row.collapse.postfix-round div.row.collapse.postfix-round
div.small-9.columns div.small-9.columns
input type="text" name="search" placeholder="Looking for a special software?" autofocus="true" input type="text" name="search" placeholder="Looking for a special software?" autofocus="true"

View file

@ -11,7 +11,8 @@ Debshots::Application.routes.draw do
#get 'packages/moderate' #get 'packages/moderate'
#get 'welcome/index' #get 'welcome/index'
get 'packages' => 'packages#index' get 'packages' => 'packages#grid', as: :packages_grid
get 'packages/list' => 'packages#list', as: :packages_list
get 'package/:name' => 'packages#details', as: :package get 'package/:name' => 'packages#details', as: :package
get 'upload/:name' => 'packages#upload', as: :upload_package get 'upload/:name' => 'packages#upload', as: :upload_package