Gyazo Server made with Ruby on Rails 4.0.5
JavaScript Ruby Other
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
app
assets
bin
config
lib
log
public
spec
vendor/assets
.gitignore
.rspec
Gemfile
Gemfile.lock
Guardfile
LICENSE.md
README.md
Rakefile
config.ru

README.md

Gyazo Server

Gyazo Server made with Ruby on Rails

Features

  • Using file system (Not using database)
  • Delete uploaded image
  • Support gif & jpg
  • Resize gif animation

Dependency

  • ImageMagick

Mac

brew install imagemagick

Ubuntu

sudo apt-get install imagemagick libmagick++-dev

Installation

git clone git@github.com:mitukiii/gyazo-server.git

Gyazo Client Configuration

Configure the host, port & gyazo id to use upload

cat assets/script \
    | sed 's/YOUR HOST/pic.example.jp/' \
    | sed 's/YOUR GYAZO ID/yourid/' \
    > /Applications/Gyazo.app/Contents/Resources/script

Gyazo Server Configuration

Set secret key

sed -i '' -e "s/YOUR SECRET KEY/$(rake secret)/" config/initializers/secret_token.rb

Configure the image upload folder & gyazo id

sed -i '' -e 's|YOUR IMAGE FOLDER|/var/images|' \
    -e 's|YOUR THUMBNAIL FOLDER|/var/images/t|' \
    -e 's|YOUR GYAZO ID|yourid|' \
    config/environments/production.rb

Nginx & Unicorn Configuration Sample

Send static files directly from Nginx And, to error page using Ruby on Rails

upstream unicorn.pic.example.com {
    server unix:/tmp/unicorn.pic.example.com.sock;
}
server {
    listen 80;
    server_name pic.example.com;
    root /var/www/example.com/pic;

    error_page 404 /404;

    access_log /var/log/nginx/pic.example.com.access.log;
    error_log /var/log/nginx/pic.example.com.error.log;

    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_pass http://unicorn.pic.example.com;
    }

    location = /favicon.ico {}
    location = /robots.txt {}

    location ~ ^/assets/ {
        gzip_static on;
        expires     max;
        add_header  Cache-Control public;
    }

    location ~ \.(png|gif|jpe?g)$ {
        if ($request_method = DELETE) {
            proxy_pass http://unicorn.pic.example.com;
            break;
        }

        root /var/images;

        gzip_static on;
        expires     max;
        add_header  Cache-Control public;
    }
}
# -*- coding: utf-8 -*-

worker_processes 3

listen '/tmp/unicorn.pic.example.com.sock'

pid '/tmp/unicorn.pic.example.com.pid'

stderr_path 'log/unicorn.log'
stdout_path 'log/unicorn.log'

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Copyright

Copyright (c) 2012 Kazuya Takeshima. See LICENSE for details.