Merge branch 'master' of bitbucket.org:signum/debshots
This commit is contained in:
commit
a2178d8226
9 changed files with 28 additions and 23 deletions
|
|
@ -82,7 +82,6 @@ properly unless the separate model validation is in place.
|
||||||
|
|
||||||
Deployment
|
Deployment
|
||||||
----------
|
----------
|
||||||
|
|
||||||
To prepare your computer to run Debshots 2.x either for development
|
To prepare your computer to run Debshots 2.x either for development
|
||||||
or production you need to…
|
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 Ruby 2.0.0 via rvm (see http://rvm.io/)
|
||||||
- install the library header packages so that the required Ruby gems
|
- install the library header packages so that the required Ruby gems
|
||||||
can be compiled:
|
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:
|
- install a PostgreSQL database:
|
||||||
sudo apt-get install postgresql
|
sudo apt-get install postgresql
|
||||||
- edit the PostgreSQL authentication configuration at
|
- edit the PostgreSQL authentication configuration at
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ class ApplicationController < ActionController::Base
|
||||||
# and show them even before moderation.
|
# and show them even before moderation.
|
||||||
def create_user_token
|
def create_user_token
|
||||||
session[:token] ||= SecureRandom.hex
|
session[:token] ||= SecureRandom.hex
|
||||||
|
session[:ip] ||= request.remote_ip
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,8 @@ class PackagesController < ApplicationController
|
||||||
@package = Package.find_by(name: params[:name])
|
@package = Package.find_by(name: params[:name])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# POST target of the screenshots upload form.
|
||||||
|
# Checks upload images and creates a new Screenshot record for it.
|
||||||
def upload_image
|
def upload_image
|
||||||
@package = Package.find_by(name: params[:name])
|
@package = Package.find_by(name: params[:name])
|
||||||
|
|
||||||
|
|
@ -33,13 +35,15 @@ class PackagesController < ApplicationController
|
||||||
new_screenshot = @package.screenshots.new(image: img)
|
new_screenshot = @package.screenshots.new(image: img)
|
||||||
|
|
||||||
# Check if the image was valid
|
# Check if the image was valid
|
||||||
unless new_screenshot.valid?
|
if new_screenshot.valid?
|
||||||
errors = new_screenshot.errors[:image].join(' and ')
|
new_screenshot.uploaderhash = session[:token]
|
||||||
flash['alert'] = "Sorry - the image #{errors}"
|
new_screenshot.uploaderip = session[:ip]
|
||||||
else
|
|
||||||
new_screenshot.save
|
new_screenshot.save
|
||||||
successful_upload_count += 1
|
successful_upload_count += 1
|
||||||
Log.log "Screenshot #{new_screenshot.id} uploaded successfully."
|
Log.log "Screenshot #{new_screenshot.id} uploaded successfully."
|
||||||
|
else
|
||||||
|
errors = new_screenshot.errors[:image].join(' and ')
|
||||||
|
flash['alert'] = "Sorry - the image #{errors}"
|
||||||
end
|
end
|
||||||
|
|
||||||
if successful_upload_count > 0
|
if successful_upload_count > 0
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ class Screenshot < ActiveRecord::Base
|
||||||
|
|
||||||
# Return Debshots 1.x path to allow migration of images into Paperclip filesystem schema
|
# Return Debshots 1.x path to allow migration of images into Paperclip filesystem schema
|
||||||
def image_url(size)
|
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
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,9 @@
|
||||||
.small-12.columns
|
.small-12.columns
|
||||||
a.black.fancybox href=screenshot.image.url(:large, timestamp: false) rel='fancybox-thumb' title=screenshot.caption
|
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)
|
= 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
|
// TODO: Enable button only if admin or uploader
|
||||||
a.button.tiny.alert[
|
a.button.tiny.alert[
|
||||||
href=delete_screenshot_path(@package.name, screenshot.id)
|
href=delete_screenshot_path(@package.name, screenshot.id)
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
#!/bin/sh -ex
|
#!/bin/sh -ex
|
||||||
|
|
||||||
IMAGE_DEST=public/screenshots
|
#IMAGE_DEST=../public
|
||||||
|
IMAGE_DEST=public
|
||||||
#IMAGE_DEST=/local/screenshots
|
#IMAGE_DEST=/local/screenshots
|
||||||
DB_HOST=localhost
|
#DB_HOST=localhost
|
||||||
#DB_HOST=torf
|
DB_HOST=torf
|
||||||
|
|
||||||
echo Getting screenshot files
|
echo Getting screenshot files
|
||||||
rsync -v root@screenshots.debian.net:/home/debshots/debshots-screenshots.tar /tmp
|
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
|
echo Unpacking screenshots tarball
|
||||||
#cd ../public
|
#cd ../public
|
||||||
cd $IMAGE_DEST
|
#cd $IMAGE_DEST
|
||||||
tar xf /tmp/debshots-screenshots.tar
|
tar -C $IMAGE_DEST -xf /tmp/debshots-screenshots.tar
|
||||||
#mv public/live/screenshots/approved public/screenshots
|
#mv public/live/screenshots/approved public/screenshots
|
||||||
#rm -r public/live
|
#rm -r public/live
|
||||||
|
ln -fs public/live/screenshots/approved public/screenshots
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ development:
|
||||||
adapter: postgresql
|
adapter: postgresql
|
||||||
database: debshots_dev
|
database: debshots_dev
|
||||||
username: debshots
|
username: debshots
|
||||||
password: GonwannEn0
|
password: shootme
|
||||||
host: localhost
|
host: torf
|
||||||
pool: 5
|
pool: 5
|
||||||
timeout: 5000
|
timeout: 5000
|
||||||
|
|
||||||
|
|
@ -19,8 +19,8 @@ test:
|
||||||
adapter: postgresql
|
adapter: postgresql
|
||||||
database: debshots_test
|
database: debshots_test
|
||||||
username: debshots
|
username: debshots
|
||||||
password: GonwannEn0
|
password: shootme
|
||||||
host: localhost
|
host: torf
|
||||||
pool: 5
|
pool: 5
|
||||||
timeout: 5000
|
timeout: 5000
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,10 +30,6 @@ Debshots::Application.configure do
|
||||||
# ActiveRecord errors propagate normally (forward deprecation to Rails 5)
|
# ActiveRecord errors propagate normally (forward deprecation to Rails 5)
|
||||||
config.active_record.raise_in_transactional_callbacks = true
|
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"
|
# DEB package repositories to parse when running "rake debshots:... tasks"
|
||||||
config.package_sources = [
|
config.package_sources = [
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -13,13 +13,13 @@ Debshots::Application.routes.draw do
|
||||||
|
|
||||||
get 'packages' => 'packages#grid', as: :packages_grid
|
get 'packages' => 'packages#grid', as: :packages_grid
|
||||||
get 'packages/list' => 'packages#list', as: :packages_list
|
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', to: redirect('/packages')
|
||||||
get 'upload/:name' => 'packages#upload', as: :upload_package_by_name
|
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 'delete_screenshot/:name/:id' => 'packages#delete_screenshot', as: :delete_screenshot
|
||||||
get 'about' => 'welcome#about'
|
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.
|
# The priority is based upon order of creation: first created -> highest priority.
|
||||||
# See how all your routes lay out with "rake routes".
|
# See how all your routes lay out with "rake routes".
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue