Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Large feature-set release

  • Loading branch information...
commit e38cf57d0ec77a7bdd8898c5bf1a28b7adf66b04 1 parent 1734073
@pnegri authored
Showing with 1,714 additions and 358 deletions.
  1. +9 −0 Makefile
  2. +16 −0 docs/_monkey-fs.html
  3. +48 −0 docs/_monkey-patching.html
  4. +51 −0 docs/arcabouco.html
  5. +7 −0 docs/arcabouco_content.html
  6. +19 −0 docs/arcabouco_controller.html
  7. +7 −0 docs/arcabouco_object_pool.html
  8. +104 −0 docs/arcabouco_request.html
  9. +7 −0 docs/arcabouco_template.html
  10. +18 −0 docs/common.html
  11. +186 −0 docs/docco.css
  12. +329 −0 docs/old_arcabouco.html
  13. +54 −0 docs/template.html
  14. +0 −1  examples/assemble-test/app.coffee
  15. +2 −4 examples/assemble-test/pieces/welcome/welcome.coffee
  16. +10 −0 examples/hello-world/app.coffee
  17. +0 −1  examples/minimal-test/app.coffee
  18. +22 −0 lib/_monkey-fs.coffee
  19. +52 −11 lib/_monkey-patching.coffee
  20. +129 −322 lib/arcabouco.coffee
  21. +47 −0 lib/arcabouco_modules/content.coffee
  22. +17 −0 lib/arcabouco_modules/controller.coffee
  23. +38 −0 lib/arcabouco_modules/objectpool.coffee
  24. +336 −0 lib/arcabouco_modules/old_arcabouco.coffee
  25. 0  lib/{template.coffee → arcabouco_modules/old_template.coffee}
  26. +101 −0 lib/arcabouco_modules/request.coffee
  27. +52 −0 lib/arcabouco_modules/template.coffee
  28. +13 −0 lib/common.coffee
  29. +3 −2 package.json
  30. +15 −15 sample-screws/screw-compatible-web-app/screw-compatible-web-app.coffee
  31. +1 −1  sample-screws/screw-html5shiv/screw-html5shiv.coffee
  32. +1 −1  sample-screws/screw-mootools/screw-mootools.coffee
  33. +20 −0 test/arcabouco.js
View
9 Makefile
@@ -0,0 +1,9 @@
+SHELL := /bin/bash
+
+test:
+ @node test/arcabouco.js
+
+doc:
+ docco lib/*.coffee
+
+.PHONY: test
View
16 docs/_monkey-fs.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html> <html> <head> <title>_monkey-fs.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="_monkey-fs.html"> _monkey-fs.coffee </a> <a class="source" href="_monkey-patching.html"> _monkey-patching.coffee </a> <a class="source" href="arcabouco.html"> arcabouco.coffee </a> <a class="source" href="arcabouco_content.html"> arcabouco_content.coffee </a> <a class="source" href="arcabouco_controller.html"> arcabouco_controller.coffee </a> <a class="source" href="arcabouco_object_pool.html"> arcabouco_object_pool.coffee </a> <a class="source" href="arcabouco_request.html"> arcabouco_request.coffee </a> <a class="source" href="arcabouco_template.html"> arcabouco_template.coffee </a> <a class="source" href="common.html"> common.coffee </a> <a class="source" href="old_arcabouco.html"> old_arcabouco.coffee </a> <a class="source" href="template.html"> template.coffee </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> _monkey-fs.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> <pre><code>Arcabouco.JS
+
+(c) 2011 Patrick Negri, Yellers Software
+Arcabouco.JS is freely distributable under the MIT license.
+For all details and documentation:
+http://github.com/pnegri/arcabouco-js
+</code></pre> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <h2>Node.JS Monkey Patching for FS</h2> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>Include Commons</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">Common = </span><span class="nx">require</span> <span class="nx">__dirname</span> <span class="o">+</span> <span class="s">&#39;/common&#39;</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <h3>readdirSyncR</h3>
+
+<p>Extend Fs with a method to read a directory sync</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">Common.Fs.readdirSyncR = </span><span class="nf">( directory ) -&gt;</span></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> <p>Normalize the input directory</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">directory = </span><span class="nx">Common</span><span class="p">.</span><span class="nx">Path</span><span class="p">.</span><span class="nx">normalize</span> <span class="nx">directory</span></pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-6">&#182;</a> </div> <p>Get all files in the directory</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">files = </span><span class="nx">Common</span><span class="p">.</span><span class="nx">Fs</span><span class="p">.</span><span class="nx">readdirSync</span> <span class="nx">directory</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>Setup an array for valid files</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">allFiles = </span><span class="p">[]</span>
+ <span class="k">for</span> <span class="nx">file</span> <span class="k">in</span> <span class="nx">files</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>Compute the full path of file</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">fileWithPath = </span><span class="nx">directory</span> <span class="o">+</span> <span class="s">&#39;/&#39;</span> <span class="o">+</span> <span class="nx">file</span></pre></div> </td> </tr> <tr id="section-9"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-9">&#182;</a> </div> <p>Get information about the file</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">stat = </span><span class="nx">Common</span><span class="p">.</span><span class="nx">Fs</span><span class="p">.</span><span class="nx">statSync</span> <span class="nx">fileWithPath</span>
+ <span class="k">if</span> <span class="nx">stat</span><span class="p">.</span><span class="nx">isFile</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>If it is a file put in all files array</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">allFiles</span><span class="p">.</span><span class="nx">push</span> <span class="nx">fileWithPath</span>
+ <span class="k">if</span> <span class="nx">stat</span><span class="p">.</span><span class="nx">isDirectory</span><span class="p">()</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>If it is a directory recursively call this method</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">dirFiles = </span><span class="nx">Common</span><span class="p">.</span><span class="nx">Fs</span><span class="p">.</span><span class="nx">readdirSyncR</span> <span class="nx">fileWithPath</span>
+ <span class="k">if</span> <span class="nx">dirFiles</span><span class="p">.</span><span class="nx">length</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>Concatenate the results with files found previousily</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">allFiles = </span><span class="nx">allFiles</span><span class="p">.</span><span class="nx">concat</span> <span class="nx">dirFiles</span>
+ <span class="nx">allFiles</span>
+
+</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
View
48 docs/_monkey-patching.html
@@ -0,0 +1,48 @@
+<!DOCTYPE html> <html> <head> <title>_monkey-patching.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="_monkey-fs.html"> _monkey-fs.coffee </a> <a class="source" href="_monkey-patching.html"> _monkey-patching.coffee </a> <a class="source" href="arcabouco.html"> arcabouco.coffee </a> <a class="source" href="arcabouco_content.html"> arcabouco_content.coffee </a> <a class="source" href="arcabouco_controller.html"> arcabouco_controller.coffee </a> <a class="source" href="arcabouco_object_pool.html"> arcabouco_object_pool.coffee </a> <a class="source" href="arcabouco_request.html"> arcabouco_request.coffee </a> <a class="source" href="arcabouco_template.html"> arcabouco_template.coffee </a> <a class="source" href="common.html"> common.coffee </a> <a class="source" href="old_arcabouco.html"> old_arcabouco.coffee </a> <a class="source" href="template.html"> template.coffee </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> _monkey-patching.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> <pre><code>Arcabouco.JS
+
+(c) 2011 Patrick Negri, Yellers Software
+Arcabouco.JS is freely distributable under the MIT license.
+For all details and documentation:
+http://github.com/pnegri/arcabouco-js
+</code></pre> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <h2>Node.JS Monkey Patching</h2> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>Include Commons</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">Common = </span><span class="nx">require</span> <span class="nx">__dirname</span> <span class="o">+</span> <span class="s">&#39;/common&#39;</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <h3>replaceLast</h3>
+
+<p>Extend String with a replaceLast method</p> </td> <td class="code"> <div class="highlight"><pre><span class="nb">String</span><span class="p">.</span><span class="nv">prototype.replaceLast = </span><span class="nf">( search, replace ) -&gt;</span>
+ <span class="nv">string = </span><span class="k">this</span>
+ <span class="nv">n = </span><span class="nx">string</span><span class="p">.</span><span class="nx">lastIndexOf</span><span class="p">(</span> <span class="nx">search</span> <span class="p">)</span>
+ <span class="k">if</span> <span class="nx">n</span> <span class="o">&gt;=</span> <span class="mi">0</span> <span class="o">&amp;&amp;</span> <span class="nx">n</span> <span class="o">+</span> <span class="nx">replace</span><span class="p">.</span><span class="nx">length</span> <span class="o">&gt;=</span> <span class="nx">string</span><span class="p">.</span><span class="nx">length</span>
+ <span class="nv">string = </span><span class="nx">string</span><span class="p">.</span><span class="nx">substring</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="nx">n</span><span class="p">)</span> <span class="o">+</span> <span class="nx">replace</span>
+ <span class="nx">string</span></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> <h2>Extending and Patching HTTP</h2> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-6">&#182;</a> </div> <h3>Response Grouping</h3>
+
+<p>Include a 'group' in response</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">Common.Http.ServerResponse.prototype.group = </span><span class="s">&#39;default&#39;</span>
+
+<span class="nv">Common.Http.ServerResponse.prototype.getGroup = </span><span class="nf">() -&gt;</span>
+ <span class="nx">@group</span>
+
+<span class="nv">Common.Http.ServerResponse.prototype.setGroup = </span><span class="nf">( groupName ) -&gt;</span>
+ <span class="vi">@group = </span><span class="nx">groupName</span></pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-7">&#182;</a> </div> <h3>Response Redirection</h3> </td> <td class="code"> <div class="highlight"><pre><span class="nv">Common.Http.ServerResponse.prototype.redirectTo = </span><span class="nf">( url ) -&gt;</span>
+ <span class="nx">@writeHead</span> <span class="mi">302</span><span class="p">,</span> <span class="p">{</span> <span class="s">&#39;Location&#39;</span><span class="o">:</span> <span class="nx">url</span> <span class="p">}</span>
+ <span class="nx">@end</span><span class="p">()</span></pre></div> </td> </tr> <tr id="section-8"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-8">&#182;</a> </div> <h3>respondWith</h3>
+
+<p>Extend Response with a cache-corrected responder</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">Common.Http.ServerResponse.prototype.respondWith = </span><span class="nf">( content, options = {} ) -&gt;</span>
+ </pre></div> </td> </tr> <tr id="section-9"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-9">&#182;</a> </div> <p>Configure default response options</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">response_option = </span><span class="p">{}</span>
+ <span class="nv">response_option.type = </span><span class="k">if</span> <span class="nx">options</span><span class="p">.</span><span class="nx">type</span> <span class="k">then</span> <span class="nx">options</span><span class="p">.</span><span class="nx">type</span> <span class="k">else</span> <span class="s">&#39;text/html&#39;</span>
+ <span class="nv">response_option.expiration = </span><span class="k">if</span> <span class="nx">options</span><span class="p">.</span><span class="nx">expiration</span> <span class="k">then</span> <span class="nx">options</span><span class="p">.</span><span class="nx">expiration</span> <span class="k">else</span> <span class="mi">0</span>
+ <span class="nv">response_option.status = </span><span class="k">if</span> <span class="nx">options</span><span class="p">.</span><span class="nx">status</span> <span class="k">then</span> <span class="nx">options</span><span class="p">.</span><span class="nx">status</span> <span class="k">else</span> <span class="mi">200</span>
+ <span class="nv">response_option.charset = </span><span class="k">if</span> <span class="nx">options</span><span class="p">.</span><span class="nx">charset</span> <span class="k">then</span> <span class="nx">options</span><span class="p">.</span><span class="nx">charset</span> <span class="k">else</span> <span class="s">&#39;utf-8&#39;</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>Calculate the expiration</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">expirationTime = </span><span class="k">new</span> <span class="nb">Date</span><span class="p">()</span>
+ <span class="nv">headers =</span>
+ <span class="s">&#39;Content-Type&#39;</span><span class="o">:</span> <span class="nx">response_option</span><span class="p">.</span><span class="nx">type</span> <span class="o">+</span> <span class="s">&#39;; charset=&#39;</span> <span class="o">+</span> <span class="nx">response_option</span><span class="p">.</span><span class="nx">charset</span>
+ <span class="k">if</span> <span class="nx">expiration</span> <span class="o">&gt;</span> <span class="mi">0</span>
+ <span class="nx">expirationTime</span><span class="p">.</span><span class="nx">setTime</span> <span class="nx">expirationTime</span><span class="p">.</span><span class="nx">getTime</span><span class="p">()</span> <span class="o">+</span> <span class="nx">response_option</span><span class="p">.</span><span class="nx">expiration</span>
+ <span class="nx">Common</span><span class="p">.</span><span class="nx">_</span><span class="p">.</span><span class="nx">extend</span> <span class="nx">headers</span><span class="p">,</span>
+ <span class="s">&#39;Cache-Control&#39;</span> <span class="o">:</span> <span class="s">&#39;max-age=&#39;</span> <span class="o">+</span> <span class="nx">response_option</span><span class="p">.</span><span class="nx">expiration</span> <span class="o">+</span> <span class="s">&#39;, public, most-revalidate&#39;</span>
+ <span class="s">&#39;Expires&#39;</span> <span class="o">:</span> <span class="nx">expirationTime</span><span class="p">.</span><span class="nx">toGMTString</span><span class="p">()</span>
+ <span class="k">else</span>
+ <span class="nx">Common</span><span class="p">.</span><span class="nx">_</span><span class="p">.</span><span class="nx">extend</span> <span class="nx">headers</span><span class="p">,</span>
+ <span class="s">&#39;Cache-Control&#39;</span> <span class="o">:</span> <span class="s">&#39;max-age=0, no-cache, no-store, must-revalidate&#39;</span>
+ <span class="s">&#39;Pragma&#39;</span> <span class="o">:</span> <span class="s">&#39;no-cache&#39;</span>
+ <span class="s">&#39;Expires&#39;</span> <span class="o">:</span> <span class="s">&#39;Thu, 01 Jan 1970 00:00:00 GMT&#39;</span>
+ <span class="nx">@writeHead</span> <span class="nx">response</span><span class="p">.</span><span class="nx">status</span><span class="p">,</span> <span class="nx">headers</span>
+ <span class="nx">@write</span> <span class="nx">content</span>
+ <span class="nx">@end</span><span class="p">()</span>
+
+</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
View
51 docs/arcabouco.html
@@ -0,0 +1,51 @@
+<!DOCTYPE html> <html> <head> <title>arcabouco.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="_monkey-fs.html"> _monkey-fs.coffee </a> <a class="source" href="_monkey-patching.html"> _monkey-patching.coffee </a> <a class="source" href="arcabouco.html"> arcabouco.coffee </a> <a class="source" href="arcabouco_content.html"> arcabouco_content.coffee </a> <a class="source" href="arcabouco_controller.html"> arcabouco_controller.coffee </a> <a class="source" href="arcabouco_object_pool.html"> arcabouco_object_pool.coffee </a> <a class="source" href="arcabouco_request.html"> arcabouco_request.coffee </a> <a class="source" href="arcabouco_template.html"> arcabouco_template.coffee </a> <a class="source" href="common.html"> common.coffee </a> <a class="source" href="old_arcabouco.html"> old_arcabouco.coffee </a> <a class="source" href="template.html"> template.coffee </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> arcabouco.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> <pre><code>Arcabouco.JS
+(c) 2011 Patrick Negri, Yellers Software
+Arcabouco.JS is freely distributable under the MIT license.
+For all details and documentation:
+http://github.com/pnegri/arcabouco-js
+</code></pre> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <h2>Helpers &amp; Setup</h2> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>Require our external dependencies, place all inside Common</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">Common = </span><span class="nx">require</span> <span class="nx">__dirname</span> <span class="o">+</span> <span class="s">&#39;/common&#39;</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>Patch node with some features</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">require</span> <span class="nx">__dirname</span> <span class="o">+</span> <span class="s">&#39;/_monkey-patching&#39;</span></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> <p>Require default pieces of framework
+TODO: Optmization Room - Only load these if no override is provided</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">ArcaboucoTemplate = </span><span class="nx">require</span> <span class="nx">__dirname</span> <span class="o">+</span> <span class="s">&#39;/arcabouco_template&#39;</span>
+<span class="nv">ArcaboucoContent = </span><span class="nx">require</span> <span class="nx">__dirname</span> <span class="o">+</span> <span class="s">&#39;/arcabouco_content&#39;</span>
+<span class="nv">ArcaboucoObjectPool = </span><span class="nx">require</span> <span class="nx">__dirname</span> <span class="o">+</span> <span class="s">&#39;/arcabouco_object_pool&#39;</span>
+<span class="nv">ArcaboucoController = </span><span class="nx">require</span> <span class="nx">__dirname</span> <span class="o">+</span> <span class="s">&#39;/arcabouco_controller&#39;</span>
+<span class="nv">ArcaboucoRequest = </span><span class="nx">require</span> <span class="nx">__dirname</span> <span class="o">+</span> <span class="s">&#39;/arcabouco_request&#39;</span>
+
+<span class="k">class</span> <span class="nx">Arcabouco</span></pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-6">&#182;</a> </div> <p>Configuration</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">config : </span><span class="p">{}</span>
+
+ <span class="nv">Template : </span><span class="kc">null</span>
+ <span class="nv">Content : </span><span class="kc">null</span>
+ <span class="nv">ObjectPool : </span><span class="kc">null</span>
+ <span class="nv">Controller : </span><span class="kc">null</span>
+ <span class="nv">Request : </span><span class="kc">null</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>putContentFor : null
+getContentFor : null</p> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-8"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-8">&#182;</a> </div> <p>renderTemplate : null
+renderPartial : null</p> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-9"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-9">&#182;</a> </div> <p>respondWithError : null
+respondWithTimeout : null
+respondWithNotFound : null</p> </td> <td class="code"> <div class="highlight"><pre> </pre></div> </td> </tr> <tr id="section-10"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-10">&#182;</a> </div> <p>assemble : null</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">work: </span><span class="nf">( object_piece ) -&gt;</span>
+ <span class="nv">index = </span><span class="nx">@Controller</span><span class="p">.</span><span class="nx">register</span><span class="p">(</span> <span class="nx">object_piece</span><span class="p">,</span> <span class="k">this</span> <span class="p">)</span>
+ <span class="nx">@Request</span><span class="p">.</span><span class="nx">parseRoutes</span><span class="p">(</span> <span class="nx">index</span><span class="p">,</span> <span class="k">this</span> <span class="p">)</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>build : null</p> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-12"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-12">&#182;</a> </div> <p>registerObject : null
+createObject : null</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">dispatch : </span><span class="nf">( request, response ) -&gt;</span>
+ <span class="k">return</span> <span class="kc">null</span> <span class="nx">unless</span> <span class="nx">@Request</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>Extend Request with Application</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">request.application = </span><span class="k">this</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>Extend Response with Application</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">response.application = </span><span class="k">this</span>
+
+ <span class="nx">@Request</span><span class="p">.</span><span class="nx">dispatch</span><span class="p">(</span> <span class="nx">request</span><span class="p">,</span> <span class="nx">response</span> <span class="p">)</span>
+
+ <span class="nv">createServer : </span><span class="o">-&gt;</span>
+ <span class="nx">Common</span><span class="p">.</span><span class="nx">Http</span><span class="p">.</span><span class="nx">createServer</span><span class="p">(</span> <span class="nx">@dispatch</span><span class="p">.</span><span class="nx">bind</span><span class="p">(</span> <span class="k">this</span> <span class="p">)</span> <span class="p">)</span>
+
+ <span class="nv">createSecureServer : </span><span class="nf">( privateKey, certificate ) -&gt;</span>
+ <span class="nv">credentials = </span><span class="nx">Common</span><span class="p">.</span><span class="nx">Crypt</span><span class="p">.</span><span class="nx">createCredentials</span> <span class="p">{</span>
+ <span class="nv">key : </span><span class="nx">privateKey</span>
+ <span class="nv">cert : </span><span class="nx">certificate</span>
+ <span class="p">}</span>
+ <span class="nv">secureServer = </span><span class="nx">Common</span><span class="p">.</span><span class="nx">Http</span><span class="p">.</span><span class="nx">createServer</span><span class="p">(</span> <span class="nx">@dispatch</span><span class="p">.</span><span class="nx">bind</span><span class="p">(</span> <span class="k">this</span> <span class="p">)</span> <span class="p">)</span>
+ <span class="nx">secureServer</span><span class="p">.</span><span class="nx">setSecure</span><span class="p">(</span> <span class="nx">credentials</span> <span class="p">)</span>
+ <span class="nx">secureServer</span>
+
+ <span class="nv">configurePackage : </span><span class="nf">( name, packages ) -&gt;</span>
+ <span class="k">this</span><span class="p">[</span> <span class="nx">name</span> <span class="p">]</span> <span class="o">=</span> <span class="k">if</span> <span class="nx">packages</span><span class="p">[</span><span class="nx">name</span><span class="p">]</span> <span class="k">then</span> <span class="k">new</span> <span class="nx">packages</span><span class="p">[</span> <span class="nx">name</span> <span class="p">]()</span> <span class="k">else</span> <span class="nb">eval</span><span class="p">(</span><span class="s">&#39;new Arcabouco&#39;</span> <span class="o">+</span> <span class="nx">name</span> <span class="o">+</span> <span class="s">&#39;()&#39;</span><span class="p">)</span></pre></div> </td> </tr> <tr id="section-15"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-15">&#182;</a> </div> <h2>The Application Fabric</h2>
+
+<p>A constructor must be called with a configuration options.
+These configurations can change everything because all
+our functions are just a proxy to internal components.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">constructor : </span><span class="nf">( @config = {} ) -&gt;</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>Try to use some user defined packages if they are sent</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">packages = </span><span class="k">if</span> <span class="nx">@config</span><span class="p">.</span><span class="nx">packages</span> <span class="k">then</span> <span class="nx">@config</span><span class="p">.</span><span class="nx">packages</span> <span class="k">else</span> <span class="p">{}</span></pre></div> </td> </tr> <tr id="section-17"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-17">&#182;</a> </div> <p>Load the packages checking for a user defined one, use a default if none is suplied</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">for</span> <span class="nx">packageName</span> <span class="k">in</span> <span class="p">[</span><span class="s">&#39;Template&#39;</span><span class="p">,</span><span class="s">&#39;Content&#39;</span><span class="p">,</span><span class="s">&#39;ObjectPool&#39;</span><span class="p">,</span><span class="s">&#39;Controller&#39;</span><span class="p">,</span><span class="s">&#39;Request&#39;</span><span class="p">]</span>
+ <span class="nx">@configurePackage</span><span class="p">(</span> <span class="nx">packageName</span> <span class="o">+</span> <span class="s">&#39;&#39;</span><span class="p">,</span> <span class="nx">packages</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>Configure delegated methods</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">module.exports = </span><span class="nx">Arcabouco</span>
+
+</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
View
7 docs/arcabouco_content.html
@@ -0,0 +1,7 @@
+<!DOCTYPE html> <html> <head> <title>arcabouco_content.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="_monkey-fs.html"> _monkey-fs.coffee </a> <a class="source" href="_monkey-patching.html"> _monkey-patching.coffee </a> <a class="source" href="arcabouco.html"> arcabouco.coffee </a> <a class="source" href="arcabouco_content.html"> arcabouco_content.coffee </a> <a class="source" href="arcabouco_controller.html"> arcabouco_controller.coffee </a> <a class="source" href="arcabouco_object_pool.html"> arcabouco_object_pool.coffee </a> <a class="source" href="arcabouco_request.html"> arcabouco_request.coffee </a> <a class="source" href="arcabouco_template.html"> arcabouco_template.coffee </a> <a class="source" href="common.html"> common.coffee </a> <a class="source" href="old_arcabouco.html"> old_arcabouco.coffee </a> <a class="source" href="template.html"> template.coffee </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> arcabouco_content.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> </td> <td class="code"> <div class="highlight"><pre><span class="k">class</span> <span class="nx">ArcaboucoContent</span>
+ <span class="nv">output: </span><span class="o">-&gt;</span>
+ <span class="nx">console</span><span class="p">.</span><span class="nx">log</span> <span class="s">&#39;Testing &#39;</span>
+
+<span class="nv">module.exports = </span><span class="nx">ArcaboucoContent</span>
+
+</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
View
19 docs/arcabouco_controller.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html> <html> <head> <title>arcabouco_controller.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="_monkey-fs.html"> _monkey-fs.coffee </a> <a class="source" href="_monkey-patching.html"> _monkey-patching.coffee </a> <a class="source" href="arcabouco.html"> arcabouco.coffee </a> <a class="source" href="arcabouco_content.html"> arcabouco_content.coffee </a> <a class="source" href="arcabouco_controller.html"> arcabouco_controller.coffee </a> <a class="source" href="arcabouco_object_pool.html"> arcabouco_object_pool.coffee </a> <a class="source" href="arcabouco_request.html"> arcabouco_request.coffee </a> <a class="source" href="arcabouco_template.html"> arcabouco_template.coffee </a> <a class="source" href="common.html"> common.coffee </a> <a class="source" href="old_arcabouco.html"> old_arcabouco.coffee </a> <a class="source" href="template.html"> template.coffee </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> arcabouco_controller.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> </td> <td class="code"> <div class="highlight"><pre><span class="k">class</span> <span class="nx">ArcaboucoController</span>
+ <span class="nv">Instances : </span><span class="p">[]</span>
+
+ <span class="nv">register: </span><span class="nf">( ControllerObject, Application ) -&gt;</span>
+ <span class="nv">instanceClass = </span><span class="k">new</span> <span class="nx">ControllerObject</span><span class="p">()</span>
+ <span class="k">if</span> <span class="nx">instanceClass</span><span class="p">.</span><span class="nx">bootstrap</span> <span class="o">or</span> <span class="nx">instanceClass</span><span class="p">.</span><span class="nx">getRoutes</span>
+ <span class="nv">ControllerObject = </span><span class="nx">instanceClass</span>
+ <span class="nx">ControllerObject</span><span class="p">.</span><span class="nx">bootstrap</span><span class="p">(</span> <span class="nx">Application</span> <span class="p">)</span> <span class="k">if</span> <span class="nx">ControllerObject</span><span class="p">.</span><span class="nx">bootstrap</span>
+ <span class="nx">@Instances</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span> <span class="nx">ControllerObject</span> <span class="p">)</span><span class="o">-</span><span class="mi">1</span>
+
+ <span class="nv">unregister: </span><span class="nf">( controllerIndex ) -&gt;</span>
+ <span class="kc">false</span>
+
+ <span class="nv">get: </span><span class="nf">( controllerIndex ) -&gt;</span>
+ <span class="k">if</span> <span class="nx">@Instances</span><span class="p">[</span> <span class="nx">controllerIndex</span> <span class="p">]</span> <span class="k">then</span> <span class="nx">@Instances</span><span class="p">[</span> <span class="nx">controllerIndex</span> <span class="p">]</span> <span class="k">else</span> <span class="kc">null</span>
+
+<span class="nv">module.exports = </span><span class="nx">ArcaboucoController</span>
+
+</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
View
7 docs/arcabouco_object_pool.html
@@ -0,0 +1,7 @@
+<!DOCTYPE html> <html> <head> <title>arcabouco_object_pool.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="_monkey-fs.html"> _monkey-fs.coffee </a> <a class="source" href="_monkey-patching.html"> _monkey-patching.coffee </a> <a class="source" href="arcabouco.html"> arcabouco.coffee </a> <a class="source" href="arcabouco_content.html"> arcabouco_content.coffee </a> <a class="source" href="arcabouco_controller.html"> arcabouco_controller.coffee </a> <a class="source" href="arcabouco_object_pool.html"> arcabouco_object_pool.coffee </a> <a class="source" href="arcabouco_request.html"> arcabouco_request.coffee </a> <a class="source" href="arcabouco_template.html"> arcabouco_template.coffee </a> <a class="source" href="common.html"> common.coffee </a> <a class="source" href="old_arcabouco.html"> old_arcabouco.coffee </a> <a class="source" href="template.html"> template.coffee </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> arcabouco_object_pool.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> </td> <td class="code"> <div class="highlight"><pre><span class="k">class</span> <span class="nx">ArcaboucoObjectPool</span>
+ <span class="nv">output: </span><span class="o">-&gt;</span>
+ <span class="nx">console</span><span class="p">.</span><span class="nx">log</span> <span class="s">&#39;Testing Object&#39;</span>
+
+<span class="nv">module.exports = </span><span class="nx">ArcaboucoObjectPool</span>
+
+</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
View
104 docs/arcabouco_request.html
@@ -0,0 +1,104 @@
+<!DOCTYPE html> <html> <head> <title>arcabouco_request.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="_monkey-fs.html"> _monkey-fs.coffee </a> <a class="source" href="_monkey-patching.html"> _monkey-patching.coffee </a> <a class="source" href="arcabouco.html"> arcabouco.coffee </a> <a class="source" href="arcabouco_content.html"> arcabouco_content.coffee </a> <a class="source" href="arcabouco_controller.html"> arcabouco_controller.coffee </a> <a class="source" href="arcabouco_object_pool.html"> arcabouco_object_pool.coffee </a> <a class="source" href="arcabouco_request.html"> arcabouco_request.coffee </a> <a class="source" href="arcabouco_template.html"> arcabouco_template.coffee </a> <a class="source" href="common.html"> common.coffee </a> <a class="source" href="old_arcabouco.html"> old_arcabouco.coffee </a> <a class="source" href="template.html"> template.coffee </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> arcabouco_request.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> </td> <td class="code"> <div class="highlight"><pre><span class="nv">Common = </span><span class="nx">require</span> <span class="nx">__dirname</span> <span class="o">+</span> <span class="s">&#39;/common&#39;</span>
+
+<span class="k">class</span> <span class="nx">ArcaboucoRequest</span>
+ <span class="nv">routeToMethod: </span><span class="p">[]</span>
+ <span class="nv">avaiableRoutes: </span><span class="p">[]</span>
+ <span class="nv">newRoutingAvaiable: </span><span class="kc">false</span>
+
+ <span class="nv">addRoutingToMethod: </span><span class="nf">( path, method, indexOfController ) -&gt;</span>
+ <span class="nx">@routeToMethod</span><span class="p">[</span> <span class="nx">path</span> <span class="p">]</span> <span class="o">=</span>
+ <span class="s">&#39;method&#39;</span> <span class="o">:</span> <span class="nx">method</span>
+ <span class="s">&#39;object&#39;</span> <span class="o">:</span> <span class="nx">indexOfController</span>
+ <span class="vi">@newRoutingAvaiable = </span><span class="kc">true</span>
+ <span class="nx">path</span>
+
+ <span class="nv">parseRoutes: </span><span class="nf">( index, Application ) -&gt;</span>
+ <span class="nv">ControllerObject = </span><span class="nx">Application</span><span class="p">.</span><span class="nx">Controller</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span> <span class="nx">index</span> <span class="p">)</span>
+ <span class="nx">unless</span> <span class="nx">ControllerObject</span><span class="p">.</span><span class="nx">getRoutes</span>
+ <span class="k">return</span> <span class="kc">false</span>
+
+ <span class="nv">controllerRoutes = </span><span class="nx">ControllerObject</span><span class="p">.</span><span class="nx">getRoutes</span><span class="p">()</span>
+ <span class="k">for</span> <span class="nx">path</span> <span class="k">of</span> <span class="nx">controllerRoutes</span>
+ <span class="nx">@addRoutingToMethod</span> <span class="nx">path</span><span class="p">,</span> <span class="nx">controllerRoutes</span><span class="p">[</span> <span class="nx">path</span> <span class="p">],</span> <span class="nx">index</span>
+
+ <span class="nv">constructRoutingForPattern : </span><span class="nf">( pattern ) -&gt;</span>
+ <span class="nv">params = </span><span class="p">[]</span>
+ <span class="nv">buildPattern = </span><span class="nx">pattern</span><span class="p">.</span><span class="nx">replace</span> <span class="sr">/\{(.*?)\}/g</span><span class="p">,</span>
+ <span class="nf">( match, sub1 ) -&gt;</span>
+ <span class="nx">params</span><span class="p">.</span><span class="nx">push</span> <span class="nx">sub1</span>
+ <span class="k">return</span> <span class="s">&#39;([^\/]+)&#39;</span>
+ <span class="nv">buildPattern = </span><span class="nx">buildPattern</span><span class="p">.</span><span class="nx">replaceLast</span><span class="p">(</span> <span class="s">&#39;([^\/]+)&#39;</span><span class="p">,</span> <span class="s">&#39;([^$]+)&#39;</span> <span class="p">)</span>
+ <span class="nv">constructedRoute =</span>
+ <span class="nv">regex : </span><span class="k">new</span> <span class="nb">RegExp</span> <span class="s">&#39;^&#39;</span> <span class="o">+</span> <span class="nx">buildPattern</span> <span class="o">+</span> <span class="s">&#39;$&#39;</span>
+ <span class="nv">params: </span><span class="nx">params</span>
+ <span class="nv">index : </span><span class="nx">pattern</span>
+
+ <span class="nv">rebuildRoutes: </span><span class="o">-&gt;</span>
+ <span class="nv">orderedRouteNames = </span><span class="nx">Common</span><span class="p">.</span><span class="nx">_</span><span class="p">.</span><span class="nx">keys</span><span class="p">(</span> <span class="nx">@routeToMethod</span> <span class="p">).</span><span class="nx">sort</span><span class="p">().</span><span class="nx">reverse</span><span class="p">()</span>
+ <span class="vi">@avaiableRoutes = </span><span class="p">[]</span>
+ <span class="k">for</span> <span class="nx">pattern</span> <span class="k">in</span> <span class="nx">orderedRouteNames</span>
+ <span class="nx">@avaiableRoutes</span><span class="p">.</span><span class="nx">push</span> <span class="nx">@constructRoutingForPattern</span><span class="p">(</span> <span class="nx">pattern</span> <span class="p">)</span>
+
+ <span class="nv">callMethodForRoute : </span><span class="nf">( route, params, Controller ) -&gt;</span>
+ <span class="k">if</span> <span class="nx">@routeToMethod</span><span class="p">[</span> <span class="nx">route</span><span class="p">.</span><span class="nx">index</span> <span class="p">]</span>
+ <span class="nv">ControllerIndex = </span><span class="nx">@routeToMethod</span><span class="p">[</span> <span class="nx">route</span><span class="p">.</span><span class="nx">index</span> <span class="p">].</span><span class="nx">object</span>
+ <span class="nv">ControllerObject = </span><span class="nx">Controller</span><span class="p">.</span><span class="nx">get</span> <span class="nx">ControllerIndex</span>
+ <span class="nx">ControllerObject</span><span class="p">[</span> <span class="nx">@routeToMethod</span><span class="p">[</span> <span class="nx">route</span><span class="p">.</span><span class="nx">index</span> <span class="p">].</span><span class="nx">method</span> <span class="p">](</span> <span class="nx">params</span> <span class="p">)</span>
+ <span class="k">else</span>
+ <span class="kc">false</span>
+
+ <span class="nv">parseRequest : </span><span class="nf">( request ) -&gt;</span>
+ <span class="nx">request</span><span class="p">.</span><span class="nx">setEncoding</span> <span class="s">&#39;utf-8&#39;</span>
+ <span class="nv">url = </span><span class="nx">Common</span><span class="p">.</span><span class="nx">Url</span><span class="p">.</span><span class="nx">parse</span> <span class="nx">request</span><span class="p">.</span><span class="nx">url</span><span class="p">,</span> <span class="kc">true</span>
+ <span class="nv">request.documentRequested = </span><span class="nx">url</span><span class="p">.</span><span class="nx">pathname</span>
+ <span class="nv">request.query = </span><span class="nx">url</span><span class="p">.</span><span class="nx">query</span>
+
+ <span class="nv">buildParamsForRequest: </span><span class="nf">( route, args, otherParams ) -&gt;</span>
+ <span class="nv">params = </span><span class="p">{}</span>
+ <span class="k">for</span> <span class="nx">index</span> <span class="k">of</span> <span class="nx">route</span><span class="p">.</span><span class="nx">params</span>
+ <span class="nx">params</span><span class="p">[</span> <span class="nx">route</span><span class="p">.</span><span class="nx">params</span><span class="p">[</span> <span class="nx">index</span> <span class="p">]</span> <span class="p">]</span> <span class="o">=</span> <span class="nx">args</span><span class="p">[</span> <span class="nb">parseInt</span><span class="p">(</span><span class="nx">index</span><span class="p">)</span><span class="o">+</span><span class="mi">1</span> <span class="p">]</span>
+ <span class="nx">Common</span><span class="p">.</span><span class="nx">_</span><span class="p">.</span><span class="nx">extend</span><span class="p">(</span> <span class="nx">params</span><span class="p">,</span> <span class="nx">otherParams</span> <span class="p">)</span>
+ <span class="nx">params</span>
+
+
+ <span class="nv">dispatch: </span><span class="nf">( request, response ) -&gt;</span>
+
+ <span class="k">if</span> <span class="nx">@newRoutingAvaiable</span>
+ <span class="nx">@rebuildRoutes</span><span class="p">()</span>
+ <span class="vi">@newRoutingAvaiable = </span><span class="kc">false</span>
+
+ <span class="nv">data = </span><span class="s">&#39;&#39;</span>
+ <span class="nx">request</span><span class="p">.</span><span class="nx">addListener</span> <span class="s">&#39;data&#39;</span><span class="p">,</span> <span class="p">(</span> <span class="nx">data_chunk</span> <span class="p">)</span> <span class="o">=&gt;</span>
+ <span class="nx">data</span> <span class="o">+=</span> <span class="nx">data_chunk</span>
+
+ <span class="nx">@parseRequest</span><span class="p">(</span> <span class="nx">request</span> <span class="p">)</span>
+
+ <span class="nx">request</span><span class="p">.</span><span class="nx">addListener</span> <span class="s">&#39;end&#39;</span><span class="p">,</span> <span class="o">=&gt;</span>
+
+ <span class="nv">hasRouted = </span><span class="kc">false</span>
+
+ <span class="k">for</span> <span class="nx">route</span> <span class="k">in</span> <span class="nx">@avaiableRoutes</span>
+ <span class="nv">routeMatches = </span><span class="nx">route</span><span class="p">.</span><span class="nx">regex</span><span class="p">.</span><span class="nx">exec</span><span class="p">(</span> <span class="nx">request</span><span class="p">.</span><span class="nx">documentRequested</span> <span class="p">)</span>
+ <span class="k">if</span> <span class="nx">routeMatches</span>
+ <span class="nv">params = </span><span class="nx">@buildParamsForRequest</span><span class="p">(</span> <span class="nx">route</span><span class="p">,</span> <span class="nx">routeMatches</span><span class="p">,</span> <span class="p">{</span>
+ <span class="nv">request : </span><span class="nx">request</span>
+ <span class="nv">response : </span><span class="nx">response</span>
+ <span class="nv">route : </span><span class="nx">route</span><span class="p">.</span><span class="nx">index</span>
+ <span class="nv">app : </span><span class="k">this</span>
+ <span class="p">})</span>
+ <span class="k">try</span> <span class="c1"># Execute the method in a sandbox</span>
+ <span class="nv">hasRouted = </span><span class="nx">@callMethodForRoute</span><span class="p">(</span> <span class="nx">route</span><span class="p">,</span> <span class="nx">params</span><span class="p">,</span> <span class="nx">request</span><span class="p">.</span><span class="nx">application</span><span class="p">.</span><span class="nx">Controller</span> <span class="p">)</span> <span class="nx">unless</span> <span class="nx">hasRouted</span>
+ <span class="k">catch</span> <span class="nx">error</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>@respondWithError response</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">response</span><span class="p">.</span><span class="nx">writeHead</span> <span class="mi">500</span><span class="p">,</span> <span class="p">{</span><span class="s">&#39;Content-Type&#39;</span><span class="o">:</span> <span class="s">&#39;text/plain&#39;</span><span class="p">}</span>
+ <span class="nx">response</span><span class="p">.</span><span class="nx">end</span> <span class="s">&#39;Testing: 500&#39;</span>
+ <span class="nv">hasRouted = </span><span class="kc">true</span>
+
+ <span class="k">if</span> <span class="nx">hasRouted</span>
+ <span class="k">break</span>
+
+ <span class="nx">unless</span> <span class="nx">hasRouted</span>
+ <span class="nx">response</span><span class="p">.</span><span class="nx">writeHead</span> <span class="mi">200</span><span class="p">,</span> <span class="p">{</span><span class="s">&#39;Content-Type&#39;</span><span class="o">:</span> <span class="s">&#39;text/plain&#39;</span><span class="p">}</span>
+ <span class="nx">response</span><span class="p">.</span><span class="nx">end</span> <span class="s">&#39;Testing: Not Found Page&#39;</span>
+
+<span class="nv">module.exports = </span><span class="nx">ArcaboucoRequest</span>
+
+</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
View
7 docs/arcabouco_template.html
@@ -0,0 +1,7 @@
+<!DOCTYPE html> <html> <head> <title>arcabouco_template.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="_monkey-fs.html"> _monkey-fs.coffee </a> <a class="source" href="_monkey-patching.html"> _monkey-patching.coffee </a> <a class="source" href="arcabouco.html"> arcabouco.coffee </a> <a class="source" href="arcabouco_content.html"> arcabouco_content.coffee </a> <a class="source" href="arcabouco_controller.html"> arcabouco_controller.coffee </a> <a class="source" href="arcabouco_object_pool.html"> arcabouco_object_pool.coffee </a> <a class="source" href="arcabouco_request.html"> arcabouco_request.coffee </a> <a class="source" href="arcabouco_template.html"> arcabouco_template.coffee </a> <a class="source" href="common.html"> common.coffee </a> <a class="source" href="old_arcabouco.html"> old_arcabouco.coffee </a> <a class="source" href="template.html"> template.coffee </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> arcabouco_template.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> </td> <td class="code"> <div class="highlight"><pre><span class="k">class</span> <span class="nx">ArcaboucoTemplate</span>
+ <span class="nv">output: </span><span class="o">-&gt;</span>
+ <span class="nx">console</span><span class="p">.</span><span class="nx">log</span> <span class="s">&#39;Testing Template&#39;</span>
+
+<span class="nv">module.exports = </span><span class="nx">ArcaboucoTemplate</span>
+
+</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
View
18 docs/common.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html> <html> <head> <title>common.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="_monkey-fs.html"> _monkey-fs.coffee </a> <a class="source" href="_monkey-patching.html"> _monkey-patching.coffee </a> <a class="source" href="arcabouco.html"> arcabouco.coffee </a> <a class="source" href="arcabouco_content.html"> arcabouco_content.coffee </a> <a class="source" href="arcabouco_controller.html"> arcabouco_controller.coffee </a> <a class="source" href="arcabouco_object_pool.html"> arcabouco_object_pool.coffee </a> <a class="source" href="arcabouco_request.html"> arcabouco_request.coffee </a> <a class="source" href="arcabouco_template.html"> arcabouco_template.coffee </a> <a class="source" href="common.html"> common.coffee </a> <a class="source" href="old_arcabouco.html"> old_arcabouco.coffee </a> <a class="source" href="template.html"> template.coffee </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> common.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> <pre><code>Arcabouco.JS
+
+(c) 2011 Patrick Negri, Yellers Software
+Underscore is freely distributable under the MIT license.
+For all details and documentation:
+http://github.com/pnegri/arcabouco-js
+</code></pre> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <h2>Common Modules</h2> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>Include a list of common used modules, keeping it all in one place</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">Common =</span>
+ <span class="nv">Os : </span><span class="nx">require</span> <span class="s">&#39;os&#39;</span>
+ <span class="nv">Http : </span><span class="nx">require</span> <span class="s">&#39;http&#39;</span>
+ <span class="nv">Fs : </span><span class="nx">require</span> <span class="s">&#39;fs&#39;</span>
+ <span class="nv">Path : </span><span class="nx">require</span> <span class="s">&#39;path&#39;</span>
+ <span class="nv">Url : </span><span class="nx">require</span> <span class="s">&#39;url&#39;</span>
+ <span class="nv">Crypt: </span><span class="nx">require</span> <span class="s">&#39;crypto&#39;</span>
+ <span class="nv">_ : </span><span class="nx">require</span> <span class="s">&#39;underscore&#39;</span> <span class="c1"># Enable Underscore Library using Common._</span>
+
+<span class="nv">module.exports = </span><span class="nx">Common</span>
+
+</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
View
186 docs/docco.css
@@ -0,0 +1,186 @@
+/*--------------------- Layout and Typography ----------------------------*/
+body {
+ font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, FreeSerif, serif;
+ font-size: 15px;
+ line-height: 22px;
+ color: #252519;
+ margin: 0; padding: 0;
+}
+a {
+ color: #261a3b;
+}
+ a:visited {
+ color: #261a3b;
+ }
+p {
+ margin: 0 0 15px 0;
+}
+h1, h2, h3, h4, h5, h6 {
+ margin: 0px 0 15px 0;
+}
+ h1 {
+ margin-top: 40px;
+ }
+#container {
+ position: relative;
+}
+#background {
+ position: fixed;
+ top: 0; left: 525px; right: 0; bottom: 0;
+ background: #f5f5ff;
+ border-left: 1px solid #e5e5ee;
+ z-index: -1;
+}
+#jump_to, #jump_page {
+ background: white;
+ -webkit-box-shadow: 0 0 25px #777; -moz-box-shadow: 0 0 25px #777;
+ -webkit-border-bottom-left-radius: 5px; -moz-border-radius-bottomleft: 5px;
+ font: 10px Arial;
+ text-transform: uppercase;
+ cursor: pointer;
+ text-align: right;
+}
+#jump_to, #jump_wrapper {
+ position: fixed;
+ right: 0; top: 0;
+ padding: 5px 10px;
+}
+ #jump_wrapper {
+ padding: 0;
+ display: none;
+ }
+ #jump_to:hover #jump_wrapper {
+ display: block;
+ }
+ #jump_page {
+ padding: 5px 0 3px;
+ margin: 0 0 25px 25px;
+ }
+ #jump_page .source {
+ display: block;
+ padding: 5px 10px;
+ text-decoration: none;
+ border-top: 1px solid #eee;
+ }
+ #jump_page .source:hover {
+ background: #f5f5ff;
+ }
+ #jump_page .source:first-child {
+ }
+table td {
+ border: 0;
+ outline: 0;
+}
+ td.docs, th.docs {
+ max-width: 450px;
+ min-width: 450px;
+ min-height: 5px;
+ padding: 10px 25px 1px 50px;
+ overflow-x: hidden;
+ vertical-align: top;
+ text-align: left;
+ }
+ .docs pre {
+ margin: 15px 0 15px;
+ padding-left: 15px;
+ }
+ .docs p tt, .docs p code {
+ background: #f8f8ff;
+ border: 1px solid #dedede;
+ font-size: 12px;
+ padding: 0 0.2em;
+ }
+ .pilwrap {
+ position: relative;
+ }
+ .pilcrow {
+ font: 12px Arial;
+ text-decoration: none;
+ color: #454545;
+ position: absolute;
+ top: 3px; left: -20px;
+ padding: 1px 2px;
+ opacity: 0;
+ -webkit-transition: opacity 0.2s linear;
+ }
+ td.docs:hover .pilcrow {
+ opacity: 1;
+ }
+ td.code, th.code {
+ padding: 14px 15px 16px 25px;
+ width: 100%;
+ vertical-align: top;
+ background: #f5f5ff;
+ border-left: 1px solid #e5e5ee;
+ }
+ pre, tt, code {
+ font-size: 12px; line-height: 18px;
+ font-family: Monaco, Consolas, "Lucida Console", monospace;
+ margin: 0; padding: 0;
+ }
+
+
+/*---------------------- Syntax Highlighting -----------------------------*/
+td.linenos { background-color: #f0f0f0; padding-right: 10px; }
+span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
+body .hll { background-color: #ffffcc }
+body .c { color: #408080; font-style: italic } /* Comment */
+body .err { border: 1px solid #FF0000 } /* Error */
+body .k { color: #954121 } /* Keyword */
+body .o { color: #666666 } /* Operator */
+body .cm { color: #408080; font-style: italic } /* Comment.Multiline */
+body .cp { color: #BC7A00 } /* Comment.Preproc */
+body .c1 { color: #408080; font-style: italic } /* Comment.Single */
+body .cs { color: #408080; font-style: italic } /* Comment.Special */
+body .gd { color: #A00000 } /* Generic.Deleted */
+body .ge { font-style: italic } /* Generic.Emph */
+body .gr { color: #FF0000 } /* Generic.Error */
+body .gh { color: #000080; font-weight: bold } /* Generic.Heading */
+body .gi { color: #00A000 } /* Generic.Inserted */
+body .go { color: #808080 } /* Generic.Output */
+body .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
+body .gs { font-weight: bold } /* Generic.Strong */
+body .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
+body .gt { color: #0040D0 } /* Generic.Traceback */
+body .kc { color: #954121 } /* Keyword.Constant */
+body .kd { color: #954121; font-weight: bold } /* Keyword.Declaration */
+body .kn { color: #954121; font-weight: bold } /* Keyword.Namespace */
+body .kp { color: #954121 } /* Keyword.Pseudo */
+body .kr { color: #954121; font-weight: bold } /* Keyword.Reserved */
+body .kt { color: #B00040 } /* Keyword.Type */
+body .m { color: #666666 } /* Literal.Number */
+body .s { color: #219161 } /* Literal.String */
+body .na { color: #7D9029 } /* Name.Attribute */
+body .nb { color: #954121 } /* Name.Builtin */
+body .nc { color: #0000FF; font-weight: bold } /* Name.Class */
+body .no { color: #880000 } /* Name.Constant */
+body .nd { color: #AA22FF } /* Name.Decorator */
+body .ni { color: #999999; font-weight: bold } /* Name.Entity */
+body .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
+body .nf { color: #0000FF } /* Name.Function */
+body .nl { color: #A0A000 } /* Name.Label */
+body .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
+body .nt { color: #954121; font-weight: bold } /* Name.Tag */
+body .nv { color: #19469D } /* Name.Variable */
+body .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
+body .w { color: #bbbbbb } /* Text.Whitespace */
+body .mf { color: #666666 } /* Literal.Number.Float */
+body .mh { color: #666666 } /* Literal.Number.Hex */
+body .mi { color: #666666 } /* Literal.Number.Integer */
+body .mo { color: #666666 } /* Literal.Number.Oct */
+body .sb { color: #219161 } /* Literal.String.Backtick */
+body .sc { color: #219161 } /* Literal.String.Char */
+body .sd { color: #219161; font-style: italic } /* Literal.String.Doc */
+body .s2 { color: #219161 } /* Literal.String.Double */
+body .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
+body .sh { color: #219161 } /* Literal.String.Heredoc */
+body .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
+body .sx { color: #954121 } /* Literal.String.Other */
+body .sr { color: #BB6688 } /* Literal.String.Regex */
+body .s1 { color: #219161 } /* Literal.String.Single */
+body .ss { color: #19469D } /* Literal.String.Symbol */
+body .bp { color: #954121 } /* Name.Builtin.Pseudo */
+body .vc { color: #19469D } /* Name.Variable.Class */
+body .vg { color: #19469D } /* Name.Variable.Global */
+body .vi { color: #19469D } /* Name.Variable.Instance */
+body .il { color: #666666 } /* Literal.Number.Integer.Long */
View
329 docs/old_arcabouco.html
@@ -0,0 +1,329 @@
+<!DOCTYPE html> <html> <head> <title>old_arcabouco.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="_monkey-fs.html"> _monkey-fs.coffee </a> <a class="source" href="_monkey-patching.html"> _monkey-patching.coffee </a> <a class="source" href="arcabouco.html"> arcabouco.coffee </a> <a class="source" href="arcabouco_content.html"> arcabouco_content.coffee </a> <a class="source" href="arcabouco_controller.html"> arcabouco_controller.coffee </a> <a class="source" href="arcabouco_object_pool.html"> arcabouco_object_pool.coffee </a> <a class="source" href="arcabouco_request.html"> arcabouco_request.coffee </a> <a class="source" href="arcabouco_template.html"> arcabouco_template.coffee </a> <a class="source" href="common.html"> common.coffee </a> <a class="source" href="old_arcabouco.html"> old_arcabouco.coffee </a> <a class="source" href="template.html"> template.coffee </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> old_arcabouco.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> </td> <td class="code"> <div class="highlight"><pre><span class="nv">Common = </span><span class="nx">require</span> <span class="nx">__dirname</span> <span class="o">+</span> <span class="s">&#39;/common&#39;</span>
+<span class="nv">Underscore = </span><span class="nx">require</span> <span class="s">&#39;underscore&#39;</span>
+<span class="nx">require</span> <span class="nx">__dirname</span> <span class="o">+</span> <span class="s">&#39;/_monkey-patching&#39;</span>
+<span class="p">{</span><span class="nx">spawn</span><span class="p">,</span> <span class="nx">exec</span><span class="p">}</span> <span class="o">=</span> <span class="nx">require</span> <span class="s">&#39;child_process&#39;</span>
+
+<span class="nv">Template = </span><span class="nx">require</span> <span class="nx">__dirname</span> <span class="o">+</span> <span class="s">&#39;/template&#39;</span>
+
+<span class="k">class</span> <span class="nx">PublicExposer</span>
+ <span class="nv">piecesArray : </span><span class="p">[]</span>
+
+ <span class="nv">addPiece: </span><span class="nf">( pieceFilename, options ) -&gt;</span>
+ <span class="nv">priority = </span><span class="mi">0</span>
+ <span class="nv">priority = </span><span class="nx">options</span><span class="p">.</span><span class="nx">priority</span> <span class="k">if</span> <span class="nx">options</span><span class="p">.</span><span class="nx">priority</span>
+
+ <span class="nx">@piecesArray</span><span class="p">.</span><span class="nx">push</span>
+ <span class="nv">filename: </span><span class="nx">pieceFilename</span>
+ <span class="nv">priority: </span><span class="nx">priority</span>
+
+ <span class="nv">build: </span><span class="nf">(application, development=false) -&gt;</span>
+
+ <span class="nv">piecesByPriority = </span><span class="nx">Underscore</span><span class="p">.</span><span class="nx">sortBy</span> <span class="nx">@piecesArray</span><span class="p">,</span>
+ <span class="nf">( obj ) -&gt;</span>
+ <span class="k">return</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">priority</span>
+
+ <span class="nv">outputDir = </span><span class="nx">application</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">baseDirectory</span> <span class="o">+</span> <span class="s">&#39;/cdn/js&#39;</span>
+
+ <span class="nv">c = </span><span class="mi">0</span>
+ <span class="k">for</span> <span class="nx">pieceDetails</span> <span class="k">in</span> <span class="nx">piecesByPriority</span>
+ <span class="nv">pieceFilename = </span><span class="nx">pieceDetails</span><span class="p">.</span><span class="nx">filename</span>
+
+ <span class="nv">baseFilename = </span><span class="nx">Common</span><span class="p">.</span><span class="nx">Path</span><span class="p">.</span><span class="nx">basename</span><span class="p">(</span> <span class="nx">pieceFilename</span><span class="p">,</span> <span class="s">&#39;.coffee&#39;</span> <span class="p">)</span> <span class="o">+</span> <span class="s">&#39;-&#39;</span> <span class="o">+</span> <span class="nx">c</span>
+
+ <span class="nx">exec</span> <span class="s">&quot;coffee --compile -p </span><span class="si">#{</span><span class="nx">pieceFilename</span><span class="si">}</span><span class="s"> &gt; </span><span class="si">#{</span><span class="nx">outputDir</span><span class="si">}</span><span class="s">/</span><span class="si">#{</span><span class="nx">baseFilename</span><span class="si">}</span><span class="s">.js&quot;</span>
+
+ <span class="nx">application</span><span class="p">.</span><span class="nx">ContentGenerator</span><span class="p">.</span><span class="nx">addContentFor</span> <span class="s">&#39;head&#39;</span><span class="p">,</span>
+ <span class="s">&quot;&lt;script src=\&quot;/cdn/js/</span><span class="si">#{</span><span class="nx">baseFilename</span><span class="si">}</span><span class="s">.js\&quot;&gt;&lt;/script&gt;&quot;</span><span class="p">,</span> <span class="p">{</span> <span class="nv">priority: </span><span class="nx">pieceDetails</span><span class="p">.</span><span class="nx">priority</span> <span class="p">}</span>
+
+ <span class="nv">c = </span><span class="nx">c</span><span class="o">+</span><span class="mi">1</span>
+
+
+<span class="k">class</span> <span class="nx">ContentGenerator</span>
+ <span class="nv">contentArray : </span><span class="p">[]</span>
+
+ <span class="nv">ensureArray: </span><span class="nf">( where, group ) -&gt;</span>
+ <span class="nx">@contentArray</span><span class="p">[</span> <span class="nx">group</span> <span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> <span class="nx">unless</span> <span class="nx">@contentArray</span><span class="p">[</span> <span class="nx">group</span> <span class="p">]</span>
+ <span class="nx">@contentArray</span><span class="p">[</span> <span class="nx">group</span> <span class="p">][</span> <span class="nx">where</span> <span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> <span class="nx">unless</span> <span class="nx">@contentArray</span><span class="p">[</span> <span class="nx">group</span> <span class="p">][</span> <span class="nx">where</span> <span class="p">]</span>
+ <span class="kc">true</span>
+
+ <span class="nv">addContentFor: </span><span class="nf">( where, data, options = { group: &#39;default&#39; } ) -&gt;</span>
+ <span class="nv">priority = </span><span class="mi">0</span>
+ <span class="nv">priority = </span><span class="nx">options</span><span class="p">.</span><span class="nx">priority</span> <span class="k">if</span> <span class="nx">options</span><span class="p">.</span><span class="nx">priority</span>
+
+ <span class="nv">group = </span><span class="s">&#39;default&#39;</span>
+ <span class="nv">group = </span><span class="nx">options</span><span class="p">.</span><span class="nx">group</span> <span class="k">if</span> <span class="nx">options</span><span class="p">.</span><span class="nx">group</span>
+
+ <span class="nx">@ensureArray</span><span class="p">(</span> <span class="nx">where</span><span class="p">,</span> <span class="nx">group</span> <span class="p">)</span>
+
+ <span class="nv">type = </span><span class="s">&#39;plain&#39;</span>
+ <span class="nv">type = </span><span class="s">&#39;function&#39;</span> <span class="k">if</span> <span class="k">typeof</span> <span class="nx">data</span> <span class="o">==</span> <span class="s">&#39;function&#39;</span>
+
+ <span class="nx">@contentArray</span><span class="p">[</span> <span class="nx">group</span> <span class="p">][</span> <span class="nx">where</span> <span class="p">].</span><span class="nx">push</span>
+ <span class="s">&#39;type&#39;</span><span class="o">:</span> <span class="nx">type</span>
+ <span class="nv">data: </span><span class="nx">data</span>
+ <span class="nv">priority: </span><span class="nx">priority</span>
+
+ <span class="nv">getContentFor: </span><span class="nf">( where, options = { group: &#39;default&#39; } ) -&gt;</span>
+ <span class="nv">group = </span><span class="nx">options</span><span class="p">.</span><span class="nx">group</span>
+
+ <span class="nx">@ensureArray</span><span class="p">(</span> <span class="nx">where</span><span class="p">,</span> <span class="nx">group</span> <span class="p">)</span>
+
+ <span class="nv">content = </span><span class="s">&#39;&#39;</span>
+ <span class="nv">priorityArray = </span><span class="nx">Underscore</span><span class="p">.</span><span class="nx">sortBy</span> <span class="nx">@contentArray</span><span class="p">[</span> <span class="nx">group</span> <span class="p">][</span> <span class="nx">where</span> <span class="p">],</span>
+ <span class="nf">( obj ) -&gt;</span>
+ <span class="k">return</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">priority</span>
+
+ <span class="k">for</span> <span class="nx">aContent</span> <span class="k">in</span> <span class="nx">priorityArray</span>
+ <span class="nv">output = </span><span class="s">&#39;&#39;</span>
+ <span class="k">if</span> <span class="nx">aContent</span><span class="p">.</span><span class="nx">type</span> <span class="o">==</span> <span class="s">&#39;plain&#39;</span>
+ <span class="nv">output = </span><span class="nx">aContent</span><span class="p">.</span><span class="nx">data</span>
+ <span class="k">else</span>
+ <span class="nv">output = </span><span class="nx">aContent</span><span class="p">.</span><span class="nx">data</span><span class="p">()</span>
+ <span class="nx">content</span> <span class="o">+=</span> <span class="nx">output</span>
+ <span class="nx">content</span>
+
+<span class="k">class</span> <span class="nx">Arcabouco</span>
+ <span class="nv">config : </span><span class="p">{}</span>
+
+ <span class="nv">Template : </span><span class="kc">false</span>
+ <span class="nv">ContentGenerator : </span><span class="kc">false</span>
+ <span class="nv">PublicExposer : </span><span class="kc">false</span>
+
+ <span class="nv">newRoutingAvaiable : </span><span class="kc">false</span>
+ <span class="nv">controllerInstances : </span><span class="p">[]</span>
+ <span class="nv">routeToMethod : </span><span class="p">[]</span>
+ <span class="nv">avaiableRoutes : </span><span class="p">[]</span>
+
+ <span class="nv">_requestsCounter : </span><span class="mi">0</span>
+ <span class="nv">_requestsPolling : </span><span class="mi">0</span>
+ <span class="nv">requestsPerSecond : </span><span class="mi">0</span>
+ <span class="nv">_lastCPU : </span><span class="p">{</span>
+ <span class="nv">user: </span><span class="mi">0</span>
+ <span class="nv">idle: </span><span class="mi">0</span>
+ <span class="nv">sys: </span><span class="mi">0</span>
+ <span class="nv">irq: </span><span class="mi">0</span>
+ <span class="nv">nice: </span><span class="mi">0</span>
+ <span class="p">}</span>
+
+ <span class="nv">constructor : </span><span class="nf">( @config ) -&gt;</span>
+ <span class="nx">unless</span> <span class="nx">@config</span><span class="p">.</span><span class="nx">baseDirectory</span>
+ <span class="nx">console</span><span class="p">.</span><span class="nx">log</span> <span class="s">&#39;Configuration doesnt have baseDirectory directive&#39;</span>
+ <span class="nx">process</span><span class="p">.</span><span class="nx">exit</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
+
+ <span class="nv">global.objects = </span><span class="p">[]</span>
+ <span class="nv">global.public_exports = </span><span class="p">[]</span>
+
+ <span class="vi">@Template = </span><span class="k">new</span> <span class="nx">Template</span><span class="p">()</span>
+ <span class="vi">@ContentGenerator = </span><span class="k">new</span> <span class="nx">ContentGenerator</span><span class="p">()</span>
+ <span class="vi">@PublicExposer = </span><span class="k">new</span> <span class="nx">PublicExposer</span><span class="p">()</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>@content_for = @ContentGenerator.getContentFor</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">@Template</span><span class="p">.</span><span class="nx">loadTemplate</span> <span class="nx">Common</span><span class="p">.</span><span class="nx">Path</span><span class="p">.</span><span class="nx">normalize</span><span class="p">(</span><span class="nx">__dirname</span> <span class="o">+</span> <span class="s">&#39;/../templates/404.haml&#39;</span><span class="p">),</span> <span class="s">&#39;404&#39;</span>
+ <span class="nx">@Template</span><span class="p">.</span><span class="nx">loadTemplate</span> <span class="nx">Common</span><span class="p">.</span><span class="nx">Path</span><span class="p">.</span><span class="nx">normalize</span><span class="p">(</span><span class="nx">__dirname</span> <span class="o">+</span> <span class="s">&#39;/../templates/500.haml&#39;</span><span class="p">),</span> <span class="s">&#39;500&#39;</span>
+
+ <span class="nx">setInterval</span> <span class="o">=&gt;</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>TODO: SEPARATE THIS INTO A CLASS</p> </td> <td class="code"> <div class="highlight"><pre> <span class="vi">@requestsPerSecond = </span><span class="nx">@_requestsCounter</span>
+ <span class="vi">@_requestsCounter = </span><span class="mi">0</span>
+ <span class="nv">totalMemory = </span><span class="nx">Common</span><span class="p">.</span><span class="nx">Os</span><span class="p">.</span><span class="nx">totalmem</span><span class="p">()</span>
+ <span class="nv">freeMemory = </span><span class="nx">Common</span><span class="p">.</span><span class="nx">Os</span><span class="p">.</span><span class="nx">freemem</span><span class="p">()</span>
+ <span class="nv">loadAverage = </span><span class="nx">Common</span><span class="p">.</span><span class="nx">Os</span><span class="p">.</span><span class="nx">loadavg</span><span class="p">()</span>
+
+ <span class="nv">cpus = </span><span class="nx">Common</span><span class="p">.</span><span class="nx">Os</span><span class="p">.</span><span class="nx">cpus</span><span class="p">()</span>
+ <span class="nv">user = </span><span class="mi">0</span>
+ <span class="nv">nice = </span><span class="mi">0</span>
+ <span class="nv">sys = </span><span class="mi">0</span>
+ <span class="nv">idle = </span><span class="mi">0</span>
+ <span class="nv">irq = </span><span class="mi">0</span>
+ <span class="k">for</span> <span class="nx">cpu</span> <span class="k">in</span> <span class="nx">cpus</span>
+ <span class="nx">user</span> <span class="o">+=</span> <span class="nx">cpu</span><span class="p">.</span><span class="nx">times</span><span class="p">.</span><span class="nx">user</span>
+ <span class="nx">nice</span> <span class="o">+=</span> <span class="nx">cpu</span><span class="p">.</span><span class="nx">times</span><span class="p">.</span><span class="nx">nice</span>
+ <span class="nx">sys</span> <span class="o">+=</span> <span class="nx">cpu</span><span class="p">.</span><span class="nx">times</span><span class="p">.</span><span class="nx">sys</span>
+ <span class="nx">idle</span> <span class="o">+=</span> <span class="nx">cpu</span><span class="p">.</span><span class="nx">times</span><span class="p">.</span><span class="nx">idle</span>
+ <span class="nx">irq</span> <span class="o">+=</span> <span class="nx">cpu</span><span class="p">.</span><span class="nx">times</span><span class="p">.</span><span class="nx">irq</span>
+ <span class="nv">total = </span><span class="nx">user</span><span class="o">+</span><span class="nx">nice</span><span class="o">+</span><span class="nx">sys</span><span class="o">+</span><span class="nx">idle</span><span class="o">+</span><span class="nx">irq</span>
+
+ <span class="nv">current_user = </span><span class="nx">user</span><span class="o">-</span><span class="nx">@_lastCPU</span><span class="p">.</span><span class="nx">user</span>
+ <span class="nv">current_nice = </span><span class="nx">nice</span><span class="o">-</span><span class="nx">@_lastCPU</span><span class="p">.</span><span class="nx">nice</span>
+ <span class="nv">current_sys = </span><span class="nx">sys</span><span class="o">-</span><span class="nx">@_lastCPU</span><span class="p">.</span><span class="nx">sys</span>
+ <span class="nv">current_idle = </span><span class="nx">idle</span><span class="o">-</span><span class="nx">@_lastCPU</span><span class="p">.</span><span class="nx">idle</span>
+ <span class="nv">current_irq = </span><span class="nx">irq</span><span class="o">-</span><span class="nx">@_lastCPU</span><span class="p">.</span><span class="nx">irq</span>
+ <span class="nv">current_total = </span><span class="nx">current_user</span><span class="o">+</span><span class="nx">current_nice</span><span class="o">+</span><span class="nx">current_sys</span><span class="o">+</span><span class="nx">current_idle</span><span class="o">+</span><span class="nx">current_irq</span>
+
+ <span class="vi">@_lastCPU.user = </span><span class="nx">user</span>
+ <span class="vi">@_lastCPU.nice = </span><span class="nx">nice</span>
+ <span class="vi">@_lastCPU.sys = </span><span class="nx">sys</span>
+ <span class="vi">@_lastCPU.idle = </span><span class="nx">idle</span>
+ <span class="vi">@_lastCPU.irq = </span><span class="nx">irq</span>
+ <span class="vi">@_lastCPU.total = </span><span class="nx">user</span><span class="o">+</span><span class="nx">nice</span><span class="o">+</span><span class="nx">sys</span><span class="o">+</span><span class="nx">idle</span><span class="o">+</span><span class="nx">irq</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <pre><code> console.log (current_user+current_nice+current_sys+current_irq) / current_total
+ console.log current_idle / current_total
+</code></pre> </td> <td class="code"> <div class="highlight"><pre> <span class="p">,</span> <span class="mi">1000</span>
+
+ <span class="nv">addRoutingToMethod : </span><span class="nf">( path, method, indexOfController ) -&gt;</span>
+ <span class="nx">@routeToMethod</span><span class="p">[</span> <span class="nx">path</span> <span class="p">]</span> <span class="o">=</span>
+ <span class="s">&#39;method&#39;</span> <span class="o">:</span> <span class="nx">method</span>
+ <span class="s">&#39;object&#39;</span> <span class="o">:</span> <span class="nx">indexOfController</span>
+ <span class="vi">@newRoutingAvaiable = </span><span class="kc">true</span>
+ <span class="nx">path</span>
+
+ <span class="nv">parseControllerRoutes : </span><span class="nf">( indexOfController ) -&gt;</span>
+ <span class="nv">ControllerObject = </span><span class="nx">@controllerInstances</span><span class="p">[</span> <span class="nx">indexOfController</span> <span class="p">]</span>
+ <span class="nx">unless</span> <span class="nx">ControllerObject</span><span class="p">.</span><span class="nx">getRoutes</span>
+ <span class="k">return</span> <span class="kc">false</span>
+
+ <span class="nv">controllerRoutes = </span><span class="nx">ControllerObject</span><span class="p">.</span><span class="nx">getRoutes</span><span class="p">()</span>
+ <span class="k">for</span> <span class="nx">path</span> <span class="k">of</span> <span class="nx">controllerRoutes</span>
+ <span class="nx">@addRoutingToMethod</span> <span class="nx">path</span><span class="p">,</span> <span class="nx">controllerRoutes</span><span class="p">[</span> <span class="nx">path</span> <span class="p">],</span> <span class="nx">indexOfController</span>
+
+ <span class="nv">loadController : </span><span class="nf">( controllerFilename ) -&gt;</span>
+ <span class="nx">unless</span> <span class="nx">controllerFilename</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="sr">/\.js$/gi</span><span class="p">)</span>
+ <span class="kc">false</span>
+
+ <span class="k">if</span> <span class="nx">controllerFilename</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="s">&#39;.&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span>
+ <span class="nv">controllerFilename = </span><span class="nx">@config</span><span class="p">.</span><span class="nx">baseDirectory</span> <span class="o">+</span> <span class="nx">controllerFilename</span><span class="p">.</span><span class="nx">substring</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
+
+ <span class="nv">ControllerObject = </span><span class="k">new</span> <span class="p">(</span><span class="nx">require</span> <span class="nx">controllerFilename</span><span class="p">)()</span>
+ <span class="nx">ControllerObject</span><span class="p">.</span><span class="nx">bootstrap</span><span class="p">(</span> <span class="k">this</span> <span class="p">)</span> <span class="k">if</span> <span class="nx">ControllerObject</span><span class="p">.</span><span class="nx">bootstrap</span>
+ <span class="nx">@parseControllerRoutes</span> <span class="nx">@controllerInstances</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">ControllerObject</span><span class="p">)</span><span class="o">-</span><span class="mi">1</span>
+
+ <span class="nv">work: </span><span class="nf">( ControllerObject ) -&gt;</span>
+
+ <span class="nv">instanceClass = </span><span class="k">new</span> <span class="nx">ControllerObject</span><span class="p">()</span>
+ <span class="k">if</span> <span class="nx">instanceClass</span><span class="p">.</span><span class="nx">bootstrap</span> <span class="o">or</span> <span class="nx">instanceClass</span><span class="p">.</span><span class="nx">getRoutes</span>
+ <span class="nv">ControllerObject = </span><span class="nx">instanceClass</span>
+
+ <span class="nx">ControllerObject</span><span class="p">.</span><span class="nx">bootstrap</span><span class="p">(</span> <span class="k">this</span> <span class="p">)</span> <span class="k">if</span> <span class="nx">ControllerObject</span><span class="p">.</span><span class="nx">bootstrap</span>
+ <span class="nx">@parseControllerRoutes</span> <span class="nx">@controllerInstances</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">ControllerObject</span><span class="p">)</span><span class="o">-</span><span class="mi">1</span>
+
+ <span class="nv">assemble: </span><span class="nf">( directory ) -&gt;</span>
+ <span class="nv">fullPath = </span><span class="nx">Common</span><span class="p">.</span><span class="nx">Path</span><span class="p">.</span><span class="nx">normalize</span><span class="p">(</span> <span class="nx">directory</span> <span class="p">)</span>
+ <span class="k">if</span> <span class="nx">Common</span><span class="p">.</span><span class="nx">Path</span><span class="p">.</span><span class="nx">existsSync</span><span class="p">(</span> <span class="nx">fullPath</span> <span class="p">)</span>
+ <span class="nv">files = </span><span class="nx">Common</span><span class="p">.</span><span class="nx">Fs</span><span class="p">.</span><span class="nx">readdirSyncR</span><span class="p">(</span> <span class="nx">fullPath</span> <span class="p">)</span>
+ <span class="k">for</span> <span class="nx">file</span> <span class="k">in</span> <span class="nx">files</span>
+ <span class="nv">valid = </span><span class="kc">false</span>
+ <span class="k">if</span> <span class="nx">file</span><span class="p">.</span><span class="nx">match</span> <span class="sr">/\.js/gi</span>
+ <span class="nv">valid = </span><span class="kc">true</span>
+ <span class="k">if</span> <span class="nx">file</span><span class="p">.</span><span class="nx">match</span> <span class="sr">/\.coffee/gi</span>
+ <span class="nv">valid = </span><span class="kc">true</span>
+ <span class="k">if</span> <span class="nx">file</span><span class="p">.</span><span class="nx">match</span> <span class="sr">/src\//gi</span>
+ <span class="nv">valid = </span><span class="kc">false</span>
+ <span class="k">if</span> <span class="nx">file</span><span class="p">.</span><span class="nx">match</span> <span class="sr">/\.swp/gi</span>
+ <span class="nv">valid = </span><span class="kc">false</span>
+ <span class="k">if</span> <span class="nx">valid</span>
+ <span class="nx">@work</span> <span class="nx">require</span> <span class="nx">file</span>
+
+ <span class="nv">registerObject : </span><span class="nf">( objectName, object ) -&gt;</span>
+ <span class="nx">global</span><span class="p">.</span><span class="nx">objects</span><span class="p">[</span> <span class="nx">objectName</span> <span class="p">]</span> <span class="o">=</span> <span class="nx">object</span>
+ <span class="kc">true</span>
+
+ <span class="nv">buildObject: </span><span class="nf">(objectName) -&gt;</span>
+ <span class="k">new</span> <span class="p">(</span><span class="nx">global</span><span class="p">.</span><span class="nx">objects</span><span class="p">[</span> <span class="nx">objectName</span> <span class="p">])</span>
+
+ <span class="nv">getRawObjects: </span><span class="nf">() -&gt;</span>
+ <span class="nx">global</span><span class="p">.</span><span class="nx">objects</span>
+
+ <span class="nv">contructRoutingForPattern : </span><span class="nf">( pattern ) -&gt;</span>
+ <span class="nv">params = </span><span class="p">[]</span>
+ <span class="nv">buildPattern = </span><span class="nx">pattern</span><span class="p">.</span><span class="nx">replace</span> <span class="sr">/\{(.*?)\}/g</span><span class="p">,</span>
+ <span class="nf">( match, sub1 ) -&gt;</span>
+ <span class="nx">params</span><span class="p">.</span><span class="nx">push</span> <span class="nx">sub1</span>
+ <span class="k">return</span> <span class="s">&#39;([^\/]+)&#39;</span>
+ <span class="nv">buildPattern = </span><span class="nx">buildPattern</span><span class="p">.</span><span class="nx">replaceLast</span><span class="p">(</span> <span class="s">&#39;([^\/]+)&#39;</span><span class="p">,</span> <span class="s">&#39;([^$]+)&#39;</span> <span class="p">)</span>
+ <span class="nv">constructedRoute =</span>
+ <span class="nv">regex : </span><span class="k">new</span> <span class="nb">RegExp</span> <span class="s">&#39;^&#39;</span> <span class="o">+</span> <span class="nx">buildPattern</span> <span class="o">+</span> <span class="s">&#39;$&#39;</span>
+ <span class="nv">params: </span><span class="nx">params</span>
+ <span class="nv">index : </span><span class="nx">pattern</span>
+
+ <span class="nv">buildRouting : </span><span class="o">-&gt;</span>
+ <span class="nv">orderedRouteNames = </span><span class="nx">Underscore</span><span class="p">.</span><span class="nx">keys</span><span class="p">(</span> <span class="nx">@routeToMethod</span> <span class="p">).</span><span class="nx">sort</span><span class="p">().</span><span class="nx">reverse</span><span class="p">()</span>
+ <span class="vi">@avaiableRoutes = </span><span class="p">[]</span>
+ <span class="k">for</span> <span class="nx">pattern</span> <span class="k">in</span> <span class="nx">orderedRouteNames</span>
+ <span class="nx">@avaiableRoutes</span><span class="p">.</span><span class="nx">push</span> <span class="nx">@contructRoutingForPattern</span><span class="p">(</span> <span class="nx">pattern</span> <span class="p">)</span>
+
+ <span class="nv">build: </span><span class="o">-&gt;</span>
+ <span class="nx">@buildRouting</span><span class="p">()</span></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> <p>TODO => development = true???</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">@PublicExposer</span><span class="p">.</span><span class="nx">build</span><span class="p">(</span> <span class="k">this</span><span class="p">,</span> <span class="kc">true</span> <span class="p">)</span>
+
+ <span class="nv">parseRequest : </span><span class="nf">( request ) -&gt;</span>
+ <span class="nx">request</span><span class="p">.</span><span class="nx">setEncoding</span> <span class="s">&#39;utf-8&#39;</span>
+ <span class="nv">url = </span><span class="nx">Common</span><span class="p">.</span><span class="nx">Url</span><span class="p">.</span><span class="nx">parse</span> <span class="nx">request</span><span class="p">.</span><span class="nx">url</span><span class="p">,</span> <span class="kc">true</span>
+ <span class="nv">request.documentRequested = </span><span class="nx">url</span><span class="p">.</span><span class="nx">pathname</span>
+ <span class="nv">request.query = </span><span class="nx">url</span><span class="p">.</span><span class="nx">query</span>
+
+ <span class="nv">parseLocaleFromRequest : </span><span class="nf">( request ) -&gt;</span>
+ <span class="nv">language = </span><span class="s">&#39;en&#39;</span>
+ <span class="k">if</span> <span class="nx">@config</span><span class="p">.</span><span class="nx">defaultLocale</span>
+ <span class="nv">language = </span><span class="nx">@config</span><span class="p">.</span><span class="nx">defaultLocale</span>
+ <span class="k">if</span> <span class="nx">request</span><span class="p">.</span><span class="nx">documentRequested</span><span class="p">.</span><span class="nx">match</span> <span class="sr">/^\/(([a-z]{1,2})(\-[a-z]{1,2})?)($|\/)/ig</span>
+ <span class="nv">requestedLocale = </span><span class="nb">RegExp</span><span class="p">.</span><span class="nx">$1</span>
+ <span class="nv">request.documentRequested = </span><span class="nx">request</span><span class="p">.</span><span class="nx">documentRequested</span><span class="p">.</span><span class="nx">replace</span> <span class="s">&#39;/&#39;</span> <span class="o">+</span> <span class="nx">requestedLocale</span><span class="p">,</span> <span class="s">&#39;&#39;</span>
+ <span class="nv">request.documentRequested = </span><span class="s">&#39;/&#39;</span> <span class="k">if</span> <span class="nx">request</span><span class="p">.</span><span class="nx">documentRequested</span> <span class="o">==</span> <span class="s">&#39;&#39;</span>
+ <span class="nv">request.documentLocale = </span><span class="nx">language</span>
+
+ <span class="nv">buildParamsForRequest: </span><span class="nf">( route, args, otherParams ) -&gt;</span>
+ <span class="nv">params = </span><span class="p">{}</span>
+ <span class="k">for</span> <span class="nx">index</span> <span class="k">of</span> <span class="nx">route</span><span class="p">.</span><span class="nx">params</span>
+ <span class="nx">params</span><span class="p">[</span> <span class="nx">route</span><span class="p">.</span><span class="nx">params</span><span class="p">[</span> <span class="nx">index</span> <span class="p">]</span> <span class="p">]</span> <span class="o">=</span> <span class="nx">args</span><span class="p">[</span> <span class="nb">parseInt</span><span class="p">(</span><span class="nx">index</span><span class="p">)</span><span class="o">+</span><span class="mi">1</span> <span class="p">]</span>
+ <span class="nx">Underscore</span><span class="p">.</span><span class="nx">extend</span><span class="p">(</span> <span class="nx">params</span><span class="p">,</span> <span class="nx">otherParams</span> <span class="p">)</span>
+ <span class="nx">params</span>
+
+ <span class="nv">callMethodForRoute : </span><span class="nf">( route, params ) -&gt;</span>
+ <span class="k">if</span> <span class="nx">@routeToMethod</span><span class="p">[</span> <span class="nx">route</span><span class="p">.</span><span class="nx">index</span> <span class="p">]</span>
+ <span class="nv">ControllerIndex = </span><span class="nx">@routeToMethod</span><span class="p">[</span> <span class="nx">route</span><span class="p">.</span><span class="nx">index</span> <span class="p">].</span><span class="nx">object</span>
+ <span class="nv">ControllerObject = </span><span class="nx">@controllerInstances</span><span class="p">[</span> <span class="nx">ControllerIndex</span> <span class="p">]</span>
+ <span class="nx">ControllerObject</span><span class="p">[</span> <span class="nx">@routeToMethod</span><span class="p">[</span> <span class="nx">route</span><span class="p">.</span><span class="nx">index</span> <span class="p">].</span><span class="nx">method</span> <span class="p">](</span> <span class="nx">params</span> <span class="p">)</span>
+ <span class="k">else</span>
+ <span class="kc">false</span>
+
+ <span class="nv">respondWithError : </span><span class="nf">( respond ) -&gt;</span>
+ <span class="nx">respond</span><span class="p">.</span><span class="nx">respondWith</span> <span class="nx">@Template</span><span class="p">.</span><span class="nx">doRender</span><span class="p">(</span> <span class="s">&#39;500&#39;</span><span class="p">,</span> <span class="k">this</span><span class="p">,</span> <span class="p">{},</span> <span class="kc">false</span> <span class="p">),</span> <span class="mi">500</span>
+
+ <span class="nv">respondWithTimeout: </span><span class="nf">( respond ) -&gt;</span>
+ <span class="nx">respond</span><span class="p">.</span><span class="nx">respondWith</span> <span class="nx">@Template</span><span class="p">.</span><span class="nx">doRender</span><span class="p">(</span> <span class="s">&#39;500&#39;</span><span class="p">,</span> <span class="k">this</span><span class="p">,</span> <span class="p">{},</span> <span class="kc">false</span><span class="p">),</span> <span class="mi">504</span>
+
+ <span class="nv">respondWithNotFound: </span><span class="nf">( respond ) -&gt;</span>
+ <span class="nx">respond</span><span class="p">.</span><span class="nx">respondWith</span> <span class="nx">@Template</span><span class="p">.</span><span class="nx">doRender</span><span class="p">(</span> <span class="s">&#39;404&#39;</span><span class="p">,</span> <span class="k">this</span><span class="p">,</span> <span class="p">{},</span> <span class="kc">false</span> <span class="p">),</span> <span class="mi">404</span><span class="p">,</span> <span class="mi">300</span>
+
+ <span class="nv">dispatchRequest : </span><span class="nf">( request, response ) -&gt;</span>
+ <span class="nx">@parseRequest</span><span class="p">(</span> <span class="nx">request</span> <span class="p">)</span>
+ <span class="nx">@parseLocaleFromRequest</span><span class="p">(</span> <span class="nx">request</span> <span class="p">)</span>
+
+ <span class="nv">data = </span><span class="s">&#39;&#39;</span>
+ <span class="nx">request</span><span class="p">.</span><span class="nx">addListener</span> <span class="s">&#39;data&#39;</span><span class="p">,</span> <span class="p">(</span> <span class="nx">data_chunk</span> <span class="p">)</span> <span class="o">=&gt;</span>
+ <span class="nx">data</span> <span class="o">+=</span> <span class="nx">data_chunk</span>
+
+ <span class="nx">request</span><span class="p">.</span><span class="nx">addListener</span> <span class="s">&#39;end&#39;</span><span class="p">,</span> <span class="o">=&gt;</span>
+ <span class="vi">@_requestsCounter = </span><span class="nx">@_requestsCounter</span><span class="o">+</span><span class="mi">1</span>
+ <span class="nv">hasRouted = </span><span class="kc">false</span>
+
+ <span class="k">for</span> <span class="nx">route</span> <span class="k">in</span> <span class="nx">@avaiableRoutes</span>
+ <span class="nv">routeMatches = </span><span class="nx">route</span><span class="p">.</span><span class="nx">regex</span><span class="p">.</span><span class="nx">exec</span><span class="p">(</span> <span class="nx">request</span><span class="p">.</span><span class="nx">documentRequested</span> <span class="p">)</span>
+ <span class="k">if</span> <span class="nx">routeMatches</span>
+ <span class="nv">params = </span><span class="nx">@buildParamsForRequest</span><span class="p">(</span> <span class="nx">route</span><span class="p">,</span> <span class="nx">routeMatches</span><span class="p">,</span> <span class="p">{</span>
+ <span class="nv">request : </span><span class="nx">request</span>
+ <span class="nv">response : </span><span class="nx">response</span>
+ <span class="nv">route : </span><span class="nx">route</span><span class="p">.</span><span class="nx">index</span>
+ <span class="nv">app : </span><span class="k">this</span>
+ <span class="p">})</span>
+ <span class="k">try</span> <span class="c1"># Execute the method in a sandbox</span>
+ <span class="nv">hasRouted = </span><span class="nx">@callMethodForRoute</span><span class="p">(</span> <span class="nx">route</span><span class="p">,</span> <span class="nx">params</span> <span class="p">)</span> <span class="nx">unless</span> <span class="nx">hasRouted</span>
+ <span class="k">catch</span> <span class="nx">error</span>
+ <span class="nx">@respondWithError</span> <span class="nx">response</span>
+ <span class="nv">hasRouted = </span><span class="kc">true</span>
+
+ <span class="k">if</span> <span class="nx">hasRouted</span>
+ <span class="k">break</span>
+
+ <span class="nx">unless</span> <span class="nx">hasRouted</span>
+ <span class="nx">@respondWithNotFound</span> <span class="nx">response</span>
+
+ <span class="nv">createServer : </span><span class="o">-&gt;</span>
+ <span class="nx">Common</span><span class="p">.</span><span class="nx">Http</span><span class="p">.</span><span class="nx">createServer</span><span class="p">(</span> <span class="nx">@dispatchRequest</span><span class="p">.</span><span class="nx">bind</span><span class="p">(</span> <span class="k">this</span> <span class="p">)</span> <span class="p">)</span>
+
+ <span class="nv">createSecureServer: </span><span class="nf">( privateKey, certificate ) -&gt;</span>
+ <span class="nv">crypto = </span><span class="nx">require</span> <span class="s">&#39;crypto&#39;</span>
+ <span class="nv">credentials = </span><span class="nx">crypto</span><span class="p">.</span><span class="nx">createCredentials</span> <span class="p">{</span>
+ <span class="nv">key: </span><span class="nx">privateKey</span>
+ <span class="nv">cert: </span><span class="nx">certificate</span>
+ <span class="p">}</span>
+ <span class="nv">secureServer = </span><span class="nx">Common</span><span class="p">.</span><span class="nx">Http</span><span class="p">.</span><span class="nx">createServer</span><span class="p">(</span> <span class="nx">@dispatchRequest</span><span class="p">.</span><span class="nx">bind</span><span class="p">(</span><span class="k">this</span><span class="p">)</span> <span class="p">)</span>
+ <span class="nx">secureServer</span><span class="p">.</span><span class="nx">setSecure</span><span class="p">(</span> <span class="nx">credentials</span> <span class="p">)</span>
+ <span class="nx">secureServer</span>
+
+<span class="nv">module.exports = </span><span class="nx">Arcabouco</span>
+
+</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
View
54 docs/template.html
@@ -0,0 +1,54 @@
+<!DOCTYPE html> <html> <head> <title>template.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="_monkey-fs.html"> _monkey-fs.coffee </a> <a class="source" href="_monkey-patching.html"> _monkey-patching.coffee </a> <a class="source" href="arcabouco.html"> arcabouco.coffee </a> <a class="source" href="arcabouco_content.html"> arcabouco_content.coffee </a> <a class="source" href="arcabouco_controller.html"> arcabouco_controller.coffee </a> <a class="source" href="arcabouco_object_pool.html"> arcabouco_object_pool.coffee </a> <a class="source" href="arcabouco_request.html"> arcabouco_request.coffee </a> <a class="source" href="arcabouco_template.html"> arcabouco_template.coffee </a> <a class="source" href="common.html"> common.coffee </a> <a class="source" href="old_arcabouco.html"> old_arcabouco.coffee </a> <a class="source" href="template.html"> template.coffee </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> template.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> </td> <td class="code"> <div class="highlight"><pre><span class="nv">Common = </span><span class="nx">require</span> <span class="s">&#39;./common&#39;</span>
+<span class="nv">Haml = </span><span class="nx">require</span> <span class="s">&#39;haml&#39;</span>
+
+<span class="k">class</span> <span class="nx">Template</span>
+ <span class="nv">loadedTemplates : </span><span class="p">[]</span></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <h1>TODO: Search for Template</h1>
+
+<h1>TODO: Modulize template for support multiple files</h1> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">getTemplate: </span><span class="nf">( templateFile ) -&gt;</span>
+ <span class="nv">templateFile = </span><span class="nx">Common</span><span class="p">.</span><span class="nx">Path</span><span class="p">.</span><span class="nx">basename</span> <span class="nx">templateFile</span>
+ <span class="nx">unless</span> <span class="nx">@loadedTemplates</span><span class="p">[</span> <span class="nx">templateFile</span> <span class="p">]</span>
+ <span class="k">return</span> <span class="kc">false</span>
+ <span class="nx">@loadedTemplates</span><span class="p">[</span> <span class="nx">templateFile</span> <span class="p">]</span>
+
+ <span class="nv">loadTemplate: </span><span class="nf">( templateFile, asTemplateName=&quot;&quot; ) -&gt;</span>
+ <span class="nx">unless</span> <span class="nx">templateFile</span>
+ <span class="k">return</span> <span class="kc">false</span>
+ <span class="nx">unless</span> <span class="nx">templateFile</span><span class="p">.</span><span class="nx">match</span> <span class="sr">/\.haml$/gi</span>
+ <span class="k">return</span> <span class="kc">false</span>
+ <span class="nv">baseTemplateFile = </span><span class="nx">Common</span><span class="p">.</span><span class="nx">Path</span><span class="p">.</span><span class="nx">basename</span> <span class="nx">templateFile</span>
+ <span class="k">if</span> <span class="nx">asTemplateName</span> <span class="o">!=</span> <span class="s">&quot;&quot;</span>
+ <span class="nv">baseTemplateFile = </span><span class="nx">asTemplateName</span>
+ <span class="nv">template = </span><span class="nx">Common</span><span class="p">.</span><span class="nx">Fs</span><span class="p">.</span><span class="nx">readFileSync</span> <span class="nx">templateFile</span><span class="p">,</span> <span class="s">&#39;utf-8&#39;</span>
+ <span class="nv">compiledTemplate = </span><span class="nx">Haml</span><span class="p">.</span><span class="nx">compile</span> <span class="nx">template</span>
+ <span class="nv">optimizedTemplate = </span><span class="nx">Haml</span><span class="p">.</span><span class="nx">optimize</span> <span class="nx">compiledTemplate</span>
+ <span class="nx">@loadedTemplates</span><span class="p">[</span> <span class="nx">baseTemplateFile</span> <span class="p">]</span> <span class="o">=</span>
+ <span class="nv">type: </span><span class="s">&#39;haml&#39;</span>
+ <span class="nv">data: </span><span class="nx">optimizedTemplate</span>
+
+ <span class="nv">loadTemplateString: </span><span class="nf">( templateString, templateName ) -&gt;</span>
+ <span class="nx">@loadedTemplates</span><span class="p">[</span> <span class="nx">templateName</span> <span class="p">]</span> <span class="o">=</span>
+ <span class="nv">type: </span><span class="s">&#39;plain&#39;</span>
+ <span class="nv">data: </span><span class="nx">templateString</span>
+
+ <span class="nv">doRender: </span><span class="nf">( templateFile, context = this, params = {}, layout = &#39;layout.haml&#39; ) -&gt;</span>
+ <span class="nv">template = </span><span class="nx">@getTemplate</span> <span class="nx">templateFile</span>
+ <span class="nx">unless</span> <span class="nx">template</span>
+ <span class="k">return</span> <span class="s">&#39;Template Missing: &#39;</span> <span class="o">+</span> <span class="nx">templateFile</span>
+
+ <span class="k">if</span> <span class="nx">template</span><span class="p">.</span><span class="nx">type</span> <span class="o">==</span> <span class="s">&#39;haml&#39;</span>
+ <span class="nv">content = </span><span class="nx">Haml</span><span class="p">.</span><span class="nx">execute</span> <span class="nx">template</span><span class="p">.</span><span class="nx">data</span><span class="p">,</span> <span class="nx">context</span><span class="p">,</span> <span class="nx">params</span>
+ <span class="k">else</span>
+ <span class="nv">content = </span><span class="nx">template</span><span class="p">.</span><span class="nx">data</span>
+
+ <span class="k">if</span> <span class="nx">layout</span>
+ <span class="nv">compiled_layout = </span><span class="nx">@getTemplate</span> <span class="nx">layout</span>
+ <span class="nv">params.content = </span><span class="nx">content</span>
+ <span class="k">return</span> <span class="nx">Haml</span><span class="p">.</span><span class="nx">execute</span> <span class="nx">layout</span><span class="p">,</span> <span class="nx">context</span><span class="p">,</span> <span class="nx">params</span>
+ <span class="k">return</span> <span class="nx">content</span>
+
+ <span class="nv">doRenderPartial: </span><span class="nf">( templateFile, context = this, params = {}) -&gt;</span>
+ <span class="nx">@doRender</span> <span class="nx">templateFile</span><span class="p">,</span> <span class="nx">context</span><span class="p">,</span> <span class="nx">params</span><span class="p">,</span> <span class="kc">false</span>
+
+<span class="nv">module.exports = </span><span class="nx">Template</span>
+
+</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
View
1  examples/assemble-test/app.coffee
@@ -6,7 +6,6 @@ config =
app = new arcabouco config
app.assemble __dirname + '/pieces'
-app.build()
server = app.createServer()
server.listen 8888
View
6 examples/assemble-test/pieces/welcome/welcome.coffee
@@ -1,12 +1,10 @@
class WelcomeController
index: ( params ) ->
- responder = params.response
- template = params.app.Template
- responder.respondWith template.doRender( 'welcome.index', this, {}, false )
+ params.response.respondWith params.app.render( 'welcome.index', this, {}, false )
bootstrap: ( application ) ->
return unless application
- application.Template.loadTemplate __dirname + '/views/index.haml', 'welcome.index'
+ application.loadTemplate __dirname + '/views/index.haml', 'welcome.index'
getRoutes: ->
'/test' : 'index'
View
10 examples/hello-world/app.coffee
@@ -0,0 +1,10 @@
+arcabouco = require '../../main.js'
+
+config =
+ baseDirectory: __dirname
+
+app = new arcabouco config
+
+server = app.createServer()
+server.listen 8888
+
View
1  examples/minimal-test/app.coffee
@@ -12,7 +12,6 @@ config =
app = new arcabouco config
app.work require 'screw-node-static'
-app.build()
server = app.createServer()
server.listen 8888
View
22 lib/_monkey-fs.coffee
@@ -1,16 +1,38 @@
+# Arcabouco.JS
+#
+# (c) 2011 Patrick Negri, Yellers Software
+# Arcabouco.JS is freely distributable under the MIT license.
+# For all details and documentation:
+# http://github.com/pnegri/arcabouco-js
+
+# Node.JS Monkey Patching for FS
+# ------------------------------
+
+# Include Commons
Common = require __dirname + '/common'
+# ### readdirSyncR
+#
+# Extend Fs with a method to read a directory sync
Common.Fs.readdirSyncR = ( directory ) ->
+ # Normalize the input directory
directory = Common.Path.normalize directory
+ # Get all files in the directory
files = Common.Fs.readdirSync directory
+ # Setup an array for valid files
allFiles = []
for file in files
+ # Compute the full path of file
fileWithPath = directory + '/' + file
+ # Get information about the file
stat = Common.Fs.statSync fileWithPath
if stat.isFile()
+ # If it is a file put in all files array
allFiles.push fileWithPath
if stat.isDirectory()
+ # If it is a directory recursively call this method
dirFiles = Common.Fs.readdirSyncR fileWithPath
if dirFiles.length
+ # Concatenate the results with files found previousily
allFiles = allFiles.concat dirFiles
allFiles
View
63 lib/_monkey-patching.coffee
@@ -1,8 +1,21 @@
-require 'coffee-script'
+# Arcabouco.JS
+#
+# (c) 2011 Patrick Negri, Yellers Software
+# Arcabouco.JS is freely distributable under the MIT license.
+# For all details and documentation:
+# http://github.com/pnegri/arcabouco-js
+
+# Node.JS Monkey Patching
+# -----------------------
+
+# Include Commons
Common = require __dirname + '/common'
-require __dirname + '/_monkey-fs'
-Underscore = require 'underscore'
+require __dirname + '/_monkey-fs.coffee'
+
+# ### replaceLast
+#
+# Extend String with a replaceLast method
String.prototype.replaceLast = ( search, replace ) ->
string = this
n = string.lastIndexOf( search )
@@ -10,6 +23,12 @@ String.prototype.replaceLast = ( search, replace ) ->
string = string.substring(0, n) + replace
string
+# Extending and Patching HTTP
+# ---------------------------
+
+# ### Response Grouping
+#
+# Include a 'group' in response
Common.Http.ServerResponse.prototype.group = 'default'
Common.Http.ServerResponse.prototype.getGroup = () ->
@@ -18,24 +37,46 @@ Common.Http.ServerResponse.prototype.getGroup = () ->
Common.Http.ServerResponse.prototype.setGroup = ( groupName ) ->
@group = groupName
+# ### Response Redirection
Common.Http.ServerResponse.prototype.redirectTo = ( url ) ->
@writeHead 302, { 'Location': url }
@end()
-Common.Http.ServerResponse.prototype.respondWith = ( content, type='text/html', status=200, expiration=0 ) ->
+# ### respondWith
+#
+# Extend Response with a cache-corrected responder
+
+Common.Http.ServerResponse.prototype.respondWith = ( content, options = {} ) ->
+
+ # Configure default response options
+ response_option = {}
+ response_option.type = if options.type then options.type else 'text/html'
+ response_option.expiration = if options.expiration then options.expiration else 0
+ response_option.status = if options.status then options.status else 200
+ response_option.charset = if options.charset then options.charset else 'utf-8'
+
+ # Calculate the expiration