Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added `stylus` to the root scope.

  • Loading branch information...
commit 69d5e9b7198aff7406539aa36c7a5a0e11c5aca4 1 parent d7af6f5
@mauricemach mauricemach authored
View
2  CHANGELOG.md
@@ -3,6 +3,8 @@
- Changed: external vars (`zappa {foo} ->`) overwrite all others.
- Fixed: inline templates with multiple apps.
+
+ - Added `stylus` to the root scope.
**v0.2.0beta** (2011-08-02):
View
8 docs/zappa.html
@@ -61,7 +61,7 @@
but locals to each module.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">globals_names = </span><span class="p">[</span><span class="s1">&#39;global&#39;</span><span class="p">,</span> <span class="s1">&#39;process&#39;</span><span class="p">,</span> <span class="s1">&#39;console&#39;</span><span class="p">,</span> <span class="s1">&#39;setTimeout&#39;</span><span class="p">,</span> <span class="s1">&#39;clearTimeout&#39;</span><span class="p">,</span> <span class="s1">&#39;setInterval&#39;</span><span class="p">,</span> <span class="s1">&#39;clearInterval&#39;</span><span class="p">,</span>
<span class="s1">&#39;require&#39;</span><span class="p">,</span> <span class="s1">&#39;module&#39;</span><span class="p">,</span> <span class="s1">&#39;__filename&#39;</span><span class="p">,</span> <span class="s1">&#39;__dirname&#39;</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>TODO: route?, error</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">root_names = </span><span class="p">[</span><span class="s1">&#39;zappa&#39;</span><span class="p">,</span> <span class="s1">&#39;express&#39;</span><span class="p">,</span> <span class="s1">&#39;app&#39;</span><span class="p">,</span> <span class="s1">&#39;io&#39;</span><span class="p">,</span> <span class="s1">&#39;requiring&#39;</span><span class="p">,</span> <span class="s1">&#39;get&#39;</span><span class="p">,</span> <span class="s1">&#39;post&#39;</span><span class="p">,</span> <span class="s1">&#39;put&#39;</span><span class="p">,</span> <span class="s1">&#39;del&#39;</span><span class="p">,</span> <span class="s1">&#39;at&#39;</span><span class="p">,</span>
<span class="s1">&#39;helper&#39;</span><span class="p">,</span> <span class="s1">&#39;def&#39;</span><span class="p">,</span> <span class="s1">&#39;view&#39;</span><span class="p">,</span> <span class="s1">&#39;set&#39;</span><span class="p">,</span> <span class="s1">&#39;use&#39;</span><span class="p">,</span> <span class="s1">&#39;configure&#39;</span><span class="p">,</span> <span class="s1">&#39;include&#39;</span><span class="p">,</span> <span class="s1">&#39;shared&#39;</span><span class="p">,</span> <span class="s1">&#39;client&#39;</span><span class="p">,</span> <span class="s1">&#39;coffee&#39;</span><span class="p">,</span> <span class="s1">&#39;js&#39;</span><span class="p">,</span> <span class="s1">&#39;css&#39;</span><span class="p">,</span>
- <span class="s1">&#39;enable&#39;</span><span class="p">,</span> <span class="s1">&#39;disable&#39;</span><span class="p">,</span> <span class="s1">&#39;settings&#39;</span><span class="p">,</span> <span class="s1">&#39;postrender&#39;</span><span class="p">]</span></pre></div> </td> </tr> <tr id="section-19"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-19">&#182;</a> </div> <p>TODO: session, cookies, app data, clients list</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">http_names = </span><span class="p">[</span><span class="s1">&#39;app&#39;</span><span class="p">,</span> <span class="s1">&#39;settings&#39;</span><span class="p">,</span> <span class="s1">&#39;response&#39;</span><span class="p">,</span> <span class="s1">&#39;request&#39;</span><span class="p">,</span> <span class="s1">&#39;next&#39;</span><span class="p">,</span> <span class="s1">&#39;params&#39;</span><span class="p">,</span> <span class="s1">&#39;send&#39;</span><span class="p">,</span> <span class="s1">&#39;render&#39;</span><span class="p">,</span> <span class="s1">&#39;redirect&#39;</span><span class="p">]</span></pre></div> </td> </tr> <tr id="section-20"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-20">&#182;</a> </div> <p>TODO: app data, clients list, join</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">ws_names = </span><span class="p">[</span><span class="s1">&#39;app&#39;</span><span class="p">,</span> <span class="s1">&#39;io&#39;</span><span class="p">,</span> <span class="s1">&#39;settings&#39;</span><span class="p">,</span> <span class="s1">&#39;socket&#39;</span><span class="p">,</span> <span class="s1">&#39;id&#39;</span><span class="p">,</span> <span class="s1">&#39;params&#39;</span><span class="p">,</span> <span class="s1">&#39;client&#39;</span><span class="p">,</span> <span class="s1">&#39;emit&#39;</span><span class="p">,</span> <span class="s1">&#39;broadcast&#39;</span><span class="p">]</span>
+ <span class="s1">&#39;stylus&#39;</span><span class="p">,</span> <span class="s1">&#39;enable&#39;</span><span class="p">,</span> <span class="s1">&#39;disable&#39;</span><span class="p">,</span> <span class="s1">&#39;settings&#39;</span><span class="p">,</span> <span class="s1">&#39;postrender&#39;</span><span class="p">]</span></pre></div> </td> </tr> <tr id="section-19"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-19">&#182;</a> </div> <p>TODO: session, cookies, app data, clients list</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">http_names = </span><span class="p">[</span><span class="s1">&#39;app&#39;</span><span class="p">,</span> <span class="s1">&#39;settings&#39;</span><span class="p">,</span> <span class="s1">&#39;response&#39;</span><span class="p">,</span> <span class="s1">&#39;request&#39;</span><span class="p">,</span> <span class="s1">&#39;next&#39;</span><span class="p">,</span> <span class="s1">&#39;params&#39;</span><span class="p">,</span> <span class="s1">&#39;send&#39;</span><span class="p">,</span> <span class="s1">&#39;render&#39;</span><span class="p">,</span> <span class="s1">&#39;redirect&#39;</span><span class="p">]</span></pre></div> </td> </tr> <tr id="section-20"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-20">&#182;</a> </div> <p>TODO: app data, clients list, join</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">ws_names = </span><span class="p">[</span><span class="s1">&#39;app&#39;</span><span class="p">,</span> <span class="s1">&#39;io&#39;</span><span class="p">,</span> <span class="s1">&#39;settings&#39;</span><span class="p">,</span> <span class="s1">&#39;socket&#39;</span><span class="p">,</span> <span class="s1">&#39;id&#39;</span><span class="p">,</span> <span class="s1">&#39;params&#39;</span><span class="p">,</span> <span class="s1">&#39;client&#39;</span><span class="p">,</span> <span class="s1">&#39;emit&#39;</span><span class="p">,</span> <span class="s1">&#39;broadcast&#39;</span><span class="p">]</span>
<span class="nv">postrender_names = </span><span class="p">[</span><span class="s1">&#39;window&#39;</span><span class="p">,</span> <span class="s1">&#39;$&#39;</span><span class="p">]</span>
@@ -119,6 +119,12 @@
<span class="nv">css = </span><span class="nb">String</span><span class="p">(</span><span class="nx">v</span><span class="p">)</span>
<span class="nx">routes</span><span class="p">.</span><span class="nx">push</span> <span class="nv">verb: </span><span class="s1">&#39;get&#39;</span><span class="p">,</span> <span class="nv">path: </span><span class="nx">k</span><span class="p">,</span> <span class="nv">handler: </span><span class="nx">css</span><span class="p">,</span> <span class="nv">contentType: </span><span class="s1">&#39;css&#39;</span>
+ <span class="nv">root_locals.stylus = </span><span class="nf">(obj) -&gt;</span>
+ <span class="k">for</span> <span class="nx">k</span><span class="p">,</span> <span class="nx">v</span> <span class="k">of</span> <span class="nx">obj</span>
+ <span class="nv">css = </span><span class="nx">require</span><span class="p">(</span><span class="s1">&#39;stylus&#39;</span><span class="p">).</span><span class="nx">render</span> <span class="nx">v</span><span class="p">,</span> <span class="nv">filename: </span><span class="nx">k</span><span class="p">,</span> <span class="nf">(err, css) -&gt;</span>
+ <span class="k">throw</span> <span class="nx">err</span> <span class="k">if</span> <span class="nx">err</span>
+ <span class="nx">routes</span><span class="p">.</span><span class="nx">push</span> <span class="nv">verb: </span><span class="s1">&#39;get&#39;</span><span class="p">,</span> <span class="nv">path: </span><span class="nx">k</span><span class="p">,</span> <span class="nv">handler: </span><span class="nx">css</span><span class="p">,</span> <span class="nv">contentType: </span><span class="s1">&#39;css&#39;</span>
+
<span class="nv">root_locals.helper = </span><span class="nf">(obj) -&gt;</span>
<span class="k">for</span> <span class="nx">k</span><span class="p">,</span> <span class="nx">v</span> <span class="k">of</span> <span class="nx">obj</span>
<span class="nx">helpers_names</span><span class="p">.</span><span class="nx">push</span> <span class="nx">k</span>
View
8 src/zappa.coffee
@@ -110,7 +110,7 @@ zappa.app = ->
# TODO: route?, error
root_names = ['zappa', 'express', 'app', 'io', 'requiring', 'get', 'post', 'put', 'del', 'at',
'helper', 'def', 'view', 'set', 'use', 'configure', 'include', 'shared', 'client', 'coffee', 'js', 'css',
- 'enable', 'disable', 'settings', 'postrender']
+ 'stylus', 'enable', 'disable', 'settings', 'postrender']
# TODO: session, cookies, app data, clients list
http_names = ['app', 'settings', 'response', 'request', 'next', 'params', 'send', 'render', 'redirect']
@@ -190,6 +190,12 @@ zappa.app = ->
css = String(v)
routes.push verb: 'get', path: k, handler: css, contentType: 'css'
+ root_locals.stylus = (obj) ->
+ for k, v of obj
+ css = require('stylus').render v, filename: k, (err, css) ->
+ throw err if err
+ routes.push verb: 'get', path: k, handler: css, contentType: 'css'
+
root_locals.helper = (obj) ->
for k, v of obj
helpers_names.push k
View
2  tests/tester.coffee
@@ -1,4 +1,4 @@
-zappa = require 'zappa'
+zappa = require '../src/zappa'
assert = require 'assert'
class exports.Tester
View
2  tests/tester.js
@@ -1,6 +1,6 @@
(function() {
var assert, zappa;
- zappa = require('zappa');
+ zappa = require('../src/zappa');
assert = require('assert');
exports.Tester = (function() {
function Tester(func) {
View
28 tests/tests.coffee
@@ -82,4 +82,32 @@ module.exports =
'''
headers = 'Content-Type': 'text/css'
body = 'font-family: sans-serif;'
+ t.response {url: '/index.css'}, {headers, body}
+
+ stylus: ->
+ t = new Tester ->
+ stylus '/index.css': '''
+ border-radius()
+ -webkit-border-radius arguments
+ -moz-border-radius arguments
+ border-radius arguments
+
+ body
+ font 12px Helvetica, Arial, sans-serif
+
+ a.button
+ border-radius 5px
+ '''
+ headers = 'Content-Type': 'text/css'
+ body = '''
+ body {
+ font: 12px Helvetica, Arial, sans-serif;
+ }
+ a.button {
+ -webkit-border-radius: 5px;
+ -moz-border-radius: 5px;
+ border-radius: 5px;
+ }
+
+ '''
t.response {url: '/index.css'}, {headers, body}
View
18 tests/tests.js
@@ -203,6 +203,24 @@
headers: headers,
body: body
});
+ },
+ stylus: function() {
+ var body, headers, t;
+ t = new Tester(function() {
+ return stylus({
+ '/index.css': 'border-radius()\n -webkit-border-radius arguments \n -moz-border-radius arguments \n border-radius arguments \n\nbody\n font 12px Helvetica, Arial, sans-serif \n\na.button\n border-radius 5px'
+ });
+ });
+ headers = {
+ 'Content-Type': 'text/css'
+ };
+ body = 'body {\n font: 12px Helvetica, Arial, sans-serif;\n}\na.button {\n -webkit-border-radius: 5px;\n -moz-border-radius: 5px;\n border-radius: 5px;\n}\n';
+ return t.response({
+ url: '/index.css'
+ }, {
+ headers: headers,
+ body: body
+ });
}
};
}).call(this);
Please sign in to comment.
Something went wrong with that request. Please try again.