Simplified browsing view

This commit is contained in:
Christoph Haas 2021-02-14 11:14:13 +01:00
parent fce8fe2dce
commit c636ee40a5
6 changed files with 56 additions and 71 deletions

View file

@ -5,10 +5,14 @@ class PackagesController < ApplicationController
def list
@packages = query_packages.paginate(page: params[:page], per_page: 6)
@view_style = :list
render :browse
end
def grid
@packages = query_packages.paginate(page: params[:page], per_page: 24)
@view_style = :grid
render :browse
end
def details
@ -185,7 +189,6 @@ class PackagesController < ApplicationController
end
# Return a 404 if the package has no screenshots or the image was not found
thumbnail_path = @screenshot.image.path(:large)
unless @screenshot
thumbnail404
return

View file

@ -1,3 +1,7 @@
a.black href=package_path(name: pkg.name)
.image
= small_img(screenshots_visible_to_user(pkg, session).first, cls: '')
.text.pkgname
= pkg.name
.text
= pkg.description

View file

@ -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?

View 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'

View file

@ -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'

View file

@ -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'