Merge branch 'master' of bitbucket.org:signum/debshots

This commit is contained in:
Christoph Haas 2015-06-15 13:05:10 +02:00
commit a2178d8226
9 changed files with 28 additions and 23 deletions

View file

@ -82,7 +82,6 @@ properly unless the separate model validation is in place.
Deployment
----------
To prepare your computer to run Debshots 2.x either for development
or production you need to…
@ -90,7 +89,7 @@ or production you need to…
- install Ruby 2.0.0 via rvm (see http://rvm.io/)
- install the library header packages so that the required Ruby gems
can be compiled:
sudo apt-get install libbz2-dev libpq-dev
sudo apt-get install libbz2-dev libpq-dev libyaml-dev
- install a PostgreSQL database:
sudo apt-get install postgresql
- edit the PostgreSQL authentication configuration at

View file

@ -9,6 +9,7 @@ class ApplicationController < ActionController::Base
# and show them even before moderation.
def create_user_token
session[:token] ||= SecureRandom.hex
session[:ip] ||= request.remote_ip
end
end

View file

@ -24,6 +24,8 @@ class PackagesController < ApplicationController
@package = Package.find_by(name: params[:name])
end
# POST target of the screenshots upload form.
# Checks upload images and creates a new Screenshot record for it.
def upload_image
@package = Package.find_by(name: params[:name])
@ -33,13 +35,15 @@ class PackagesController < ApplicationController
new_screenshot = @package.screenshots.new(image: img)
# Check if the image was valid
unless new_screenshot.valid?
errors = new_screenshot.errors[:image].join(' and ')
flash['alert'] = "Sorry - the image #{errors}"
else
if new_screenshot.valid?
new_screenshot.uploaderhash = session[:token]
new_screenshot.uploaderip = session[:ip]
new_screenshot.save
successful_upload_count += 1
Log.log "Screenshot #{new_screenshot.id} uploaded successfully."
else
errors = new_screenshot.errors[:image].join(' and ')
flash['alert'] = "Sorry - the image #{errors}"
end
if successful_upload_count > 0

View file

@ -42,7 +42,7 @@ class Screenshot < ActiveRecord::Base
# Return Debshots 1.x path to allow migration of images into Paperclip filesystem schema
def image_url(size)
"#{Rails.configuration.images_path_prefix}/#{self.package.name[0]}/#{self.package.name}/#{self.id}_#{size}.png"
"live/screenshots/approved/#{self.package.name[0]}/#{self.package.name}/#{self.id}_#{size}.png"
end

View file

@ -10,6 +10,9 @@
.small-12.columns
a.black.fancybox href=screenshot.image.url(:large, timestamp: false) rel='fancybox-thumb' title=screenshot.caption
= image_tag(screenshot.image.url(:large, timestamp: false), alt: screenshot.caption)
.imgcaption =screenshot.caption
// TODO: Show information only if admin
p Uploader IP=#{screenshot.uploaderip} / Token=#{screenshot.uploaderhash}
// TODO: Enable button only if admin or uploader
a.button.tiny.alert[
href=delete_screenshot_path(@package.name, screenshot.id)

View file

@ -1,9 +1,10 @@
#!/bin/sh -ex
IMAGE_DEST=public/screenshots
#IMAGE_DEST=../public
IMAGE_DEST=public
#IMAGE_DEST=/local/screenshots
DB_HOST=localhost
#DB_HOST=torf
#DB_HOST=localhost
DB_HOST=torf
echo Getting screenshot files
rsync -v root@screenshots.debian.net:/home/debshots/debshots-screenshots.tar /tmp
@ -30,8 +31,9 @@ psql -h $DB_HOST debshots_test debshots < /tmp/debshots.sql
echo Unpacking screenshots tarball
#cd ../public
cd $IMAGE_DEST
tar xf /tmp/debshots-screenshots.tar
#cd $IMAGE_DEST
tar -C $IMAGE_DEST -xf /tmp/debshots-screenshots.tar
#mv public/live/screenshots/approved public/screenshots
#rm -r public/live
ln -fs public/live/screenshots/approved public/screenshots

View file

@ -7,8 +7,8 @@ development:
adapter: postgresql
database: debshots_dev
username: debshots
password: GonwannEn0
host: localhost
password: shootme
host: torf
pool: 5
timeout: 5000
@ -19,8 +19,8 @@ test:
adapter: postgresql
database: debshots_test
username: debshots
password: GonwannEn0
host: localhost
password: shootme
host: torf
pool: 5
timeout: 5000

View file

@ -30,10 +30,6 @@ Debshots::Application.configure do
# ActiveRecord errors propagate normally (forward deprecation to Rails 5)
config.active_record.raise_in_transactional_callbacks = true
# URL prefix leading to the static images that should get delivered by the web server
config.images_path_prefix = '/screenshots'
# DEB package repositories to parse when running "rake debshots:... tasks"
config.package_sources = [
{

View file

@ -13,13 +13,13 @@ Debshots::Application.routes.draw do
get 'packages' => 'packages#grid', as: :packages_grid
get 'packages/list' => 'packages#list', as: :packages_list
get 'package/:name' => 'packages#details', as: :package
get 'package/:name' => 'packages#details', as: :package, name: /[^\/]+/
get 'upload', to: redirect('/packages')
get 'upload/:name' => 'packages#upload', as: :upload_package_by_name
post 'upload_image/:name' => 'packages#upload_image', as: :upload_image
post 'upload_image/:name' => 'packages#upload_image', as: :upload_image, name: /[^\/]+/
get 'delete_screenshot/:name/:id' => 'packages#delete_screenshot', as: :delete_screenshot
get 'about' => 'welcome#about'
get 'thumbnail/:name' => 'packages#thumbnail', as: :thumbnail_image
get 'thumbnail/:name' => 'packages#thumbnail', as: :thumbnail_image, name: /[^\/]+/
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".