De-duplicate code into medium_image partial template

This commit is contained in:
Christoph Haas 2020-10-24 17:45:27 +02:00
parent 9cc09451f7
commit 1734655bc6

View file

@ -17,37 +17,13 @@
- if idx==0 - if idx==0
.small-12.medium-12.cell .small-12.medium-12.cell
.margin-bottom-3 .margin-bottom-3
= render(partial:'medium_image', locals: {screenshot: screenshot})
/ TODO: de-duplicate
a href =url_for(screenshot.large_image_watermarked) rel='fancybox-thumb' title=screenshot.caption data-fancybox='gallery' data-caption=screenshot_caption(screenshot)
.image-with-zoom-icon
= image_tag(url_for(screenshot.medium_image), alt: screenshot.caption, class: 'thumbnail')
.magnifying-glass-icon
i.fa.fa-search
/.imgcaption =screenshot_caption(screenshot)
.imgcaption
= screenshot.description
/ Display further screenshots as smaller images / Display further screenshots as smaller images
- else - else
.small-12.medium-6.cell .small-12.medium-6.cell
.margin-bottom-3 .margin-bottom-3
= render(partial:'medium_image', locals: {screenshot: screenshot})
a href =url_for(screenshot.large_image_watermarked) rel='fancybox-thumb' title=screenshot.caption data-fancybox='gallery' data-caption=screenshot_caption(screenshot)
.image-with-zoom-icon
= image_tag(url_for(screenshot.medium_image), alt: screenshot.caption, class: 'thumbnail')
.magnifying-glass-icon
i.fa.fa-search
/.imgcaption =screenshot_caption(screenshot)
.imgcaption
= screenshot.description
// Has the unmoderated screenshot been uploaded by the current user? // Has the unmoderated screenshot been uploaded by the current user?
- if screenshot_uploaded_by_current_user?(screenshot) - if screenshot_uploaded_by_current_user?(screenshot)
@ -56,9 +32,6 @@
- unless screenshot.approved - unless screenshot.approved
| (but not public yet) | (but not public yet)
- if user_signed_in? and current_user.is_admin?
.imgcaption
span.label.secondary #{screenshot.adminstatus}
// Show detailed information about the screenshot object when in dev mode // Show detailed information about the screenshot object when in dev mode
@ -67,11 +40,8 @@
/ tt / tt
/ = screenshot.inspect / = screenshot.inspect
// Is the user an admin? // Is the user an admin?
// TODO: fix dropdowns do not enforce javascript // TODO: fix dropdowns do not enforce javascript
/ - if user_signed_in? and current_user.is_admin?
/ = render(partial: 'admin_dropdown', locals: {screenshot: screenshot})
// or does the screenshot belong to the user (determined by session cookie) // or does the screenshot belong to the user (determined by session cookie)
/ - elsif user_signed_in? and screenshot.user == current_user / - elsif user_signed_in? and screenshot.user == current_user
/ = render(partial: 'user_dropdown', locals: {screenshot: screenshot}) / = render(partial: 'user_dropdown', locals: {screenshot: screenshot})