Merge branch 'master' of git.workaround.org:chaas/debshots
This commit is contained in:
commit
681ef50495
9 changed files with 47 additions and 26 deletions
|
|
@ -584,7 +584,24 @@ $topbar-breakpoint: 800px;
|
||||||
$topbar-media-query: "only screen and (min-width: #{$topbar-breakpoint})";
|
$topbar-media-query: "only screen and (min-width: #{$topbar-breakpoint})";
|
||||||
|
|
||||||
// Import Google font
|
// Import Google font
|
||||||
@import url(http://fonts.googleapis.com/css?family=Droid+Sans:400,700);
|
// @import url(//fonts.googleapis.com/css?family=Droid+Sans:400,700);
|
||||||
|
|
||||||
|
// Use fonts from out own site. Do not load from Google for privacy reasons.
|
||||||
|
@font-face {
|
||||||
|
font-family: 'Droid Sans';
|
||||||
|
font-style: normal;
|
||||||
|
font-weight: 400;
|
||||||
|
src: local('Droid Sans'), local('DroidSans'), url(/fonts/DroidSans.woff2) format('woff2');
|
||||||
|
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
|
||||||
|
}
|
||||||
|
@font-face {
|
||||||
|
font-family: 'Droid Sans';
|
||||||
|
font-style: normal;
|
||||||
|
font-weight: 700;
|
||||||
|
src: local('Droid Sans Bold'), local('DroidSans-Bold'), url(/fonts/DroidSans-Bold.woff2) format('woff2');
|
||||||
|
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
|
||||||
|
}
|
||||||
|
|
||||||
$body-font-family: "Droid Sans";
|
$body-font-family: "Droid Sans";
|
||||||
|
|
||||||
$button-tny: rem-calc(4);
|
$button-tny: rem-calc(4);
|
||||||
|
|
|
||||||
|
|
@ -3,15 +3,6 @@ class ApplicationController < ActionController::Base
|
||||||
# For APIs, you may want to use :null_session instead.
|
# For APIs, you may want to use :null_session instead.
|
||||||
protect_from_forgery with: :exception
|
protect_from_forgery with: :exception
|
||||||
|
|
||||||
before_filter :create_user_token
|
|
||||||
|
|
||||||
# Do not mention passwords in the log file
|
# Do not mention passwords in the log file
|
||||||
# filter_parameter_logging :password
|
# filter_parameter_logging :password
|
||||||
|
|
||||||
# Assign the visitor a unique hash so that we can track their uploads
|
|
||||||
# and show them even before moderation.
|
|
||||||
def create_user_token
|
|
||||||
session[:token] ||= SecureRandom.hex
|
|
||||||
session[:ip] ||= request.remote_ip
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,25 @@
|
||||||
class JsonController < ApplicationController
|
class JsonController < ApplicationController
|
||||||
# JSON information on a single package
|
# JSON information on a single package
|
||||||
def package
|
def package
|
||||||
|
expires_in 1.hours, public: true
|
||||||
@p = Package.find_by_name! params[:name]
|
@p = Package.find_by_name! params[:name]
|
||||||
end
|
end
|
||||||
|
|
||||||
# JSON information on all packages
|
# JSON information on all packages
|
||||||
def packages
|
def packages
|
||||||
|
expires_in 1.days, public: true
|
||||||
@p = Package.all
|
@p = Package.all
|
||||||
end
|
end
|
||||||
|
|
||||||
# JSON information on all screenshots
|
# JSON information on all screenshots
|
||||||
def screenshots
|
def screenshots
|
||||||
|
expires_in 1.days, public: true
|
||||||
@s = Screenshot.includes(:package)
|
@s = Screenshot.includes(:package)
|
||||||
end
|
end
|
||||||
|
|
||||||
# JSON list of packages that do not have screenshots
|
# JSON list of packages that do not have screenshots
|
||||||
def packages_without_screenshots
|
def packages_without_screenshots
|
||||||
|
expires_in 1.hours, public: true
|
||||||
@p = Package.without_screenshots.all
|
@p = Package.without_screenshots.all
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -11,18 +11,20 @@ class PackagesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def details
|
def details
|
||||||
@package = Package.find_by(name: params[:name])
|
@package = Package.find_by!(name: params[:name])
|
||||||
end
|
end
|
||||||
|
|
||||||
def upload
|
def upload
|
||||||
raise "name not given" unless params[:name]
|
@package = Package.find_by!(name: params[:name])
|
||||||
@package = Package.find_by(name: params[:name])
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# POST target of the screenshots upload form.
|
# POST target of the screenshots upload form.
|
||||||
# Checks upload images and creates a new Screenshot record for it.
|
# Checks upload images and creates a new Screenshot record for it.
|
||||||
def upload_image
|
def upload_image
|
||||||
@package = Package.find_by(name: params[:name])
|
# Remember the user by the cookie session
|
||||||
|
create_user_token
|
||||||
|
|
||||||
|
@package = Package.find_by!(name: params[:name])
|
||||||
|
|
||||||
successful_upload_count = 0
|
successful_upload_count = 0
|
||||||
|
|
||||||
|
|
@ -61,7 +63,7 @@ class PackagesController < ApplicationController
|
||||||
# - description
|
# - description
|
||||||
# - file
|
# - file
|
||||||
def legacy_uploadfile
|
def legacy_uploadfile
|
||||||
@package = Package.find_by(name: params[:packagename])
|
@package = Package.find_by!(name: params[:packagename])
|
||||||
|
|
||||||
new_screenshot = @package.screenshots.new(image: params[:file])
|
new_screenshot = @package.screenshots.new(image: params[:file])
|
||||||
|
|
||||||
|
|
@ -81,7 +83,7 @@ class PackagesController < ApplicationController
|
||||||
|
|
||||||
def delete_screenshot
|
def delete_screenshot
|
||||||
# Is the user allowed to delete the screenshot?
|
# Is the user allowed to delete the screenshot?
|
||||||
@screenshot = Screenshot.find(params[:id])
|
@screenshot = Screenshot.find!(params[:id])
|
||||||
|
|
||||||
if user_can_alter_screenshot?
|
if user_can_alter_screenshot?
|
||||||
@screenshot.destroy
|
@screenshot.destroy
|
||||||
|
|
@ -93,7 +95,7 @@ class PackagesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def approve_screenshot
|
def approve_screenshot
|
||||||
@screenshot = Screenshot.find(params[:id])
|
@screenshot = Screenshot.find!(params[:id])
|
||||||
@screenshot.approve_screenshot!
|
@screenshot.approve_screenshot!
|
||||||
flash['notice'] = "Screenshot approved."
|
flash['notice'] = "Screenshot approved."
|
||||||
redirect_to :back
|
redirect_to :back
|
||||||
|
|
@ -104,7 +106,7 @@ class PackagesController < ApplicationController
|
||||||
# If the package is found but has no screenshots then it also returns a
|
# If the package is found but has no screenshots then it also returns a
|
||||||
# dummy image along with status 404.
|
# dummy image along with status 404.
|
||||||
def thumbnail
|
def thumbnail
|
||||||
@package = Package.find_by(name: params[:name])
|
@package = Package.find_by!(name: params[:name])
|
||||||
unless @package
|
unless @package
|
||||||
thumbnail404
|
thumbnail404
|
||||||
return
|
return
|
||||||
|
|
@ -133,7 +135,7 @@ class PackagesController < ApplicationController
|
||||||
# If the package is found but has no screenshots then it also returns a
|
# If the package is found but has no screenshots then it also returns a
|
||||||
# dummy image along with status 404.
|
# dummy image along with status 404.
|
||||||
def screenshot
|
def screenshot
|
||||||
@package = Package.find_by(name: params[:name])
|
@package = Package.find_by!(name: params[:name])
|
||||||
unless @package
|
unless @package
|
||||||
screenshot404
|
screenshot404
|
||||||
return
|
return
|
||||||
|
|
@ -160,7 +162,7 @@ class PackagesController < ApplicationController
|
||||||
# Receives a form with a simple text field 'description' so that users can update
|
# Receives a form with a simple text field 'description' so that users can update
|
||||||
# the description of their screenshot.
|
# the description of their screenshot.
|
||||||
def update_screenshot_description
|
def update_screenshot_description
|
||||||
@screenshot = Screenshot.find(params[:id])
|
@screenshot = Screenshot.find!(params[:id])
|
||||||
@screenshot.description = params[:description]
|
@screenshot.description = params[:description]
|
||||||
@screenshot.save!
|
@screenshot.save!
|
||||||
flash['notice'] = "Description updated."
|
flash['notice'] = "Description updated."
|
||||||
|
|
@ -169,7 +171,7 @@ class PackagesController < ApplicationController
|
||||||
|
|
||||||
# Receive an anonymous report from a user to have a screenshot removed.
|
# Receive an anonymous report from a user to have a screenshot removed.
|
||||||
def report_screenshot
|
def report_screenshot
|
||||||
@screenshot = Screenshot.find(params[:id])
|
@screenshot = Screenshot.find!(params[:id])
|
||||||
@screenshot.delete_reason = params[:delete_reason]
|
@screenshot.delete_reason = params[:delete_reason]
|
||||||
@screenshot.markedfordelete = true
|
@screenshot.markedfordelete = true
|
||||||
@screenshot.save!
|
@screenshot.save!
|
||||||
|
|
@ -222,4 +224,12 @@ class PackagesController < ApplicationController
|
||||||
# - Is the user an admin (=logged in)?
|
# - Is the user an admin (=logged in)?
|
||||||
@screenshot.uploaderhash == session[:token] or user_signed_in?
|
@screenshot.uploaderhash == session[:token] or user_signed_in?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Store a random identifier and the client's IP address in the session
|
||||||
|
# for later identification.
|
||||||
|
def create_user_token
|
||||||
|
session[:token] ||= SecureRandom.hex
|
||||||
|
session[:ip] ||= request.remote_ip
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -92,9 +92,9 @@ class Screenshot < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return the number of screenshots that need to be approved
|
# Return the number of screenshots that need to be approved
|
||||||
def self.unapproved
|
# def self.unapproved
|
||||||
self.where(approved: false)
|
# self.where(approved: false)
|
||||||
end
|
# end
|
||||||
|
|
||||||
# Publish a screenshot from the moderation queue
|
# Publish a screenshot from the moderation queue
|
||||||
def approve_screenshot!
|
def approve_screenshot!
|
||||||
|
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 0 B After Width: | Height: | Size: 1.9 KiB |
BIN
public/fonts/DroidSans-Bold.woff2
Normal file
BIN
public/fonts/DroidSans-Bold.woff2
Normal file
Binary file not shown.
BIN
public/fonts/DroidSans.woff2
Normal file
BIN
public/fonts/DroidSans.woff2
Normal file
Binary file not shown.
|
|
@ -1,4 +1,3 @@
|
||||||
User-agent: *
|
User-agent: *
|
||||||
Disallow: /json
|
Disallow: /json
|
||||||
Disallow: /api
|
Disallow: /upload
|
||||||
Disallow:
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue