debshots/app/views/packages/browse.slim
Christoph Haas 323b7004ed Expose which search strategy produced each result
query_packages now assigns @search_sources - a hash mapping package
ids to the matching strategy that put them into the results: :exact,
:name_prefix, :name_contains, :semantic or :fulltext. The grid and
list views render a small badge with a humanized label per result,
making the search tiers observable. semantic_results() was folded
into search_packages() so each branch tags its own source. Adds the
rails-controller-testing gem for assigns() in tests.
2026-08-23 10:39:50 +02:00

64 lines
2.3 KiB
Text

// 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.each do |pkg|
.cell.pkgcard data-equalizer-watch=true
a.black href=package_path(name: pkg.name)
.image
/ This leads to an N+1 SQL query for each image. Ideas for optimization welcome.
= small_img(pkg.screenshots.accessible_by(current_ability, :view).first, cls: '')
.text.pkgname
= pkg.name
.text
= pkg.description
- if @search_sources[pkg.id]
.text.search-source
span.label.secondary = search_source_label(@search_sources[pkg.id])
- elsif @view_style==:list
- @packages.to_a.each do |pkg|
.grid-x.grid-margin-x.listview
.small-12.medium-4.cell.pkgcard
a.black href=package_path(name: pkg.name)
.image
/ This leads to an N+1 SQL query for each image. Ideas for optimization welcome.
= small_img(pkg.screenshots.accessible_by(current_ability, :view).first, cls: '')
.small-12.medium-8.cell
h2
a href=package_path(name: pkg.name)
=pkg.name
p =pkg.description
- if @search_sources[pkg.id]
p
span.label.secondary = search_source_label(@search_sources[pkg.id])
.listview.longdescription
= pkg.long_description_first_paragraph
- 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'