Switch branches/tags
Nothing to show
Commits on Sep 1, 2011
  1. README File

    caleywoods committed Sep 1, 2011
    We're adding the README file which shows on the Github repo and explains what this
    is and how to make it work.
  2. Views & CSS/Images

    caleywoods committed Sep 1, 2011
    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
    ``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.
  3. Gemfile & Dependencies

    caleywoods committed Sep 1, 2011
    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
    This also gets ran when you scale your application on DotCloud. See for details about Bundler and the
    Gemfile format.
  4. Demo Sinatra Application and Rack Config

    caleywoods committed Sep 1, 2011
    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.
    ```` 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 ```` file at
    `this site
    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.
  5. YAML Configuration File

    caleywoods committed Sep 1, 2011
    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 on the `Twilio homepage <>`_.
    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
  6. Dotcloud Build File

    caleywoods committed Sep 1, 2011
    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,
  7. No commit message

    caleywoods committed Sep 1, 2011