diff --git a/CHANGELOG.md b/CHANGELOG.md index f80b61a..22f720d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +**v0.3.7** (2012-05-25): + + * Chatroom example [scien] + * Added generic CSS template module support + * Added support for socket.io acknowledgments [Radagaisus] + * Made @include work with require'd modules [imzshh] + * Added option to disable socket.io [scien] + **v0.3.6** (2012-04-24): - Migrated to coffeecup, closes #1 diff --git a/README.md b/README.md index 15e0a81..1d0ba79 100644 --- a/README.md +++ b/README.md @@ -117,7 +117,7 @@ require('zappajs') -> - Get the gist with the [crash course](http://zappajs.org/docs/crashcourse) -- Check the [API reference](http://zappajs.org/docs/0.3-gumbo/reference) +- Check the [API reference](http://zappajs.org/docs/reference) - See the [examples](https://github.com/zappajs/zappajs/tree/master/examples) included with the source @@ -135,8 +135,6 @@ require('zappajs') -> - Check the project's history at the [change log](https://github.com/zappajs/zappajs/blob/master/CHANGELOG.md) -- Migrating from an earlier version? Read the announcements ([0.2.x](http://zappajs.org/docs/0.2-peaches/announcement)/[0.3.x](http://zappajs.org/docs/0.3-gumbo/announcement)) for an overview on changes, and follow the TL;DR migration guides ([0.2.x](http://zappajs.org/docs/0.2-peaches/migration)/[0.3.x](http://zappajs.org/docs/0.3-gumbo/migration)) - - Deploying to heroku? Check [this blog post](http://blog.superbigtree.com/blog/2011/08/19/hosting-zappa-0-2-x-on-heroku/) ## Thanks loads diff --git a/docs/zappa.html b/docs/zappa.html index 82d2ed7..aba51ea 100644 --- a/docs/zappa.html +++ b/docs/zappa.html @@ -1,8 +1,8 @@
zappa.coffee | ||
---|---|---|
Zappa is a CoffeeScript DSL-ish interface for building web apps on the node.js runtime, integrating express, socket.io -and other best-of-breed libraries. | zappa = version: '0.3.6'
+and other best-of-breed libraries. | zappa = version: '0.3.7'
-codename = 'It Must Be a Camel'
+codename = 'Overture to a Holiday in Berlin'
log = console.log
fs = require 'fs'
@@ -63,7 +63,7 @@
fs.readFileSync p, 'utf8'
catch err
p = @path
- fs.readFileSync p, 'utf8' |
Takes in a function and builds express/socket.io apps based on the rules contained in it. | zappa.app = (func) ->
+ fs.readFileSync p, 'utf8' | |
Takes in a function and builds express/socket.io apps based on the rules contained in it. | zappa.app = (func,disable_io,require_css) ->
context = {id: uuid(), zappa, express}
context.root = path.dirname(module.parent.filename) | |
Storage for user-provided stuff. @@ -72,7 +72,7 @@ postrenders = {} app = context.app = express.createServer() - io = context.io = socketio.listen(app) | ||
Reference to the zappa client, the value will be set later. | client = null
+ io = if disable_io then null else context.io = socketio.listen(app) | |
Reference to the zappa client, the value will be set later. | client = null
| |
Tracks if the zappa middleware is already mounted ( | zappa_used = no | |
Zappa's default settings. | app.set 'view engine', 'coffee'
app.register '.coffee', zappa.adapter require('coffeecup').adapters.express,
blacklist: ['format', 'autoescape', 'locals', 'hardcode', 'cache'] | |
Sets default view dir to @root ( | app.set 'views', path.join(context.root, '/views')
@@ -110,11 +110,13 @@
css = String(v)
route verb: 'get', path: k, handler: css, contentType: 'css'
- context.stylus = (obj) ->
- for k, v of obj
- css = require('stylus').render v, filename: k, (err, css) ->
- throw err if err
- route verb: 'get', path: k, handler: css, contentType: 'css'
+ if typeof require_css is 'string' then require_css = [require_css]
+ for name in require_css
+ context[name] = (obj) ->
+ for k, v of obj
+ css = require(name).render v, filename: k, (err, css) ->
+ throw err if err
+ route verb: 'get', path: k, handler: css, contentType: 'css'
context.helper = (obj) ->
for k, v of obj
@@ -197,7 +199,7 @@
v.apply(context, [context])
context.include = (p) ->
- sub = require path.join(context.root, p)
+ sub = if typeof p is 'string' then require path.join(context.root, p) else p
sub.include.apply(context, [context]) | |
Register a route with express. | route = (r) ->
if typeof r.handler is 'string'
app[r.verb] r.path, (req, res) ->
@@ -261,7 +263,7 @@
res.contentType(r.contentType) if r.contentType?
if typeof result is 'string' then res.send result
else return result
- | |
Register socket.io handlers. | io.sockets.on 'connection', (socket) ->
+ | |
Register socket.io handlers. | io?.sockets.on 'connection', (socket) ->
c = {}
build_ctx = ->
@@ -319,9 +321,10 @@
for name, h of ws_handlers
do (name, h) ->
if name isnt 'connection' and name isnt 'disconnect'
- socket.on name, (data) ->
+ socket.on name, (data, ack) ->
ctx = build_ctx()
ctx.data = data
+ ctx.ack = ack
switch app.settings['databag']
when 'this' then h.apply(data, [ctx])
when 'param' then h.apply(ctx, [data])
@@ -357,6 +360,8 @@
host = null
port = 3000
root_function = null
+ disable_io = false
+ require_css = ['stylus']
for a in arguments
switch typeof a
@@ -365,8 +370,15 @@
else port = (Number) a
when 'number' then port = a
when 'function' then root_function = a
-
- zapp = zappa.app(root_function)
+ when 'object'
+ for k, v of a
+ switch k
+ when 'host' then host = v
+ when 'port' then port = v
+ when 'css' then require_css = v
+ when 'disable_io' then disable_io = v
+
+ zapp = zappa.app(root_function,disable_io,require_css)
app = zapp.app
if host then app.listen port, host
diff --git a/package.json b/package.json
index eea063c..369f5a4 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "zappajs",
"description": "CoffeeScript minimalist interface to express, socket.io and others",
- "version": "0.3.6",
+ "version": "0.3.7",
"author": "Stephane Alnet |