/json/packages and /json/screenshots implemented
This commit is contained in:
parent
b3d0b2dc06
commit
a90bb51b38
4 changed files with 25 additions and 0 deletions
|
|
@ -1,14 +1,20 @@
|
|||
class JsonController < ApplicationController
|
||||
# JSON information on a single package
|
||||
def package
|
||||
@p = Package.find_by_name! params[:name]
|
||||
end
|
||||
|
||||
# JSON information on all packages
|
||||
def packages
|
||||
@p = Package.all
|
||||
end
|
||||
|
||||
# JSON information on all screenshots
|
||||
def screenshots
|
||||
@s = Screenshot.includes(:package)
|
||||
end
|
||||
|
||||
# JSON list of packages that do not have screenshots
|
||||
def packages_without_screenshots
|
||||
end
|
||||
end
|
||||
|
|
|
|||
6
app/views/json/packages.json.jbuilder
Normal file
6
app/views/json/packages.json.jbuilder
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
json.cache! ['json_packages'], expires_in: 1.hour do
|
||||
json.packages @p do |p|
|
||||
json.extract! p, :maintainer, :name, :section, :maintainer_email, :homepage, :description
|
||||
json.url package_url(p.name)
|
||||
end
|
||||
end
|
||||
10
app/views/json/screenshots.json.jbuilder
Normal file
10
app/views/json/screenshots.json.jbuilder
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
json.cache! ['json_screenshots'], expires_in: 1.hour do
|
||||
json.screenshots @s do |s|
|
||||
p = s.package
|
||||
json.extract! s, :version
|
||||
json.extract! p, :maintainer, :name, :section, :maintainer_email, :homepage, :description
|
||||
json.url package_url(p.name)
|
||||
json.small_image_url "#{request.protocol}#{request.host_with_port}#{s.image.url(:thumb, timestamp: false)}"
|
||||
json.large_image_url "#{request.protocol}#{request.host_with_port}#{s.image.url(:large, timestamp: false)}"
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue