Permalink
Browse files

Merging

  • Loading branch information...
2 parents a4596b0 + 4091801 commit 0c06e0deebf277ff6ffee8b61f1230c3fff2a4fe @TrevorBurnham TrevorBurnham committed Mar 5, 2012
View
@@ -39,6 +39,7 @@ task 'test', 'Run the test suite (and re-run if anything changes)', ->
'ProductionIntegration'
'AbsoluteIntegration'
'RemoteIntegration'
+ 'CdnIntegration'
'BenchmarkDynamic'
'BenchmarkStatic'
]
View
@@ -10,7 +10,9 @@ connect-assets can:
1. Serve `.coffee` ([CoffeeScript](http://coffeescript.org)) files as compiled `.js`
1. Concatenate `.coffee` and `.js` together using [Snockets](https://github.com/TrevorBurnham/snockets)
-1. Serve `.styl` ([Stylus](http://learnboost.github.com/stylus/)) as compiled `.css` (with [nib](https://github.com/visionmedia/nib) baked in when available)
+1. Serve `.styl` ([Stylus](http://learnboost.github.com/stylus/)) as compiled `.css` with
+ - [nib](https://github.com/visionmedia/nib)
+ - [Twitter Bootstrap](https://github.com/shomeya/bootstrap-stylus)
1. Serve files with an MD5 hash suffix and use a far-future expires header for maximum efficiency
1. Avoid redundant git diffs by storing compiled `.js` and `.css` files in memory rather than writing them to the disk—except when you want them (e.g. for deployment to a CDN).
@@ -25,6 +27,7 @@ Also install any specific compilers you'll need, e.g.:
npm install coffee-script
npm install stylus
npm install nib
+ npm install bootstrap-stylus
Then add this line to your app's configuration:
View
@@ -8,6 +8,7 @@
<span class="p">{</span><span class="nx">parse</span><span class="p">}</span> <span class="o">=</span> <span class="nx">require</span> <span class="s1">&#39;url&#39;</span>
<span class="nv">libs = </span><span class="p">{}</span>
+<span class="nv">jsCompilers = </span><span class="nx">Snockets</span><span class="p">.</span><span class="nx">compilers</span>
<span class="nv">module.exports = exports = </span><span class="nf">(options = {}) -&gt;</span>
<span class="k">return</span> <span class="nx">connectAssets</span> <span class="k">if</span> <span class="nx">connectAssets</span>
@@ -24,7 +25,9 @@
<span class="nx">options</span><span class="p">.</span><span class="nx">buildsExpire</span> <span class="o">?=</span> <span class="kc">false</span>
<span class="nx">options</span><span class="p">.</span><span class="nx">detectChanges</span> <span class="o">?=</span> <span class="kc">true</span>
<span class="nx">options</span><span class="p">.</span><span class="nx">minifyBuilds</span> <span class="o">?=</span> <span class="kc">true</span>
-
+ <span class="nx">options</span><span class="p">.</span><span class="nx">pathsOnly</span> <span class="o">?=</span> <span class="kc">false</span>
+ <span class="nv">jsCompilers = </span><span class="nx">_</span><span class="p">.</span><span class="nx">extend</span> <span class="nx">jsCompilers</span><span class="p">,</span> <span class="nx">options</span><span class="p">.</span><span class="nx">jsCompilers</span> <span class="o">||</span> <span class="p">{}</span>
+
<span class="nv">connectAssets = module.exports.instance = </span><span class="k">new</span> <span class="nx">ConnectAssets</span> <span class="nx">options</span>
<span class="nx">connectAssets</span><span class="p">.</span><span class="nx">createHelpers</span> <span class="nx">options</span>
<span class="nx">connectAssets</span><span class="p">.</span><span class="nx">cache</span><span class="p">.</span><span class="nx">middleware</span>
@@ -43,15 +46,16 @@
<span class="k">if</span> <span class="nx">shortRoute</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">is</span> <span class="s1">&#39;/&#39;</span> <span class="k">then</span> <span class="nv">shortRoute = </span><span class="nx">shortRoute</span><span class="p">[</span><span class="mi">1</span><span class="p">..]</span>
<span class="k">else</span>
<span class="nv">shortRoute = </span><span class="nx">rootDir</span> <span class="o">+</span> <span class="s1">&#39;/&#39;</span> <span class="o">+</span> <span class="nx">shortRoute</span>
- <span class="k">if</span> <span class="nx">shortRoute</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">ext</span><span class="p">,</span> <span class="nx">shortRoute</span><span class="p">.</span><span class="nx">length</span> <span class="o">-</span> <span class="nx">ext</span><span class="p">.</span><span class="nx">length</span><span class="p">)</span> <span class="o">is</span> <span class="o">-</span><span class="mi">1</span>
+ <span class="k">if</span> <span class="nx">ext</span> <span class="o">and</span> <span class="nx">shortRoute</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">ext</span><span class="p">,</span> <span class="nx">shortRoute</span><span class="p">.</span><span class="nx">length</span> <span class="o">-</span> <span class="nx">ext</span><span class="p">.</span><span class="nx">length</span><span class="p">)</span> <span class="o">is</span> <span class="o">-</span><span class="mi">1</span>
<span class="nx">shortRoute</span> <span class="o">+=</span> <span class="nx">ext</span>
<span class="nx">shortRoute</span>
<span class="nv">context.css = </span><span class="p">(</span><span class="nx">route</span><span class="p">)</span> <span class="o">=&gt;</span>
<span class="nv">route = </span><span class="nx">expandRoute</span> <span class="nx">route</span><span class="p">,</span> <span class="s1">&#39;.css&#39;</span><span class="p">,</span> <span class="nx">context</span><span class="p">.</span><span class="nx">css</span><span class="p">.</span><span class="nx">root</span>
<span class="nx">unless</span> <span class="nx">route</span><span class="p">.</span><span class="nx">match</span> <span class="nx">REMOTE_PATH</span>
- <span class="nv">route = </span><span class="nx">@compileCSS</span> <span class="nx">route</span>
- <span class="s2">&quot;&lt;link rel=&#39;stylesheet&#39; href=&#39;#{@options.servePath}#{route}&#39;&gt;&quot;</span>
+ <span class="nv">route = </span><span class="nx">@options</span><span class="p">.</span><span class="nx">servePath</span> <span class="o">+</span> <span class="nx">@compileCSS</span> <span class="nx">route</span>
+ <span class="k">return</span> <span class="nx">route</span> <span class="k">if</span> <span class="nx">@options</span><span class="p">.</span><span class="nx">pathsOnly</span>
+ <span class="s2">&quot;&lt;link rel=&#39;stylesheet&#39; href=&#39;#{route}&#39;&gt;&quot;</span>
<span class="nv">context.css.root = </span><span class="s1">&#39;css&#39;</span>
<span class="nv">context.js = </span><span class="p">(</span><span class="nx">route</span><span class="p">)</span> <span class="o">=&gt;</span>
@@ -61,8 +65,10 @@
<span class="k">else</span> <span class="k">if</span> <span class="nx">srcIsRemote</span>
<span class="nv">routes = </span><span class="p">[</span><span class="s2">&quot;#{@options.src}/#{route}&quot;</span><span class="p">]</span>
<span class="k">else</span>
- <span class="nv">routes = </span><span class="nx">@compileJS</span> <span class="nx">route</span>
- <span class="p">(</span><span class="s2">&quot;&lt;script src=&#39;#{@options.servePath}#{r}&#39;&gt;&lt;/script&gt;&quot;</span> <span class="k">for</span> <span class="nx">r</span> <span class="k">in</span> <span class="nx">routes</span><span class="p">).</span><span class="nx">join</span> <span class="s1">&#39;\n&#39;</span>
+ <span class="nv">routes = </span><span class="p">(</span><span class="nx">@options</span><span class="p">.</span><span class="nx">servePath</span> <span class="o">+</span> <span class="nx">p</span> <span class="k">for</span> <span class="nx">p</span> <span class="k">in</span> <span class="nx">@compileJS</span> <span class="nx">route</span><span class="p">)</span>
+
+ <span class="k">return</span> <span class="nx">routes</span> <span class="k">if</span> <span class="nx">@options</span><span class="p">.</span><span class="nx">pathsOnly</span>
+ <span class="p">(</span><span class="s2">&quot;&lt;script src=&#39;#{r}&#39;&gt;&lt;/script&gt;&quot;</span> <span class="k">for</span> <span class="nx">r</span> <span class="k">in</span> <span class="nx">routes</span><span class="p">).</span><span class="nx">join</span> <span class="s1">&#39;\n&#39;</span>
<span class="nv">context.js.root = </span><span class="s1">&#39;js&#39;</span>
<span class="nv">context.img = </span><span class="p">(</span><span class="nx">route</span><span class="p">)</span> <span class="o">=&gt;</span>
@@ -72,8 +78,8 @@
<span class="k">else</span> <span class="k">if</span> <span class="nx">srcIsRemote</span>
<span class="nv">route = </span><span class="s2">&quot;#{@options.src}/#{route}&quot;</span>
<span class="k">else</span>
- <span class="nv">route = </span><span class="nx">@cacheImg</span> <span class="nx">route</span>
- <span class="s2">&quot;#{@options.servePath}#{route}&quot;</span>
+ <span class="nv">route = </span><span class="nx">@options</span><span class="p">.</span><span class="nx">servePath</span> <span class="o">+</span> <span class="nx">@cacheImg</span> <span class="nx">route</span>
+ <span class="nx">route</span>
<span class="nv">context.img.root = </span><span class="s1">&#39;img&#39;</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>Synchronously lookup image and return the route</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">cacheImg: </span><span class="nf">(route) -&gt;</span>
<span class="k">if</span> <span class="o">!</span><span class="nx">@options</span><span class="p">.</span><span class="nx">detectChanges</span> <span class="o">and</span> <span class="nx">@cachedRoutePaths</span><span class="p">[</span><span class="nx">route</span><span class="p">]</span>
@@ -223,19 +229,21 @@
<span class="nv">result = </span><span class="nx">js</span>
<span class="nx">libs</span><span class="p">.</span><span class="nx">stylus</span> <span class="o">or=</span> <span class="nx">require</span> <span class="s1">&#39;stylus&#39;</span>
- <span class="nx">libs</span><span class="p">.</span><span class="nx">bootstrap</span> <span class="o">or=</span> <span class="k">try</span> <span class="nx">require</span> <span class="s1">&#39;bootstrap&#39;</span> <span class="k">catch</span> <span class="nx">e</span> <span class="k">then</span> <span class="p">(</span><span class="o">-&gt;</span> <span class="o">-&gt;</span><span class="p">)</span>
+ <span class="nx">libs</span><span class="p">.</span><span class="nx">bootstrap</span> <span class="o">or=</span> <span class="k">try</span> <span class="nx">require</span> <span class="s1">&#39;bootstrap-stylus&#39;</span> <span class="k">catch</span> <span class="nx">e</span> <span class="k">then</span> <span class="p">(</span><span class="o">-&gt;</span> <span class="o">-&gt;</span><span class="p">)</span>
<span class="nx">libs</span><span class="p">.</span><span class="nx">nib</span> <span class="o">or=</span> <span class="k">try</span> <span class="nx">require</span> <span class="s1">&#39;nib&#39;</span> <span class="k">catch</span> <span class="nx">e</span> <span class="k">then</span> <span class="p">(</span><span class="o">-&gt;</span> <span class="o">-&gt;</span><span class="p">)</span>
+ <span class="nx">libs</span><span class="p">.</span><span class="nx">bootstrap</span> <span class="o">or=</span> <span class="k">try</span> <span class="nx">require</span> <span class="s1">&#39;bootstrap-stylus&#39;</span> <span class="k">catch</span> <span class="nx">e</span> <span class="k">then</span> <span class="p">(</span><span class="o">-&gt;</span> <span class="o">-&gt;</span><span class="p">)</span>
<span class="nv">options = </span><span class="nx">@optionsMap</span><span class="p">[</span><span class="nx">sourcePath</span><span class="p">]</span> <span class="o">?=</span>
<span class="nv">filename: </span><span class="nx">sourcePath</span>
<span class="nx">libs</span><span class="p">.</span><span class="nx">stylus</span><span class="p">(</span><span class="nx">source</span><span class="p">,</span> <span class="nx">options</span><span class="p">)</span>
<span class="p">.</span><span class="nx">use</span><span class="p">(</span><span class="nx">libs</span><span class="p">.</span><span class="nx">bootstrap</span><span class="p">())</span>
<span class="p">.</span><span class="nx">use</span><span class="p">(</span><span class="nx">libs</span><span class="p">.</span><span class="nx">nib</span><span class="p">())</span>
+ <span class="p">.</span><span class="nx">use</span><span class="p">(</span><span class="nx">libs</span><span class="p">.</span><span class="nx">bootstrap</span><span class="p">())</span>
<span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">&#39;compress&#39;</span><span class="p">,</span> <span class="nx">@compress</span><span class="p">)</span>
<span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">&#39;include css&#39;</span><span class="p">,</span> <span class="kc">true</span><span class="p">)</span>
<span class="p">.</span><span class="nx">render</span> <span class="nx">callback</span>
<span class="nx">result</span>
-<span class="nv">exports.jsCompilers = jsCompilers = </span><span class="nx">Snockets</span><span class="p">.</span><span class="nx">compilers</span></pre></div> </td> </tr> <tr id="section-10"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-10">&#182;</a> </div> <h2>Regexes</h2> </td> <td class="code"> <div class="highlight"><pre><span class="nv">BEFORE_DOT = </span><span class="sr">/([^.]*)(\..*)?$/</span>
+<span class="nv">exports.jsCompilers = </span><span class="nx">jsCompilers</span></pre></div> </td> </tr> <tr id="section-10"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-10">&#182;</a> </div> <h2>Regexes</h2> </td> <td class="code"> <div class="highlight"><pre><span class="nv">BEFORE_DOT = </span><span class="sr">/([^.]*)(\..*)?$/</span>
<span class="nv">EXPLICIT_PATH = </span><span class="sr">/^\/|\/\/|\w:/</span>
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -20,6 +20,7 @@
"coffee-script": "1.1.2",
"connect": "1.8.5",
"nib": "0.2.0",
+ "bootstrap-stylus": "0.2.0",
"nodeunit": "0.5.4",
"stylus": "0.22.2",
"request": "2.1.1",
Oops, something went wrong.

0 comments on commit 0c06e0d

Please sign in to comment.