No description
Find a file
2016-06-22 18:10:43 +02:00
app Prepared back link (still ugly) in details view 2016-06-22 18:10:33 +02:00
bin Fixed data migration script 2015-06-26 21:18:17 +02:00
config Do not serve static files from the application in production mode 2016-06-21 10:58:34 +02:00
db Schema fixed 2016-05-16 23:48:05 +02:00
lib Typo fixed 2016-06-22 18:10:43 +02:00
log Blank rails 4.0 project started 2013-07-27 00:19:29 +02:00
public Added dummy image for no-screenshots-available as SVG 2015-04-27 00:16:25 +02:00
test Authlogic cruft removed 2016-06-14 17:04:43 +02:00
vendor/assets Removed vendor jQuery fancybox stylesheet - it's included in the Gem 2016-04-06 16:42:20 +02:00
.gitignore Bundling vendor packages 2016-06-13 17:53:23 +02:00
.ruby-version rbenv Ruby version added 2016-05-18 18:40:32 +02:00
config.ru Blank rails 4.0 project started 2013-07-27 00:19:29 +02:00
debshots.komodoproject Komodo Edit project added 2013-11-13 23:23:39 +01:00
debshots2.sublime-project Ignoring files and directories does not work in project files. 2016-03-01 17:03:02 +01:00
Gemfile debugger disabled - currently broken 2016-05-16 23:44:14 +02:00
Gemfile.lock debugger disabled - currently broken 2016-05-16 23:44:14 +02:00
Guardfile Removed "rails s" from Guardfile 2015-04-24 12:20:06 +02:00
Rakefile Blank rails 4.0 project started 2013-07-27 00:19:29 +02:00
README.Developer Added hint on how to add admins 2015-07-15 18:00:09 +02:00
README.rdoc Deployment documentation improved 2016-06-16 10:41:49 +02:00

== Installing debshots

=== Prepare PostgreSQL database server and user (ident-based authentication)

apt install postgresql

su - postgres

createuser -d debshots

createdb -O debshots -E UTF8 -T template0 debshots

=== Create an application user

adduser debshots

su - debshots

=== Install the required Ruby version using rbenv

https://github.com/rbenv/rbenv

git clone https://github.com/rbenv/rbenv.git ~/.rbenv

echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile


# Load rbenv automatically by appending
# the following to ~/.bashrc:

eval "$(rbenv init -)"


https://github.com/rbenv/ruby-build#readme

git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build

=== Get the application

Clone the debshots Git repository.

=== Install the Ruby dependencies

rbenv install

echo "gem: --no-rdoc --no-ri" > ~/.gemrc

gem install bundler

bundle install --deployment

=== Copy screenshots and database from the former live website

scp screenshots.debian.net:debshots-screenshots.tar .

tar -C public/ -xvf debshots-screenshots.tar

scp screenshots.debian.net:debshots.sql .

psql debshots < debshots.sql

Switch to production environment:

export RAILS_ENV=production

Migrate database:

bundle exec rake db:migrate RAILS_ENV=production

(config/database.yml: production: user/password/host must be commented out)

Convert screenshots to new format (paperclip):

bundle exec rake debshots:screenshots_to_paperclip RAILS_ENV=production

Remove old screenshots directory structure:

rm -r public/live

Render the assets:

bundle exec rake assets:precompile RAILS_ENV=production

Test the application:

bundle exec rails s -b 0.0.0.0 -e production

http://...:3000/

Create a user for moderation:

bundle exec rails c -e production

user = User.create(realname: 'Christoph Haas', password: 'foobartest', email: 'email@christoph-haas.de')
user.save!

Tidy up the screenshot data:

bundle exec rake debshots:remove_broken_screenshots

bundle exec rake debshots:remove_duplicate_images

Import new package information:

bundle exec rake debshots:list_deb_repos

bundle exec rake debshots:update_from_deb_repos

bundle exec debshots:update_longdescription_from_deb_repos

=== Install passenger to run the application behind nginx

https://www.phusionpassenger.com/library/walkthroughs/deploy/ruby/ownserver/nginx/oss/jessie/install_passenger.html

Example nginx vhost config:

server {
    listen 85.25.83.22:80 default_server;
    passenger_enabled on;
    passenger_ruby /home/debshots/.rbenv/versions/2.3.1/bin/ruby;
    root /home/debshots/debshots/public;
    server_name _;
}

=== Enable nginx caching

mkdir /var/cache/nginx

chown www-data.www-data /var/cache/nginx

nginx config…

proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=my_cache:10m max_size=10g inactive=60m use_temp_path=off;

== Supported URL paths (aka routes)

/screenshots/:package_inital/:package/:(id)_:size.png
* package = name of the package
* id = numerical ID of the screenshot
* size = "large" or "small"
* Returns a PNG image of a screenshot
* Should be served as a static asset

/image/:(id)_:size.png
* id = numerical ID of the screenshot
* size = "large" or "small"
* Returns a PNG image of a screenshot
* Usually used for unapproved images that should just be shown to the uploader

/about
* Return an informational HTML page

/packages
* Return a list of packages with pagination

/packages/with_screenshots
* Return a list of packages with pagination
* Select only those packages that have screenshots.

/packages/without_screenshots
* Return a list of packages with pagination
* Select only those packages that do not have screenshots.

/packages/games_without_screenshots (deprecated)
* Return a list of packages with pagination
* Select only those packages that belong to Debian's "games" section

/json/packages
* Return a JSON data structure of all packages

/json/screenshots
* Return a JSON data structure containing packages and screenshots

/json/packages-without-screenshots
* Return a JSON data structure of those packages that do not have any screenshots

/packages/moderate
* Return a HTML page showing packages that need moderation
* Must only be available to logged in moderators

/upload
* Return a HTML page containing an upload form for new screenshots

/guidelines (deprecated)
* Return a HTML page showing general guidelines for creating screenshots
* Should just redirect to the /upload page

/upload/:package
* ??

/uploadfile
* ??

/login
* Show a login form

/logout
* Logout the user by invalidating the cookie session.

/package/:package
* Show details of a certain package

/json/package/:package
* Return a JSON data structure containing details of a certain package

/thumbnail/:package
/thumbnail-404/:package (deprecated)
* Return a small (160x120 pixel) PNG screenshot file of a package
* If the package does not have any screenshots then return a 404 code

/thumbnail-with-version/:package/:version
* Return a small (160x120 pixel) PNG screenshot file of a package
* If the package does not have any screenshots then return a 404 code
* Prefer screenshots of a certain version

/screenshot/:package
/screenshot-404/:package (deprecated)
* Return a small (320x240 pixel) PNG screenshot file of a package
* If the package does not have any screenshots then return a 404 code

/screenshot-with-version/:package/:version
* Return a large (320x240 pixel) PNG screenshot file of a package
* If the package does not have any screenshots then return a 404 code
* Prefer screenshots of a certain version

/delete_screenshot/:screenshot
* Users: request deletion of a screenshot
* Moderators: delete a screenshot

/approve_screenshot/:screenshot
* Users: 403
* Moderators: approve a screenshot

/keep_screenshot/:screenshot
* Users: 403
* Moderators: re-approve a screenshot that was requested for deletion

/rss
* Return an RSS feed of new uploads of screenshots