Simplified browsing view
This commit is contained in:
parent
fce8fe2dce
commit
c636ee40a5
6 changed files with 56 additions and 71 deletions
|
|
@ -5,10 +5,14 @@ class PackagesController < ApplicationController
|
||||||
|
|
||||||
def list
|
def list
|
||||||
@packages = query_packages.paginate(page: params[:page], per_page: 6)
|
@packages = query_packages.paginate(page: params[:page], per_page: 6)
|
||||||
|
@view_style = :list
|
||||||
|
render :browse
|
||||||
end
|
end
|
||||||
|
|
||||||
def grid
|
def grid
|
||||||
@packages = query_packages.paginate(page: params[:page], per_page: 24)
|
@packages = query_packages.paginate(page: params[:page], per_page: 24)
|
||||||
|
@view_style = :grid
|
||||||
|
render :browse
|
||||||
end
|
end
|
||||||
|
|
||||||
def details
|
def details
|
||||||
|
|
@ -185,7 +189,6 @@ class PackagesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return a 404 if the package has no screenshots or the image was not found
|
# Return a 404 if the package has no screenshots or the image was not found
|
||||||
thumbnail_path = @screenshot.image.path(:large)
|
|
||||||
unless @screenshot
|
unless @screenshot
|
||||||
thumbnail404
|
thumbnail404
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,7 @@
|
||||||
a.black href=package_path(name: pkg.name)
|
a.black href=package_path(name: pkg.name)
|
||||||
.image
|
.image
|
||||||
= small_img(screenshots_visible_to_user(pkg, session).first, cls: '')
|
= small_img(screenshots_visible_to_user(pkg, session).first, cls: '')
|
||||||
|
.text.pkgname
|
||||||
|
= pkg.name
|
||||||
|
.text
|
||||||
|
= pkg.description
|
||||||
|
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
div.panel.callout.radius
|
|
||||||
' Sorry. I couldn't find any software package like that.
|
|
||||||
' Would you like to view
|
|
||||||
'
|
|
||||||
a href=url_for(show: params[:show]) all packages
|
|
||||||
'
|
|
||||||
' instead?
|
|
||||||
48
app/views/packages/browse.slim
Normal file
48
app/views/packages/browse.slim
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
// Paginator and search bar
|
||||||
|
.grid-x
|
||||||
|
.small-6.medium-8.large-9.cell
|
||||||
|
// Paginator
|
||||||
|
= render(partial: 'packages/paginator', locals: {items: @packages})
|
||||||
|
|
||||||
|
.small-6.medium-4.large-3.cell
|
||||||
|
// Search form
|
||||||
|
= render 'packages/searchfield'
|
||||||
|
|
||||||
|
// Grid view of packages
|
||||||
|
.grid-x
|
||||||
|
.small-9.large-10.cell
|
||||||
|
- if @packages.any?
|
||||||
|
- if @view_style==:grid
|
||||||
|
.grid-x.grid-margin-x.small-up-1.medium-up-2.large-up-3 data-equalizer=true data-equalize-on="medium"
|
||||||
|
- @packages.all.each do |pkg|
|
||||||
|
.cell.pkgcard data-equalizer-watch=true
|
||||||
|
= render partial: 'packages/grid_small_image', locals: { pkg: pkg }
|
||||||
|
- elsif @view_style==:list
|
||||||
|
- @packages.to_a.each do |pkg|
|
||||||
|
.grid-x.listview
|
||||||
|
.small-12.medium-4.cell.pkgcard
|
||||||
|
= render partial: 'packages/grid_small_image', locals: { pkg: pkg }
|
||||||
|
.small-12.medium-8.cell
|
||||||
|
h1
|
||||||
|
a href=package_path(name: pkg.name)
|
||||||
|
=pkg.name
|
||||||
|
.packagedetails
|
||||||
|
h2 =pkg.description
|
||||||
|
= pkg.long_description_first_paragraph or 'Sorry - no description available.'
|
||||||
|
|
||||||
|
|
||||||
|
- else
|
||||||
|
div.panel.callout.radius
|
||||||
|
' Sorry. I couldn't find any software package like that.
|
||||||
|
' Would you like to view
|
||||||
|
'
|
||||||
|
a href=url_for(show: params[:show]) all packages
|
||||||
|
'
|
||||||
|
' instead?
|
||||||
|
|
||||||
|
// Paginator
|
||||||
|
= render(partial: 'packages/paginator', locals: {items: @packages})
|
||||||
|
|
||||||
|
// Icon sidebar for options and views
|
||||||
|
.small-3.large-2.cell
|
||||||
|
= render 'packages/sidebar'
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
// Paginator and search bar
|
|
||||||
.grid-x
|
|
||||||
.small-6.medium-8.large-9.cell
|
|
||||||
// Paginator
|
|
||||||
= render(partial: 'packages/paginator', locals: {items: @packages})
|
|
||||||
|
|
||||||
.small-6.medium-4.large-3.cell
|
|
||||||
// Search form
|
|
||||||
= render 'packages/searchfield'
|
|
||||||
|
|
||||||
// Grid view of packages
|
|
||||||
.grid-x
|
|
||||||
.small-9.large-10.cell
|
|
||||||
- if @packages.length>0
|
|
||||||
.grid-x.grid-margin-x.small-up-1.medium-up-2.large-up-3 data-equalizer=true data-equalize-on="medium"
|
|
||||||
- @packages.all.each do |pkg|
|
|
||||||
.cell.pkgcard data-equalizer-watch=true
|
|
||||||
= render partial: 'packages/grid_small_image', locals: { pkg: pkg }
|
|
||||||
|
|
||||||
- else
|
|
||||||
= render 'packages/noresults'
|
|
||||||
|
|
||||||
// Paginator
|
|
||||||
= render(partial: 'packages/paginator', locals: {items: @packages})
|
|
||||||
|
|
||||||
// Icon sidebar for options and views
|
|
||||||
.small-3.large-2.cell
|
|
||||||
= render 'packages/sidebar'
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
// Paginator and search bar
|
|
||||||
.grid-x
|
|
||||||
.small-6.medium-8.large-9.cell
|
|
||||||
// Paginator
|
|
||||||
= render(partial: 'packages/paginator', locals: {items: @packages})
|
|
||||||
|
|
||||||
.small-6.medium-4.large-3.cell
|
|
||||||
// Search form
|
|
||||||
= render 'packages/searchfield'
|
|
||||||
|
|
||||||
// List view of packages
|
|
||||||
.grid-x
|
|
||||||
.small-9.medium-10.cell
|
|
||||||
- if @packages.length>0
|
|
||||||
- @packages.to_a.each do |pkg|
|
|
||||||
.grid-x.listview
|
|
||||||
.small-12.medium-4.cell.pkgcard
|
|
||||||
= render partial: 'packages/grid_small_image', locals: { pkg: pkg }
|
|
||||||
.small-12.medium-8.cell
|
|
||||||
h1
|
|
||||||
a href=package_path(name: pkg.name)
|
|
||||||
=pkg.name
|
|
||||||
.packagedetails
|
|
||||||
h2 =pkg.description
|
|
||||||
= pkg.long_description_first_paragraph or 'Sorry - no description available.'
|
|
||||||
|
|
||||||
// Second paginator at the bottom so the user does not have to scroll up again
|
|
||||||
= render(partial: 'packages/paginator', locals: {items: @packages})
|
|
||||||
|
|
||||||
- else
|
|
||||||
= render 'packages/noresults'
|
|
||||||
|
|
||||||
// Icon sidebar for options and views
|
|
||||||
.small-3.medium-2.cell
|
|
||||||
= render 'packages/sidebar'
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue