CoverImages is a web service for retrieving cover images for books, music albums, DVDs, and other media.
- Ruby-2.3.1
- Redis for sidekiq workers
- ImageMagick for paperclip processing
- Mysql
server config is kept in .env
.
.env.production
will override .env
when RAILS_ENV=production.
For development, only the api keys are required.
The admin panel uses UVa's Netbadge authorization. Apache must be configured for this.
Authorized users need to be listed in config/authorized_users.yml
.
Admins can perform CRUD actions on all cover images. Including manual creation with a solr id. The workers link shows the built-in sidekiq/background job dashboard.
In order by priority. If no image is found from a source, we use the next one.
Each service has it's own rate limits, defined in app/workers/*
- Google Books
- LibraryThing
- Syndetics (undocumented)
- OpenLibrary
GET /cover_images/[solr_id].json
is the only public endpoint.
Query Param | Values | Required |
---|---|---|
doc_type | music or non_music | yes |
title | no | |
isbn | * | |
oclc | * | |
lccn | * | |
upc | * | |
mbid | no | |
artist_name | yes, for music | |
album_name | yes, for music | |
* At least one of the starred ids is required for books. |
Returns JSON. A default image is sent if the resord has not been processed yet.
{
image_base64: [Base64 encoded image],
not_found: [true,false],
errors: [Error String]
}
Certain images have been reported as incorrect and have been replaced with correct versions.
When starting with an empty instance of cover images run rake preload:locked_images
this will load images from project_root/locked_images/. This can be rerun multiple times in order to get the latest changes.
Images in locked_images/ should be named with their corresponding document id found in Virgo ex: u333.jpg
Rails 5 with minitest: rails test
The VCR gem is used to record and play back api responses for testing.
To record new responses (if an api changes) run rm -rf test/fixtures/vcr_cassettes
and the next rails test
will make real api requests.
cap production deploy
Capistrano handles deployments and restarting puma, sidekiq.
config/deploy.rb
and config/deploy/[staging,production].rb
have the details.
Most config files including .env, database.yml, authorized_users.yml and the actual cover images located at public/system
are located in [deploy_path]/shared
and symlinked to the [deploy_path]/current
folder during deployment.
Anything that is server specific and preserved between deployments should be in a capistrano linked file.