Bake your HTML5 website with Awestruct and publish it with git

mojavelinux.github.com/decks/awestruct-git

mojavelinux.github.com/decks/awestruct-git
awestruct-logo.png

A static site-baking tool

Awestruct makes it easy to create non-trivial static websites

html5-logo.png

The cornerstone of the Open Web Platform

html5css3js.png

Static is the new dynamic

git-logo.png

--distributed-even-if-your-workflow-isnt

From black box to open book

baking-process.jpg
The baking process

Project layout

Content page structure

about.md
---
layout: base
title: About
---
## Who are we?

We are hackers.

## What do we like?

We like code we don't have to escape.

    <xml>
      <hell>Just frag it and use yaml</hell>
    </xml>
Notes

talk about page structure (front-matter, content)

Markup of choice

Layout page structure

_layouts/base.html.haml
!!!5
%html
  %head
    %title= site.title
  %body
    .container
      ~ content
Notes

~ inserts special character to preserve whitespace)

Site properties

_config/site.yml
title: My Site
_layouts/base.html.haml
%title= site.title
Notes

compiler is important to emphasize / expand on; leverages existing stuff

Available Extensions

What else could an extension do?

Extension

_ext/my_extension.rb
class MyExtension
  def execute(site)
    site.pages.each do |page|
      ...
    end
  end
end
Notes

An extension class only need implement a single method, execute(site). Each extension in the pipeline will be called, in-order, and passed the site object.

Transformer

_ext/my_transformer.rb
class MyTransformer
  def transform(site, page, input)
     ...
  end
end

Configuring the pipeline

_ext/pipeline.rb
require 'my_extension'
require 'my_transformer'

Awestruct::Extensions::Pipeline.new do
  extension MyExtension.new
  transformer MyTransformer.new
  ...
end
Notes

The _ext/ directory is automatically added to the $LOAD_PATH so that site-supplied extensions may easily be loaded.

generator-pipeline.png
Generator pipeline
Notes

The extension pipeline runs immediately before the final URL assignment to pages and generating the final output pages.

Who else is baking?

Install (Ruby)

$ gem install awestruct rb-inotify

Install (JRuby)

$ jgem install awestruct rb-inotify

Bootstrap

$ mkdir mysite
$ cd mysite
$ awestruct -i -f bootstrap
Bux fix!
$ rm -f .awestruct_ignore
bootstrap-left-logo.png

Build & preview (Dev Mode)

$ awestruct -d

Head over to http://localhost:4242 to see your progress!

Changes to files are picked up automatically.

Force clean

$ awestruct -d --force

Purges _site directory

Build a blog demo

and blog like a hacker!

Notes

Compile CoffeeScript demo

Add tooltips to links

index.html.haml
%a{:href=>post.url, :title=>'Go to post', :rel=>'tooltip'}= post.title

Activate tooltip component in CoffeeScript

javascripts/site.coffee
$ ->
  $('*[rel=tooltip]').tooltip placement: 'right'
  $('h1.title a').hover (-> $(@).css fontStyle: 'italic'),
    (-> $(@).css fontStyle: 'normal')

Get dynamic by scraping the web

CoffeeScript to fetch news feed

javascripts/site.coffee
this.fetchNews = (url, loc, num = 10) ->
  $.jGFeed url, ((feeds) -> $.each(feeds.entries,
    (idx, entry) -> $(loc).append
      """<li><a href="\#{entry.link}">\#{entry.title}</li>""")), num

Load scripts

index.html.haml
%script{:type=>'text/javascript',
  :src=>'//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.0.4/bootstrap.min.js'} <1>
%script{:type=>'text/javascript',
  :src=>"#{site.base_url}/javascripts/jquery-jgfeed.js"}
%script{:type=>'text/javascript',
  :src=>"#{site.base_url}/javascripts/site.js"} <2>
  1. Note the use of a CDN to grab the bootstrap script

  2. site.coffeescript has been compiled to site.js

Fetch news

index.html.haml
:javascript
  fetchNews('http://therichwebexperience.com/s/rss/rich.rss', '#news');

Qualified URL extension demo

Make it SASSy

stylesheets/screen.scss
$bootstrapUrl: "//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.2.1";
$iconSpritePath: url("#{$bootstrapUrl}/img/glyphicons-halflings.png");
$iconWhiteSpritePath: url("#{$bootstrapUrl}/img/glyphicons-halflings-white.png");

// NFJS colors
$navbarBackground: #303030;
$navbarBackgroundHighlight: #6771DB;
$navbarBrandColor: #FFCC66;
$navbarLinkColor: #D9E0FF;

Deploy to GitHub pages demo

Site polishing

Notes

github pages autogenerator is just for a single page (markdown → html)

Who’s onboard?

Notes

CDI is planned

case study arquillian

arquillian-site-screenshot.png
arquillian.org

Dynamic features

Gotchas

Final recap

Fast, cheap, customizable, collaborative & secure

Blog like a hacker!

Thank the browser for making this possible

awestruct-expression-crop.jpg
Are you {:awestruct}?

Get {:awestuct}!