Toggling menus
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent 3a7d5a0 · Browse files · 13 files·+673 added−349 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
13 files+673 added−349 removed
- other:+673 added−349 removed
Provenance
- Commit
9719a24- Tree
8f273f3- Author
Tj Holowaychuk <tj@vision-media.ca>- Committer
Tj Holowaychuk <tj@vision-media.ca>- Parent
3a7d5a0
13 files changed+673 added−349 removed
modified:docs/layout/head.html+17 added
1234567858 unmodified lines67686970717273747576777871 unmodified lines15015115215315415515615715815916016116216316416516616716816914 unmodified lines<html> <head> <title>Express - node web framework</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <style> #tagline { margin-left: 75px; margin-bottom: 30px;58 unmodified lines ul li { margin: 0; padding: 2px 0; list-style: square; } ul li ul { margin: 0; padding-left: 12px; }
.sect { margin-left: 40px; }
71 unmodified lines background: rgba(0,0,0,0.1); -webkit-box-shadow: 1px 1px 1px rgba(0,0,0,0.4); -moz-box-shadow: 1px 1px 1px rgba(0,0,0,0.4); } </style> <script> $(function(){ $('.section').hide(); $('.toggle, a.section-title').toggle(function(){ $(this).siblings('ul').fadeIn(300); return false; }, function(){ $(this).siblings('ul').fadeOut(300); return false; }); }); </script> </head> <body> <a href='http://github.com/visionmedia/express'> <img alt='Fork me on GitHub' id='ribbon' src='http://s3.amazonaws.com/github/ribbons/forkme_right_white_ffffff.png' /> 14 unmodified linesmodified:docs/api.html+365 added-285 removed
158 unmodified lines159 </p>160 </td>161 <td class="code">162 <pre><code><span class="variable">require</span>(<span class="string">'./view'</span>);163-<span class="variable">require</span>(<span class="string">'./request'</span>);163 <span class="variable">require</span>(<span class="string">'./response'</span>);164+<span class="variable">require</span>(<span class="string">'./request'</span>);165 </code></pre>166 </td>167 </tr><tr class="filename"><td><h2 id="lib/express/request.js"><a href="#">request</a></h2></td><td>lib/express/request.js</td></tr><tr class="code">168 <td class="docs">7 unmodified lines176 </td>177 </tr>178 <tr class="code">179 <td class="docs">180+<p>Default flash formatters.</p>181+182+<ul><li><p><strong>type</strong>: <em>Object</em></p></li></ul>183+</td>184+<td class="code">185+<pre><code><span class="keyword">var</span> <span class="variable">flashFormatters</span> = <span class="variable">exports</span>.<span class="variable">flashFormatters</span> = {186+ <span class="variable">s</span>: <span class="keyword">function</span>(<span class="variable">val</span>){187+ <span class="keyword">return</span> <span class="class">String</span>(<span class="variable">val</span>);188+ }189+};</code></pre>190+</td>191+</tr>192+<tr class="code">193+<td class="docs">194 <p>Return request header or optional default.</p>195 196 <h2>Examples</h2>197 126 unmodified lines324 325 req.flash();326 // => { error: ['email delivery failed'], info: [] }</code></pre>327 328+<h2>Formatting</h2>329+330+<p>Flash notifications also support arbitrary formatting support.331+For example you may pass variable arguments to <code>req.flash()</code>332+and use the %s specifier to be replaced by the associated argument:</p>333+334+<pre><code>req.flash('info', 'email has been sent to %s.', userName);</code></pre>335+336+<p>To add custom formatters use the <code>exports.flashFormatters</code> object.</p>337+338 <h2></h2>339 340 <ul><li><p><strong>param</strong>: <em>String</em> type</p></li><li><p><strong>param</strong>: <em>String</em> msg</p></li><li><p><strong>return</strong>: <em>Array | Object | Number</em> </p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>341 </td>342 <td class="code">343 <pre><code><span class="variable">http</span>.<span class="class">IncomingMessage</span>.<span class="variable">prototype</span>.<span class="variable">flash</span> = <span class="keyword">function</span>(<span class="variable">type</span>, <span class="variable">msg</span>){344 <span class="keyword">var</span> <span class="variable">msgs</span> = <span class="this">this</span>.<span class="variable">session</span>.<span class="variable">flash</span> = <span class="this">this</span>.<span class="variable">session</span>.<span class="variable">flash</span> || {};345 <span class="keyword">if</span> (<span class="variable">type</span> &<span class="variable">amp</span>;&<span class="variable">amp</span>; <span class="variable">msg</span>) {346+ <span class="keyword">var</span> <span class="variable">i</span> = <span class="number integer">2</span>,347+ <span class="variable">args</span> = <span class="variable">arguments</span>,348+ <span class="variable">formatters</span> = <span class="this">this</span>.<span class="variable">app</span>.<span class="variable">flashFormatters</span> || {};349+ <span class="variable">formatters</span>.<span class="variable">__proto__</span> = <span class="variable">flashFormatters</span>;350 <span class="variable">msg</span> = <span class="variable">utils</span>.<span class="variable">miniMarkdown</span>(<span class="variable">utils</span>.<span class="variable">htmlEscape</span>(<span class="variable">msg</span>));351+ <span class="variable">msg</span> = <span class="variable">msg</span>.<span class="variable">replace</span>(<span class="regexp">/%([a-zA-Z])/g</span>, <span class="keyword">function</span>(<span class="variable">_</span>, <span class="variable">format</span>){352+ <span class="keyword">var</span> <span class="variable">formatter</span> = <span class="variable">formatters</span>[<span class="variable">format</span>];353+ <span class="keyword">if</span> (<span class="variable">formatter</span>) <span class="keyword">return</span> <span class="variable">formatter</span>(<span class="variable">args</span>[<span class="variable">i</span>++]);354+ });355 <span class="keyword">return</span> (<span class="variable">msgs</span>[<span class="variable">type</span>] = <span class="variable">msgs</span>[<span class="variable">type</span>] || []).<span class="variable">push</span>(<span class="variable">msg</span>);356 } <span class="keyword">else</span> <span class="keyword">if</span> (<span class="variable">type</span>) {357 <span class="keyword">var</span> <span class="variable">arr</span> = <span class="variable">msgs</span>[<span class="variable">type</span>];358 <span class="keyword">delete</span> <span class="variable">msgs</span>[<span class="variable">type</span>];22 unmodified lines381 <td class="code">382 <pre><code><span class="variable">http</span>.<span class="class">IncomingMessage</span>.<span class="variable">prototype</span>.<span class="variable">__defineGetter__</span>(<span class="string">'isXMLHttpRequest'</span>, <span class="variable">isxhr</span>);383 <span class="variable">http</span>.<span class="class">IncomingMessage</span>.<span class="variable">prototype</span>.<span class="variable">__defineGetter__</span>(<span class="string">'xhr'</span>, <span class="variable">isxhr</span>);</code></pre>384 </td>385+</tr><tr class="filename"><td><h2 id="lib/express/response.js"><a href="#">response</a></h2></td><td>lib/express/response.js</td></tr><tr class="code">386+<td class="docs">387+<p>Module dependencies.388+ </p>389+</td>390+<td class="code">391+<pre><code><span class="keyword">var</span> <span class="variable">fs</span> = <span class="variable">require</span>(<span class="string">'fs'</span>),392+ <span class="variable">http</span> = <span class="variable">require</span>(<span class="string">'http'</span>),393+ <span class="variable">path</span> = <span class="variable">require</span>(<span class="string">'path'</span>),394+ <span class="variable">utils</span> = <span class="variable">require</span>(<span class="string">'connect/utils'</span>),395+ <span class="variable">mime</span> = <span class="variable">require</span>(<span class="string">'connect/utils'</span>).<span class="variable">mime</span>,396+ <span class="class">Buffer</span> = <span class="variable">require</span>(<span class="string">'buffer'</span>).<span class="class">Buffer</span>;</code></pre>397+</td>398+</tr>399+<tr class="code">400+<td class="docs">401+<p>Header fields supporting multiple values.</p>402+403+<ul><li><p><strong>type</strong>: <em>Array</em></p></li></ul>404+</td>405+<td class="code">406+<pre><code><span class="keyword">var</span> <span class="variable">multiple</span> = [<span class="string">'Set-Cookie'</span>];</code></pre>407+</td>408+</tr>409+<tr class="code">410+<td class="docs">411+<p>Send a response with the given <code>body</code> and optional <code>headers</code> and <code>status</code> code.</p>412+413+<h2>Examples</h2>414+415+<pre><code>res.send();416+res.send(new Buffer('wahoo'));417+res.send({ some: 'json' });418+res.send('<p>some html</p>');419+res.send('Sorry, cant find that', 404);420+res.send('text', { 'Content-Type': 'text/plain' }, 201);421+res.send(404);</code></pre>422+423+<h2></h2>424+425+<ul><li><p><strong>param</strong>: <em>String | Object | Number | Buffer</em> body or status</p></li><li><p><strong>param</strong>: <em>Object | Number</em> headers or status</p></li><li><p><strong>param</strong>: <em>Number</em> status</p></li><li><p><strong>return</strong>: <em>ServerResponse</em> </p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>426+</td>427+<td class="code">428+<pre><code><span class="variable">http</span>.<span class="class">ServerResponse</span>.<span class="variable">prototype</span>.<span class="variable">send</span> = <span class="keyword">function</span>(<span class="variable">body</span>, <span class="variable">headers</span>, <span class="variable">status</span>){429+ <span class="comment">// Allow status as second arg</span>430+ <span class="keyword">if</span> (<span class="keyword">typeof</span> <span class="variable">headers</span> === <span class="string">'number'</span>) {431+ <span class="variable">status</span> = <span class="variable">headers</span>,432+ <span class="variable">headers</span> = <span class="keyword">null</span>;433+ }434+435+ <span class="comment">// Defaults</span>436+ <span class="variable">status</span> = <span class="variable">status</span> || <span class="number integer">200</span>;437+438+ <span class="comment">// Allow 0 args as 204</span>439+ <span class="keyword">if</span> (!<span class="variable">arguments</span>.<span class="variable">length</span>) {440+ <span class="variable">body</span> = <span class="variable">status</span> = <span class="number integer">204</span>;441+ }442+443+ <span class="comment">// Determine content type</span>444+ <span class="keyword">switch</span> (<span class="keyword">typeof</span> <span class="variable">body</span>) {445+ <span class="keyword">case</span> <span class="string">'number'</span>:446+ <span class="keyword">if</span> (!<span class="this">this</span>.<span class="variable">headers</span>[<span class="string">'Content-Type'</span>]) {447+ <span class="this">this</span>.<span class="variable">contentType</span>(<span class="string">'.txt'</span>);448+ }449+ <span class="variable">body</span> = <span class="variable">http</span>.<span class="class">STATUS_CODES</span>[<span class="variable">status</span> = <span class="variable">body</span>];450+ <span class="keyword">break</span>;451+ <span class="keyword">case</span> <span class="string">'string'</span>:452+ <span class="keyword">if</span> (!<span class="this">this</span>.<span class="variable">headers</span>[<span class="string">'Content-Type'</span>]) {453+ <span class="this">this</span>.<span class="variable">contentType</span>(<span class="string">'.html'</span>);454+ }455+ <span class="keyword">break</span>;456+ <span class="keyword">case</span> <span class="string">'object'</span>:457+ <span class="keyword">if</span> (<span class="variable">body</span> <span class="variable">instanceof</span> <span class="class">Buffer</span>) {458+ <span class="keyword">if</span> (!<span class="this">this</span>.<span class="variable">headers</span>[<span class="string">'Content-Type'</span>]) {459+ <span class="this">this</span>.<span class="variable">contentType</span>(<span class="string">'.bin'</span>);460+ }461+ } <span class="keyword">else</span> {462+ <span class="keyword">if</span> (!<span class="this">this</span>.<span class="variable">headers</span>[<span class="string">'Content-Type'</span>]) {463+ <span class="this">this</span>.<span class="variable">contentType</span>(<span class="string">'.json'</span>);464+ }465+ <span class="variable">body</span> = <span class="class">JSON</span>.<span class="variable">stringify</span>(<span class="variable">body</span>);466+ }467+ <span class="keyword">break</span>;468+ }469+470+ <span class="comment">// Populate Content-Length</span>471+ <span class="keyword">if</span> (!<span class="this">this</span>.<span class="variable">headers</span>[<span class="string">'Content-Length'</span>]) {472+ <span class="this">this</span>.<span class="variable">header</span>(<span class="string">'Content-Length'</span>, <span class="variable">body</span> <span class="variable">instanceof</span> <span class="class">Buffer</span>473+ ? <span class="variable">body</span>.<span class="variable">length</span>474+ : <span class="class">Buffer</span>.<span class="variable">byteLength</span>(<span class="variable">body</span>));475+ }476+477+ <span class="comment">// Merge headers passed</span>478+ <span class="keyword">if</span> (<span class="variable">headers</span>) {479+ <span class="keyword">var</span> <span class="variable">fields</span> = <span class="class">Object</span>.<span class="variable">keys</span>(<span class="variable">headers</span>);480+ <span class="keyword">for</span> (<span class="keyword">var</span> <span class="variable">i</span> = <span class="number integer">0</span>, <span class="variable">len</span> = <span class="variable">fields</span>.<span class="variable">length</span>; <span class="variable">i</span> &<span class="variable">lt</span>; <span class="variable">len</span>; ++<span class="variable">i</span>) {481+ <span class="keyword">var</span> <span class="variable">field</span> = <span class="variable">fields</span>[<span class="variable">i</span>];482+ <span class="this">this</span>.<span class="variable">header</span>(<span class="variable">field</span>, <span class="variable">headers</span>[<span class="variable">field</span>]);483+ }484+ }485+486+ <span class="comment">// Strip irrelevant headers</span>487+ <span class="keyword">if</span> (<span class="number integer">204</span> === <span class="variable">status</span>) {488+ <span class="keyword">delete</span> <span class="this">this</span>.<span class="variable">headers</span>[<span class="string">'Content-Type'</span>];489+ <span class="keyword">delete</span> <span class="this">this</span>.<span class="variable">headers</span>[<span class="string">'Content-Length'</span>];490+ }491+492+ <span class="comment">// Respond</span>493+ <span class="this">this</span>.<span class="variable">writeHead</span>(<span class="variable">status</span>, <span class="this">this</span>.<span class="variable">headers</span>);494+ <span class="this">this</span>.<span class="variable">end</span>(<span class="variable">body</span>);495+};</code></pre>496+</td>497+</tr>498+<tr class="code">499+<td class="docs">500+<p>Transfer the file at the given <code>path</code>. Automatically sets 501+the <em>Content-Type</em> response header via <code>res.contentType()</code>. </p>502+503+<p>The given callback <code>fn</code> is invoked when an error occurs,504+passing it as the first argument, or when the file is transferred,505+passing the path as the second argument.</p>506+507+<h2></h2>508+509+<ul><li><p><strong>param</strong>: <em>String</em> path</p></li><li><p><strong>param</strong>: <em>Function</em> fn</p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>510+</td>511+<td class="code">512+<pre><code><span class="variable">http</span>.<span class="class">ServerResponse</span>.<span class="variable">prototype</span>.<span class="variable">sendfile</span> = <span class="keyword">function</span>(<span class="variable">path</span>, <span class="variable">fn</span>){513+ <span class="keyword">var</span> <span class="variable">self</span> = <span class="this">this</span>;514+ <span class="variable">fs</span>.<span class="variable">readFile</span>(<span class="variable">path</span>, <span class="keyword">function</span>(<span class="variable">err</span>, <span class="variable">buf</span>){515+ <span class="keyword">if</span> (<span class="variable">err</span>) {516+ <span class="keyword">if</span> (<span class="variable">fn</span>) {517+ <span class="variable">fn</span>(<span class="variable">err</span>, <span class="variable">path</span>);518+ } <span class="keyword">else</span> {519+ <span class="variable">self</span>.<span class="variable">req</span>.<span class="variable">next</span>(<span class="variable">err</span>);520+ }521+ } <span class="keyword">else</span> {522+ <span class="variable">self</span>.<span class="variable">contentType</span>(<span class="variable">path</span>);523+ <span class="variable">self</span>.<span class="variable">send</span>(<span class="variable">buf</span>);524+ <span class="variable">fn</span> &<span class="variable">amp</span>;&<span class="variable">amp</span>; <span class="variable">fn</span>(<span class="keyword">null</span>, <span class="variable">path</span>);525+ }526+ });527+};</code></pre>528+</td>529+</tr>530+<tr class="code">531+<td class="docs">532+<p>Set <em>Content-Type</em> response header passed through <code>mime.type()</code>.</p>533+534+<h2>Examples</h2>535+536+<pre><code>var filename = 'path/to/image.png';537+res.contentType(filename);538+// res.headers['Content-Type'] is now "image/png"</code></pre>539+540+<h2></h2>541+542+<ul><li><p><strong>param</strong>: <em>String</em> type</p></li><li><p><strong>return</strong>: <em>String</em> the resolved mime type</p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>543+</td>544+<td class="code">545+<pre><code><span class="variable">http</span>.<span class="class">ServerResponse</span>.<span class="variable">prototype</span>.<span class="variable">contentType</span> = <span class="keyword">function</span>(<span class="variable">type</span>){546+ <span class="keyword">return</span> <span class="this">this</span>.<span class="variable">header</span>(<span class="string">'Content-Type'</span>, <span class="variable">mime</span>.<span class="variable">type</span>(<span class="variable">type</span>));547+};</code></pre>548+</td>549+</tr>550+<tr class="code">551+<td class="docs">552+<p>Set <em>Content-Disposition</em> header to <em>attachment</em> with optional <code>filename</code>.</p>553+554+<h2></h2>555+556+<ul><li><p><strong>param</strong>: <em>String</em> filename</p></li><li><p><strong>return</strong>: <em>ServerResponse</em> </p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>557+</td>558+<td class="code">559+<pre><code><span class="variable">http</span>.<span class="class">ServerResponse</span>.<span class="variable">prototype</span>.<span class="variable">attachment</span> = <span class="keyword">function</span>(<span class="variable">filename</span>){560+ <span class="this">this</span>.<span class="variable">header</span>(<span class="string">'Content-Disposition'</span>, <span class="variable">filename</span>561+ ? <span class="string">'attachment; filename="'</span> + <span class="variable">path</span>.<span class="variable">basename</span>(<span class="variable">filename</span>) + <span class="string">'"'</span>562+ : <span class="string">'attachment'</span>);563+ <span class="keyword">return</span> <span class="this">this</span>;564+};</code></pre>565+</td>566+</tr>567+<tr class="code">568+<td class="docs">569+<p>Transfer the file at the given <code>path</code>, with optional 570+<code>filename</code> as an attachment. Once transferred, or if an571+error occurs <code>fn</code> is called with the error and path.</p>572+573+<h2></h2>574+575+<ul><li><p><strong>param</strong>: <em>String</em> path</p></li><li><p><strong>param</strong>: <em>String</em> filename</p></li><li><p><strong>param</strong>: <em>Function</em> fn</p></li><li><p><strong>return</strong>: <em>Type</em> </p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>576+</td>577+<td class="code">578+<pre><code><span class="variable">http</span>.<span class="class">ServerResponse</span>.<span class="variable">prototype</span>.<span class="variable">download</span> = <span class="keyword">function</span>(<span class="variable">path</span>, <span class="variable">filename</span>, <span class="variable">fn</span>){579+ <span class="this">this</span>.<span class="variable">attachment</span>(<span class="variable">filename</span> || <span class="variable">path</span>).<span class="variable">sendfile</span>(<span class="variable">path</span>, <span class="variable">fn</span>);580+};</code></pre>581+</td>582+</tr>583+<tr class="code">584+<td class="docs">585+<p>Set or get response header <code>name</code> with optional <code>val</code>.</p>586+587+<p>Headers that may be set multiple times (as indicated by the <code>multiple</code> array)588+can be called with a value several times, for example:</p>589+590+<p> res.header('Set-Cookie', '...');591+ res.header('Set-Cookie', '...');</p>592+593+<h2></h2>594+595+<ul><li><p><strong>param</strong>: <em>String</em> name</p></li><li><p><strong>param</strong>: <em>String</em> val</p></li><li><p><strong>return</strong>: <em>String</em> </p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>596+</td>597+<td class="code">598+<pre><code><span class="variable">http</span>.<span class="class">ServerResponse</span>.<span class="variable">prototype</span>.<span class="variable">header</span> = <span class="keyword">function</span>(<span class="variable">name</span>, <span class="variable">val</span>){599+ <span class="keyword">if</span> (<span class="variable">val</span> === <span class="variable">undefined</span>) {600+ <span class="keyword">return</span> <span class="this">this</span>.<span class="variable">headers</span>[<span class="variable">name</span>];601+ } <span class="keyword">else</span> {602+ <span class="keyword">if</span> (<span class="this">this</span>.<span class="variable">headers</span>[<span class="variable">name</span>] &<span class="variable">amp</span>;&<span class="variable">amp</span>; ~<span class="variable">multiple</span>.<span class="variable">indexOf</span>(<span class="variable">name</span>)) {603+ <span class="keyword">return</span> <span class="this">this</span>.<span class="variable">headers</span>[<span class="variable">name</span>] += <span class="string">'\r\n'</span> + <span class="variable">name</span> + <span class="string">': '</span> + <span class="variable">val</span>;604+ } <span class="keyword">else</span> {605+ <span class="keyword">return</span> <span class="this">this</span>.<span class="variable">headers</span>[<span class="variable">name</span>] = <span class="variable">val</span>;606+ }607+ }608+};</code></pre>609+</td>610+</tr>611+<tr class="code">612+<td class="docs">613+<p>Clear cookie <code>name</code>.</p>614+615+<h2></h2>616+617+<ul><li><p><strong>param</strong>: <em>String</em> name</p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>618+</td>619+<td class="code">620+<pre><code><span class="variable">http</span>.<span class="class">ServerResponse</span>.<span class="variable">prototype</span>.<span class="variable">clearCookie</span> = <span class="keyword">function</span>(<span class="variable">name</span>){621+ <span class="this">this</span>.<span class="variable">cookie</span>(<span class="variable">name</span>, <span class="string">''</span>, { <span class="variable">expires</span>: <span class="keyword">new</span> <span class="class">Date</span>(<span class="number integer">1</span>) });622+};</code></pre>623+</td>624+</tr>625+<tr class="code">626+<td class="docs">627+<p>Set cookie <code>name</code> to <code>val</code>.</p>628+629+<h2>Examples</h2>630+631+<p> // "Remember Me" for 15 minutes632+ res.cookie('rememberme', '1', { expires: new Date(Date.now() + 900000), httpOnly: true });</p>633+634+<h2></h2>635+636+<ul><li><p><strong>param</strong>: <em>String</em> name</p></li><li><p><strong>param</strong>: <em>String</em> val</p></li><li><p><strong>param</strong>: <em>Options</em> options</p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>637+</td>638+<td class="code">639+<pre><code><span class="variable">http</span>.<span class="class">ServerResponse</span>.<span class="variable">prototype</span>.<span class="variable">cookie</span> = <span class="keyword">function</span>(<span class="variable">name</span>, <span class="variable">val</span>, <span class="variable">options</span>){640+ <span class="keyword">var</span> <span class="variable">cookie</span> = <span class="variable">utils</span>.<span class="variable">serializeCookie</span>(<span class="variable">name</span>, <span class="variable">val</span>, <span class="variable">options</span>);641+ <span class="this">this</span>.<span class="variable">header</span>(<span class="string">'Set-Cookie'</span>, <span class="variable">cookie</span>);642+};</code></pre>643+</td>644+</tr>645+<tr class="code">646+<td class="docs">647+<p>Redirect to the given <code>url</code> with optional response <code>status</code>648+defauling to 302.</p>649+650+<p>The given <code>url</code> can also be the name of a mapped url, for651+example by default express supports "back" which redirects652+to the <em>Referrer</em> or <em>Referer</em> headers or the application's653+"home" setting. Express also supports "home" out of the box,654+which can be set via <code>app.set('home', '/blog');</code>, and defaults655+to '/'.</p>656+657+<h2>Redirect Mapping</h2>658+659+<p> To extend the redirect mapping capabilities that Express provides,660+ we may use the <code>app.redirect()</code> method:</p>661+662+<pre><code>app.redirect('google', 'http://google.com');</code></pre>663+664+<p> Now in a route we may call:</p>665+666+<pre><code>res.redirect('google');</code></pre>667+668+<p> We may also map dynamic redirects:</p>669+670+<pre><code> app.redirect('comments', function(req, res){671+ return '/post/' + req.params.id + '/comments';672+ });</code></pre>673+674+<p> So now we may do the following, and the redirect will dynamically adjust to675+ the context of the request. If we called this route with <em>GET /post/12</em> our676+ redirect <em>Location</em> would be <em>/post/12/comments</em>.</p>677+678+<pre><code> app.get('/post/:id', function(req, res){679+ res.redirect('comments');680+ });</code></pre>681+682+<h2></h2>683+684+<ul><li><p><strong>param</strong>: <em>String</em> url</p></li><li><p><strong>param</strong>: <em>Number</em> code</p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>685+</td>686+<td class="code">687+<pre><code><span class="variable">http</span>.<span class="class">ServerResponse</span>.<span class="variable">prototype</span>.<span class="variable">redirect</span> = <span class="keyword">function</span>(<span class="variable">url</span>, <span class="variable">status</span>){688+ <span class="keyword">var</span> <span class="variable">basePath</span> = <span class="this">this</span>.<span class="variable">app</span>.<span class="variable">set</span>(<span class="string">'home'</span>) || <span class="string">'/'</span>;689+690+ <span class="comment">// Setup redirect map</span>691+ <span class="keyword">var</span> <span class="variable">map</span> = {692+ <span class="variable">back</span>: <span class="this">this</span>.<span class="variable">req</span>.<span class="variable">headers</span>.<span class="variable">referrer</span> || <span class="this">this</span>.<span class="variable">req</span>.<span class="variable">headers</span>.<span class="variable">referer</span> || <span class="variable">basePath</span>,693+ <span class="variable">home</span>: <span class="variable">basePath</span>694+ };695+696+ <span class="comment">// Support custom redirect map</span>697+ <span class="variable">map</span>.<span class="variable">__proto__</span> = <span class="this">this</span>.<span class="variable">app</span>.<span class="variable">redirects</span>;698+699+ <span class="comment">// Attempt mapped redirect</span>700+ <span class="keyword">var</span> <span class="variable">mapped</span> = <span class="keyword">typeof</span> <span class="variable">map</span>[<span class="variable">url</span>] === <span class="string">'function'</span>701+ ? <span class="variable">map</span>[<span class="variable">url</span>](<span class="this">this</span>.<span class="variable">req</span>, <span class="this">this</span>)702+ : <span class="variable">map</span>[<span class="variable">url</span>];703+704+ <span class="comment">// Perform redirect</span>705+ <span class="variable">url</span> = <span class="variable">mapped</span> || <span class="variable">url</span>;706+707+ <span class="comment">// Respond</span>708+ <span class="this">this</span>.<span class="variable">send</span>(<span class="string">'Redirecting to '</span> + <span class="variable">url</span>, {709+ <span class="string">'Content-Type'</span>: <span class="string">'text/plain'</span>,710+ <span class="string">'Location'</span>: <span class="variable">url</span>711+ }, <span class="variable">status</span> || <span class="number integer">302</span>);712+};713+</code></pre>714+</td>715 </tr><tr class="filename"><td><h2 id="lib/express/server.js"><a href="#">server</a></h2></td><td>lib/express/server.js</td></tr><tr class="code">716 <td class="docs">717 <p>Module dependencies.718 </p>330 unmodified lines1049 <span class="keyword">return</span> <span class="variable">arguments</span>.<span class="variable">callee</span>;1050 })(<span class="string">'get'</span>)(<span class="string">'post'</span>)(<span class="string">'put'</span>)(<span class="string">'del'</span>);1051 </code></pre>1052 </td>691-</tr><tr class="filename"><td><h2 id="lib/express/response.js"><a href="#">response</a></h2></td><td>lib/express/response.js</td></tr><tr class="code">692-<td class="docs">693-<p>Module dependencies.694- </p>695-</td>696-<td class="code">697-<pre><code><span class="keyword">var</span> <span class="variable">fs</span> = <span class="variable">require</span>(<span class="string">'fs'</span>),698- <span class="variable">http</span> = <span class="variable">require</span>(<span class="string">'http'</span>),699- <span class="variable">path</span> = <span class="variable">require</span>(<span class="string">'path'</span>),700- <span class="variable">utils</span> = <span class="variable">require</span>(<span class="string">'connect/utils'</span>),701- <span class="variable">mime</span> = <span class="variable">require</span>(<span class="string">'connect/utils'</span>).<span class="variable">mime</span>,702- <span class="class">Buffer</span> = <span class="variable">require</span>(<span class="string">'buffer'</span>).<span class="class">Buffer</span>;</code></pre>703-</td>704-</tr>705-<tr class="code">706-<td class="docs">707-<p>Header fields supporting multiple values.</p>708-709-<ul><li><p><strong>type</strong>: <em>Array</em></p></li></ul>710-</td>711-<td class="code">712-<pre><code><span class="keyword">var</span> <span class="variable">multiple</span> = [<span class="string">'Set-Cookie'</span>];</code></pre>713-</td>714-</tr>715-<tr class="code">716-<td class="docs">717-<p>Send a response with the given <code>body</code> and optional <code>headers</code> and <code>status</code> code.</p>718-719-<h2>Examples</h2>720-721-<pre><code>res.send(new Buffer('wahoo'));722-res.send({ some: 'json' });723-res.send('<p>some html</p>');724-res.send('Sorry, cant find that', 404);725-res.send('text', { 'Content-Type': 'text/plain' }, 201);726-res.send(404);</code></pre>727-728-<h2></h2>729-730-<ul><li><p><strong>param</strong>: <em>String | Object | Number | Buffer</em> body or status</p></li><li><p><strong>param</strong>: <em>Object | Number</em> headers or status</p></li><li><p><strong>param</strong>: <em>Number</em> status</p></li><li><p><strong>return</strong>: <em>ServerResponse</em> </p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>731-</td>732-<td class="code">733-<pre><code><span class="variable">http</span>.<span class="class">ServerResponse</span>.<span class="variable">prototype</span>.<span class="variable">send</span> = <span class="keyword">function</span>(<span class="variable">body</span>, <span class="variable">headers</span>, <span class="variable">status</span>){734- <span class="comment">// Allow status as second arg</span>735- <span class="keyword">if</span> (<span class="keyword">typeof</span> <span class="variable">headers</span> === <span class="string">'number'</span>) {736- <span class="variable">status</span> = <span class="variable">headers</span>,737- <span class="variable">headers</span> = <span class="keyword">null</span>;738- }739-740- <span class="comment">// Defaults</span>741- <span class="variable">status</span> = <span class="variable">status</span> || <span class="number integer">200</span>;742-743- <span class="comment">// Determine content type</span>744- <span class="keyword">switch</span> (<span class="keyword">typeof</span> <span class="variable">body</span>) {745- <span class="keyword">case</span> <span class="string">'number'</span>:746- <span class="keyword">if</span> (!<span class="this">this</span>.<span class="variable">headers</span>[<span class="string">'Content-Type'</span>]) {747- <span class="this">this</span>.<span class="variable">contentType</span>(<span class="string">'.txt'</span>);748- }749- <span class="variable">body</span> = <span class="variable">http</span>.<span class="class">STATUS_CODES</span>[<span class="variable">status</span> = <span class="variable">body</span>];750- <span class="keyword">break</span>;751- <span class="keyword">case</span> <span class="string">'string'</span>:752- <span class="keyword">if</span> (!<span class="this">this</span>.<span class="variable">headers</span>[<span class="string">'Content-Type'</span>]) {753- <span class="this">this</span>.<span class="variable">contentType</span>(<span class="string">'.html'</span>);754- }755- <span class="keyword">break</span>;756- <span class="keyword">case</span> <span class="string">'object'</span>:757- <span class="keyword">if</span> (<span class="variable">body</span> <span class="variable">instanceof</span> <span class="class">Buffer</span>) {758- <span class="keyword">if</span> (!<span class="this">this</span>.<span class="variable">headers</span>[<span class="string">'Content-Type'</span>]) {759- <span class="this">this</span>.<span class="variable">contentType</span>(<span class="string">'.bin'</span>);760- }761- } <span class="keyword">else</span> {762- <span class="keyword">if</span> (!<span class="this">this</span>.<span class="variable">headers</span>[<span class="string">'Content-Type'</span>]) {763- <span class="this">this</span>.<span class="variable">contentType</span>(<span class="string">'.json'</span>);764- }765- <span class="variable">body</span> = <span class="class">JSON</span>.<span class="variable">stringify</span>(<span class="variable">body</span>);766- }767- <span class="keyword">break</span>;768- }769-770- <span class="comment">// Populate Content-Length</span>771- <span class="keyword">if</span> (!<span class="this">this</span>.<span class="variable">headers</span>[<span class="string">'Content-Length'</span>]) {772- <span class="this">this</span>.<span class="variable">header</span>(<span class="string">'Content-Length'</span>, <span class="variable">body</span> <span class="variable">instanceof</span> <span class="class">Buffer</span>773- ? <span class="variable">body</span>.<span class="variable">length</span>774- : <span class="class">Buffer</span>.<span class="variable">byteLength</span>(<span class="variable">body</span>));775- }776-777- <span class="comment">// Merge headers passed</span>778- <span class="keyword">if</span> (<span class="variable">headers</span>) {779- <span class="keyword">var</span> <span class="variable">fields</span> = <span class="class">Object</span>.<span class="variable">keys</span>(<span class="variable">headers</span>);780- <span class="keyword">for</span> (<span class="keyword">var</span> <span class="variable">i</span> = <span class="number integer">0</span>, <span class="variable">len</span> = <span class="variable">fields</span>.<span class="variable">length</span>; <span class="variable">i</span> &<span class="variable">lt</span>; <span class="variable">len</span>; ++<span class="variable">i</span>) {781- <span class="keyword">var</span> <span class="variable">field</span> = <span class="variable">fields</span>[<span class="variable">i</span>];782- <span class="this">this</span>.<span class="variable">header</span>(<span class="variable">field</span>, <span class="variable">headers</span>[<span class="variable">field</span>]);783- }784- }785-786- <span class="comment">// Respond</span>787- <span class="this">this</span>.<span class="variable">writeHead</span>(<span class="variable">status</span>, <span class="this">this</span>.<span class="variable">headers</span>);788- <span class="this">this</span>.<span class="variable">end</span>(<span class="variable">body</span>);789-};</code></pre>790-</td>791-</tr>792-<tr class="code">793-<td class="docs">794-<p>Transfer the file at the given <code>path</code>. Automatically sets 795-the <em>Content-Type</em> response header via <code>res.contentType()</code>. </p>796-797-<p>The given callback <code>fn</code> is invoked when an error occurs,798-passing it as the first argument, or when the file is transferred,799-passing the path as the second argument.</p>800-801-<h2></h2>802-803-<ul><li><p><strong>param</strong>: <em>String</em> path</p></li><li><p><strong>param</strong>: <em>Function</em> fn</p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>804-</td>805-<td class="code">806-<pre><code><span class="variable">http</span>.<span class="class">ServerResponse</span>.<span class="variable">prototype</span>.<span class="variable">sendfile</span> = <span class="keyword">function</span>(<span class="variable">path</span>, <span class="variable">fn</span>){807- <span class="keyword">var</span> <span class="variable">self</span> = <span class="this">this</span>;808- <span class="variable">fs</span>.<span class="variable">readFile</span>(<span class="variable">path</span>, <span class="keyword">function</span>(<span class="variable">err</span>, <span class="variable">buf</span>){809- <span class="keyword">if</span> (<span class="variable">err</span>) {810- <span class="keyword">if</span> (<span class="variable">fn</span>) {811- <span class="variable">fn</span>(<span class="variable">err</span>, <span class="variable">path</span>);812- } <span class="keyword">else</span> {813- <span class="variable">self</span>.<span class="variable">req</span>.<span class="variable">next</span>(<span class="variable">err</span>);814- }815- } <span class="keyword">else</span> {816- <span class="variable">self</span>.<span class="variable">contentType</span>(<span class="variable">path</span>);817- <span class="variable">self</span>.<span class="variable">send</span>(<span class="variable">buf</span>);818- <span class="variable">fn</span> &<span class="variable">amp</span>;&<span class="variable">amp</span>; <span class="variable">fn</span>(<span class="keyword">null</span>, <span class="variable">path</span>);819- }820- });821-};</code></pre>822-</td>823-</tr>824-<tr class="code">825-<td class="docs">826-<p>Set <em>Content-Type</em> response header passed through <code>mime.type()</code>.</p>827-828-<h2>Examples</h2>829-830-<pre><code>var filename = 'path/to/image.png';831-res.contentType(filename);832-// res.headers['Content-Type'] is now "image/png"</code></pre>833-834-<h2></h2>835-836-<ul><li><p><strong>param</strong>: <em>String</em> type</p></li><li><p><strong>return</strong>: <em>String</em> the resolved mime type</p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>837-</td>838-<td class="code">839-<pre><code><span class="variable">http</span>.<span class="class">ServerResponse</span>.<span class="variable">prototype</span>.<span class="variable">contentType</span> = <span class="keyword">function</span>(<span class="variable">type</span>){840- <span class="keyword">return</span> <span class="this">this</span>.<span class="variable">header</span>(<span class="string">'Content-Type'</span>, <span class="variable">mime</span>.<span class="variable">type</span>(<span class="variable">type</span>));841-};</code></pre>842-</td>843-</tr>844-<tr class="code">845-<td class="docs">846-<p>Set <em>Content-Disposition</em> header to <em>attachment</em> with optional <code>filename</code>.</p>847-848-<h2></h2>849-850-<ul><li><p><strong>param</strong>: <em>String</em> filename</p></li><li><p><strong>return</strong>: <em>ServerResponse</em> </p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>851-</td>852-<td class="code">853-<pre><code><span class="variable">http</span>.<span class="class">ServerResponse</span>.<span class="variable">prototype</span>.<span class="variable">attachment</span> = <span class="keyword">function</span>(<span class="variable">filename</span>){854- <span class="this">this</span>.<span class="variable">header</span>(<span class="string">'Content-Disposition'</span>, <span class="variable">filename</span>855- ? <span class="string">'attachment; filename="'</span> + <span class="variable">path</span>.<span class="variable">basename</span>(<span class="variable">filename</span>) + <span class="string">'"'</span>856- : <span class="string">'attachment'</span>);857- <span class="keyword">return</span> <span class="this">this</span>;858-};</code></pre>859-</td>860-</tr>861-<tr class="code">862-<td class="docs">863-<p>Transfer the file at the given <code>path</code>, with optional 864-<code>filename</code> as an attachment. Once transferred, or if an865-error occurs <code>fn</code> is called with the error and path.</p>866-867-<h2></h2>868-869-<ul><li><p><strong>param</strong>: <em>String</em> path</p></li><li><p><strong>param</strong>: <em>String</em> filename</p></li><li><p><strong>param</strong>: <em>Function</em> fn</p></li><li><p><strong>return</strong>: <em>Type</em> </p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>870-</td>871-<td class="code">872-<pre><code><span class="variable">http</span>.<span class="class">ServerResponse</span>.<span class="variable">prototype</span>.<span class="variable">download</span> = <span class="keyword">function</span>(<span class="variable">path</span>, <span class="variable">filename</span>, <span class="variable">fn</span>){873- <span class="this">this</span>.<span class="variable">attachment</span>(<span class="variable">filename</span> || <span class="variable">path</span>).<span class="variable">sendfile</span>(<span class="variable">path</span>, <span class="variable">fn</span>);874-};</code></pre>875-</td>876-</tr>877-<tr class="code">878-<td class="docs">879-<p>Set or get response header <code>name</code> with optional <code>val</code>.</p>880-881-<p>Headers that may be set multiple times (as indicated by the <code>multiple</code> array)882-can be called with a value several times, for example:</p>883-884-<p> res.header('Set-Cookie', '...');885- res.header('Set-Cookie', '...');</p>886-887-<h2></h2>888-889-<ul><li><p><strong>param</strong>: <em>String</em> name</p></li><li><p><strong>param</strong>: <em>String</em> val</p></li><li><p><strong>return</strong>: <em>String</em> </p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>890-</td>891-<td class="code">892-<pre><code><span class="variable">http</span>.<span class="class">ServerResponse</span>.<span class="variable">prototype</span>.<span class="variable">header</span> = <span class="keyword">function</span>(<span class="variable">name</span>, <span class="variable">val</span>){893- <span class="keyword">if</span> (<span class="variable">val</span> === <span class="variable">undefined</span>) {894- <span class="keyword">return</span> <span class="this">this</span>.<span class="variable">headers</span>[<span class="variable">name</span>];895- } <span class="keyword">else</span> {896- <span class="keyword">if</span> (<span class="this">this</span>.<span class="variable">headers</span>[<span class="variable">name</span>] &<span class="variable">amp</span>;&<span class="variable">amp</span>; ~<span class="variable">multiple</span>.<span class="variable">indexOf</span>(<span class="variable">name</span>)) {897- <span class="keyword">return</span> <span class="this">this</span>.<span class="variable">headers</span>[<span class="variable">name</span>] += <span class="string">'\r\n'</span> + <span class="variable">name</span> + <span class="string">': '</span> + <span class="variable">val</span>;898- } <span class="keyword">else</span> {899- <span class="keyword">return</span> <span class="this">this</span>.<span class="variable">headers</span>[<span class="variable">name</span>] = <span class="variable">val</span>;900- }901- }902-};</code></pre>903-</td>904-</tr>905-<tr class="code">906-<td class="docs">907-<p>Redirect to the given <code>url</code> with optional response <code>status</code>908-defauling to 302.</p>909-910-<p>The given <code>url</code> can also be the name of a mapped url, for911-example by default express supports "back" which redirects912-to the <em>Referrer</em> or <em>Referer</em> headers or the application's913-"home" setting. Express also supports "home" out of the box,914-which can be set via <code>app.set('home', '/blog');</code>, and defaults915-to '/'.</p>916-917-<h2>Redirect Mapping</h2>918-919-<p> To extend the redirect mapping capabilities that Express provides,920- we may use the <code>app.redirect()</code> method:</p>921-922-<pre><code>app.redirect('google', 'http://google.com');</code></pre>923-924-<p> Now in a route we may call:</p>925-926-<pre><code>res.redirect('google');</code></pre>927-928-<p> We may also map dynamic redirects:</p>929-930-<pre><code> app.redirect('comments', function(req, res){931- return '/post/' + req.params.id + '/comments';932- });</code></pre>933-934-<p> So now we may do the following, and the redirect will dynamically adjust to935- the context of the request. If we called this route with <em>GET /post/12</em> our936- redirect <em>Location</em> would be <em>/post/12/comments</em>.</p>937-938-<pre><code> app.get('/post/:id', function(req, res){939- res.redirect('comments');940- });</code></pre>941-942-<h2></h2>943-944-<ul><li><p><strong>param</strong>: <em>String</em> url</p></li><li><p><strong>param</strong>: <em>Number</em> code</p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>945-</td>946-<td class="code">947-<pre><code><span class="variable">http</span>.<span class="class">ServerResponse</span>.<span class="variable">prototype</span>.<span class="variable">redirect</span> = <span class="keyword">function</span>(<span class="variable">url</span>, <span class="variable">status</span>){948- <span class="keyword">var</span> <span class="variable">basePath</span> = <span class="this">this</span>.<span class="variable">app</span>.<span class="variable">set</span>(<span class="string">'home'</span>) || <span class="string">'/'</span>;949-950- <span class="comment">// Setup redirect map</span>951- <span class="keyword">var</span> <span class="variable">map</span> = {952- <span class="variable">back</span>: <span class="this">this</span>.<span class="variable">req</span>.<span class="variable">headers</span>.<span class="variable">referrer</span> || <span class="this">this</span>.<span class="variable">req</span>.<span class="variable">headers</span>.<span class="variable">referer</span> || <span class="variable">basePath</span>,953- <span class="variable">home</span>: <span class="variable">basePath</span>954- };955-956- <span class="comment">// Support custom redirect map</span>957- <span class="variable">map</span>.<span class="variable">__proto__</span> = <span class="this">this</span>.<span class="variable">app</span>.<span class="variable">redirects</span>;958-959- <span class="comment">// Attempt mapped redirect</span>960- <span class="keyword">var</span> <span class="variable">mapped</span> = <span class="keyword">typeof</span> <span class="variable">map</span>[<span class="variable">url</span>] === <span class="string">'function'</span>961- ? <span class="variable">map</span>[<span class="variable">url</span>](<span class="this">this</span>.<span class="variable">req</span>, <span class="this">this</span>)962- : <span class="variable">map</span>[<span class="variable">url</span>];963-964- <span class="comment">// Perform redirect</span>965- <span class="variable">url</span> = <span class="variable">mapped</span> || <span class="variable">url</span>;966- <span class="this">this</span>.<span class="variable">send</span>(<span class="string">'Redirecting to '</span> + <span class="variable">url</span>, {967- <span class="string">'Content-Type'</span>: <span class="string">'text/plain'</span>,968- <span class="string">'Location'</span>: <span class="variable">url</span>969- }, <span class="variable">status</span> || <span class="number integer">302</span>);970-};971-</code></pre>972-</td>1053 </tr><tr class="filename"><td><h2 id="lib/express/utils.js"><a href="#">utils</a></h2></td><td>lib/express/utils.js</td></tr><tr class="code">1054 <td class="docs">1055 <p>Parse mini markdown implementation.1056 The following conversions are supported,175 unmodified lines1232 1233 <p> Most engines accept one or more of the following options,1234 both <em>haml</em> and <em>jade</em> accept all:</p>1235 1156-<ul><li><code>context|scope</code> Template evaluation context (<code>this</code>)</li><li><code>locals</code> Object containing local variables</li><li><code>debug</code> Output debugging information</li></ul>1236+<ul><li><code>context|scope</code> Template evaluation context (<code>this</code>)</li><li><code>locals</code> Object containing local variables</li><li><code>debug</code> Output debugging information</li><li><code>status</code> Response status code, defaults to 200</li><li><code>headers</code> Response headers object</li></ul>1237 1238 <h2></h2>1239 1240 <ul><li><p><strong>param</strong>: <em>String</em> view</p></li><li><p><strong>param</strong>: <em>Object | Function</em> options or callback function</p></li><li><p><strong>param</strong>: <em>Function</em> fn</p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>116 unmodified lines1357 <span class="keyword">return</span> <span class="variable">str</span>;1358 } <span class="keyword">else</span> <span class="keyword">if</span> (<span class="variable">fn</span>) {1359 <span class="variable">fn</span>(<span class="keyword">null</span>, <span class="variable">str</span>);1360 } <span class="keyword">else</span> {1281- <span class="variable">self</span>.<span class="variable">send</span>(<span class="variable">str</span>);1361+ <span class="variable">self</span>.<span class="variable">send</span>(<span class="variable">str</span>, <span class="variable">options</span>.<span class="variable">headers</span>, <span class="variable">options</span>.<span class="variable">status</span>);1362 }1363 };1364 </code></pre>1365 </td>2 unmodified linesmodified:docs/contrib.1+5 added-2 removed
1-.\" generated with Ronn/v0.6.62-.\" http://github.com/rtomayko/ronn/1+.\" generated with Ronn/v0.7.32+.\" http://github.com/rtomayko/ronn/tree/0.7.33 .4 .TH "CONTRIB" "" "July 2010" "" ""5 .6+.SH "NAME"7+\fBcontrib\fR8+.9 .SS "Development Dependencies"10 Express development dependencies are stored within the \fI\./support\fR directory\. To update them execute:11 .12 .IP "" 470 unmodified linesmodified:docs/contrib.html+21 added
1 <html>2 <head>3 <title>Express - node web framework</title>4+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>5 <style>6 #tagline {7 margin-left: 75px;8 margin-bottom: 30px;58 unmodified lines67 ul li {68 margin: 0;69 padding: 2px 0;70 list-style: square; }71+ ul li ul {72+ margin: 0;73+ padding-left: 12px;74+ }75 76 .sect {77 margin-left: 40px; }78 71 unmodified lines150 background: rgba(0,0,0,0.1);151 -webkit-box-shadow: 1px 1px 1px rgba(0,0,0,0.4);152 -moz-box-shadow: 1px 1px 1px rgba(0,0,0,0.4); }153 </style>154+ <script>155+ $(function(){156+ $('.section').hide();157+ $('.toggle, a.section-title').toggle(function(){158+ $(this).siblings('ul').fadeIn(300);159+ return false;160+ }, function(){161+ $(this).siblings('ul').fadeOut(300);162+ return false;163+ });164+ });165+ </script>166 </head>167 <body>168 <a href='http://github.com/visionmedia/express'> 169 <img alt='Fork me on GitHub' id='ribbon' src='http://s3.amazonaws.com/github/ribbons/forkme_right_white_ffffff.png' /> 11 unmodified lines181 <li><a href="contrib.html">Contributing</a></li>182 <li><a href="migrate.html">1.x Migration</a></li>183 </ul>184 <div class='mp'>185+<h2 id="Express">Express</h2>186+<p class="man-name">187+ <code>contrib</code>188+</p>189 <h3 id="Development-Dependencies">Development Dependencies</h3>190 191 <p>Express development dependencies are stored within the <em>./support</em> directory. To192 update them execute:</p>46 unmodified linesmodified:docs/executable.1+5 added-2 removed
1-.\" generated with Ronn/v0.6.62-.\" http://github.com/rtomayko/ronn/1+.\" generated with Ronn/v0.7.32+.\" http://github.com/rtomayko/ronn/tree/0.7.33 .4 .TH "EXECUTABLE" "" "July 2010" "" ""5 .6+.SH "NAME"7+\fBexecutable\fR8+.9 .SH "Synopsis"10 .11 .nf12 16 unmodified linesmodified:docs/executable.html+21 added
1 <html>2 <head>3 <title>Express - node web framework</title>4+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>5 <style>6 #tagline {7 margin-left: 75px;8 margin-bottom: 30px;58 unmodified lines67 ul li {68 margin: 0;69 padding: 2px 0;70 list-style: square; }71+ ul li ul {72+ margin: 0;73+ padding-left: 12px;74+ }75 76 .sect {77 margin-left: 40px; }78 71 unmodified lines150 background: rgba(0,0,0,0.1);151 -webkit-box-shadow: 1px 1px 1px rgba(0,0,0,0.4);152 -moz-box-shadow: 1px 1px 1px rgba(0,0,0,0.4); }153 </style>154+ <script>155+ $(function(){156+ $('.section').hide();157+ $('.toggle, a.section-title').toggle(function(){158+ $(this).siblings('ul').fadeIn(300);159+ return false;160+ }, function(){161+ $(this).siblings('ul').fadeOut(300);162+ return false;163+ });164+ });165+ </script>166 </head>167 <body>168 <a href='http://github.com/visionmedia/express'> 169 <img alt='Fork me on GitHub' id='ribbon' src='http://s3.amazonaws.com/github/ribbons/forkme_right_white_ffffff.png' /> 11 unmodified lines181 <li><a href="contrib.html">Contributing</a></li>182 <li><a href="migrate.html">1.x Migration</a></li>183 </ul>184 <div class='mp'>185+<h2 id="Express">Express</h2>186+<p class="man-name">187+ <code>executable</code>188+</p>189 <h2 id="Synopsis">Synopsis</h2>190 191 <pre><code>express [-h|--help] [-v|--version] [PATH]192 </code></pre>18 unmodified linesmodified:docs/guide.1+96 added-29 removed
1-.\" generated with Ronn/v0.6.62-.\" http://github.com/rtomayko/ronn/1+.\" generated with Ronn/v0.7.32+.\" http://github.com/rtomayko/ronn/tree/0.7.33 .4-.TH "GUIDE" "" "August 2010" "" ""4+.TH "GUIDE" "" "September 2010" "" ""5 .6+.SH "NAME"7+\fBguide\fR8+.9 .SS "Installation"10 curl:11 .12 .IP "" 491 unmodified lines104 105 app\.configure(function(){106 app\.set(\'views\', __dirname + \'/views\');107 app\.set(\'views\');105- // => \"\.\.\. views directory \.\.\.\"108+ // => "\.\.\. views directory \.\.\."109 110 app\.enable(\'some feature\');111 // same as app\.set(\'some feature\', true);112 62 unmodified lines175 .IP "" 4176 .177 .nf178 176-\\/user\\/([^\\/]+)\\/?179+\e/user\e/([^\e/]+)\e/?180 .181 .fi182 .183 .IP "" 04 unmodified lines188 .IP "" 4189 .190 .nf191 189-app\.get(/^\\/users?(?:\\/(\\d+)(?:\\\.\\\.(\\d+))?)?/, function(req, res){192+app\.get(/^\e/users?(?:\e/(\ed+)(?:\e\.\e\.(\ed+))?)?/, function(req, res){193 res\.send(req\.params);194 });195 .196 .fi11 unmodified lines208 [null,null]209 $ curl http://dev:3000/users210 [null,null]211 $ curl http://dev:3000/users/1209- [\"1\",null]212+ ["1",null]213 $ curl http://dev:3000/users/1\.\.15211- [\"1\",\"15\"]214+ ["1","15"]215 .216 .fi217 .218 .IP "" 04 unmodified lines223 .IP "" 4224 .225 .nf226 224- \"/user/:id\"227+ "/user/:id"228 /user/12229 227- \"/users/:id?\"230+ "/users/:id?"231 /users/5232 /users233 231- \"/files/*\"234+ "/files/*"235 /files/jquery\.js236 /files/javascripts/jquery\.js237 235- \"/file/*\.*\"238+ "/file/*\.*"239 /files/jquery\.js240 /files/javascripts/jquery\.js241 239- \"/user/:id/:operation?\"242+ "/user/:id/:operation?"243 /user/1244 /user/1/edit245 243- \"/products\.:format\"246+ "/products\.:format"247 /products\.json248 /products\.xml249 247- \"/products\.:format?\"250+ "/products\.:format?"251 /products\.json252 /products\.xml253 /products254 .25 unmodified lines280 .281 .IP "" 0282 .283 .SS "Middleware"281-The Express \fIPlugin\fR is no more! middleware via Connect \fIhttp://github\.com/extjs/Connect\fR can be passed to \fIexpress\.createServer()\fR as you would with a regular Connect server\. For example:284+The Express \fIPlugin\fR is no more! middleware via Connect \fIhttp://github\.com/senchalabs/connect\fR can be passed to \fIexpress\.createServer()\fR as you would with a regular Connect server\. For example:285 .286 .IP "" 4287 .288 .nf117 unmodified lines406 .407 .IP "" 0408 .409 .P407-Our apps could also utilize the Connect \fIerrorHandler\fR middleware to report on exceptions\. For example if we wish to output exceptions in \"development\" mode to \fIstderr\fR we can use:410+Our apps could also utilize the Connect \fIerrorHandler\fR middleware to report on exceptions\. For example if we wish to output exceptions in "development" mode to \fIstderr\fR we can use:411 .412 .IP "" 4413 .414 .nf20 unmodified lines435 .P436 The \fIerrorHandler\fR middleware also responds with \fIjson\fR if \fIAccept: application/json\fR is present, which is useful for developing apps that rely heavily on client\-side JavaScript\.437 .438 .SS "View Rendering"436-View filenames take the form \fINAME\fR\.\fIENGINE\fR, where \fIENGINE\fR is the name of the module that will be required\. For example the view \fIlayout\.ejs\fR will tell the view system to \fIrequire(\'ejs\')\fR, the module being loaded must export the method \fIexports\.render(str, options)\fR to comply with Express, however \fIapp\.register()\fR can be used to map engines to file extensions, so that for example \"foo\.html\" can be rendered by jade\.439+View filenames take the form \fINAME\fR\.\fIENGINE\fR, where \fIENGINE\fR is the name of the module that will be required\. For example the view \fIlayout\.ejs\fR will tell the view system to \fIrequire(\'ejs\')\fR, the module being loaded must export the method \fIexports\.render(str, options)\fR to comply with Express, however \fIapp\.register()\fR can be used to map engines to file extensions, so that for example "foo\.html" can be rendered by jade\.440 .441 .P442 Below is an example using Haml\.js \fIhttp://github\.com/visionmedia/haml\.js\fR to render \fIindex\.html\fR, and since we do not use \fIlayout: false\fR the rendered contents of \fIindex\.html\fR will be passed as the \fIbody\fR local variable in \fIlayout\.haml\fR\.443 .107 unmodified lines551 .552 .IP "" 0553 .554 .SS "View Partials"552-The Express view system has built\-in support for partials and collections, which are sort of \"mini\" views representing a document fragment\. For example rather than iterating in a view to display comments, we would use a partial with collection support:555+The Express view system has built\-in support for partials and collections, which are sort of "mini" views representing a document fragment\. For example rather than iterating in a view to display comments, we would use a partial with collection support:556 .557 .IP "" 4558 .559 .nf30 unmodified lines590 .591 .IP "" 0592 .593 .P591-When using the partial collection support a few \"magic\" variables are provided for free:594+When using the partial collection support a few "magic" variables are provided for free:595 .596 .IP "\(bu" 4597 \fIfirstInCollection\fR True if this is the first object598 .37 unmodified lines636 .SS "req\.accepts(type)"637 Check if the \fIAccept\fR header is present, and includes the given \fItype\fR\.638 .639 .P637-When the \fIAccept\fR header is not present \fItrue\fR is returned\. Otherwise the given \fItype\fR is matched by an exact match, and then subtypes\. You may pass the subtype such as \"html\" which is then converted internally to \"text/html\" using the mime lookup table\.640+When the \fIAccept\fR header is not present \fItrue\fR is returned\. Otherwise the given \fItype\fR is matched by an exact match, and then subtypes\. You may pass the subtype such as "html" which is then converted internally to "text/html" using the mime lookup table\.641 .642 .IP "" 4643 .644 .nf58 unmodified lines703 .fi704 .705 .IP "" 0706 .707+.P708+Flash notification message may also utilize formatters, by default only the %s string formatter is available:709+.710+.IP "" 4711+.712+.nf713+714+req\.flash(\'info\', \'email delivery to _%s_ from _%s_ failed\.\', toUser, fromUser);715+.716+.fi717+.718+.IP "" 0719+.720 .SS "req\.isXMLHttpRequest"721 Also aliased as \fIreq\.xhr\fR, this getter checks the \fIX\-Requested\-With\fR header to see if it was issued by an \fIXMLHttpRequest\fR:722 .723 .IP "" 435 unmodified lines759 .nf760 761 var filename = \'path/to/image\.png\';762 res\.contentType(filename);747- // res\.headers[\'Content\-Type\'] is now \"image/png\"763+ // res\.headers[\'Content\-Type\'] is now "image/png"764 .765 .fi766 .767 .IP "" 0768 .769 .SS "res\.attachment([filename])"754-Sets the \fIContent\-Disposition\fR response header to \"attachment\", with optional \fIfilename\fR\.770+Sets the \fIContent\-Disposition\fR response header to "attachment", with optional \fIfilename\fR\.771 .772 .IP "" 4773 .774 .nf54 unmodified lines829 .IP "" 4830 .831 .nf832 833+ res\.send(); // 204834 res\.send(new Buffer(\'wahoo\'));835 res\.send({ some: \'json\' });836 res\.send(\'<p>some html</p>\');837 res\.send(\'Sorry, cant find that\', 404);24 unmodified lines862 .863 .IP "" 0864 .865 .P849-Express supports \"redirect mapping\", which by default provides \fIhome\fR, and \fIback\fR\. The \fIback\fR map checks the \fIReferrer\fR and \fIReferer\fR headers, while \fIhome\fR utilizes the \"home\" setting and defaults to \"/\"\.866+Express supports "redirect mapping", which by default provides \fIhome\fR, and \fIback\fR\. The \fIback\fR map checks the \fIReferrer\fR and \fIReferer\fR headers, while \fIhome\fR utilizes the "home" setting and defaults to "/"\.867 .868+.SS "res\.cookie(name, val[, options])"869+Sets the given cookie \fIname\fR to \fIval\fR, with \fIoptions\fR such as "httpOnly: true", "expires", "secure" etc\.870+.871+.IP "" 4872+.873+.nf874+875+// "Remember me" for 15 minutes876+res\.cookie(\'rememberme\', \'yes\', { expires: new Date(Date\.now() + 900000), httpOnly: true });877+.878+.fi879+.880+.IP "" 0881+.882+.P883+To parse incoming \fICookie\fR headers, use the \fIcookieDecoder\fR middleware, which provides the \fIreq\.cookies\fR object:884+.885+.IP "" 4886+.887+.nf888+889+app\.use(express\.cookieDecoder());890+891+app\.get(\'/\', function(req, res){892+ // use req\.cookies\.rememberme893+});894+.895+.fi896+.897+.IP "" 0898+.899+.SS "res\.clearCookie(name)"900+Clear cookie \fIname\fR by setting "expires" far in the past\.901+.902+.IP "" 4903+.904+.nf905+906+res\.clearCookie(\'rememberme\');907+.908+.fi909+.910+.IP "" 0911+.912 .SS "res\.render(view[, options[, fn]])"913 Render \fIview\fR with the given \fIoptions\fR and optional callback \fIfn\fR\. When a callback function is given a response will \fInot\fR be made automatically, however otherwise a response of \fI200\fR and \fItext/html\fR is given\.914 .915 .P7 unmodified lines923 .924 .IP "\(bu" 4925 \fIdebug\fR Output debugging information926 .927+.IP "\(bu" 4928+\fIstatus\fR Response status code, defaults to 200929+.930+.IP "\(bu" 4931+\fIheaders\fR Response headers object932+.933 .IP "" 0934 .935 .SS "res\.partial(view[, options])"936 Render \fIview\fR partial with the given \fIoptions\fR\. This method is always available to the view as a local variable\.34 unmodified lines971 .972 .IP "" 0973 .974 .P908-To change the local from \fImovie\fR to \fIvideo\fR we can use the \"as\" option:975+To change the local from \fImovie\fR to \fIvideo\fR we can use the "as" option:976 .977 .IP "" 4978 .979 .nf19 unmodified lines999 .1000 .IP "" 01001 .1002 .P936-Another alternative is to \"explode\" the properties of the collection item into pseudo globals (local variables) by using \fIas: global\fR, which again is syntactic sugar:1003+Another alternative is to "explode" the properties of the collection item into pseudo globals (local variables) by using \fIas: global\fR, which again is syntactic sugar:1004 .1005 .IP "" 41006 .1007 .nf204 unmodified lines1212 blog = express\.createServer();1213 1214 blog\.mounted(function(parent){1215 // parent is app1149- // \"this\" is blog1216+ // "this" is blog1217 });1218 1219 app\.use(blog);1220 .1 unmodified line1222 .1223 .IP "" 01224 .1225 .SS "app\.register(ext, exports)"1159-Register the given template engine \fIexports\fR as \fIext\fR\. For example we may wish to map \"\.html\" files to jade:1226+Register the given template engine \fIexports\fR as \fIext\fR\. For example we may wish to map "\.html" files to jade:1227 .1228 .IP "" 41229 .1230 .nf4 unmodified lines1235 .1236 .IP "" 01237 .1238 .P1172-This is also useful for libraries that may not match extensions correctly\. For example my haml\.js library is installed from npm as \"hamljs\" so instead of layout\.hamljs, we can register the engine as \"\.haml\":1239+This is also useful for libraries that may not match extensions correctly\. For example my haml\.js library is installed from npm as "hamljs" so instead of layout\.hamljs, we can register the engine as "\.haml":1240 .1241 .IP "" 41242 .1243 .nf73 unmodified linesmodified:docs/guide.html+88 added-27 removed
1 <html>2 <head>3 <title>Express - node web framework</title>4+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>5 <style>6 #tagline {7 margin-left: 75px;8 margin-bottom: 30px;58 unmodified lines67 ul li {68 margin: 0;69 padding: 2px 0;70 list-style: square; }71+ ul li ul {72+ margin: 0;73+ padding-left: 12px;74+ }75 76 .sect {77 margin-left: 40px; }78 71 unmodified lines150 background: rgba(0,0,0,0.1);151 -webkit-box-shadow: 1px 1px 1px rgba(0,0,0,0.4);152 -moz-box-shadow: 1px 1px 1px rgba(0,0,0,0.4); }153 </style>154+ <script>155+ $(function(){156+ $('.section').hide();157+ $('.toggle, a.section-title').toggle(function(){158+ $(this).siblings('ul').fadeIn(300);159+ return false;160+ }, function(){161+ $(this).siblings('ul').fadeOut(300);162+ return false;163+ });164+ });165+ </script>166 </head>167 <body>168 <a href='http://github.com/visionmedia/express'> 169 <img alt='Fork me on GitHub' id='ribbon' src='http://s3.amazonaws.com/github/ribbons/forkme_right_white_ffffff.png' /> 10 unmodified lines180 <li><a href="#Error-Handling">Error Handling</a></li>181 <li><a href="#View-Rendering">View Rendering</a></li>182 <li><a href="#View-Partials">View Partials</a></li>183 <li><a href="#Template-Engines">Template Engines</a></li>167-<li><a href="#req-header-key-defaultValue-">req.header()</a></li>168-<li><a href="#req-accepts-type-">req.accepts()</a></li>169-<li><a href="#req-param-name-">req.param()</a></li>170-<li><a href="#req-flash-type-msg-">req.flash()</a></li>171-<li><a href="#req-isXMLHttpRequest">req.isXMLHttpRequest</a></li>172-<li><a href="#res-header-key-val-">res.header()</a></li>173-<li><a href="#res-contentType-type-">res.contentType()</a></li>174-<li><a href="#res-attachment-filename-">res.attachment()</a></li>175-<li><a href="#res-sendfile-path-">res.sendfile()</a></li>176-<li><a href="#res-download-file-filename-">res.download()</a></li>177-<li><a href="#res-send-body-status-headers-status-status-">res.send()</a></li>178-<li><a href="#res-redirect-url-status-">res.redirect()</a></li>179-<li><a href="#res-render-view-options-fn-">res.render()</a></li>180-<li><a href="#res-partial-view-options-">res.partial()</a></li>181-<li><a href="#app-set-name-val-">app.set()</a></li>182-<li><a href="#app-enable-name-">app.enable()</a></li>183-<li><a href="#app-disable-name-">app.disable()</a></li>184-<li><a href="#app-configure-env-function-function-">app.configure()</a></li>185-<li><a href="#app-redirect-name-val-">app.redirect()</a></li>186-<li><a href="#app-error-function-">app.error()</a></li>187-<li><a href="#app-helpers-obj-">app.helpers()</a></li>188-<li><a href="#app-dynamicHelpers-obj-">app.dynamicHelpers()</a></li>189-<li><a href="#app-mounted-fn-">app.mounted()</a></li>190-<li><a href="#app-register-ext-exports-">app.register()</a></li>191-<li><a href="#app-listen-port-host-">app.listen()</a></li>184+<li><a href="#" class="toggle">+</a> <a class="section-title" href="#">Request</a><ul class="section" id="section-Request">185+<li><a href="#req-header-key-defaultValue-">header()</a></li>186+<li><a href="#req-accepts-type-">accepts()</a></li>187+<li><a href="#req-param-name-">param()</a></li>188+<li><a href="#req-flash-type-msg-">flash()</a></li>189+<li><a href="#req-isXMLHttpRequest">isXMLHttpRequest</a></li>190+</ul></li>191+<li><a href="#" class="toggle">+</a> <a class="section-title" href="#">Response</a><ul class="section" id="section-Response">192+<li><a href="#res-header-key-val-">header()</a></li>193+<li><a href="#res-contentType-type-">contentType()</a></li>194+<li><a href="#res-attachment-filename-">attachment()</a></li>195+<li><a href="#res-sendfile-path-">sendfile()</a></li>196+<li><a href="#res-download-file-filename-">download()</a></li>197+<li><a href="#res-send-body-status-headers-status-status-">send()</a></li>198+<li><a href="#res-redirect-url-status-">redirect()</a></li>199+<li><a href="#res-cookie-name-val-options-">cookie()</a></li>200+<li><a href="#res-clearCookie-name-">clearCookie()</a></li>201+<li><a href="#res-render-view-options-fn-">render()</a></li>202+<li><a href="#res-partial-view-options-">partial()</a></li>203+</ul></li>204+<li><a href="#" class="toggle">+</a> <a class="section-title" href="#">Server</a><ul class="section" id="section-Server">205+<li><a href="#app-set-name-val-">set()</a></li>206+<li><a href="#app-enable-name-">enable()</a></li>207+<li><a href="#app-disable-name-">disable()</a></li>208+<li><a href="#app-configure-env-function-function-">configure()</a></li>209+<li><a href="#app-redirect-name-val-">redirect()</a></li>210+<li><a href="#app-error-function-">error()</a></li>211+<li><a href="#app-helpers-obj-">helpers()</a></li>212+<li><a href="#app-dynamicHelpers-obj-">dynamicHelpers()</a></li>213+<li><a href="#app-mounted-fn-">mounted()</a></li>214+<li><a href="#app-register-ext-exports-">register()</a></li>215+<li><a href="#app-listen-port-host-">listen()</a></li>216+</ul></li>217 </ul>218 <a href='http://github.com/visionmedia/express' id='logo'>Express</a> 219 <p id="tagline">220 High performance, high class web development for5 unmodified lines226 <li><a href="contrib.html">Contributing</a></li>227 <li><a href="migrate.html">1.x Migration</a></li>228 </ul>229 <div class='mp'>230+<h2 id="Express">Express</h2>231+<p class="man-name">232+ <code>guide</code>233+</p>234 <h3 id="Installation">Installation</h3>235 236 <p>curl:</p>237 181 unmodified lines419 </code></pre>420 421 <h3 id="Middleware">Middleware</h3>422 394-<p>The Express <em>Plugin</em> is no more! middleware via <a href="http://github.com/extjs/Connect">Connect</a> can be423+<p>The Express <em>Plugin</em> is no more! middleware via <a href="http://github.com/senchalabs/connect">Connect</a> can be424 passed to <em>express.createServer()</em> as you would with a regular Connect server. For example:</p>425 426 <pre><code>var express = require('express');427 257 unmodified lines685 req.flash();686 // => { error: ['email delivery failed'], info: [] }687 </code></pre>688 689+<p>Flash notification message may also utilize formatters, by default only the %s string formatter is available:</p>690+691+<pre><code>req.flash('info', 'email delivery to _%s_ from _%s_ failed.', toUser, fromUser);692+</code></pre>693+694 <h3 id="req-isXMLHttpRequest">req.isXMLHttpRequest</h3>695 696 <p>Also aliased as <em>req.xhr</em>, this getter checks the <em>X-Requested-With</em> header697 to see if it was issued by an <em>XMLHttpRequest</em>:</p>63 unmodified lines761 <p>The <code>res.send()</code> method is a high level response utility allowing you to pass762 objects to respond with json, strings for html, arbitrary _Buffer_s or numbers for status763 code based responses. The following are all valid uses:</p>764 731-<pre><code> res.send(new Buffer('wahoo'));765+<pre><code> res.send(); // 204766+ res.send(new Buffer('wahoo'));767 res.send({ some: 'json' });768 res.send('<p>some html</p>');769 res.send('Sorry, cant find that', 404);770 res.send('text', { 'Content-Type': 'text/plain' }, 201);18 unmodified lines789 <p>Express supports "redirect mapping", which by default provides <em>home</em>, and <em>back</em>.790 The <em>back</em> map checks the <em>Referrer</em> and <em>Referer</em> headers, while <em>home</em> utilizes791 the "home" setting and defaults to "/".</p>792 793+<h3 id="res-cookie-name-val-options-">res.cookie(name, val[, options])</h3>794+795+<p>Sets the given cookie <em>name</em> to <em>val</em>, with <em>options</em> such as "httpOnly: true", "expires", "secure" etc.</p>796+797+<pre><code>// "Remember me" for 15 minutes 798+res.cookie('rememberme', 'yes', { expires: new Date(Date.now() + 900000), httpOnly: true });799+</code></pre>800+801+<p>To parse incoming <em>Cookie</em> headers, use the <em>cookieDecoder</em> middleware, which provides the <em>req.cookies</em> object:</p>802+803+<pre><code>app.use(express.cookieDecoder());804+805+app.get('/', function(req, res){806+ // use req.cookies.rememberme807+});808+</code></pre>809+810+<h3 id="res-clearCookie-name-">res.clearCookie(name)</h3>811+812+<p>Clear cookie <em>name</em> by setting "expires" far in the past.</p>813+814+<pre><code>res.clearCookie('rememberme');815+</code></pre>816+817 <h3 id="res-render-view-options-fn-">res.render(view[, options[, fn]])</h3>818 819 <p>Render <em>view</em> with the given <em>options</em> and optional callback <em>fn</em>.820 When a callback function is given a response will <em>not</em> be made5 unmodified lines826 <ul>827 <li><em>context|scope</em> Template evaluation context (<em>this</em>)</li>828 <li><em>locals</em> Object containing local variables</li>829 <li><em>debug</em> Output debugging information</li>830+<li><em>status</em> Response status code, defaults to 200</li>831+<li><em>headers</em> Response headers object</li>832 </ul>833 834 835 <h3 id="res-partial-view-options-">res.partial(view[, options])</h3>237 unmodified linesmodified:docs/index.1+5 added-2 removed
1-.\" generated with Ronn/v0.6.62-.\" http://github.com/rtomayko/ronn/1+.\" generated with Ronn/v0.7.32+.\" http://github.com/rtomayko/ronn/tree/0.7.33 .4 .TH "INDEX" "" "August 2010" "" ""5 .6+.SH "NAME"7+\fBindex\fR8+.9 .IP "" 410 .11 .nf12 122 unmodified linesmodified:docs/index.html+21 added
1 <html>2 <head>3 <title>Express - node web framework</title>4+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>5 <style>6 #tagline {7 margin-left: 75px;8 margin-bottom: 30px;58 unmodified lines67 ul li {68 margin: 0;69 padding: 2px 0;70 list-style: square; }71+ ul li ul {72+ margin: 0;73+ padding-left: 12px;74+ }75 76 .sect {77 margin-left: 40px; }78 71 unmodified lines150 background: rgba(0,0,0,0.1);151 -webkit-box-shadow: 1px 1px 1px rgba(0,0,0,0.4);152 -moz-box-shadow: 1px 1px 1px rgba(0,0,0,0.4); }153 </style>154+ <script>155+ $(function(){156+ $('.section').hide();157+ $('.toggle, a.section-title').toggle(function(){158+ $(this).siblings('ul').fadeIn(300);159+ return false;160+ }, function(){161+ $(this).siblings('ul').fadeOut(300);162+ return false;163+ });164+ });165+ </script>166 </head>167 <body>168 <a href='http://github.com/visionmedia/express'> 169 <img alt='Fork me on GitHub' id='ribbon' src='http://s3.amazonaws.com/github/ribbons/forkme_right_white_ffffff.png' /> 11 unmodified lines181 <li><a href="contrib.html">Contributing</a></li>182 <li><a href="migrate.html">1.x Migration</a></li>183 </ul>184 <div class='mp'>185+<h2 id="Express">Express</h2>186+<p class="man-name">187+ <code>index</code>188+</p>189 <pre><code>var app = express.createServer();190 191 app.get('/', function(req, res){192 res.send('Hello World');67 unmodified linesmodified:docs/migrate.1+5 added-2 removed
1-.\" generated with Ronn/v0.6.62-.\" http://github.com/rtomayko/ronn/1+.\" generated with Ronn/v0.7.32+.\" http://github.com/rtomayko/ronn/tree/0.7.33 .4 .TH "MIGRATE" "" "August 2010" "" ""5 .6+.SH "NAME"7+\fBmigrate\fR8+.9 .SS "Built On Connect"10 Express 1\.x is written to run on\-top of the Connect \fIhttp://extjs\.github\.com/Connect\fR middlware framework, thus the \fIPlugin\fR has been replaced by Connect\'s middleware\. By abstracting our middleware to Connect we allow additional community frameworks to develop robust, high\-level frameworks using the same technologies as Express\.11 .12 .SS "Creating Applications"335 unmodified linesmodified:docs/migrate.html+21 added
1 <html>2 <head>3 <title>Express - node web framework</title>4+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>5 <style>6 #tagline {7 margin-left: 75px;8 margin-bottom: 30px;58 unmodified lines67 ul li {68 margin: 0;69 padding: 2px 0;70 list-style: square; }71+ ul li ul {72+ margin: 0;73+ padding-left: 12px;74+ }75 76 .sect {77 margin-left: 40px; }78 71 unmodified lines150 background: rgba(0,0,0,0.1);151 -webkit-box-shadow: 1px 1px 1px rgba(0,0,0,0.4);152 -moz-box-shadow: 1px 1px 1px rgba(0,0,0,0.4); }153 </style>154+ <script>155+ $(function(){156+ $('.section').hide();157+ $('.toggle, a.section-title').toggle(function(){158+ $(this).siblings('ul').fadeIn(300);159+ return false;160+ }, function(){161+ $(this).siblings('ul').fadeOut(300);162+ return false;163+ });164+ });165+ </script>166 </head>167 <body>168 <a href='http://github.com/visionmedia/express'> 169 <img alt='Fork me on GitHub' id='ribbon' src='http://s3.amazonaws.com/github/ribbons/forkme_right_white_ffffff.png' /> 11 unmodified lines181 <li><a href="contrib.html">Contributing</a></li>182 <li><a href="migrate.html">1.x Migration</a></li>183 </ul>184 <div class='mp'>185+<h2 id="Express">Express</h2>186+<p class="man-name">187+ <code>migrate</code>188+</p>189 <h3 id="Built-On-Connect">Built On Connect</h3>190 191 <p>Express 1.x is written to run on-top of the <a href="http://extjs.github.com/Connect">Connect</a> middlware192 framework, thus the <em>Plugin</em> has been replaced by Connect's middleware. By abstracting our middleware211 unmodified linesmodified:support/toc.js+3 added
15 unmodified lines16 if (~title.indexOf('.')) {17 var parts = title.split('.'),18 recv = parts.shift(),19 method = parts.shift();20+ if (recv == 'app') recv = 'Server';21+ if (recv == 'req') recv = 'Request';22+ if (recv == 'res') recv = 'Response';23 sections[recv] = sections[recv] || [];24 sections[recv].push('<li><a href="#' + id + '">' + method + '</a></li>');25 } else {26 toc.push('<li><a href="#' + id + '">' + title + '</a></li>');20 unmodified lines