48 lines
1.3 KiB
Ruby
48 lines
1.3 KiB
Ruby
module PackagesHelper
|
|
|
|
# Return the description and/or the version of the package
|
|
def screenshot_caption(screenshot)
|
|
str = []
|
|
str << screenshot.description if screenshot.description.present?
|
|
str << "#{screenshot.package.name} version #{screenshot.version}" if screenshot.version.present?
|
|
str << "uploaded #{time_ago_in_words(screenshot.created_at)} ago"
|
|
str.join(' ∙ ')
|
|
end
|
|
|
|
def small_img(screenshot, cls: 'thumbnail')
|
|
if screenshot && screenshot.simage(:small)
|
|
image = screenshot.simage(:small)
|
|
image_tag(
|
|
image.url,
|
|
width: image.width,
|
|
height: image.height,
|
|
alt: screenshot.caption,
|
|
class: cls
|
|
)
|
|
else
|
|
image_tag(
|
|
'/images/dummy/no-screenshots-upload-one.svg',
|
|
width: 220,
|
|
height: 220 * 3 / 4
|
|
)
|
|
end
|
|
end
|
|
|
|
# Show filled/empty star icons from FontAwesome
|
|
# depending on the rating (1-5)
|
|
# def star_rating(rating)
|
|
# filled_stars = fa_icon('star') * rating
|
|
# empty_stars = fa_icon('star-o') * (5-rating)
|
|
# (filled_stars+empty_stars).html_safe
|
|
# end
|
|
|
|
def status_text(screenshot)
|
|
# TODO: markedfordelete/reporting will be removed
|
|
if screenshot.approved
|
|
fa_icon('check-square') + ' Public'
|
|
else
|
|
fa_icon('hourglass') + ' Waiting for approval'
|
|
end
|
|
end
|
|
|
|
end
|