/picto

Email driven web image gallery

Primary LanguageRuby

Picto

Email driven web image gallery

Requirements

  • Ruby 2.2.0
  • ImageMagick
  • Postgres
  • Redis

Instalation

$ git clone git@github.com:b0oh/picto.git
$ cd picto
$ bundle
$ cp config/config.yml.example config/config.yml
$ open config/config.yml
$ bundle exec rake db:create db:migrate
$ bundle exec rackup

Running tests

$ RACK_ENV=test bundle exec rake db:create db:migrate
$ bundle exec rake

Running workers

$ bundle exec sidekiq -c 5 -r ./lib/picto.rb

API

Possible responses

  • 200 application/json

  • 204

  • 400 application/json

      { "error": {
          "status": "invalid_param",
          "message": "error message"
        }
      }
    
  • 404 application/json

      { "error": {
          "status": "not_found",
          "message": "not found"
        }
      }
    
  • 422 application/json

      { "error": {
          "status": "unprocessable_entity",
          "message": "error message"
        }
      }
    

Get config:

GET: /api/config

Response:

Status: 200 OK

{ "config": {
    "mail": "to@send_pics"
  }
}

Get images:

Request:    
offset optional Skip number of results from beginning.
limit optional Number of results to return per page.
GET: /api/images

Response:

Status: 200 OK

{ "images": [
    {
      "id": "abcdef",
      "url": "https://url-to-image",
      "width": 400,
      "height": 300,
      "user": {
        "id": 1,
        "email": "email"
      }
    }
  ],
  "pagination": {
    "total": 351,
    "count": 4,
    "offset": 347,
    "limit": 100
  }
}

Post images:

Request:    
sender required Sender's email.
attachment-count optional Number of sended attachments
attachment-#{n} optional Attachment as multipart data
POST: /api/images/post

Response:

Status: 204 OK