Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

pre-0.4.9 release doc updates

  • Loading branch information...
commit 83a772abbc6afc73a047fb1d7167ad82dff2cd5e 1 parent cf021b8
@shimaore shimaore authored
View
14 CHANGELOG.md
@@ -1,3 +1,17 @@
+**v0.4.9** (2012-09-06)
+
+ * API Change:
+ The databag option has been simplified and only applies to views.
+ Callback functions can only be called one way.
+
+ * API Change:
+ Callback functions no longer receive the context as argument;
+ fixes #41 (and mauricemach/zappa#99)
+
+ * Added `@all` (#40), `@params`, and `@locals` in root scope.
+ * Overwrote `session` middleware, got rid of `session_store` middleware.
+ * Update heroku blog link (#33)
+
**v0.4.8** (2012-08-26)
* `@use 'zappa'`: Added `/zappa/Zappa.js` combined download option.
View
15 docs/client.html
@@ -12,9 +12,8 @@
<span class="k">for</span> <span class="nx">name</span><span class="p">,</span> <span class="nx">helper</span> <span class="k">of</span> <span class="nx">helpers</span>
<span class="nx">do</span> <span class="nf">(name, helper) -&gt;</span>
<span class="k">if</span> <span class="k">typeof</span> <span class="nx">helper</span> <span class="o">is</span> <span class="s">&#39;function&#39;</span>
- <span class="nx">ctx</span><span class="p">[</span><span class="nx">name</span><span class="p">]</span> <span class="o">=</span> <span class="nf">(args...) -&gt;</span>
- <span class="nx">args</span><span class="p">.</span><span class="nx">push</span> <span class="nx">ctx</span>
- <span class="nx">helper</span><span class="p">.</span><span class="nx">apply</span> <span class="nx">ctx</span><span class="p">,</span> <span class="nx">args</span>
+ <span class="nx">ctx</span><span class="p">[</span><span class="nx">name</span><span class="p">]</span> <span class="o">=</span> <span class="o">-&gt;</span>
+ <span class="nx">helper</span><span class="p">.</span><span class="nx">apply</span> <span class="nx">ctx</span><span class="p">,</span> <span class="nx">arguments</span>
<span class="k">else</span>
<span class="nx">ctx</span><span class="p">[</span><span class="nx">name</span><span class="p">]</span> <span class="o">=</span> <span class="nx">helper</span>
<span class="nx">ctx</span>
@@ -59,10 +58,7 @@
<span class="nv">ctx.sammy_context = </span><span class="nx">sammy_context</span>
<span class="nv">ctx.render = </span><span class="o">-&gt;</span> <span class="nx">sammy_context</span><span class="p">.</span><span class="nx">render</span><span class="p">.</span><span class="nx">apply</span> <span class="nx">sammy_context</span><span class="p">,</span> <span class="nx">arguments</span>
<span class="nv">ctx.redirect = </span><span class="o">-&gt;</span> <span class="nx">sammy_context</span><span class="p">.</span><span class="nx">redirect</span><span class="p">.</span><span class="nx">apply</span> <span class="nx">sammy_context</span><span class="p">,</span> <span class="nx">arguments</span>
- <span class="k">switch</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">r</span><span class="p">.</span><span class="nx">handler</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="nx">sammy_context</span><span class="p">.</span><span class="nx">params</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">r</span><span class="p">.</span><span class="nx">handler</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">sammy_context</span><span class="p">.</span><span class="nx">params</span><span class="p">])</span>
- <span class="k">else</span> <span class="nx">r</span><span class="p">.</span><span class="nx">handler</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">ctx</span><span class="p">])</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>GO!!!</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">func</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-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p>Implements the websockets client with socket.io.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">if</span> <span class="nx">context</span><span class="p">.</span><span class="nx">socket</span><span class="o">?</span>
+ <span class="nx">r</span><span class="p">.</span><span class="nx">handler</span><span class="p">.</span><span class="nx">apply</span> <span class="nx">ctx</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>GO!!!</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">func</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-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p>Implements the websockets client with socket.io.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">if</span> <span class="nx">context</span><span class="p">.</span><span class="nx">socket</span><span class="o">?</span>
<span class="nx">context</span><span class="p">.</span><span class="nx">socket</span><span class="p">.</span><span class="kc">on</span> <span class="s">&#39;connect&#39;</span><span class="p">,</span> <span class="o">-&gt;</span>
<span class="nx">context</span><span class="p">.</span><span class="nx">share</span> <span class="s">&#39;__local&#39;</span><span class="p">,</span> <span class="nx">context</span><span class="p">.</span><span class="nx">socket</span><span class="p">,</span> <span class="nf">(data) -&gt;</span>
<span class="nv">context.key = </span><span class="nx">data</span><span class="p">.</span><span class="nx">key</span>
@@ -80,10 +76,7 @@
<span class="nx">apply_helpers</span> <span class="nx">ctx</span>
- <span class="k">switch</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>
- <span class="k">else</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">ctx</span><span class="p">])</span>
+ <span class="nx">h</span><span class="p">.</span><span class="nx">apply</span> <span class="nx">ctx</span>
<span class="nx">$</span><span class="p">(</span><span class="o">-&gt;</span> <span class="nx">app</span><span class="p">.</span><span class="nx">run</span> <span class="s">&#39;#/&#39;</span><span class="p">)</span> <span class="k">if</span> <span class="nx">app</span><span class="o">?</span>
View
2  docs/reference.md
@@ -1,6 +1,6 @@
---
layout: default
-title: API Reference (v0.4.8)
+title: API Reference (v0.4.9)
---
# {{page.title}}
View
129 docs/zappa.html
@@ -1,6 +1,7 @@
-<!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.4.8&#39;</span>
+<!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.4.9&#39;</span>
<span class="nv">codename = </span><span class="s">&#39;Freak Out!&#39;</span>
@@ -17,18 +18,25 @@
<span class="nv">socketio_key = </span><span class="s">&#39;__session&#39;</span></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>Soft dependencies:</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">jsdom = </span><span class="kc">null</span>
<span class="nv">express_partials = </span><span class="kc">null</span>
-<span class="nv">coffee_css = </span><span class="kc">null</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>CoffeeScript-generated JavaScript may contain anyone of these; when we "rewrite"
-a function (see below) though, it loses access to its parent scope, and consequently to
-any helpers it might need. So we need to reintroduce these helpers manually inside any
-"rewritten" function.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">coffeescript_helpers = </span><span class="s">&quot;&quot;&quot;</span>
+<span class="nv">coffee_css = </span><span class="kc">null</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>CoffeeScript-generated JavaScript may contain anyone of these; when we
+"rewrite" a function (see below) though, it loses access to its parent scope,
+and consequently to any helpers it might need. So we need to reintroduce
+these helpers manually inside any "rewritten" function.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">coffeescript_helpers = </span><span class="s">&quot;&quot;&quot;</span>
<span class="s"> var __slice = Array.prototype.slice;</span>
<span class="s"> var __hasProp = Object.prototype.hasOwnProperty;</span>
-<span class="s"> var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };</span>
+<span class="s"> var __bind = function(fn, me){</span>
+<span class="s"> return function(){ return fn.apply(me, arguments); };</span>
+<span class="s"> };</span>
<span class="s"> var __extends = function(child, parent) {</span>
-<span class="s"> for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }</span>
+<span class="s"> for (var key in parent) {</span>
+<span class="s"> if (__hasProp.call(parent, key)) child[key] = parent[key];</span>
+<span class="s"> }</span>
<span class="s"> function ctor() { this.constructor = child; }</span>
-<span class="s"> ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype;</span>
-<span class="s"> return child; };</span>
+<span class="s"> ctor.prototype = parent.prototype;</span>
+<span class="s"> child.prototype = new ctor;</span>
+<span class="s"> child.__super__ = parent.prototype;</span>
+<span class="s"> return child;</span>
+<span class="s"> };</span>
<span class="s"> var __indexOf = Array.prototype.indexOf || function(item) {</span>
<span class="s"> for (var i = 0, l = this.length; i &lt; l; i++) {</span>
<span class="s"> if (this[i] === item) return i;</span>
@@ -76,7 +84,8 @@
<span class="nx">callback</span> <span class="kc">true</span>
<span class="k">else</span>
<span class="nx">native_exists</span><span class="p">.</span><span class="nx">apply</span> <span class="nx">fs</span><span class="p">,</span> <span class="nx">native_array</span> <span class="nx">arguments</span><span class="p">...</span></pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-7">&#182;</a> </div> <p>Express must first be called after we modify the <code>fs</code> module.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">express = </span><span class="nx">require</span> <span class="s">&#39;express&#39;</span>
-<span class="nv">socketio = </span><span class="nx">require</span> <span class="s">&#39;socket.io&#39;</span></pre></div> </td> </tr> <tr id="section-8"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-8">&#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,options={}) -&gt;</span>
+<span class="nv">socketio = </span><span class="nx">require</span> <span class="s">&#39;socket.io&#39;</span></pre></div> </td> </tr> <tr id="section-8"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-8">&#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,options={}) -&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">real_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>
@@ -91,11 +100,14 @@
<span class="nv">context.server = </span><span class="nx">require</span><span class="p">(</span><span class="s">&#39;https&#39;</span><span class="p">).</span><span class="nx">createServer</span> <span class="nx">options</span><span class="p">.</span><span class="nx">https</span><span class="p">,</span> <span class="nx">app</span>
<span class="k">else</span>
<span class="nv">context.server = </span><span class="nx">require</span><span class="p">(</span><span class="s">&#39;http&#39;</span><span class="p">).</span><span class="nx">createServer</span> <span class="nx">app</span>
- <span class="nv">io = </span><span class="k">if</span> <span class="nx">options</span><span class="p">.</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">context</span><span class="p">.</span><span class="nx">server</span><span class="p">)</span></pre></div> </td> </tr> <tr id="section-10"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-10">&#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="k">if</span> <span class="nx">options</span><span class="p">.</span><span class="nx">disable_io</span>
+ <span class="nv">io = </span><span class="kc">null</span>
+ <span class="k">else</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">context</span><span class="p">.</span><span class="nx">server</span><span class="p">)</span></pre></div> </td> </tr> <tr id="section-10"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-10">&#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">client_bundled = </span><span class="kc">null</span></pre></div> </td> </tr> <tr id="section-11"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-11">&#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-12"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-12">&#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">engine</span> <span class="s">&#39;coffee&#39;</span><span class="p">,</span> <span class="nx">coffeecup_adapter</span></pre></div> </td> </tr> <tr id="section-13"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-13">&#182;</a> </div> <p>Sets default view dir to @root</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">root</span><span class="p">,</span> <span class="s">&#39;/views&#39;</span><span class="p">)</span>
- <span class="k">for</span> <span class="nx">verb</span> <span class="k">in</span> <span class="p">[</span><span class="s">&#39;get&#39;</span><span class="p">,</span> <span class="s">&#39;post&#39;</span><span class="p">,</span> <span class="s">&#39;put&#39;</span><span class="p">,</span> <span class="s">&#39;del&#39;</span><span class="p">]</span>
+ <span class="k">for</span> <span class="nx">verb</span> <span class="k">in</span> <span class="p">[</span><span class="s">&#39;get&#39;</span><span class="p">,</span> <span class="s">&#39;post&#39;</span><span class="p">,</span> <span class="s">&#39;put&#39;</span><span class="p">,</span> <span class="s">&#39;del&#39;</span><span class="p">,</span> <span class="s">&#39;all&#39;</span><span class="p">]</span>
<span class="nx">do</span> <span class="nf">(verb) -&gt;</span>
<span class="nx">context</span><span class="p">[</span><span class="nx">verb</span><span class="p">]</span> <span class="o">=</span> <span class="nf">(args...) -&gt;</span>
<span class="nv">arity = </span><span class="nx">args</span><span class="p">.</span><span class="nx">length</span>
@@ -163,8 +175,7 @@
<span class="nv">context.view = </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">ext = </span><span class="nx">path</span><span class="p">.</span><span class="nx">extname</span> <span class="nx">k</span>
- <span class="nv">p = </span><span class="nx">path</span><span class="p">.</span><span class="nx">join</span> <span class="nx">app</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s">&#39;views&#39;</span><span class="p">),</span> <span class="nx">k</span>
- <span class="nx">zappa_fs</span><span class="p">[</span><span class="nx">p</span><span class="p">]</span> <span class="o">=</span> <span class="nx">v</span> <span class="c1"># I&#39;m not even sure this is needed -- Express doesn&#39;t ask for it</span>
+ <span class="nv">p = </span><span class="nx">path</span><span class="p">.</span><span class="nx">join</span> <span class="nx">app</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s">&#39;views&#39;</span><span class="p">),</span> <span class="nx">k</span></pre></div> </td> </tr> <tr id="section-14"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-14">&#182;</a> </div> <p>I'm not even sure this is needed -- Express doesn't ask for it</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">zappa_fs</span><span class="p">[</span><span class="nx">p</span><span class="p">]</span> <span class="o">=</span> <span class="nx">v</span>
<span class="k">if</span> <span class="o">not</span> <span class="nx">ext</span>
<span class="nv">ext = </span><span class="s">&#39;.&#39;</span> <span class="o">+</span> <span class="nx">app</span><span class="p">.</span><span class="nx">get</span> <span class="s">&#39;view engine&#39;</span>
<span class="nx">zappa_fs</span><span class="p">[</span><span class="nx">p</span><span class="o">+</span><span class="nx">ext</span><span class="p">]</span> <span class="o">=</span> <span class="nx">v</span>
@@ -184,7 +195,7 @@
<span class="nx">app</span><span class="p">.</span><span class="nx">disable</span> <span class="nx">i</span> <span class="k">for</span> <span class="nx">i</span> <span class="k">in</span> <span class="nx">arguments</span>
<span class="nv">context.use = </span><span class="o">-&gt;</span>
- <span class="nv">zappa_middleware =</span></pre></div> </td> </tr> <tr id="section-14"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-14">&#182;</a> </div> <p>Connect <code>static</code> middlewate uses fs.stat().</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">static: </span><span class="p">(</span><span class="nv">p = </span><span class="nx">path</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="nx">real_root</span><span class="p">,</span> <span class="s">&#39;/public&#39;</span><span class="p">))</span> <span class="o">-&gt;</span>
+ <span class="nv">zappa_middleware =</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>Connect <code>static</code> middlewate uses fs.stat().</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">static: </span><span class="p">(</span><span class="nv">p = </span><span class="nx">path</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="nx">real_root</span><span class="p">,</span> <span class="s">&#39;/public&#39;</span><span class="p">))</span> <span class="o">-&gt;</span>
<span class="nx">express</span><span class="p">.</span><span class="nx">static</span><span class="p">(</span><span class="nx">p</span><span class="p">)</span>
<span class="nv">zappa: </span><span class="o">-&gt;</span>
<span class="nv">zappa_used = </span><span class="kc">yes</span>
@@ -207,8 +218,9 @@
<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">maps</span>
<span class="nx">partials</span><span class="p">.</span><span class="nx">register</span> <span class="nx">k</span><span class="p">,</span> <span class="nx">v</span>
<span class="nx">partials</span>
- <span class="nv">session_store: </span><span class="nf">(store) -&gt;</span>
- <span class="nv">context.session_store = </span><span class="nx">store</span>
+ <span class="nv">session: </span><span class="nf">(options) -&gt;</span>
+ <span class="nv">context.session_store = </span><span class="nx">options</span><span class="p">.</span><span class="nx">store</span>
+ <span class="nx">express</span><span class="p">.</span><span class="nx">session</span> <span class="nx">options</span>
<span class="nv">use = </span><span class="nf">(name, arg = null) -&gt;</span>
<span class="k">if</span> <span class="nx">zappa_middleware</span><span class="p">[</span><span class="nx">name</span><span class="p">]</span>
@@ -231,6 +243,7 @@
<span class="k">else</span> <span class="nx">app</span><span class="p">.</span><span class="nx">configure</span> <span class="nx">k</span><span class="p">,</span> <span class="nx">v</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">p</span>
<span class="nv">context.settings = </span><span class="nx">app</span><span class="p">.</span><span class="nx">settings</span>
+ <span class="nv">context.locals = </span><span class="nx">app</span><span class="p">.</span><span class="nx">locals</span>
<span class="nv">context.shared = </span><span class="nf">(obj) -&gt;</span>
<span class="nx">context</span><span class="p">.</span><span class="nx">use</span> <span class="s">&#39;zappa&#39;</span> <span class="nx">unless</span> <span class="nx">zappa_used</span>
@@ -238,24 +251,23 @@
<span class="nv">js = </span><span class="s">&quot;;zappa.run(</span><span class="si">#{</span><span class="nx">v</span><span class="si">}</span><span class="s">);&quot;</span>
<span class="nv">js = </span><span class="nx">minify</span><span class="p">(</span><span class="nx">js</span><span class="p">)</span> <span class="k">if</span> <span class="nx">app</span><span class="p">.</span><span class="nx">settings</span><span class="p">[</span><span class="s">&#39;minify&#39;</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">js</span><span class="p">,</span> <span class="nv">contentType: </span><span class="s">&#39;js&#39;</span>
- <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="nx">v</span><span class="p">.</span><span class="nx">apply</span> <span class="nx">context</span>
<span class="nv">context.include = </span><span class="nf">(p) -&gt;</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">real_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>
+ <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="nx">context</span>
<span class="nv">apply_helpers = </span><span class="nf">(ctx) -&gt;</span>
<span class="k">for</span> <span class="nx">name</span><span class="p">,</span> <span class="nx">helper</span> <span class="k">of</span> <span class="nx">helpers</span>
<span class="nx">do</span> <span class="nf">(name, helper) -&gt;</span>
<span class="k">if</span> <span class="k">typeof</span> <span class="nx">helper</span> <span class="o">is</span> <span class="s">&#39;function&#39;</span>
- <span class="nx">ctx</span><span class="p">[</span><span class="nx">name</span><span class="p">]</span> <span class="o">=</span> <span class="nf">(args...) -&gt;</span>
- <span class="nx">args</span><span class="p">.</span><span class="nx">push</span> <span class="nx">ctx</span>
- <span class="nx">helper</span><span class="p">.</span><span class="nx">apply</span> <span class="nx">ctx</span><span class="p">,</span> <span class="nx">args</span>
+ <span class="nx">ctx</span><span class="p">[</span><span class="nx">name</span><span class="p">]</span> <span class="o">=</span> <span class="o">-&gt;</span>
+ <span class="nx">helper</span><span class="p">.</span><span class="nx">apply</span> <span class="nx">ctx</span><span class="p">,</span> <span class="nx">arguments</span>
<span class="k">else</span>
<span class="nx">ctx</span><span class="p">[</span><span class="nx">name</span><span class="p">]</span> <span class="o">=</span> <span class="nx">helper</span>
- <span class="nx">ctx</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>Local socket</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">request_socket = </span><span class="nf">(req) -&gt;</span>
+ <span class="nx">ctx</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>Local socket</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">request_socket = </span><span class="nf">(req) -&gt;</span>
<span class="nv">socket_id = </span><span class="nx">req</span><span class="p">.</span><span class="nx">session</span><span class="o">?</span><span class="p">.</span><span class="nx">__socket</span><span class="o">?</span><span class="p">[</span><span class="s">&#39;__local&#39;</span><span class="p">]</span><span class="o">?</span><span class="p">.</span><span class="nx">id</span>
- <span class="nx">socket_id</span> <span class="o">and</span> <span class="nx">io</span><span class="o">?</span><span class="p">.</span><span class="nx">sockets</span><span class="p">.</span><span class="nx">socket</span> <span class="nx">socket_id</span><span class="p">,</span> <span class="kc">true</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>The callback will receive (err,session).</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">socket_session = </span><span class="nf">(socket,cb) -&gt;</span>
+ <span class="nx">socket_id</span> <span class="o">and</span> <span class="nx">io</span><span class="o">?</span><span class="p">.</span><span class="nx">sockets</span><span class="p">.</span><span class="nx">socket</span> <span class="nx">socket_id</span><span class="p">,</span> <span class="kc">true</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>The callback will receive (err,session).</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">socket_session = </span><span class="nf">(socket,cb) -&gt;</span>
<span class="nx">socket</span><span class="p">.</span><span class="nx">get</span> <span class="nx">socketio_key</span><span class="p">,</span> <span class="nf">(err,data) -&gt;</span>
<span class="k">if</span> <span class="nx">err</span>
<span class="k">return</span> <span class="nx">cb</span> <span class="nx">err</span>
@@ -263,12 +275,29 @@
<span class="k">if</span> <span class="nx">data</span><span class="p">.</span><span class="nx">id</span><span class="o">?</span>
<span class="nx">context</span><span class="p">.</span><span class="nx">session_store</span><span class="p">.</span><span class="nx">get</span> <span class="nx">data</span><span class="p">.</span><span class="nx">id</span><span class="p">,</span> <span class="nx">cb</span>
<span class="k">else</span>
- <span class="nx">cb</span> <span class="nx">err</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>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="nx">r</span><span class="p">.</span><span class="nx">middleware</span> <span class="o">?=</span> <span class="p">[]</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>Rewrite middleware</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">r.middleware = </span><span class="nx">r</span><span class="p">.</span><span class="nx">middleware</span><span class="p">.</span><span class="nx">map</span> <span class="nf">(f) -&gt;</span>
+ <span class="nx">cb</span> <span class="nx">err</span>
+
+ <span class="nv">context.param = </span><span class="nf">(obj) -&gt;</span>
+ <span class="nv">build = </span><span class="nf">(callback) -&gt;</span>
+ <span class="nf">(req,res,next,p) -&gt;</span>
+ <span class="nv">ctx =</span>
+ <span class="nv">request: </span><span class="nx">req</span>
+ <span class="nv">req: </span><span class="nx">req</span>
+ <span class="nv">response: </span><span class="nx">res</span>
+ <span class="nv">res: </span><span class="nx">res</span>
+ <span class="nv">next: </span><span class="nx">next</span>
+ <span class="nv">param: </span><span class="nx">p</span>
+ <span class="nx">apply_helpers</span> <span class="nx">ctx</span>
+ <span class="nx">callback</span><span class="p">.</span><span class="nx">apply</span> <span class="nx">ctx</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="nx">@app</span><span class="p">.</span><span class="nx">param</span> <span class="nx">k</span><span class="p">,</span> <span class="nx">build</span> <span class="nx">v</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>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="nx">r</span><span class="p">.</span><span class="nx">middleware</span> <span class="o">?=</span> <span class="p">[]</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>Rewrite middleware</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">r.middleware = </span><span class="nx">r</span><span class="p">.</span><span class="nx">middleware</span><span class="p">.</span><span class="nx">map</span> <span class="nf">(f) -&gt;</span>
<span class="nf">(req,res,next) -&gt;</span>
<span class="nv">ctx =</span>
<span class="nv">app: </span><span class="nx">app</span>
<span class="nv">settings: </span><span class="nx">app</span><span class="p">.</span><span class="nx">settings</span>
+ <span class="nv">locals: </span><span class="nx">res</span><span class="p">.</span><span class="nx">locals</span>
<span class="nv">request: </span><span class="nx">req</span>
<span class="nv">req: </span><span class="nx">req</span>
<span class="nv">query: </span><span class="nx">req</span><span class="p">.</span><span class="nx">query</span>
@@ -282,13 +311,10 @@
<span class="nx">apply_helpers</span> <span class="nx">ctx</span>
<span class="k">if</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="nv">data = </span><span class="p">{}</span>
- <span class="nx">copy_data_to</span> <span class="nx">data</span><span class="p">,</span> <span class="p">[</span><span class="nx">req</span><span class="p">.</span><span class="nx">query</span><span class="p">,</span> <span class="nx">req</span><span class="p">.</span><span class="nx">params</span><span class="p">,</span> <span class="nx">req</span><span class="p">.</span><span class="nx">body</span><span class="p">]</span>
+ <span class="nv">ctx.data = </span><span class="p">{}</span>
+ <span class="nx">copy_data_to</span> <span class="nx">ctx</span><span class="p">.</span><span class="nx">data</span><span class="p">,</span> <span class="p">[</span><span class="nx">req</span><span class="p">.</span><span class="nx">query</span><span class="p">,</span> <span class="nx">req</span><span class="p">.</span><span class="nx">params</span><span class="p">,</span> <span class="nx">req</span><span class="p">.</span><span class="nx">body</span><span class="p">]</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">f</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">f</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>
- <span class="k">else</span> <span class="nv">result = </span><span class="nx">f</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">ctx</span><span class="p">])</span>
+ <span class="nx">f</span><span class="p">.</span><span class="nx">apply</span> <span class="nx">ctx</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="nx">r</span><span class="p">.</span><span class="nx">middleware</span><span class="p">...,</span> <span class="nf">(req, res) -&gt;</span>
@@ -299,6 +325,7 @@
<span class="nv">ctx =</span>
<span class="nv">app: </span><span class="nx">app</span>
<span class="nv">settings: </span><span class="nx">app</span><span class="p">.</span><span class="nx">settings</span>
+ <span class="nv">locals: </span><span class="nx">res</span><span class="p">.</span><span class="nx">locals</span>
<span class="nv">request: </span><span class="nx">req</span>
<span class="nv">req: </span><span class="nx">req</span>
<span class="nv">query: </span><span class="nx">req</span><span class="p">.</span><span class="nx">query</span>
@@ -332,7 +359,7 @@
<span class="k">if</span> <span class="nx">err</span>
<span class="nx">next</span> <span class="nx">err</span>
<span class="k">else</span>
- <span class="nx">res</span><span class="p">.</span><span class="nx">send</span> <span class="nx">html</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>Make sure the second arg is an object.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">if</span> <span class="k">typeof</span> <span class="nx">opts</span> <span class="o">is</span> <span class="s">&#39;function&#39;</span>
+ <span class="nx">res</span><span class="p">.</span><span class="nx">send</span> <span class="nx">html</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>Make sure the second arg is an object.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">if</span> <span class="k">typeof</span> <span class="nx">opts</span> <span class="o">is</span> <span class="s">&#39;function&#39;</span>
<span class="nv">fn = </span><span class="nx">opts</span>
<span class="nv">opts = </span><span class="p">{}</span>
@@ -343,10 +370,10 @@
<span class="nv">postrender = </span><span class="nx">report</span>
<span class="k">else</span>
<span class="nv">postrender = </span><span class="nf">(err, str) -&gt;</span>
- <span class="k">if</span> <span class="nx">err</span> <span class="k">then</span> <span class="k">return</span> <span class="nx">report</span> <span class="nx">err</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>Apply postrender before sending response.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">jsdom</span><span class="p">.</span><span class="nx">env</span> <span class="nv">html: </span><span class="nx">str</span><span class="p">,</span> <span class="nv">src: </span><span class="p">[</span><span class="nx">jquery</span><span class="p">],</span> <span class="nv">done: </span><span class="nf">(err, window) -&gt;</span>
+ <span class="k">if</span> <span class="nx">err</span> <span class="k">then</span> <span class="k">return</span> <span class="nx">report</span> <span class="nx">err</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>Apply postrender before sending response.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">jsdom</span><span class="p">.</span><span class="nx">env</span> <span class="nv">html: </span><span class="nx">str</span><span class="p">,</span> <span class="nv">src: </span><span class="p">[</span><span class="nx">jquery</span><span class="p">],</span> <span class="nv">done: </span><span class="nf">(err, window) -&gt;</span>
<span class="k">if</span> <span class="nx">err</span> <span class="k">then</span> <span class="k">return</span> <span class="nx">report</span> <span class="nx">err</span>
<span class="nv">ctx.window = </span><span class="nb">window</span>
- <span class="nv">rendered = </span><span class="nx">postrenders</span><span class="p">[</span><span class="nx">opts</span><span class="p">.</span><span class="nx">postrender</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="nb">window</span><span class="p">.</span><span class="nx">$</span><span class="p">,</span> <span class="nx">ctx</span><span class="p">])</span>
+ <span class="nv">rendered = </span><span class="nx">postrenders</span><span class="p">[</span><span class="nx">opts</span><span class="p">.</span><span class="nx">postrender</span><span class="p">].</span><span class="nx">apply</span> <span class="nx">ctx</span><span class="p">,</span> <span class="p">[</span><span class="nb">window</span><span class="p">.</span><span class="nx">$</span><span class="p">]</span>
<span class="nv">doctype = </span><span class="p">(</span><span class="nb">window</span><span class="p">.</span><span class="nb">document</span><span class="p">.</span><span class="nx">doctype</span> <span class="o">or</span> <span class="s">&#39;&#39;</span><span class="p">)</span> <span class="o">+</span> <span class="s">&quot;\n&quot;</span>
<span class="nv">html = </span><span class="nx">doctype</span> <span class="o">+</span> <span class="nb">window</span><span class="p">.</span><span class="nb">document</span><span class="p">.</span><span class="nx">documentElement</span><span class="p">.</span><span class="nx">outerHTML</span>
@@ -357,11 +384,10 @@
<span class="nx">apply_helpers</span> <span class="nx">ctx</span>
<span class="k">if</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="nv">data = </span><span class="p">{}</span>
- <span class="nx">copy_data_to</span> <span class="nx">data</span><span class="p">,</span> <span class="p">[</span><span class="nx">req</span><span class="p">.</span><span class="nx">query</span><span class="p">,</span> <span class="nx">req</span><span class="p">.</span><span class="nx">params</span><span class="p">,</span> <span class="nx">req</span><span class="p">.</span><span class="nx">body</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>Go!</p> </td> <td class="code"> <div class="highlight"><pre> <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="nv">result = </span><span class="nx">r</span><span class="p">.</span><span class="nx">handler</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="nv">result = </span><span class="nx">r</span><span class="p">.</span><span class="nx">handler</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>
- <span class="k">else</span> <span class="nv">result = </span><span class="nx">r</span><span class="p">.</span><span class="nx">handler</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">ctx</span><span class="p">])</span>
+ <span class="nv">ctx.data = </span><span class="p">{}</span>
+ <span class="nx">copy_data_to</span> <span class="nx">ctx</span><span class="p">.</span><span class="nx">data</span><span class="p">,</span> <span class="p">[</span><span class="nx">req</span><span class="p">.</span><span class="nx">query</span><span class="p">,</span> <span class="nx">req</span><span class="p">.</span><span class="nx">params</span><span class="p">,</span> <span class="nx">req</span><span class="p">.</span><span class="nx">body</span><span class="p">]</span>
+
+ <span class="nv">result = </span><span class="nx">r</span><span class="p">.</span><span class="nx">handler</span><span class="p">.</span><span class="nx">apply</span> <span class="nx">ctx</span>
<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>
@@ -373,6 +399,7 @@
<span class="nv">app: </span><span class="nx">app</span>
<span class="nv">io: </span><span class="nx">io</span>
<span class="nv">settings: </span><span class="nx">app</span><span class="p">.</span><span class="nx">settings</span>
+ <span class="nv">locals: </span><span class="nx">app</span><span class="p">.</span><span class="nx">locals</span>
<span class="nv">socket: </span><span class="nx">socket</span>
<span class="nv">id: </span><span class="nx">socket</span><span class="p">.</span><span class="nx">id</span>
<span class="nv">client: </span><span class="nx">c</span>
@@ -406,11 +433,11 @@
<span class="nx">ctx</span>
<span class="nv">ctx = </span><span class="nx">build_ctx</span><span class="p">()</span>
- <span class="nx">ws_handlers</span><span class="p">.</span><span class="nx">connection</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">ctx</span><span class="p">])</span> <span class="k">if</span> <span class="nx">ws_handlers</span><span class="p">.</span><span class="nx">connection</span><span class="o">?</span>
+ <span class="nx">ws_handlers</span><span class="p">.</span><span class="nx">connection</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="k">if</span> <span class="nx">ws_handlers</span><span class="p">.</span><span class="nx">connection</span><span class="o">?</span>
<span class="nx">socket</span><span class="p">.</span><span class="kc">on</span> <span class="s">&#39;disconnect&#39;</span><span class="p">,</span> <span class="o">-&gt;</span>
<span class="nv">ctx = </span><span class="nx">build_ctx</span><span class="p">()</span>
- <span class="nx">ws_handlers</span><span class="p">.</span><span class="nx">disconnect</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">ctx</span><span class="p">])</span> <span class="k">if</span> <span class="nx">ws_handlers</span><span class="p">.</span><span class="nx">disconnect</span><span class="o">?</span>
+ <span class="nx">ws_handlers</span><span class="p">.</span><span class="nx">disconnect</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="k">if</span> <span class="nx">ws_handlers</span><span class="p">.</span><span class="nx">disconnect</span><span class="o">?</span>
<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>
@@ -419,10 +446,7 @@
<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>
- <span class="k">else</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">ctx</span><span class="p">])</span></pre></div> </td> </tr> <tr id="section-23"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-23">&#182;</a> </div> <p>Go!</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">func</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-24"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-24">&#182;</a> </div> <p>The stringified zappa client.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">client = </span><span class="nx">require</span><span class="p">(</span><span class="s">&#39;./client&#39;</span><span class="p">).</span><span class="nx">build</span><span class="p">(</span><span class="nx">zappa</span><span class="p">.</span><span class="nx">version</span><span class="p">,</span> <span class="nx">app</span><span class="p">.</span><span class="nx">settings</span><span class="p">)</span>
+ <span class="nx">h</span><span class="p">.</span><span class="nx">apply</span> <span class="nx">ctx</span></pre></div> </td> </tr> <tr id="section-23"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-23">&#182;</a> </div> <p>Go!</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">func</span><span class="p">.</span><span class="nx">apply</span> <span class="nx">context</span></pre></div> </td> </tr> <tr id="section-24"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-24">&#182;</a> </div> <p>The stringified zappa client.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">client = </span><span class="nx">require</span><span class="p">(</span><span class="s">&#39;./client&#39;</span><span class="p">).</span><span class="nx">build</span><span class="p">(</span><span class="nx">zappa</span><span class="p">.</span><span class="nx">version</span><span class="p">,</span> <span class="nx">app</span><span class="p">.</span><span class="nx">settings</span><span class="p">)</span>
<span class="nv">client = </span><span class="s">&quot;;</span><span class="si">#{</span><span class="nx">coffeescript_helpers</span><span class="si">}</span><span class="s">(</span><span class="si">#{</span><span class="nx">client</span><span class="si">}</span><span class="s">)();&quot;</span>
<span class="nv">client = </span><span class="nx">minify</span><span class="p">(</span><span class="nx">client</span><span class="p">)</span> <span class="k">if</span> <span class="nx">app</span><span class="p">.</span><span class="nx">settings</span><span class="p">[</span><span class="s">&#39;minify&#39;</span><span class="p">]</span>
<span class="nv">client_bundled =</span>
@@ -469,10 +493,9 @@
<span class="nx">@send</span> <span class="nx">error</span><span class="o">:</span><span class="s">&#39;No session&#39;</span>
<span class="nx">context</span></pre></div> </td> </tr> <tr id="section-29"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-29">&#182;</a> </div> <p>zappa.run [host,] [port,] [{options},] root_function
-Takes a function and runs it as a zappa app. Optionally accepts a port number, and/or
-a hostname (any order). The hostname must be a string, and the port number must be
-castable as a number.
-Returns an object where <code>app</code> is the express server and <code>io</code> is the socket.io handle.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">zappa.run = </span><span class="o">-&gt;</span>
+Takes a function and runs it as a zappa app. Optionally accepts a port
+number, and/or a hostname (any order). The hostname must be a string, and
+the port number must be castable as a number.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">zappa.run = </span><span class="o">-&gt;</span>
<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>
@@ -516,7 +539,7 @@
<p>Zappa, by default, automatically sends all request params to templates,
but inside the <code>params</code> local.</p>
-<p>This adapter adds a "root local" for each of these params, <em>only</em>
+<p>This adapter adds a "root local" for each of these params, <em>only</em>
if a local with the same name doesn't exist already, <em>and</em> the name is not
in the optional blacklist.</p>
View
2  src/zappa.coffee
@@ -3,7 +3,7 @@
# integrating [express](http://expressjs.com), [socket.io](http://socket.io)
# and other best-of-breed libraries.
-zappa = version: '0.4.8'
+zappa = version: '0.4.9'
codename = 'Freak Out!'
Please sign in to comment.
Something went wrong with that request. Please try again.