Glue is a simple static site generator for Ruby that uses Haml, Sass and Textile/Markdown.
You can create static website so easily that you’ll imagine how could you live without it!
Glue has only what you’ll need:
- Partial support
- Automatic Sitemap & Feed from your pages
- Simple text writing using Markdown or Textile
- Beautiful and easy-to-maintain layouts using Haml & Sass
Getting started
To install Glue, you’ll need a working Ruby installation with Rubygems. If you’re cool with it, just run the following command to install it.
sudo gem install glue-site
After installing Glue and its dependencies, you can create your site so easily! Just run the following command from your terminal window.
$ glue mysite creating mysite directory... done! creating public directory... done! creating public/javascripts directory... done! creating public/images directory... done! creating views/layouts directory... done! creating config directory... done! copying config/glue.yml... done! copying views/stylesheets/style.sass... done! copying Rakefile... done! copying config/helper.rb... done! copying views/layouts/main.haml... done! copying views/index.haml... done! copying views/404.haml... done! copying views/_footer.haml... done! copying public/.htaccess... done! copying public/robots.txt... done!
This command will create a mysite
directory with all the Glue structure.
Now you're ready to configure your Glue site.
Configuring
All your site settings are defined in config/glue.yml
.
There are 3 main blocks: site
, sitemap
and feed
.
site: # Set default page title. title: "The awesome Glue!" # Set default page description description: "Glue is a simple static site generator for Ruby that uses Haml, Sass and Textile/Markdown." # Set default keywords keywords: "glue, ruby, haml, sass, static site, textile, markdown" # Set your base url. # Include domain and path (if needed). # Domain is required for sitemap generation. base_url: http://fnando.github.com/ # If you're using Apache you can enable `MultiViews` # or mod_rewrite and access your URL like # http://example.com/about instead of http://example.com/about.html friendly_url: true # Set your language for feeds and meta tags language: en-us sitemap: # Do generate sitemap enabled: true # Filters will be applied against full filename. # Use .*? to match all. Use regular expressions. filters: - .*? feed: # Do generate feed enabled: true # Filters will be applied against full filename. # Use .*? to match all. Use regular expressions. filters: - .*?
Views
Views are placed in the "views" directory. All .haml
files will be exported as .html
,
respecting the structure you define.
So, if you create a file views/index.haml
, a correspondent public/index.html
will be exported;
if you create views/articles/using-glue.haml
, Glue will export it as
public/articles/using-glue.html
, and so on.
Meta data
To specify layouts, titles, descriptions and any other value you want, your document must have meta data. Meta data is nothing but Haml comments. Here's the meta data from this page you're viewing:
/ title: The awesome Glue! / description: Glue is a simple static site generator for Ruby that uses Haml, Sass and Textile/Markdown. / keywords: Glue, Ruby, Static Site, Haml, Sass, Markdown, Textile / layout: main / id: glue / tagline: Static site generator / version: 0.0.5
The are some meta data that is Glue-reserved.
-
layout
-
Specify the layout your page is going to use. Layouts must be placed on
views/layouts
. If you don't want to use a layout, set it tonone
. -
index
-
When set to
yes
, define if the current page should also exported aspublic/index.html
. The default isno
. -
sitemap
-
When set to
no
, the page is not added topublic/sitemap.xml
. The default isyes
. -
feed
-
When set to
no
, the page is not added topublic/feed.xml
. The default isyes
.
Using helpers
There are some helpers that comes with Glue:
-
markdown(text)
-
Parse a given text as Markdown code.
%p :markdown This text will be converted to HTML using [RDiscount](http://github.com/rtomayko/rdiscount/tree/master).
You can call it directly:%p= markdown("*Markdown* rules!")
-
textile(text)
-
Parse a given text as Textile code.
%p :textile This text will be converted to HTML using "RedCloth":http://redcloth.org/.
You can call it directly:%p= textile("*Textile* rules!")
-
haml(text)
-
Parse a given text as Haml code.
You can call it directly:
%p= haml("%strong Haml\nis so nice!")
-
url_for(path, options={})
-
Return an URL considering the
base_url
configuration option. If you want to retrieve a full URL (that include the host), set the option:full
totrue
.%p= url_for("feed.xml", :full => true)
-
feed_tag
-
Return the
link
tag pointing to yourfeed.xml
.= feed_tag
-
render(path)
-
Render will lookup for the path your provide, according to the file extension.
The example below will search for
footer.haml
,footer.markdown
and thenfooter.textile
, rendering the first it founds.= render("footer")
To add your own helpers, use the file config/helper
.
Let's create a helper that reverses a given text.
module Helper def reversed(text) text.reverse end end
Just call it from your view like this:
%p = reversed("Some cool text!")
Notice that you need to return a string. DO NOT output directly;
use the equal sign like in = reversed("Some cool text!")
If you want to output directly, use the haml_concat
method in your helper.
module Helper def reversed(text) haml_concat text.reverse end end
Then you can just call the helper.
%p - reversed("Some cool text!")
Capistrano & Dreamhost
Here's a simple deploy task for Capistrano & Dreamhost.
First, create a new domain/subdomain pointing to the public
directory.
Then run capify
from the root directory. Edit the config/deploy.rb
file,
pasting the sample below.
set :application, "howto" set :scm, :git set :repository, "git@github.com:USER/some-repo.git" set :deploy_to, "/home/USER/example.com" set :user, "USER" set :use_sudo, false role :web, "example.com"
Now, run cap deploy:setup
to prepare your server.
To update your site, just run cap deploy:update
.
Could not be easier!
Maintainer
This project was created by Nando Vieira.
Check it out another interesting projects at http://fnando.github.com.