Giter VIP home page Giter VIP logo

virginia's Introduction

Virginia Build Status

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.

Configuration

The plugin defines three configuration keys.

  • host: Which IP to bind on (defaults to 0.0.0.0)
  • port: Which port to listen on (defaults to 8080)
  • rackup: Location of the Rackup configuration file (defaults to config.ru)

Sinatra Example

This example uses Sinatra, but this should work with any Rack-compatible framework.

Update Gemfile

Add the framework gem to your Gemfile, in our case, Sinatra:

gem 'sinatra'

Don't forget to run bundle install.

Create the app

Here is a simple "Hello World" app in Sinatra. Place this in lib/sinatra_app.rb:

require 'sinatra'

get '/' do
  'Hello world!'
end

Configure Rack

Finally, tell Rack how to start your web app. Place this in config.ru:

require "#{Adhearsion.root}/lib/sinatra_app.rb"
run Sinatra::Application

Test the app

Start Adhearsion. You should be able to visit http://localhost:8080/ in your browser and see "Hello world!"

Using the built-in document cache

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.

Contributors

Original author: Luca Pradovera

Contributors:

Links

Note on Patches/Pull Requests

  • Fork the project.
  • Make your feature addition or bug fix.
  • Add tests for it. This is important so I don't break it in a future version unintentionally.
  • Commit, do not mess with rakefile, version, or history.
    • If you want to have your own version, that is fine but bump version in a commit by itself so I can ignore when I pull
  • Send me a pull request. Bonus points for topic branches.

Copyright

Copyright (c) 2012-2014 Adhearsion Foundation Inc. MIT license (see LICENSE for details).

virginia's People

Contributors

benlangfeld avatar bklang avatar lpradovera avatar mehakdeep avatar neildecapia avatar pungoyal avatar victorluft avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.