Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Releaving v0.3.7.

  • Loading branch information...
commit 1e9f75fbd67f7df72a8e24ef1fe153d41cb6806f 1 parent c6ab814
@shimaore shimaore authored
View
8 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
View
4 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
View
40 docs/zappa.html
@@ -1,8 +1,8 @@
<!DOCTYPE html> <html> <head> <title>zappa.coffee</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="client.html"> client.coffee </a> <a class="source" href="zappa.html"> zappa.coffee </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> zappa.coffee </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> <p><strong>Zappa</strong> is a <a href="http://coffeescript.org">CoffeeScript</a> DSL-ish interface for building web apps on the
<a href="http://nodejs.org">node.js</a> runtime, integrating <a href="http://expressjs.com">express</a>, <a href="http://socket.io">socket.io</a>
-and other best-of-breed libraries.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">zappa = version: </span><span class="s">&#39;0.3.6&#39;</span>
+and other best-of-breed libraries.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">zappa = version: </span><span class="s">&#39;0.3.7&#39;</span>
-<span class="nv">codename = </span><span class="s">&#39;It Must Be a Camel&#39;</span>
+<span class="nv">codename = </span><span class="s">&#39;Overture to a Holiday in Berlin&#39;</span>
<span class="nv">log = </span><span class="nx">console</span><span class="p">.</span><span class="nx">log</span>
<span class="nv">fs = </span><span class="nx">require</span> <span class="s">&#39;fs&#39;</span>
@@ -63,7 +63,7 @@
<span class="nx">fs</span><span class="p">.</span><span class="nx">readFileSync</span> <span class="nx">p</span><span class="p">,</span> <span class="s">&#39;utf8&#39;</span>
<span class="k">catch</span> <span class="nx">err</span>
<span class="nv">p = </span><span class="nx">@path</span>
- <span class="nx">fs</span><span class="p">.</span><span class="nx">readFileSync</span> <span class="nx">p</span><span class="p">,</span> <span class="s">&#39;utf8&#39;</span></pre></div> </td> </tr> <tr id="section-15"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-15">&#182;</a> </div> <p>Takes in a function and builds express/socket.io apps based on the rules contained in it.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">zappa.app = </span><span class="nf">(func) -&gt;</span>
+ <span class="nx">fs</span><span class="p">.</span><span class="nx">readFileSync</span> <span class="nx">p</span><span class="p">,</span> <span class="s">&#39;utf8&#39;</span></pre></div> </td> </tr> <tr id="section-15"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-15">&#182;</a> </div> <p>Takes in a function and builds express/socket.io apps based on the rules contained in it.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">zappa.app = </span><span class="nf">(func,disable_io,require_css) -&gt;</span>
<span class="nv">context = </span><span class="p">{</span><span class="nv">id: </span><span class="nx">uuid</span><span class="p">(),</span> <span class="nx">zappa</span><span class="p">,</span> <span class="nx">express</span><span class="p">}</span>
<span class="nv">context.root = </span><span class="nx">path</span><span class="p">.</span><span class="nx">dirname</span><span class="p">(</span><span class="nx">module</span><span class="p">.</span><span class="nx">parent</span><span class="p">.</span><span class="nx">filename</span><span class="p">)</span></pre></div> </td> </tr> <tr id="section-16"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-16">&#182;</a> </div> <p>Storage for user-provided stuff.
@@ -72,7 +72,7 @@
<span class="nv">postrenders = </span><span class="p">{}</span>
<span class="nv">app = context.app = </span><span class="nx">express</span><span class="p">.</span><span class="nx">createServer</span><span class="p">()</span>
- <span class="nv">io = context.io = </span><span class="nx">socketio</span><span class="p">.</span><span class="nx">listen</span><span class="p">(</span><span class="nx">app</span><span class="p">)</span></pre></div> </td> </tr> <tr id="section-17"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-17">&#182;</a> </div> <p>Reference to the zappa client, the value will be set later.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">client = </span><span class="kc">null</span>
+ <span class="nv">io = </span><span class="k">if</span> <span class="nx">disable_io</span> <span class="k">then</span> <span class="kc">null</span> <span class="k">else</span> <span class="nv">context.io = </span><span class="nx">socketio</span><span class="p">.</span><span class="nx">listen</span><span class="p">(</span><span class="nx">app</span><span class="p">)</span></pre></div> </td> </tr> <tr id="section-17"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-17">&#182;</a> </div> <p>Reference to the zappa client, the value will be set later.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">client = </span><span class="kc">null</span>
</pre></div> </td> </tr> <tr id="section-18"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-18">&#182;</a> </div> <p>Tracks if the zappa middleware is already mounted (<code>@use 'zappa'</code>).</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">zappa_used = </span><span class="kc">no</span></pre></div> </td> </tr> <tr id="section-19"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-19">&#182;</a> </div> <p>Zappa's default settings.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">app</span><span class="p">.</span><span class="nx">set</span> <span class="s">&#39;view engine&#39;</span><span class="p">,</span> <span class="s">&#39;coffee&#39;</span>
<span class="nx">app</span><span class="p">.</span><span class="nx">register</span> <span class="s">&#39;.coffee&#39;</span><span class="p">,</span> <span class="nx">zappa</span><span class="p">.</span><span class="nx">adapter</span> <span class="nx">require</span><span class="p">(</span><span class="s">&#39;coffeecup&#39;</span><span class="p">).</span><span class="nx">adapters</span><span class="p">.</span><span class="nx">express</span><span class="p">,</span>
<span class="nv">blacklist: </span><span class="p">[</span><span class="s">&#39;format&#39;</span><span class="p">,</span> <span class="s">&#39;autoescape&#39;</span><span class="p">,</span> <span class="s">&#39;locals&#39;</span><span class="p">,</span> <span class="s">&#39;hardcode&#39;</span><span class="p">,</span> <span class="s">&#39;cache&#39;</span><span class="p">]</span></pre></div> </td> </tr> <tr id="section-20"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-20">&#182;</a> </div> <p>Sets default view dir to @root (<code>path.dirname(module.parent.filename)</code>).</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">app</span><span class="p">.</span><span class="nx">set</span> <span class="s">&#39;views&#39;</span><span class="p">,</span> <span class="nx">path</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="nx">context</span><span class="p">.</span><span class="nx">root</span><span class="p">,</span> <span class="s">&#39;/views&#39;</span><span class="p">)</span>
@@ -110,11 +110,13 @@
<span class="nv">css = </span><span class="nb">String</span><span class="p">(</span><span class="nx">v</span><span class="p">)</span>
<span class="nx">route</span> <span class="nv">verb: </span><span class="s">&#39;get&#39;</span><span class="p">,</span> <span class="nv">path: </span><span class="nx">k</span><span class="p">,</span> <span class="nv">handler: </span><span class="nx">css</span><span class="p">,</span> <span class="nv">contentType: </span><span class="s">&#39;css&#39;</span>
- <span class="nv">context.stylus = </span><span class="nf">(obj) -&gt;</span>
- <span class="k">for</span> <span class="nx">k</span><span class="p">,</span> <span class="nx">v</span> <span class="k">of</span> <span class="nx">obj</span>
- <span class="nv">css = </span><span class="nx">require</span><span class="p">(</span><span class="s">&#39;stylus&#39;</span><span class="p">).</span><span class="nx">render</span> <span class="nx">v</span><span class="p">,</span> <span class="nv">filename: </span><span class="nx">k</span><span class="p">,</span> <span class="nf">(err, css) -&gt;</span>
- <span class="k">throw</span> <span class="nx">err</span> <span class="k">if</span> <span class="nx">err</span>
- <span class="nx">route</span> <span class="nv">verb: </span><span class="s">&#39;get&#39;</span><span class="p">,</span> <span class="nv">path: </span><span class="nx">k</span><span class="p">,</span> <span class="nv">handler: </span><span class="nx">css</span><span class="p">,</span> <span class="nv">contentType: </span><span class="s">&#39;css&#39;</span>
+ <span class="k">if</span> <span class="k">typeof</span> <span class="nx">require_css</span> <span class="o">is</span> <span class="s">&#39;string&#39;</span> <span class="k">then</span> <span class="nv">require_css = </span><span class="p">[</span><span class="nx">require_css</span><span class="p">]</span>
+ <span class="k">for</span> <span class="nx">name</span> <span class="k">in</span> <span class="nx">require_css</span>
+ <span class="nx">context</span><span class="p">[</span><span class="nx">name</span><span class="p">]</span> <span class="o">=</span> <span class="nf">(obj) -&gt;</span>
+ <span class="k">for</span> <span class="nx">k</span><span class="p">,</span> <span class="nx">v</span> <span class="k">of</span> <span class="nx">obj</span>
+ <span class="nv">css = </span><span class="nx">require</span><span class="p">(</span><span class="nx">name</span><span class="p">).</span><span class="nx">render</span> <span class="nx">v</span><span class="p">,</span> <span class="nv">filename: </span><span class="nx">k</span><span class="p">,</span> <span class="nf">(err, css) -&gt;</span>
+ <span class="k">throw</span> <span class="nx">err</span> <span class="k">if</span> <span class="nx">err</span>
+ <span class="nx">route</span> <span class="nv">verb: </span><span class="s">&#39;get&#39;</span><span class="p">,</span> <span class="nv">path: </span><span class="nx">k</span><span class="p">,</span> <span class="nv">handler: </span><span class="nx">css</span><span class="p">,</span> <span class="nv">contentType: </span><span class="s">&#39;css&#39;</span>
<span class="nv">context.helper = </span><span class="nf">(obj) -&gt;</span>
<span class="k">for</span> <span class="nx">k</span><span class="p">,</span> <span class="nx">v</span> <span class="k">of</span> <span class="nx">obj</span>
@@ -197,7 +199,7 @@
<span class="nx">v</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="nx">context</span><span class="p">,</span> <span class="p">[</span><span class="nx">context</span><span class="p">])</span>
<span class="nv">context.include = </span><span class="nf">(p) -&gt;</span>
- <span class="nv">sub = </span><span class="nx">require</span> <span class="nx">path</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="nx">context</span><span class="p">.</span><span class="nx">root</span><span class="p">,</span> <span class="nx">p</span><span class="p">)</span>
+ <span class="nv">sub = </span><span class="k">if</span> <span class="k">typeof</span> <span class="nx">p</span> <span class="o">is</span> <span class="s">&#39;string&#39;</span> <span class="k">then</span> <span class="nx">require</span> <span class="nx">path</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="nx">context</span><span class="p">.</span><span class="nx">root</span><span class="p">,</span> <span class="nx">p</span><span class="p">)</span> <span class="k">else</span> <span class="nx">p</span>
<span class="nx">sub</span><span class="p">.</span><span class="nx">include</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="nx">context</span><span class="p">,</span> <span class="p">[</span><span class="nx">context</span><span class="p">])</span></pre></div> </td> </tr> <tr id="section-21"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-21">&#182;</a> </div> <p>Register a route with express.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">route = </span><span class="nf">(r) -&gt;</span>
<span class="k">if</span> <span class="k">typeof</span> <span class="nx">r</span><span class="p">.</span><span class="nx">handler</span> <span class="o">is</span> <span class="s">&#39;string&#39;</span>
<span class="nx">app</span><span class="p">[</span><span class="nx">r</span><span class="p">.</span><span class="nx">verb</span><span class="p">]</span> <span class="nx">r</span><span class="p">.</span><span class="nx">path</span><span class="p">,</span> <span class="nf">(req, res) -&gt;</span>
@@ -261,7 +263,7 @@
<span class="nx">res</span><span class="p">.</span><span class="nx">contentType</span><span class="p">(</span><span class="nx">r</span><span class="p">.</span><span class="nx">contentType</span><span class="p">)</span> <span class="k">if</span> <span class="nx">r</span><span class="p">.</span><span class="nx">contentType</span><span class="o">?</span>
<span class="k">if</span> <span class="k">typeof</span> <span class="nx">result</span> <span class="o">is</span> <span class="s">&#39;string&#39;</span> <span class="k">then</span> <span class="nx">res</span><span class="p">.</span><span class="nx">send</span> <span class="nx">result</span>
<span class="k">else</span> <span class="k">return</span> <span class="nx">result</span>
- </pre></div> </td> </tr> <tr id="section-30"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-30">&#182;</a> </div> <p>Register socket.io handlers.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">io</span><span class="p">.</span><span class="nx">sockets</span><span class="p">.</span><span class="kc">on</span> <span class="s">&#39;connection&#39;</span><span class="p">,</span> <span class="nf">(socket) -&gt;</span>
+ </pre></div> </td> </tr> <tr id="section-30"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-30">&#182;</a> </div> <p>Register socket.io handlers.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">io</span><span class="o">?</span><span class="p">.</span><span class="nx">sockets</span><span class="p">.</span><span class="kc">on</span> <span class="s">&#39;connection&#39;</span><span class="p">,</span> <span class="nf">(socket) -&gt;</span>
<span class="nv">c = </span><span class="p">{}</span>
<span class="nv">build_ctx = </span><span class="o">-&gt;</span>
@@ -319,9 +321,10 @@
<span class="k">for</span> <span class="nx">name</span><span class="p">,</span> <span class="nx">h</span> <span class="k">of</span> <span class="nx">ws_handlers</span>
<span class="nx">do</span> <span class="nf">(name, h) -&gt;</span>
<span class="k">if</span> <span class="nx">name</span> <span class="o">isnt</span> <span class="s">&#39;connection&#39;</span> <span class="o">and</span> <span class="nx">name</span> <span class="o">isnt</span> <span class="s">&#39;disconnect&#39;</span>
- <span class="nx">socket</span><span class="p">.</span><span class="kc">on</span> <span class="nx">name</span><span class="p">,</span> <span class="nf">(data) -&gt;</span>
+ <span class="nx">socket</span><span class="p">.</span><span class="kc">on</span> <span class="nx">name</span><span class="p">,</span> <span class="nf">(data, ack) -&gt;</span>
<span class="nv">ctx = </span><span class="nx">build_ctx</span><span class="p">()</span>
<span class="nv">ctx.data = </span><span class="nx">data</span>
+ <span class="nv">ctx.ack = </span><span class="nx">ack</span>
<span class="k">switch</span> <span class="nx">app</span><span class="p">.</span><span class="nx">settings</span><span class="p">[</span><span class="s">&#39;databag&#39;</span><span class="p">]</span>
<span class="k">when</span> <span class="s">&#39;this&#39;</span> <span class="k">then</span> <span class="nx">h</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="nx">data</span><span class="p">,</span> <span class="p">[</span><span class="nx">ctx</span><span class="p">])</span>
<span class="k">when</span> <span class="s">&#39;param&#39;</span> <span class="k">then</span> <span class="nx">h</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="p">[</span><span class="nx">data</span><span class="p">])</span>
@@ -357,6 +360,8 @@
<span class="nv">host = </span><span class="kc">null</span>
<span class="nv">port = </span><span class="mi">3000</span>
<span class="nv">root_function = </span><span class="kc">null</span>
+ <span class="nv">disable_io = </span><span class="kc">false</span>
+ <span class="nv">require_css = </span><span class="p">[</span><span class="s">&#39;stylus&#39;</span><span class="p">]</span>
<span class="k">for</span> <span class="nx">a</span> <span class="k">in</span> <span class="nx">arguments</span>
<span class="k">switch</span> <span class="k">typeof</span> <span class="nx">a</span>
@@ -365,8 +370,15 @@
<span class="k">else</span> <span class="nv">port = </span><span class="p">(</span><span class="nb">Number</span><span class="p">)</span> <span class="nx">a</span>
<span class="k">when</span> <span class="s">&#39;number&#39;</span> <span class="k">then</span> <span class="nv">port = </span><span class="nx">a</span>
<span class="k">when</span> <span class="s">&#39;function&#39;</span> <span class="k">then</span> <span class="nv">root_function = </span><span class="nx">a</span>
-
- <span class="nv">zapp = </span><span class="nx">zappa</span><span class="p">.</span><span class="nx">app</span><span class="p">(</span><span class="nx">root_function</span><span class="p">)</span>
+ <span class="k">when</span> <span class="s">&#39;object&#39;</span>
+ <span class="k">for</span> <span class="nx">k</span><span class="p">,</span> <span class="nx">v</span> <span class="k">of</span> <span class="nx">a</span>
+ <span class="k">switch</span> <span class="nx">k</span>
+ <span class="k">when</span> <span class="s">&#39;host&#39;</span> <span class="k">then</span> <span class="nv">host = </span><span class="nx">v</span>
+ <span class="k">when</span> <span class="s">&#39;port&#39;</span> <span class="k">then</span> <span class="nv">port = </span><span class="nx">v</span>
+ <span class="k">when</span> <span class="s">&#39;css&#39;</span> <span class="k">then</span> <span class="nv">require_css = </span><span class="nx">v</span>
+ <span class="k">when</span> <span class="s">&#39;disable_io&#39;</span> <span class="k">then</span> <span class="nv">disable_io = </span><span class="nx">v</span>
+
+ <span class="nv">zapp = </span><span class="nx">zappa</span><span class="p">.</span><span class="nx">app</span><span class="p">(</span><span class="nx">root_function</span><span class="p">,</span><span class="nx">disable_io</span><span class="p">,</span><span class="nx">require_css</span><span class="p">)</span>
<span class="nv">app = </span><span class="nx">zapp</span><span class="p">.</span><span class="nx">app</span>
<span class="k">if</span> <span class="nx">host</span> <span class="k">then</span> <span class="nx">app</span><span class="p">.</span><span class="nx">listen</span> <span class="nx">port</span><span class="p">,</span> <span class="nx">host</span>
View
6 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 <stephane@shimaore.net>",
"homepage": "http://zappajs.github.com/zappajs/",
"repository": {"type": "git", "url": "git://github.com/zappajs/zappajs.git"},
@@ -45,6 +45,8 @@
"Fossil Jue <imzshh@gmail.com>",
"Bryant Williams <b.n.williams@gmail.com>",
"Wes Morgan <cap10morgan@gmail.com>",
- "Evangenieur"
+ "Evangenieur",
+ "Radagaisus <radagaisus@gmail.com>",
+ "Fossil Jue <imzshh@gmail.com>"
]
}
View
4 src/zappa.coffee
@@ -2,9 +2,9 @@
# [node.js](http://nodejs.org) runtime, integrating [express](http://expressjs.com), [socket.io](http://socket.io)
# and other best-of-breed libraries.
-zappa = version: '0.3.6'
+zappa = version: '0.3.7'
-codename = 'It Must Be a Camel'
+codename = 'Overture to a Holiday in Berlin'
log = console.log
fs = require 'fs'
Please sign in to comment.
Something went wrong with that request. Please try again.