Package pages get a "Related packages" section: a nearest neighbor query against the package's own stored embedding (no external service call), excluding the package itself. Packages without an embedding render no section.
91 lines
3.7 KiB
Text
91 lines
3.7 KiB
Text
/ If images were just uploaded then show upload success/errors
|
|
/ in a callout.
|
|
= render 'receive_upload'
|
|
|
|
.packagepage
|
|
h1 = @package.name
|
|
|
|
h2 = @package.description
|
|
|
|
.grid-x.grid-margin-x
|
|
.small-7.medium-7.cell
|
|
/ Left column contains images
|
|
|
|
- if @screenshots.any?
|
|
= render(partial: 'packages/paginator', locals: {items: @screenshots})
|
|
#gallery.grid-x.grid-margin-x.medium-up-1.large-up-2 data-equalizer=true data-equalize-on="medium"
|
|
- @screenshots.each do |screenshot|
|
|
- @divclasses = %W(cell pkgcard)
|
|
- @divclasses << (screenshot.approved ? "approved" : "unapproved")
|
|
- @divclasses << 'highlight' if screenshot.id == @highlight_id
|
|
- @divclasses << 'hidden' if screenshot.hidden
|
|
div class=(@divclasses.join(' ')) data-equalizer-watch=true
|
|
/ TODO: try to align the buttons to the bottom
|
|
= render(partial: 'admin_buttons', locals: {screenshot: screenshot})
|
|
/ Photoswipe needs to know the dimensions of the full-size image to zoom to
|
|
a.foobar.black [
|
|
href=screenshot_image_with_id_path(screenshot.package, screenshot.id)
|
|
data-pswp-width=screenshot.simage.width
|
|
data-pswp-height=screenshot.simage.height
|
|
]
|
|
.image.image-with-zoom-icon
|
|
= small_img(screenshot, cls: '')
|
|
|
|
.magnifying-glass-icon
|
|
= icon('zoom-in')
|
|
.text
|
|
= screenshot.caption
|
|
// Has the unmoderated screenshot been uploaded by the current user?
|
|
- if current_user && current_user.screenshots.include?(screenshot)
|
|
.text
|
|
span.label.secondary
|
|
' Uploaded by you
|
|
- unless screenshot.approved
|
|
' (needs to be approved)
|
|
|
|
|
|
// Second paginator at the bottom so the user does not have to scroll up again
|
|
= render(partial: 'packages/paginator', locals: {items: @screenshots})
|
|
|
|
|
|
// Show detailed information about the screenshot object when in dev mode
|
|
/ - if Rails.env == 'development'
|
|
/ p
|
|
/ tt
|
|
/ = screenshot.inspect
|
|
|
|
|
|
|
|
// or is the user not related to the screenshot and the screenshot is public?
|
|
// TODO: Move to a seperate page with a form
|
|
//- elsif screenshot.approved
|
|
// = render(partial: 'report_dropdown', locals: {screenshot: screenshot})
|
|
|
|
- else
|
|
/.listview
|
|
img src='/images/dummy/no-screenshots-upload-one.svg' width='100%' style='padding: 0 10%'
|
|
|
|
#metadata.small-5.medium-5.cell
|
|
/ Right column contains metadata about the package.
|
|
/ #metadata is the anchor for this sticky container.
|
|
= render(partial: 'details_rightbox', locals: {pkg: @package})
|
|
|
|
/ Semantically similar packages, based on the package's description embedding
|
|
- if @related_packages.any?
|
|
#related
|
|
h3 Related packages
|
|
.grid-x.grid-margin-x.medium-up-2.large-up-3 data-equalizer=true
|
|
- @related_packages.each do |pkg|
|
|
.cell.pkgcard data-equalizer-watch=true
|
|
a.black href=package_path(name: pkg.name)
|
|
.text.pkgname
|
|
= pkg.name
|
|
.text.small
|
|
= pkg.description
|
|
|
|
javascript:
|
|
// Where to send POST requests for uploads
|
|
let ajax_upload_url = '#{{upload_receive_json_path}}';
|
|
|
|
// Where to go to after a successful image upload
|
|
let after_upload_url = '#{{package_path(@package)}}';
|