Mango release 0.6.2 (June 6, 2011)

Copyright (c) 2011 Ryan Sobol. Licensed under the MIT license. Please see the LICENSE for more information.

SYNOPSIS

Mango is a dynamic, database-free, and open source website framework that is designed to make life easier for small teams of developers, designers, and writers.

FEATURES

Mango eliminates the barriers to collaboration by decoupling from one another the activities of writing, theming, publishing, extending, and maintaining a website. Mango websites are also decoupled from a database, and instead utilize file-based storage and "convention over configuration".

Easy to write

Writing and revising copy using the clunky administrator interface of a CMS is painful. Which is why it's common for people to work in a text editor and then copy-and-paste their changes back into the CMS.

Mango leverages the writing tools you're already familiar with -- the file system and your favorite text editor. As a bonus, files match perfectly with version control systems, like Git, making for powerful revision history.

Mango supports the following content formats:

Don't see your favorite content format? Patches are welcome

Easy to theme

Mango separates a website's theme from it's content. Using a powerful and flexible template system, Mango facilitates both uniformity of major sections and individuality of content presentation. In addition to the standard browser formats -- HTML, CSS, and JavaScript -- Mango also supports the following template formats:

Don't see your favorite template formats? Patches are welcome

Easy to publish

Mango websites are dead-simple to publish. Mango supports a wide variety of publishing tools like:

Easy to extend

Mango is related to a family of tools called static website generators. One killer feature missing from Mango's cousins is the ability to dynamically process HTTP requests on the server.

Mango websites leverage the Sinatra framework to connect web requests to content pages on-the-fly. Additionally, developers can enhance a Mango website to intercept specific web requests and dynamically customize the HTTP response, communicate with other Internet services, or serve unique content.

With Mango and server-side processing you can:

Easy to maintain

Mango is distributed as a RubyGem and respects Semantic Versioning. In concert with Bundler, upgrading a Mango website is painless and backwards-compatible between patch releases.

REQUIREMENTS

Mango respects Semantic Versioning.

Required dependencies

Optional development dependencies

INSTALLING

Ensuring Ruby 1.9.2 is installed and active

I highly recommend RVM by Wayne E. Seguin. It trivializes managing multiple versions of Ruby on one machine.

$ ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.7.0]

TIP: The revision and arch-type may differ on your machine.

Installing the Mango gem

Mango, and all its necessary components, are packaged as RubyGems for easy distribution.

$ gem install mango

TIP: If you're not using RVM, you may want to prepend the gem command with sudo.

Upgrading a Mango website

Simply edit the gem version in your website's Gemfile and re-install with Bundler.

$ cd /path/to/your/app
$ cat Gemfile
# encoding: UTF-8
source "http://rubygems.org"
gem "mango", "~> 0.6.2"
$ bundle install

TIP: If you're working in the insolation of an RVM gemset, type gem clean to uninstall outdated gems.

GETTING STARTED

Generating a Mango website

With Mango installed, the mango command will generate a new website.

$ mango create /path/to/your/app

Starting the web-server

Mango websites are compatible with any Rack supported web-server. The rackup command will start a web-server (default: WEBrick) listening at http://0.0.0.0:9292.

$ cd /path/to/your/app
$ rackup
[2010-10-30 15:39:41] INFO  WEBrick 1.3.1
[2010-10-30 15:39:41] INFO  ruby 1.9.2 (2010-08-18) [x86_64-darwin10.4.0]
[2010-10-30 15:39:41] INFO  WEBrick::HTTPServer#start: pid=27513 port=9292

TIP: Type Control + C to quit rackup.

Using an alternative web-server

If you prefer an alternative web-server (e.g. thin), simply install the gem and use the -s SERVER option to specify the web-server.

$ cd /path/to/your/app
$ gem install thin
$ rackup -s thin
>> Thin web server (v1.2.7 codename No Hup)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:9292, CTRL+C to stop

TIP: To see a list of all the rackup command-line options, use the --help option.

Generated website structure

Now that the newly generated Mango website is running, here's how the website is structured.

$ tree /path/to/your/app
/path/to/your/app
├── Gemfile
├── README.md
├── config.ru
├── content
│   └── index.erb
└── themes
    └── default
        ├── javascripts
        │   └── timer.coffee
        ├── public
        │   ├── favicon.ico
        │   ├── images
        │   │   └── particles.gif
        │   ├── javascripts
        │   │   └── fireworks.js
        │   ├── robots.txt
        │   └── stylesheets
        │       ├── fireworks.css
        │       └── reset.css
        ├── stylesheets
        │   └── screen.sass
        └── views
            ├── 404.haml
            ├── layout.haml
            └── page.haml

TIP: The tree command is awesome!

Under the hood

WRITING

Authors write and revise copy in text file called a content page. A content page contains two optional components -- a body and a header. Though optional, the majority of authors will utilize both components.

For example, the Mango website generator produces the following content page:

$ cat content/index.erb
---
title: Congratulations!
---
<h1><%= page.title %></h1>

<h2>You did it!</h2>

The above example highlights the key facets of writing a content page.

  1. A content page is stored as a file in the content directory. Here, the file name is index.erb.
  2. The header, if defined, comes first and is embedded within triple-dashed --- dividers.
  3. The body comes second, nestled comfortably below the header.
  4. The header is composed of key-value attribute pairs in YAML format.
  5. The file's extension signals that the body should be treated as ERB.

The Header

The header is composed of key-value attribute pairs in YAML format. Utilizing the page local variable, attribute data is available within the content page's body and view template.

In the previous example, the message Congratulations! is substituted for <%= page.title %> whenever the content page is rendered.

The Body

The body of a content page supports many writer and designer friendly formats. The content page's file extension determines the body's format. Rendering a content page converts the body to HTML.

Mango supports the following body formats:

The Data and Body Attributes

A handful of attributes are automatically inserted into every content page and cannot be altered in the header. Two such attributes are data and body which contain a content page's data and pre-rendered body respectively.

For example, given the following content page:

---
title: Congratulations!
---
<h1><%= page.title %></h1>

<h2>You did it!</h2>

Calling <%= page.data %> would yield:

---
title: Congratulations!
---
<h1><%= page.title %></h1>

<h2>You did it!</h2>

and calling <%= page.body %> would yield:

<h1><%= page.title %></h1>

<h2>You did it!</h2>

The Content Attribute

The content attribute contains the rendered body of a content page. Like the data and body attributes, the content attribute is automatically inserted into every content page and cannot be altered in the header. The rendered body contained within the content attribute is only available inside a view template.

For example, given the following content page:

---
title: Congratulations!
---
<h1><%= page.title %></h1>

<h2>You did it!</h2>

Calling <%= page.content %> in a view template would yield:

<h1>Congratulations!</h1>

<h2>You did it!</h2>

THEMING

Coming soon. Patches are welcome.

PUBLISHING

Deploying to the cloud with Heroku

Heroku (pronounced her-OH-koo) is a cloud platform for Ruby-powered web applications. Heroku lets app developers spend 100% of their time on their application code, not managing servers, deployment, ongoing operations, or scaling. And best of all, Mango websites can leverage this power with their free Blossom tier.

If you haven't done so already, prepare your Mango website with Git. Just initialize a new Git repository, add the project directory, and commit.

$ cd /path/to/your/app
$ git init
$ git add .
$ git commit -m "First commit"

Next, get started with Heroku by signing up for an account, installing the heroku gem, and adding your ssh public key to their network.

$ gem install heroku
$ heroku keys:add

Then create a heroku app that targets the "Badius Bamboo" plus "Matz Ruby Implementation" 1.9.2 platform stack.

$ heroku create APP_NAME --stack bamboo-mri-1.9.2

Finally, deploy the heroku app. If you've followed these instructions carefully, deployment is trivial.

$ git push heroku master

Now, bask in the glory of your live website in the cloud.

$ heroku open

TIP: Like the entire the platform, the heroku command-line tool has great documentation.

Deploying to a single target with secure FTP uploads

Coming soon. Patches are welcome.

Deploying to multiple targets with Capistrano

Coming soon. Patches are welcome.

EXTENDING

Coming soon. Patches are welcome.

PHILOSOPHY

Painless collaboration

Mango is designed to make life easier for small, integrated teams. They prefer tools that allow for shared access to the same resources and for processes that provide instantaneous feedback.

Harness the power of the Ruby toolbox

The Ruby on Rails revolution has arrived. The world's next-generation web applications are built with powerful tools from the Ruby eco-system. Mango is designed to harness this power, but delivered in a smaller package to meet the needs of simpler websites.

CONTRIBUTING

Thank you for taking the time to help improve Mango.

Reporting Issues

Is Mango not behaving like you expect it should? Please forgive me. Submit a report over at the Issue Tracker and I'll get that sorted out.

TIP: You can read through existing issues and vote for the ones you'd like to see resolved first.

Submitting Patches

Is Mango not behaving like you need? Patches are always welcome and appreciated. Report your issue to make sure we're not duplicating any work and go to town. Alternatively, you can lend a hand on existing issues.

Once you've been assigned an issue, the process for contributing your work back to the source is straight-forward.

TIP: Take a moment to get a feel for the style of coding, specifications, and in-line documentation.

Mango has a plethora of documentation to bring a Rubyist of any level up to speed. Once the development dependencies are met (please see the REQUIREMENTS section), fire up the documentation web server.

$ yard server

Then point your browser to http://0.0.0.0:8808

CREDITS

Thanks to all of my friends and family for their invaluable support!