Showing newest and most wanted package on home page
This commit is contained in:
parent
dbca1e0a19
commit
9ad5a05914
3 changed files with 48 additions and 38 deletions
|
|
@ -1,12 +1,14 @@
|
||||||
class WelcomeController < ApplicationController
|
class WelcomeController < ApplicationController
|
||||||
def home
|
def home
|
||||||
# TODO: Use the package with the actual newest uploaded screenshot
|
# TODO: Only approved screenshots!
|
||||||
@newest_uploaded_package = Package.with_screenshots.first
|
@newest_upload = Screenshot.newest_upload
|
||||||
|
|
||||||
# TODO: Use the actually most popular package and not just a random one
|
# TODO: Use the actually most popular package and not just a random one
|
||||||
@most_popular_package = Package.with_screenshots.first
|
@most_popular_package = Package.with_screenshots.first
|
||||||
|
|
||||||
@package_count = Package.count
|
@package_count = Package.count
|
||||||
|
|
||||||
|
@most_wanted = Package.without_screenshots_most_visits.first
|
||||||
end
|
end
|
||||||
|
|
||||||
def about
|
def about
|
||||||
|
|
|
||||||
|
|
@ -100,4 +100,12 @@ class Screenshot < ActiveRecord::Base
|
||||||
self.approved = true
|
self.approved = true
|
||||||
self.save!
|
self.save!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.newest_upload
|
||||||
|
self.order(updated_at: :desc).first
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.approved
|
||||||
|
self.find_by(approved: true)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -22,40 +22,40 @@
|
||||||
div.small-3.columns
|
div.small-3.columns
|
||||||
input.button.postfix type="submit" value="Search"
|
input.button.postfix type="submit" value="Search"
|
||||||
|
|
||||||
/ div.row
|
div.row
|
||||||
/ hr
|
hr
|
||||||
|
|
||||||
/ div.row
|
div.row
|
||||||
/ div.large-4.medium-12.small-12.columns.text-center
|
div.large-4.medium-12.small-12.columns.text-center
|
||||||
/ h2 Newest upload
|
h2 Newest upload
|
||||||
/ // TODO: load actual newest upload and cache it
|
// TODO: load actual newest upload and cache it
|
||||||
/ // TODO: link to the package page
|
// TODO: link to the package page
|
||||||
/ a.black href=package_path(@newest_uploaded_package.name)
|
a.black href=package_path(@newest_upload.package.name)
|
||||||
/ img src=@newest_uploaded_package.screenshots.first.image.url(:large, timestamp: false)
|
= image_tag(@newest_upload.image.url(:large, timestamp: false), alt: @newest_upload.caption)
|
||||||
/ p
|
p
|
||||||
/ strong
|
strong
|
||||||
/ =@newest_uploaded_package.name
|
=@newest_upload.package.name
|
||||||
/ ' :
|
' :
|
||||||
/ '
|
'
|
||||||
/ =@newest_uploaded_package.description
|
=@newest_upload.package.description
|
||||||
/ div.large-4.medium-12.small-12.columns.text-center
|
div.large-4.medium-12.small-12.columns.text-center
|
||||||
/ h2 Most popular
|
h2 Most popular
|
||||||
/ // TODO: load actual most popular package and highest-rated screenshot and cache it
|
// TODO: load actual most popular package and highest-rated screenshot and cache it
|
||||||
/ // TODO: link to the package page
|
// TODO: link to the package page
|
||||||
/ a.black href=package_path(@most_popular_package.name)
|
a.black href=package_path(@most_popular_package.name)
|
||||||
/ img src=@most_popular_package.screenshots.first.image.url(:large, timestamp: false)
|
img src=@most_popular_package.screenshots.first.image.url(:large, timestamp: false)
|
||||||
/ p
|
p
|
||||||
/ strong
|
strong
|
||||||
/ =@most_popular_package.name
|
=@most_popular_package.name
|
||||||
/ ' :
|
' :
|
||||||
/ '
|
'
|
||||||
/ =@most_popular_package.description
|
=@most_popular_package.description
|
||||||
/ div.large-4.medium-12.small-12.columns.text-center
|
div.large-4.medium-12.small-12.columns.text-center
|
||||||
/ h2 Your help needed
|
h2 Your help needed
|
||||||
/ // TODO: load actual most popular package without a screenshot and cache it
|
// TODO: load actual most popular package without a screenshot and cache it
|
||||||
/ a href=upload_package_by_name_path('firefox')
|
a href=upload_package_by_name_path('firefox')
|
||||||
/ img src="/images/dummy/no-screenshots-upload-one.svg" width="80%"
|
img src="/images/dummy/no-screenshots-upload-one.svg" width="80%"
|
||||||
/ p
|
p
|
||||||
/ ' We lack a screenshot for the Firefox package. Can you
|
' We lack a screenshot for the Firefox package. Can you
|
||||||
/ a href=upload_package_by_name_path('firefox') provide one
|
a href=upload_package_by_name_path('firefox') provide one
|
||||||
/ ' ?
|
' ?
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue