Virginia is a Reel interface to Adhearsion, named after a dance originating in the 17th century, the Virginia Reel. Now your web apps can dance with your voice apps!
Virginia allows you to bundle a simple web interface in your Adhearsion application. You can use any Rack-compatible framework with Reel.
The plugin defines three configuration keys.
This example uses Sinatra, but this should work with any Rack-compatible framework.
Add the framework gem to your Gemfile, in our case, Sinatra:
gem 'sinatra'
Don't forget to run bundle install
.
Here is a simple "Hello World" app in Sinatra. Place this in lib/sinatra_app.rb
:
require 'sinatra'
get '/' do
'Hello world!'
end
Finally, tell Rack how to start your web app. Place this in config.ru
:
require "#{Adhearsion.root}/lib/sinatra_app.rb"
run Sinatra::Application
Start Adhearsion. You should be able to visit http://localhost:8080/
in your browser and see "Hello world!"
Assuming you are using Sinatra like in the above examples, put this in your lib/sinatra_app.rb
:
require 'sinatra'
get '/documents/:id' do
begin
document = Virginia::DocumentCache.fetch params[:id]
headers['Content-Type'] = document.content_type
document.body
rescue Virginia::DocumentCache::NotFound
raise Sinatra::NotFound
end
end
Then, to store a document in the cache, do this in your CallController:
cache_id = Virginia::DocumentCache.store 'Hello World!'
virginia_config = Adhearsion.config.virginia
logger.info "Document has been cached to http://#{virginia_config.host}:#{virginia_config.port}/documents/#{cache_id}"
You should be able to retrieve the document at the logged URL.
Original author: Luca Pradovera
Contributors:
Copyright (c) 2012-2014 Adhearsion Foundation Inc. MIT license (see LICENSE for details).