Created
September 10, 2010 00:51
-
-
Save vito/572857 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
load: "examples/html.atomo" | |
load: "examples/web.hs" | |
Association = Object clone | |
a -> b := Association clone do: { from = a; to = b } | |
Demo = Website clone do: { | |
routes = [ | |
"/" -> @index, | |
"hello/:name" -> @hello:, | |
-- assigning a route to a block to be called | |
-- first arg is Demo, but we ignore it here | |
"some/:block/:args" -> { _ b a | "Got: " .. [b, a] show } | |
] | |
} | |
Demo index = | |
HTML new (do: { | |
doctype | |
html: { | |
head: { | |
title: "Hi!" | |
} | |
body: { | |
h1: "Hello, world!" | |
p: "Hop on over to the REPL and add some methods to the Demo object!" | |
p: { a: "Another page!" href: "/hello/world" } | |
} | |
} | |
}) (as: String) | |
Demo hello: name := "Hello, " .. name .. "!" | |
-- be sure to load this in the REPL and play around with | |
-- Demo, adding new routes at runtime | |
{ Demo start-on: 8000 } spawn |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment