An example Rails app that uses the LayerVault API.
What does it do? It makes sweet GIFs and MOVs of your work, like so:
The above GIF was created from this LayerVault public project.
pummeldoge is a Rails 4 application. You will need gifsicle, ffmpeg, and imagemagick installed.
To install those in one swift go with Homebrew:
brew install ffmpeg
brew install gifsicle
brew install imagemagick
You will also need to register a LayerVault application. You can do that from your LayerVault Development page. (Account required. Accounts are free.)
Next, define your API keys in your shell:
export LAYERVAULT_CLIENT_ID=MY_LAYERVAULT_CLIENT_ID_FROM_THE_SITE
export LAYERVAULT_CLIENT_SECRET=MY_LAYERVAULT_SECRET_FROM_THE_SITE
Then:
git clone git@github.com:layervault/pummeldoge.git
cd pummeldoge
bundle
bundle exec foreman start
open http://localhost:3000
Hot doge!
This app uses Sidekiq and postgres. That might seem a little heavy for a demo app. This is done to cut down on processing time, most folks likely have multi-core processors these days. If we're doing a lot of work at the same time, the Rails-default SQLite3 has terrible write performance. To fix that, we use postgres by default.
You will need to change your username in config/database.yml
to take advantage of postgres.
This example application is a good demonstration of top-to-bottom use of the LayerVault API.
To authenticate users, we use the omniauth-layervault gem. You can
see how we create a User
object from the response in
app/controllers/auth_controller.rb and app/models/user.rb.
To actually get data out of LayerVault, we use the layervault gem. You can see that in action in the PreviewGatheringService.
Once we have URLs to all of the previews we need, it's just a matter of pulling them down and mushing them into GIFs and MOVs.