Skip to content
This repository
Browse code

Added `cake vendor` and updated jquery (1.6.4) and sammy (0.7.0).

Backport of b718272 from 0.2.x.
  • Loading branch information...
commit 92f6f994e18cf11bd33881c68bbe0f5c846d24b2 1 parent 217fd40
Maurice Machado mauricemach authored
3  .gitignore
@@ -5,4 +5,5 @@ lib/*.js
5 5 benchmarks/out/*.dat
6 6 benchmarks/out/*.out
7 7 tests/*.js
8   -_site
  8 +_site
  9 +vendor
6 Cakefile
@@ -12,6 +12,12 @@ task 'bench', ->
12 12
13 13 task 'docs', ->
14 14 run 'docco src/*.coffee'
  15 +
  16 +task 'vendor', ->
  17 + run 'mkdir -p vendor && cd vendor && curl -OL http://code.jquery.com/jquery-1.6.4.min.js', ->
  18 + run 'cd vendor && curl -OL http://raw.github.com/quirkey/sammy/v0.7.0/lib/min/sammy-0.7.0.min.js', ->
  19 + run 'head -n 1 vendor/jquery*', ->
  20 + run 'head -n 3 vendor/sammy*'
15 21
16 22 run = (args...) ->
17 23 for a in args
4 docs/reference.md
Source Rendered
@@ -479,11 +479,11 @@ Serves `/zappa/zappa.js`, required to use the zappa client API. Automatically en
479 479
480 480 ### serve jquery
481 481
482   -Serves `/zappa/jquery.js` (minified jQuery 1.6.2 from npm).
  482 +Serves `/zappa/jquery.js` (just standard, minified jQuery).
483 483
484 484 ### serve sammy
485 485
486   -Serves `/zappa/sammy.js` (minified Sammy 0.6.3).
  486 +Serves `/zappa/sammy.js` (just standard, minified Sammy).
487 487
488 488 ### minify
489 489
23 docs/zappa.html
@@ -9,8 +9,8 @@
9 9 <span class="nv">express = </span><span class="nx">require</span> <span class="s1">&#39;express&#39;</span>
10 10 <span class="nv">socketio = </span><span class="nx">require</span> <span class="s1">&#39;socket.io&#39;</span>
11 11 <span class="nv">jsdom = </span><span class="nx">require</span> <span class="s1">&#39;jsdom&#39;</span>
12   -<span class="nv">jquery = </span><span class="nx">fs</span><span class="p">.</span><span class="nx">readFileSync</span><span class="p">(</span><span class="nx">__dirname</span> <span class="o">+</span> <span class="s1">&#39;/../node_modules/jquery/dist/node-jquery.min.js&#39;</span><span class="p">).</span><span class="nx">toString</span><span class="p">()</span>
13   -<span class="nv">sammy = </span><span class="nx">fs</span><span class="p">.</span><span class="nx">readFileSync</span><span class="p">(</span><span class="nx">__dirname</span> <span class="o">+</span> <span class="s1">&#39;/../vendor/sammy-latest.min.js&#39;</span><span class="p">).</span><span class="nx">toString</span><span class="p">()</span>
  12 +<span class="nv">jquery = </span><span class="nx">fs</span><span class="p">.</span><span class="nx">readFileSync</span><span class="p">(</span><span class="nx">__dirname</span> <span class="o">+</span> <span class="s1">&#39;/../vendor/jquery-1.6.4.min.js&#39;</span><span class="p">).</span><span class="nx">toString</span><span class="p">()</span>
  13 +<span class="nv">sammy = </span><span class="nx">fs</span><span class="p">.</span><span class="nx">readFileSync</span><span class="p">(</span><span class="nx">__dirname</span> <span class="o">+</span> <span class="s1">&#39;/../vendor/sammy-0.7.0.min.js&#39;</span><span class="p">).</span><span class="nx">toString</span><span class="p">()</span>
14 14 <span class="nv">uglify = </span><span class="nx">require</span> <span class="s1">&#39;uglify-js&#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>CoffeeScript-generated JavaScript may contain anyone of these; when we "rewrite"
15 15 a function (see below) though, it loses access to its parent scope, and consequently to
16 16 any helpers it might need. So we need to reintroduce these helpers manually inside any
@@ -192,27 +192,26 @@
192 192 </pre></div> </td> </tr> <tr id="section-22"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-22">&#182;</a> </div> <p>Make sure the second arg is an object.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">args</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">?=</span> <span class="p">{}</span>
193 193 <span class="nx">args</span><span class="p">.</span><span class="nx">splice</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="p">{}</span> <span class="k">if</span> <span class="k">typeof</span> <span class="nx">args</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">is</span> <span class="s1">&#39;function&#39;</span>
194 194 </pre></div> </td> </tr> <tr id="section-23"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-23">&#182;</a> </div> <p>Automatically send request input vars to template.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">args</span><span class="p">[</span><span class="mi">1</span><span class="p">].</span><span class="nv">params = </span><span class="p">{}</span>
195   - <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">ctx</span>
196   - <span class="nx">args</span><span class="p">[</span><span class="mi">1</span><span class="p">].</span><span class="nx">params</span><span class="p">[</span><span class="nx">k</span><span class="p">]</span> <span class="o">=</span> <span class="nx">v</span> <span class="nx">unless</span> <span class="nx">k</span> <span class="k">in</span> <span class="nx">names</span>
  195 + <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">ctx</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>TODO: What if I <em>want</em> to pass, say, @request to the view?</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">args</span><span class="p">[</span><span class="mi">1</span><span class="p">].</span><span class="nx">params</span><span class="p">[</span><span class="nx">k</span><span class="p">]</span> <span class="o">=</span> <span class="nx">v</span> <span class="nx">unless</span> <span class="nx">k</span> <span class="k">in</span> <span class="nx">names</span>
197 196
198   - <span class="k">if</span> <span class="nx">args</span><span class="p">[</span><span class="mi">1</span><span class="p">].</span><span class="nx">postrender</span><span class="o">?</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>Apply postrender before sending response.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">res</span><span class="p">.</span><span class="nx">render</span> <span class="nx">args</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="nx">args</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="nf">(err, str) -&gt;</span>
  197 + <span class="k">if</span> <span class="nx">args</span><span class="p">[</span><span class="mi">1</span><span class="p">].</span><span class="nx">postrender</span><span class="o">?</span></pre></div> </td> </tr> <tr id="section-25"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-25">&#182;</a> </div> <p>Apply postrender before sending response.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">res</span><span class="p">.</span><span class="nx">render</span> <span class="nx">args</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="nx">args</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="nf">(err, str) -&gt;</span>
199 198 <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>
200 199 <span class="nv">rendered = </span><span class="nx">postrenders</span><span class="p">[</span><span class="nx">args</span><span class="p">[</span><span class="mi">1</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="nv">data: </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">$</span><span class="p">,</span> <span class="nb">window</span><span class="p">])</span>
201 200
202 201 <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="s1">&#39;&#39;</span><span class="p">)</span> <span class="o">+</span> <span class="s2">&quot;\n&quot;</span>
203 202 <span class="nx">res</span><span class="p">.</span><span class="nx">send</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>
204   - <span class="k">else</span></pre></div> </td> </tr> <tr id="section-25"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-25">&#182;</a> </div> <p>Just forward params to express.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">res</span><span class="p">.</span><span class="nx">render</span><span class="p">.</span><span class="nx">apply</span> <span class="nx">res</span><span class="p">,</span> <span class="nx">args</span>
  203 + <span class="k">else</span></pre></div> </td> </tr> <tr id="section-26"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-26">&#182;</a> </div> <p>Just forward params to express.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">res</span><span class="p">.</span><span class="nx">render</span><span class="p">.</span><span class="nx">apply</span> <span class="nx">res</span><span class="p">,</span> <span class="nx">args</span>
205 204
206 205 <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>
207 206 <span class="nx">do</span> <span class="nf">(name, helper) -&gt;</span>
208 207 <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>
209   - <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></pre></div> </td> </tr> <tr id="section-26"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-26">&#182;</a> </div> <p>Names of non-input context vars.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">names = </span><span class="p">[]</span>
210   - <span class="nx">names</span><span class="p">.</span><span class="nx">push</span> <span class="nx">k</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">ctx</span></pre></div> </td> </tr> <tr id="section-27"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-27">&#182;</a> </div> <p>Imports input vars to ctx.data, and in ctx if the name is not taken.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">copy_data_to</span> <span class="nx">ctx</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-28"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-28">&#182;</a> </div> <p>Go!</p> </td> <td class="code"> <div class="highlight"><pre> <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>
  208 + <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></pre></div> </td> </tr> <tr id="section-27"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-27">&#182;</a> </div> <p>Names of non-input context vars.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">names = </span><span class="p">[]</span>
  209 + <span class="nx">names</span><span class="p">.</span><span class="nx">push</span> <span class="nx">k</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">ctx</span></pre></div> </td> </tr> <tr id="section-28"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-28">&#182;</a> </div> <p>Imports input vars to ctx.data, and in ctx if the name is not taken.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">copy_data_to</span> <span class="nx">ctx</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-29"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-29">&#182;</a> </div> <p>Go!</p> </td> <td class="code"> <div class="highlight"><pre> <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>
211 210
212 211 <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>
213 212 <span class="k">if</span> <span class="k">typeof</span> <span class="nx">result</span> <span class="o">is</span> <span class="s1">&#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>
214 213 <span class="k">else</span> <span class="k">return</span> <span class="nx">result</span>
215   - </pre></div> </td> </tr> <tr id="section-29"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-29">&#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="s1">&#39;connection&#39;</span><span class="p">,</span> <span class="nf">(socket) -&gt;</span>
  214 + </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="s1">&#39;connection&#39;</span><span class="p">,</span> <span class="nf">(socket) -&gt;</span>
216 215 <span class="nv">c = </span><span class="p">{}</span>
217 216
218 217 <span class="nv">build_ctx = </span><span class="o">-&gt;</span>
@@ -245,7 +244,7 @@
245 244 <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>
246 245 <span class="nv">ctx = </span><span class="nx">build_ctx</span><span class="p">()</span>
247 246 <span class="nx">copy_data_to</span> <span class="nx">ctx</span><span class="p">,</span> <span class="p">[</span><span class="nx">data</span><span class="p">]</span>
248   - <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-30"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-30">&#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>
  247 + <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-31"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-31">&#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>
249 248
250 249 <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="s1">&#39;serve zappa&#39;</span><span class="p">]</span>
251 250 <span class="nx">app</span><span class="p">.</span><span class="nx">get</span> <span class="s1">&#39;/zappa/zappa.js&#39;</span><span class="p">,</span> <span class="nf">(req, res) -&gt;</span>
@@ -281,7 +280,7 @@
281 280 <span class="nx">style</span> <span class="nx">@style</span> <span class="k">if</span> <span class="nx">@style</span>
282 281 <span class="nx">body</span> <span class="nx">@body</span>
283 282
284   - <span class="p">{</span><span class="nv">id: </span><span class="nx">context</span><span class="p">.</span><span class="nx">id</span><span class="p">,</span> <span class="nx">app</span><span class="p">,</span> <span class="nx">io</span><span class="p">}</span></pre></div> </td> </tr> <tr id="section-31"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-31">&#182;</a> </div> <p>Takes a function and runs it as a zappa app. Optionally accepts a port number, and/or
  283 + <span class="p">{</span><span class="nv">id: </span><span class="nx">context</span><span class="p">.</span><span class="nx">id</span><span class="p">,</span> <span class="nx">app</span><span class="p">,</span> <span class="nx">io</span><span class="p">}</span></pre></div> </td> </tr> <tr id="section-32"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-32">&#182;</a> </div> <p>Takes a function and runs it as a zappa app. Optionally accepts a port number, and/or
285 284 a hostname (any order). The hostname must be a string, and the port number must be
286 285 castable as a number.
287 286 Returns an object where <code>app</code> is the express server and <code>io</code> is the socket.io handle.
@@ -312,7 +311,7 @@
312 311
313 312 <span class="nx">log</span> <span class="s2">&quot;Zappa #{zappa.version} orchestrating the show&quot;</span>
314 313
315   - <span class="nx">zapp</span></pre></div> </td> </tr> <tr id="section-32"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-32">&#182;</a> </div> <p>Creates a zappa view adapter for templating engine <code>engine</code>. This adapter
  314 + <span class="nx">zapp</span></pre></div> </td> </tr> <tr id="section-33"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-33">&#182;</a> </div> <p>Creates a zappa view adapter for templating engine <code>engine</code>. This adapter
316 315 can be used with <code>app.register</code> and creates params "shortcuts".</p>
317 316
318 317 <p>Zappa, by default, automatically sends all request params to templates,
3  package.json
@@ -9,7 +9,6 @@
9 9 "express": "2.4.6",
10 10 "socket.io": "0.8.4",
11 11 "jsdom": "0.2.4",
12   - "jquery": "1.6.2",
13 12 "coffeekup": "0.3.0",
14 13 "node-uuid": "1.2.0",
15 14 "uglify-js": "1.0.7"
@@ -31,7 +30,7 @@
31 30 "Yuya Nishiyama <nsy@ulz.nu>",
32 31 "Esa-Matti Suuronen <esa-matti@suuronen.org>",
33 32 "Isaac Wolkerstorfer <agnoster@gmail.com>",
34   - "Jason King <jasonk@amcoonline.net>",
  33 + "Jason King <jk@handle.it>",
35 34 "Stéphane Alnet <stephane@shimaore.net>",
36 35 "Rachel Carvalho <rachel.carvalho@gmail.com>",
37 36 "Tim Shadel <github@timshadel.com>",
4 src/zappa.coffee
@@ -11,8 +11,8 @@ uuid = require 'node-uuid'
11 11 express = require 'express'
12 12 socketio = require 'socket.io'
13 13 jsdom = require 'jsdom'
14   -jquery = fs.readFileSync(__dirname + '/../node_modules/jquery/dist/node-jquery.min.js').toString()
15   -sammy = fs.readFileSync(__dirname + '/../vendor/sammy-latest.min.js').toString()
  14 +jquery = fs.readFileSync(__dirname + '/../vendor/jquery-1.6.4.min.js').toString()
  15 +sammy = fs.readFileSync(__dirname + '/../vendor/sammy-0.7.0.min.js').toString()
16 16 uglify = require 'uglify-js'
17 17
18 18 # CoffeeScript-generated JavaScript may contain anyone of these; when we "rewrite"
10 tests/assets.coffee
@@ -99,7 +99,7 @@ port = 15200
99 99 c = t.client(zapp.app)
100 100 c.get '/zappa/jquery.js', (err, res) ->
101 101 t.equal 'content-type', res.headers['content-type'], 'application/javascript'
102   - t.equal 'length', res.headers['content-length'], '92334'
  102 + t.equal 'length', res.headers['content-length'], '91669'
103 103
104 104 sammy: (t) ->
105 105 t.expect 'content-type', 'length'
@@ -111,7 +111,7 @@ port = 15200
111 111 c = t.client(zapp.app)
112 112 c.get '/zappa/sammy.js', (err, res) ->
113 113 t.equal 'content-type', res.headers['content-type'], 'application/javascript'
114   - t.equal 'length', res.headers['content-length'], '16854'
  114 + t.equal 'length', res.headers['content-length'], '18059'
115 115
116 116 zappa: (t) ->
117 117 t.expect 'content-type', 'length'
@@ -123,7 +123,7 @@ port = 15200
123 123 c = t.client(zapp.app)
124 124 c.get '/zappa/zappa.js', (err, res) ->
125 125 t.equal 'content-type', res.headers['content-type'], 'application/javascript'
126   - t.equal 'length', res.headers['content-length'], '5156'
  126 + t.equal 'length', res.headers['content-length'], '5160'
127 127
128 128 'zappa (automatic)': (t) ->
129 129 t.expect 'content-type', 'length'
@@ -135,7 +135,7 @@ port = 15200
135 135 c = t.client(zapp.app)
136 136 c.get '/zappa/zappa.js', (err, res) ->
137 137 t.equal 'content-type', res.headers['content-type'], 'application/javascript'
138   - t.equal 'length', res.headers['content-length'], '5156'
  138 + t.equal 'length', res.headers['content-length'], '5160'
139 139
140 140 minify: (t) ->
141 141 t.expect 'zappa', 'client', 'shared', 'coffee', 'js'
@@ -150,7 +150,7 @@ port = 15200
150 150
151 151 c = t.client(zapp.app)
152 152 c.get '/zappa/zappa.js', (err, res) ->
153   - t.equal 'zappa', res.headers['content-length'], '2663'
  153 + t.equal 'zappa', res.headers['content-length'], '2667'
154 154 c.get '/client.js', (err, res) ->
155 155 t.equal 'client', res.headers['content-length'], '42'
156 156 c.get '/shared.js', (err, res) ->
5 vendor/sammy-latest.min.js
... ... @@ -1,5 +0,0 @@
1   -// -- Sammy.js -- /sammy.js
2   -// http://sammyjs.org
3   -// Version: 0.6.3
4   -// Built: 2011-01-27 10:31:14 -0800
5   -(function(h,j){var o,g="([^/]+)",k=/:([\w\d]+)/g,l=/\?([^#]*)$/,c=function(p){return Array.prototype.slice.call(p)},d=function(p){return Object.prototype.toString.call(p)==="[object Function]"},m=function(p){return Object.prototype.toString.call(p)==="[object Array]"},i=function(p){return decodeURIComponent(p.replace(/\+/g," "))},b=encodeURIComponent,f=function(p){return String(p).replace(/&(?!\w+;)/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},n=function(p){return function(q,r){return this.route.apply(this,[p,q,r])}},a={},e=[];o=function(){var q=c(arguments),r,p;o.apps=o.apps||{};if(q.length===0||q[0]&&d(q[0])){return o.apply(o,["body"].concat(q))}else{if(typeof(p=q.shift())=="string"){r=o.apps[p]||new o.Application();r.element_selector=p;if(q.length>0){h.each(q,function(s,t){r.use(t)})}if(r.element_selector!=p){delete o.apps[p]}o.apps[r.element_selector]=r;return r}}};o.VERSION="0.6.3";o.addLogger=function(p){e.push(p)};o.log=function(){var p=c(arguments);p.unshift("["+Date()+"]");h.each(e,function(r,q){q.apply(o,p)})};if(typeof j.console!="undefined"){if(d(j.console.log.apply)){o.addLogger(function(){j.console.log.apply(j.console,arguments)})}else{o.addLogger(function(){j.console.log(arguments)})}}else{if(typeof console!="undefined"){o.addLogger(function(){console.log.apply(console,arguments)})}}h.extend(o,{makeArray:c,isFunction:d,isArray:m});o.Object=function(p){return h.extend(this,p||{})};h.extend(o.Object.prototype,{escapeHTML:f,h:f,toHash:function(){var p={};h.each(this,function(r,q){if(!d(q)){p[r]=q}});return p},toHTML:function(){var p="";h.each(this,function(r,q){if(!d(q)){p+="<strong>"+r+"</strong> "+q+"<br />"}});return p},keys:function(p){var q=[];for(var r in this){if(!d(this[r])||!p){q.push(r)}}return q},has:function(p){return this[p]&&h.trim(this[p].toString())!=""},join:function(){var q=c(arguments);var p=q.shift();return q.join(p)},log:function(){o.log.apply(o,arguments)},toString:function(p){var q=[];h.each(this,function(s,r){if(!d(r)||p){q.push('"'+s+'": '+r.toString())}});return"Sammy.Object: {"+q.join(",")+"}"}});o.HashLocationProxy=function(q,p){this.app=q;this.is_native=false;this._startPolling(p)};o.HashLocationProxy.prototype={bind:function(){var p=this,q=this.app;h(j).bind("hashchange."+this.app.eventNamespace(),function(s,r){if(p.is_native===false&&!r){o.log("native hash change exists, using");p.is_native=true;j.clearInterval(o.HashLocationProxy._interval)}q.trigger("location-changed")});if(!o.HashLocationProxy._bindings){o.HashLocationProxy._bindings=0}o.HashLocationProxy._bindings++},unbind:function(){h(j).unbind("hashchange."+this.app.eventNamespace());o.HashLocationProxy._bindings--;if(o.HashLocationProxy._bindings<=0){j.clearInterval(o.HashLocationProxy._interval)}},getLocation:function(){var p=j.location.toString().match(/^[^#]*(#.+)$/);return p?p[1]:""},setLocation:function(p){return(j.location=p)},_startPolling:function(r){var q=this;if(!o.HashLocationProxy._interval){if(!r){r=10}var p=function(){var s=q.getLocation();if(!o.HashLocationProxy._last_location||s!=o.HashLocationProxy._last_location){j.setTimeout(function(){h(j).trigger("hashchange",[true])},13)}o.HashLocationProxy._last_location=s};p();o.HashLocationProxy._interval=j.setInterval(p,r)}}};o.Application=function(p){var q=this;this.routes={};this.listeners=new o.Object({});this.arounds=[];this.befores=[];this.namespace=(new Date()).getTime()+"-"+parseInt(Math.random()*1000,10);this.context_prototype=function(){o.EventContext.apply(this,arguments)};this.context_prototype.prototype=new o.EventContext();if(d(p)){p.apply(this,[this])}if(!this._location_proxy){this.setLocationProxy(new o.HashLocationProxy(this,this.run_interval_every))}if(this.debug){this.bindToAllEvents(function(s,r){q.log(q.toString(),s.cleaned_type,r||{})})}};o.Application.prototype=h.extend({},o.Object.prototype,{ROUTE_VERBS:["get","post","put","delete"],APP_EVENTS:["run","unload","lookup-route","run-route","route-found","event-context-before","event-context-after","changed","error","check-form-submission","redirect","location-changed"],_last_route:null,_location_proxy:null,_running:false,element_selector:"body",debug:false,raise_errors:false,run_interval_every:50,template_engine:null,toString:function(){return"Sammy.Application:"+this.element_selector},$element:function(p){return p?h(this.element_selector).find(p):h(this.element_selector)},use:function(){var p=c(arguments),r=p.shift(),q=r||"";try{p.unshift(this);if(typeof r=="string"){q="Sammy."+r;r=o[r]}r.apply(this,p)}catch(s){if(typeof r==="undefined"){this.error("Plugin Error: called use() but plugin ("+q.toString()+") is not defined",s)}else{if(!d(r)){this.error("Plugin Error: called use() but '"+q.toString()+"' is not a function",s)}else{this.error("Plugin Error",s)}}}return this},setLocationProxy:function(p){var q=this._location_proxy;this._location_proxy=p;if(this.isRunning()){if(q){q.unbind()}this._location_proxy.bind()}},route:function(t,q,v){var s=this,u=[],p,r;if(!v&&d(q)){q=t;v=q;t="any"}t=t.toLowerCase();if(q.constructor==String){k.lastIndex=0;while((r=k.exec(q))!==null){u.push(r[1])}q=new RegExp("^"+q.replace(k,g)+"$")}if(typeof v=="string"){v=s[v]}p=function(w){var x={verb:w,path:q,callback:v,param_names:u};s.routes[w]=s.routes[w]||[];s.routes[w].push(x)};if(t==="any"){h.each(this.ROUTE_VERBS,function(x,w){p(w)})}else{p(t)}return this},get:n("get"),post:n("post"),put:n("put"),del:n("delete"),any:n("any"),mapRoutes:function(q){var p=this;h.each(q,function(r,s){p.route.apply(p,s)});return this},eventNamespace:function(){return["sammy-app",this.namespace].join("-")},bind:function(p,r,t){var s=this;if(typeof t=="undefined"){t=r}var q=function(){var w,u,v;w=arguments[0];v=arguments[1];if(v&&v.context){u=v.context;delete v.context}else{u=new s.context_prototype(s,"bind",w.type,v,w.target)}w.cleaned_type=w.type.replace(s.eventNamespace(),"");t.apply(u,[w,v])};if(!this.listeners[p]){this.listeners[p]=[]}this.listeners[p].push(q);if(this.isRunning()){this._listen(p,q)}return this},trigger:function(p,q){this.$element().trigger([p,this.eventNamespace()].join("."),[q]);return this},refresh:function(){this.last_location=null;this.trigger("location-changed");return this},before:function(p,q){if(d(p)){q=p;p={}}this.befores.push([p,q]);return this},after:function(p){return this.bind("event-context-after",p)},around:function(p){this.arounds.push(p);return this},isRunning:function(){return this._running},helpers:function(p){h.extend(this.context_prototype.prototype,p);return this},helper:function(p,q){this.context_prototype.prototype[p]=q;return this},run:function(p){if(this.isRunning()){return false}var q=this;h.each(this.listeners.toHash(),function(r,s){h.each(s,function(u,t){q._listen(r,t)})});this.trigger("run",{start_url:p});this._running=true;this.last_location=null;if(this.getLocation()==""&&typeof p!="undefined"){this.setLocation(p)}this._checkLocation();this._location_proxy.bind();this.bind("location-changed",function(){q._checkLocation()});this.bind("submit",function(s){var r=q._checkFormSubmission(h(s.target).closest("form"));return(r===false)?s.preventDefault():false});h(j).bind("beforeunload",function(){q.unload()});return this.trigger("changed")},unload:function(){if(!this.isRunning()){return false}var p=this;this.trigger("unload");this._location_proxy.unbind();this.$element().unbind("submit").removeClass(p.eventNamespace());h.each(this.listeners.toHash(),function(q,r){h.each(r,function(t,s){p._unlisten(q,s)})});this._running=false;return this},bindToAllEvents:function(q){var p=this;h.each(this.APP_EVENTS,function(r,s){p.bind(s,q)});h.each(this.listeners.keys(true),function(s,r){if(p.APP_EVENTS.indexOf(r)==-1){p.bind(r,q)}});return this},routablePath:function(p){return p.replace(l,"")},lookupRoute:function(s,q){var r=this,p=false;this.trigger("lookup-route",{verb:s,path:q});if(typeof this.routes[s]!="undefined"){h.each(this.routes[s],function(u,t){if(r.routablePath(q).match(t.path)){p=t;return false}})}return p},runRoute:function(r,E,t,w){var s=this,C=this.lookupRoute(r,E),q,z,u,y,D,A,x,B,p;this.log("runRoute",[r,E].join(" "));this.trigger("run-route",{verb:r,path:E,params:t});if(typeof t=="undefined"){t={}}h.extend(t,this._parseQueryString(E));if(C){this.trigger("route-found",{route:C});if((B=C.path.exec(this.routablePath(E)))!==null){B.shift();h.each(B,function(F,G){if(C.param_names[F]){t[C.param_names[F]]=i(G)}else{if(!t.splat){t.splat=[]}t.splat.push(i(G))}})}q=new this.context_prototype(this,r,E,t,w);u=this.arounds.slice(0);D=this.befores.slice(0);x=[q].concat(t.splat);z=function(){var F;while(D.length>0){A=D.shift();if(s.contextMatchesOptions(q,A[0])){F=A[1].apply(q,[q]);if(F===false){return false}}}s.last_route=C;q.trigger("event-context-before",{context:q});F=C.callback.apply(q,x);q.trigger("event-context-after",{context:q});return F};h.each(u.reverse(),function(F,G){var H=z;z=function(){return G.apply(q,[H])}});try{p=z()}catch(v){this.error(["500 Error",r,E].join(" "),v)}return p}else{return this.notFound(r,E)}},contextMatchesOptions:function(s,u,q){var r=u;if(typeof r==="undefined"||r=={}){return true}if(typeof q==="undefined"){q=true}if(typeof r==="string"||d(r.test)){r={path:r}}if(r.only){return this.contextMatchesOptions(s,r.only,true)}else{if(r.except){return this.contextMatchesOptions(s,r.except,false)}}var p=true,t=true;if(r.path){if(d(r.path.test)){p=r.path.test(s.path)}else{p=(r.path.toString()===s.path)}}if(r.verb){t=r.verb===s.verb}return q?(t&&p):!(t&&p)},getLocation:function(){return this._location_proxy.getLocation()},setLocation:function(p){return this._location_proxy.setLocation(p)},swap:function(p){return this.$element().html(p)},templateCache:function(p,q){if(typeof q!="undefined"){return a[p]=q}else{return a[p]}},clearTemplateCache:function(){return a={}},notFound:function(r,q){var p=this.error(["404 Not Found",r,q].join(" "));return(r==="get")?p:true},error:function(q,p){if(!p){p=new Error()}p.message=[q,p.message].join(" ");this.trigger("error",{message:p.message,error:p});if(this.raise_errors){throw (p)}else{this.log(p.message,p)}},_checkLocation:function(){var p,q;p=this.getLocation();if(!this.last_location||this.last_location[0]!="get"||this.last_location[1]!=p){this.last_location=["get",p];q=this.runRoute("get",p)}return q},_getFormVerb:function(r){var q=h(r),s,p;p=q.find('input[name="_method"]');if(p.length>0){s=p.val()}if(!s){s=q[0].getAttribute("method")}if(!s||s==""){s="get"}return h.trim(s.toString().toLowerCase())},_checkFormSubmission:function(r){var p,s,u,t,q;this.trigger("check-form-submission",{form:r});p=h(r);s=p.attr("action");u=this._getFormVerb(p);this.log("_checkFormSubmission",p,s,u);if(u==="get"){this.setLocation(s+"?"+this._serializeFormParams(p));q=false}else{t=h.extend({},this._parseFormParams(p));q=this.runRoute(u,s,t,r.get(0))}return(typeof q=="undefined")?false:q},_serializeFormParams:function(q){var s="",p=q.serializeArray(),r;if(p.length>0){s=this._encodeFormPair(p[0].name,p[0].value);for(r=1;r<p.length;r++){s=s+"&"+this._encodeFormPair(p[r].name,p[r].value)}}return s},_encodeFormPair:function(p,q){return b(p)+"="+b(q)},_parseFormParams:function(p){var s={},r=p.serializeArray(),q;for(q=0;q<r.length;q++){s=this._parseParamPair(s,r[q].name,r[q].value)}return s},_parseQueryString:function(s){var u={},r,q,t,p;r=s.match(l);if(r){q=r[1].split("&");for(p=0;p<q.length;p++){t=q[p].split("=");u=this._parseParamPair(u,i(t[0]),i(t[1]))}}return u},_parseParamPair:function(r,p,q){if(r[p]){if(m(r[p])){r[p].push(q)}else{r[p]=[r[p],q]}}else{r[p]=q}return r},_listen:function(p,q){return this.$element().bind([p,this.eventNamespace()].join("."),q)},_unlisten:function(p,q){return this.$element().unbind([p,this.eventNamespace()].join("."),q)}});o.RenderContext=function(p){this.event_context=p;this.callbacks=[];this.previous_content=null;this.content=null;this.next_engine=false;this.waiting=false};o.RenderContext.prototype=h.extend({},o.Object.prototype,{then:function(r){if(!d(r)){if(typeof r==="string"&&r in this.event_context){var q=this.event_context[r];r=function(s){return q.apply(this.event_context,[s])}}else{return this}}var p=this;if(this.waiting){this.callbacks.push(r)}else{this.wait();j.setTimeout(function(){var s=r.apply(p,[p.content,p.previous_content]);if(s!==false){p.next(s)}},13)}return this},wait:function(){this.waiting=true},next:function(p){this.waiting=false;if(typeof p!=="undefined"){this.previous_content=this.content;this.content=p}if(this.callbacks.length>0){this.then(this.callbacks.shift())}},load:function(p,q,s){var r=this;return this.then(function(){var t,u,w,v;if(d(q)){s=q;q={}}else{q=h.extend({},q)}if(s){this.then(s)}if(typeof p==="string"){w=(p.match(/\.json$/)||q.json);t=((w&&q.cache===true)||q.cache!==false);r.next_engine=r.event_context.engineFor(p);delete q.cache;delete q.json;if(q.engine){r.next_engine=q.engine;delete q.engine}if(t&&(u=this.event_context.app.templateCache(p))){return u}this.wait();h.ajax(h.extend({url:p,data:{},dataType:w?"json":null,type:"get",success:function(x){if(t){r.event_context.app.templateCache(p,x)}r.next(x)}},q));return false}else{if(p.nodeType){return p.innerHTML}if(p.selector){r.next_engine=p.attr("data-engine");if(q.clone===false){return p.remove()[0].innerHTML.toString()}else{return p[0].innerHTML.toString()}}}})},render:function(p,q,r){if(d(p)&&!q){return this.then(p)}else{if(!q&&this.content){q=this.content}return this.load(p).interpolate(q,p).then(r)}},partial:function(p,q){return this.render(p,q).swap()},send:function(){var r=this,q=c(arguments),p=q.shift();if(m(q[0])){q=q[0]}return this.then(function(s){q.push(function(t){r.next(t)});r.wait();p.apply(p,q);return false})},collect:function(t,s,p){var r=this;var q=function(){if(d(t)){s=t;t=this.content}var u=[],v=false;h.each(t,function(w,y){var x=s.apply(r,[w,y]);if(x.jquery&&x.length==1){x=x[0];v=true}u.push(x);return x});return v?u:u.join("")};return p?q():this.then(q)},renderEach:function(p,q,r,s){if(m(q)){s=r;r=q;q=null}return this.load(p).then(function(u){var t=this;if(!r){r=m(this.previous_content)?this.previous_content:[]}if(s){h.each(r,function(v,x){var y={},w=this.next_engine||p;q?(y[q]=x):(y=x);s(x,t.event_context.interpolate(u,y,w))})}else{return this.collect(r,function(v,x){var y={},w=this.next_engine||p;q?(y[q]=x):(y=x);return this.event_context.interpolate(u,y,w)},true)}})},interpolate:function(s,r,p){var q=this;return this.then(function(u,t){if(!s&&t){s=t}if(this.next_engine){r=this.next_engine;this.next_engine=false}var v=q.event_context.interpolate(u,s,r);return p?t+v:v})},swap:function(){return this.then(function(p){this.event_context.swap(p)}).trigger("changed",{})},appendTo:function(p){return this.then(function(q){h(p).append(q)}).trigger("changed",{})},prependTo:function(p){return this.then(function(q){h(p).prepend(q)}).trigger("changed",{})},replace:function(p){return this.then(function(q){h(p).html(q)}).trigger("changed",{})},trigger:function(p,q){return this.then(function(r){if(typeof q=="undefined"){q={content:r}}this.event_context.trigger(p,q)})}});o.EventContext=function(t,s,q,r,p){this.app=t;this.verb=s;this.path=q;this.params=new o.Object(r);this.target=p};o.EventContext.prototype=h.extend({},o.Object.prototype,{$element:function(){return this.app.$element(c(arguments).shift())},engineFor:function(r){var q=this,p;if(d(r)){return r}r=(r||q.app.template_engine).toString();if((p=r.match(/\.([^\.]+)$/))){r=p[1]}if(r&&d(q[r])){return q[r]}if(q.app.template_engine){return this.engineFor(q.app.template_engine)}return function(s,t){return s}},interpolate:function(q,r,p){return this.engineFor(p).apply(this,[q,r])},render:function(p,q,r){return new o.RenderContext(this).render(p,q,r)},renderEach:function(p,q,r,s){return new o.RenderContext(this).renderEach(p,q,r,s)},load:function(p,q,r){return new o.RenderContext(this).load(p,q,r)},partial:function(p,q){return new o.RenderContext(this).partial(p,q)},send:function(){var p=new o.RenderContext(this);return p.send.apply(p,arguments)},redirect:function(){var r,q=c(arguments),p=this.app.getLocation();if(q.length>1){q.unshift("/");r=this.join.apply(this,q)}else{r=q[0]}this.trigger("redirect",{to:r});this.app.last_location=[this.verb,this.path];this.app.setLocation(r);if(p==r){this.app.trigger("location-changed")}},trigger:function(p,q){if(typeof q=="undefined"){q={}}if(!q.context){q.context=this}return this.app.trigger(p,q)},eventNamespace:function(){return this.app.eventNamespace()},swap:function(p){return this.app.swap(p)},notFound:function(){return this.app.notFound(this.verb,this.path)},json:function(p){return h.parseJSON(p)},toString:function(){return"Sammy.EventContext: "+[this.verb,this.path,this.params].join(" ")}});h.sammy=j.Sammy=o})(jQuery,window);

0 comments on commit 92f6f99

Please sign in to comment.
Something went wrong with that request. Please try again.