Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Commits on Sep 8, 2011
  1. oops on app.rb

    authored
  2. trashed .DS_Store

    authored
  3. README File

    authored
    We're adding the README file which shows on the Github repo and explains what this
    is and how to make it work.
  4. Views & CSS/Images

    authored
    Now that we've gotten the Gemfile taken care of so DotCloud can install
    our dependencies we add the last parts of our application. We're adding
    all the views used, as well as the images and CSS on the page.
    
    This tutorial is using Haml as the markup language but you could
    substitute your preferred language (erb, slim, etc). Let's talk just a
    bit about some of the views.
    
    First, ``layout.haml`` serves to generate the "layout" of our site or
    "what goes where" if you will. Thanks to Haml we save quite a bit of
    typing. Sinatra by default looks for a file named layout in the
    ``views/`` directory to serve as the applications layout, we don't need
    to do anything special to get this to work.
    
    The ``index.haml`` gives us the header text, image, and 'view source'
    link and tells Sinatra to render our two remaining templates, text and
    footer.
    
    ``text.haml`` is the form that contains the input fields for "Number"
    and "Message" as well as the "Text Me!" button. Finally ``footer.haml``
    is made up of just the Twitter logo. It might be overkill in this simple
    example to give this its own template but if the application were to
    grow it makes it a little easier to add things and keeps our templates small.
    
    With these files added you can now ``dotcloud push cloudsinger`` and
    then visit the URL of your deployed app. When you visit the URL you
    should be able to supply a phone number and a message (140 characters or
    less of course!) that you would like to send. Click on "Text Me!" and if
    you've setup ``config.yml`` correctly and all systems are go, you should
    get a text shortly at the number you provided. Please note that if
    you're using a Twilio demo account you may need to edit ``app.rb`` line
    33. In this file you will need to add your Twilio PIN as the first
    argument to ``Twilio::Sms.message()``, this is also documented directly
    in ``app.rb``.
    
    This is just the beginning of what's possible with Twilio. You can make
    and receive phone calls, record them, create conferences, and receive
    SMS messages. In a non-trivial application you would login to the Twilio
    dashboard and setup Twilio to HTTP POST to a URL of your app when
    someone calls or SMS messages your application and you would then write
    the code to handle those POST events.
    
    I hope you've enjoyed this DotCloud + Twilio demo, feel free to drop us
    a line if you have problems.
  5. Gemfile & Dependencies

    authored
    To tell DotCloud to automatically install the gems we need (Haml and
    Twilio), we create a standard Gemfile. DotCloud will detect this and
    automatically use ``bundler`` to install dependencies defined in
    Gemfile.
    
    This also gets ran when you scale your application on DotCloud. See
    http://gembundler.com/gemfile.html for details about Bundler and the
    Gemfile format.
Commits on Sep 1, 2011
  1. Demo Sinatra Application and Rack Config

    authored
    This is a simple sinatra application and rack configuration
    file. The sinatra application is contained in ``app.rb`` and is fairly
    straightforward. This application will display a simple form that asks
    for a phone number and gives a textarea for the message you wish to send
    via SMS.
    
    ``config.ru`` is also telling rack to serve static files from
    ``public/css`` and ``public/images``. Sinatra, by default, looks in
    public (and we've told it again by saying ``:root => 'public'``) so you
    won't need to use it when referring to static file locations within your
    Sinatra application. In this example, you would link the CSS by writing
    ``/css/style.css``; see how we didn't use ``public/`` at the beginning
    of the path? You can find more information on the ``config.ru`` file at
    http://www.modrails.com/documentation/Users%20guide%20Nginx.html#deploying_a_rack_app.
    
    You should have an account by now and you should've configured your phone
    number, SID, and Twilio token in ``config/config.yml``. As a bonus,
    twilio gives you $30 when you sign up!!
    
    Our application isn't quite ready yet, but almost. I've chosen to use
    Haml for templates, so we'll add those views shortly.
  2. YAML Configuration File

    authored
    Next we're adding a YAML file that contains our Twilio information that
    will be used later in ``app.rb``. If you don't have an account already
    you can sign up for one here: http://twilio.com.
    
    Change the settings in this file to match your Twilio number, SID, and
    token. ``app.rb`` is already setup to use the settings you place in
    ``config.yml``.
  3. Dotcloud Build File

    authored
    The DotCloud Build File, ``dotcloud.yml`` describes our stack.
    
    We declare a single ruby service. We use ruby because it features two
    useful things for us:
    
    * a Ruby interpreter and a mechanism to install gems
    * a public-facing HTTP server (nginx)
    
    The role and syntax of the DotCloud Build File is explained in further
    detail in the documentation,
    http://docs.dotcloud.com/guides/build-file/
  4. No commit message

    authored
Something went wrong with that request. Please try again.