Permalink
Browse files

Started new docs

  • Loading branch information...
1 parent 02e32a7 commit 29641ae16a7da479a6b6b6c28c6c7328a2ac709f @tj tj committed Jul 6, 2010
Showing with 197 additions and 65 deletions.
  1. +4 −3 Makefile
  2. +41 −20 docs/api.html
  3. +15 −0 docs/executable.md
  4. +10 −15 docs/index.1
  5. +44 −13 docs/index.html
  6. +7 −13 docs/index.md
  7. +3 −0 docs/layout/foot.html
  8. +35 −0 docs/layout/head.html
  9. +38 −1 docs/migrate.html
View
@@ -17,13 +17,14 @@ docs/api.html: lib/express/*.js
%.1: %.md
@echo "... $< -> $@"
- @ronn -r --pipe $< > $@
+ @ronn -r --pipe $< > $@ &
%.html: %.md
@echo "... $< -> $@"
@ronn -5 --pipe --fragment $< \
- | sed 's/NAME/Express/g' \
- > $@
+ | cat docs/layout/head.html - docs/layout/foot.html \
+ | sed 's/NAME/Express/g' \
+ > $@ &
docclean:
rm -f docs/*.{1,html}
View
@@ -304,7 +304,7 @@
</tr>
<tr class="code">
<td class="docs">
-<p>Inherit from <code>connect.Server</code>.</p>
+<p>Inherit from <code>connect.Server</code>.</p>
</td>
<td class="code">
<pre><code><span class="variable">sys</span>.<span class="variable">inherits</span>(<span class="class">Server</span>, <span class="variable">connect</span>.<span class="class">Server</span>);</code></pre>
@@ -514,13 +514,13 @@
<span class="keyword">if</span> (<span class="variable">collection</span>) {
<span class="keyword">var</span> <span class="variable">name</span> = <span class="variable">options</span>.<span class="variable">as</span> || <span class="variable">view</span>.<span class="variable">split</span>(<span class="string">'.'</span>)[<span class="number integer">0</span>],
<span class="variable">len</span> = <span class="variable">collection</span>.<span class="variable">length</span>;
- <span class="variable">options</span>.<span class="variable">locals</span> = <span class="variable">options</span>.<span class="variable">locals</span> || {};
- <span class="variable">options</span>.<span class="variable">locals</span>.<span class="variable">collectionLength</span> = <span class="variable">len</span>;
+ <span class="keyword">var</span> <span class="variable">locals</span> = <span class="variable">options</span>.<span class="variable">locals</span> = <span class="variable">options</span>.<span class="variable">locals</span> || {};
+ <span class="variable">locals</span>.<span class="variable">collectionLength</span> = <span class="variable">len</span>;
<span class="keyword">return</span> <span class="variable">collection</span>.<span class="variable">map</span>(<span class="keyword">function</span>(<span class="variable">val</span>, <span class="variable">i</span>){
- <span class="variable">options</span>[<span class="variable">name</span>] = <span class="variable">val</span>;
- <span class="variable">options</span>.<span class="variable">locals</span>.<span class="variable">firstInCollection</span> = <span class="variable">i</span> === <span class="number integer">0</span>;
- <span class="variable">options</span>.<span class="variable">locals</span>.<span class="variable">indexInCollection</span> = <span class="variable">i</span>;
- <span class="variable">options</span>.<span class="variable">locals</span>.<span class="variable">lastInCollection</span> = <span class="variable">i</span> === <span class="variable">len</span> - <span class="number integer">1</span>;
+ <span class="variable">locals</span>[<span class="variable">name</span>] = <span class="variable">val</span>;
+ <span class="variable">locals</span>.<span class="variable">firstInCollection</span> = <span class="variable">i</span> === <span class="number integer">0</span>;
+ <span class="variable">locals</span>.<span class="variable">indexInCollection</span> = <span class="variable">i</span>;
+ <span class="variable">locals</span>.<span class="variable">lastInCollection</span> = <span class="variable">i</span> === <span class="variable">len</span> - <span class="number integer">1</span>;
<span class="keyword">return</span> <span class="this">this</span>.<span class="variable">render</span>(<span class="variable">view</span>, <span class="variable">options</span>);
}, <span class="this">this</span>).<span class="variable">join</span>(<span class="string">''</span>);
} <span class="keyword">else</span> {
@@ -543,17 +543,19 @@
<li><p><strong>param</strong>: <em>Function</em> fn</p></li>
<li><p><strong>api</strong>: <em>public</em></p></li>
</ul>
+/p>
+"
</td>
<td class="code">
<pre><code><span class="variable">http</span>.<span class="class">ServerResponse</span>.<span class="variable">prototype</span>.<span class="variable">render</span> = <span class="keyword">function</span>(<span class="variable">view</span>, <span class="variable">options</span>, <span class="variable">fn</span>){
<span class="variable">options</span> = <span class="variable">options</span> || {};
<span class="comment">// Defaults</span>
<span class="keyword">var</span> <span class="variable">self</span> = <span class="this">this</span>,
- <span class="variable">root</span> = <span class="variable">options</span>.<span class="variable">root</span> || <span class="this">this</span>.<span class="variable">app</span>.<span class="variable">set</span>(<span class="string">'views'</span>) || <span class="variable">process</span>.<span class="variable">cwd</span>() + <span class="string">'/views'</span>,
- <span class="variable">path</span> = <span class="variable">root</span> + <span class="string">'/'</span> + <span class="variable">view</span>,
<span class="variable">ext</span> = <span class="variable">extname</span>(<span class="variable">view</span>),
+ <span class="variable">partial</span> = <span class="variable">options</span>.<span class="variable">partial</span>,
+ <span class="variable">root</span> = <span class="variable">options</span>.<span class="variable">root</span> || <span class="this">this</span>.<span class="variable">app</span>.<span class="variable">set</span>(<span class="string">'views'</span>) || <span class="variable">process</span>.<span class="variable">cwd</span>() + <span class="string">'/views'</span>,
<span class="variable">layout</span> = <span class="variable">options</span>.<span class="variable">layout</span> === <span class="variable">undefined</span> ? <span class="variable">true</span> : <span class="variable">options</span>.<span class="variable">layout</span>,
<span class="variable">layout</span> = <span class="variable">layout</span> === <span class="variable">true</span>
? <span class="string">'layout'</span> + <span class="variable">ext</span>
@@ -570,6 +572,9 @@
<span class="variable">root</span> += <span class="string">'/partials'</span>;
}
+ <span class="comment">// View path</span>
+ <span class="keyword">var</span> <span class="variable">path</span> = <span class="variable">root</span> + <span class="string">'/'</span> + <span class="variable">view</span>;
+
<span class="comment">// Send response</span>
<span class="keyword">function</span> <span class="variable">send</span>(<span class="variable">str</span>) {
<span class="variable">self</span>.<span class="variable">writeHead</span>(<span class="number integer">200</span>, {
@@ -582,20 +587,36 @@
<span class="comment">// Pass filename to the engine</span>
<span class="variable">options</span>.<span class="variable">filename</span> = <span class="variable">path</span>;
+ <span class="keyword">function</span> <span class="variable">error</span>(<span class="variable">err</span>) {
+ <span class="keyword">if</span> (<span class="variable">fn</span>) {
+ <span class="variable">fn</span>(<span class="variable">err</span>);
+ } <span class="keyword">else</span> {
+ <span class="keyword">throw</span> <span class="variable">err</span>;
+ }
+ }
+
<span class="comment">// Render</span>
<span class="variable">fs</span>.<span class="variable">readFile</span>(<span class="variable">path</span>, <span class="string">'utf8'</span>, <span class="keyword">function</span>(<span class="variable">err</span>, <span class="variable">str</span>){
- <span class="comment">// TODO: error handling</span>
- <span class="keyword">var</span> <span class="variable">engine</span> = <span class="variable">cache</span>[<span class="variable">ext</span>] || (<span class="variable">cache</span>[<span class="variable">ext</span>] = <span class="variable">require</span>(<span class="variable">ext</span>.<span class="variable">substr</span>(<span class="number integer">1</span>)));
- <span class="variable">str</span> = <span class="variable">engine</span>.<span class="variable">render</span>(<span class="variable">str</span>, <span class="variable">options</span>);
- <span class="keyword">if</span> (<span class="variable">layout</span>) {
- <span class="variable">options</span>.<span class="variable">locals</span> = <span class="variable">options</span>.<span class="variable">locals</span> || {};
- <span class="variable">options</span>.<span class="variable">layout</span> = <span class="variable">false</span>;
- <span class="variable">options</span>.<span class="variable">locals</span>.<span class="variable">body</span> = <span class="variable">str</span>;
- <span class="variable">self</span>.<span class="variable">render</span>(<span class="variable">layout</span>, <span class="variable">options</span>);
- } <span class="keyword">else</span> <span class="keyword">if</span> (<span class="variable">fn</span>) {
- <span class="variable">fn</span>(<span class="keyword">null</span>, <span class="variable">str</span>);
+ <span class="keyword">if</span> (<span class="variable">err</span>) {
+ <span class="variable">error</span>(<span class="variable">err</span>);
} <span class="keyword">else</span> {
- <span class="variable">send</span>(<span class="variable">str</span>);
+ <span class="keyword">var</span> <span class="variable">engine</span> = <span class="variable">cache</span>[<span class="variable">ext</span>] || (<span class="variable">cache</span>[<span class="variable">ext</span>] = <span class="variable">require</span>(<span class="variable">ext</span>.<span class="variable">substr</span>(<span class="number integer">1</span>)));
+ <span class="keyword">try</span> {
+ <span class="variable">str</span> = <span class="variable">engine</span>.<span class="variable">render</span>(<span class="variable">str</span>, <span class="variable">options</span>);
+ } <span class="keyword">catch</span> (<span class="variable">err</span>) {
+ <span class="variable">error</span>(<span class="variable">err</span>);
+ }
+ <span class="keyword">if</span> (<span class="variable">layout</span>) {
+ <span class="variable">options</span>.<span class="variable">layout</span> = <span class="variable">false</span>;
+ <span class="variable">options</span>.<span class="variable">locals</span>.<span class="variable">body</span> = <span class="variable">str</span>;
+ <span class="variable">self</span>.<span class="variable">render</span>(<span class="variable">layout</span>, <span class="variable">options</span>);
+ } <span class="keyword">else</span> <span class="keyword">if</span> (<span class="variable">partial</span>) {
+ <span class="keyword">return</span> <span class="variable">str</span>;
+ } <span class="keyword">else</span> <span class="keyword">if</span> (<span class="variable">fn</span>) {
+ <span class="variable">fn</span>(<span class="keyword">null</span>, <span class="variable">str</span>);
+ } <span class="keyword">else</span> {
+ <span class="variable">send</span>(<span class="variable">str</span>);
+ }
}
});
};
View
@@ -0,0 +1,15 @@
+express(1) -- node web framework
+========================================
+
+## Synopsis
+
+ express [-h|--help] [PATH]
+
+## Description
+
+Express is a high performance Sinatra-inspired web framework.
+
+## Executable Options
+
+ -h, --help Display help information
+
View
@@ -1,27 +1,22 @@
.\" generated with Ronn/v0.6.6
.\" http://github.com/rtomayko/ronn/
.
-.TH "EXPRESS" "1" "July 2010" "" ""
+.TH "INDEX" "" "July 2010" "" ""
.
-.SH "NAME"
-\fBexpress\fR \- node web framework
+.SH "Express"
+Express is a \fIhigh performance\fR Sinatra \fIhttp://sinatrarb\.com\fR inspired web framework for nodejs \fIhttp://nodejs\.org\fR\.
.
-.SH "Synopsis"
+.IP "" 4
.
.nf
-express [\-h|\-\-help] [PATH]
-.
-.fi
-.
-.SH "Description"
-Express is a high performance Sinatra\-inspired web framework\.
-.
-.SH "Executable Options"
-.
-.nf
+var app = express\.createServer();
-\-h, \-\-help Display help information
+app\.get(\'/\', function(req, res){
+ res\.send(\'Hello World\');
+});
.
.fi
+.
+.IP "" 0
View
@@ -1,19 +1,50 @@
-<div class='mp'>
-<h2 id='Express'>Express</h2>
-<p><code>express</code> - node web framework</p>
+<html>
+ <head>
+ <title>Express - node web framework</title>
+ <style>
+ body {
+ margin: 0;
+ font: 14px/1.2 "Lucida Grande", "Helvetica Nueue", Arial, sans-serif;
+ text-align: center;
+ }
+ #header {
+ padding: 15px 40px;
+ border-bottom: 1px solid #EDEBC9;
+ background: #FFFAE5 url(http://www.sencha.com/favicon.ico) no-repeat 15px 50%;
+ text-align: left;
+ }
+ #container {
+ margin: 0 auto;
+ padding: 15px 40px;
+ width: 900px;
+ text-align: left;
+ }
+ h2 {
+ font-size: 30px;
+ }
+ pre {
+ margin: 20px;
+ padding: 20px;
+ border: 1px solid #eee;
+ color: #222;
+ }
+ </style>
+ </head>
+ <body>
+ <div id="header"><strong>Sencha</strong> labs</div>
+ <div id="container"><div class='mp'>
+<h2 id="Express">Express</h2>
-<h2 id="Synopsis">Synopsis</h2>
+<p>Express is a <em>high performance</em> <a href="http://sinatrarb.com">Sinatra</a> inspired web framework for <a href="http://nodejs.org">nodejs</a>.</p>
-<pre><code>express [-h|--help] [PATH]
-</code></pre>
-
-<h2 id="Description">Description</h2>
-
-<p>Express is a high performance Sinatra-inspired web framework.</p>
-
-<h2 id="Executable-Options">Executable Options</h2>
+<pre><code>var app = express.createServer();
-<pre><code>-h, --help Display help information
+app.get('/', function(req, res){
+ res.send('Hello World');
+});
</code></pre>
</div>
+ </div>
+ </body>
+</html>
View
@@ -1,15 +1,9 @@
-express(1) -- node web framework
-========================================
+## Express
-## Synopsis
-
- express [-h|--help] [PATH]
-
-## Description
-
-Express is a high performance Sinatra-inspired web framework.
-
-## Executable Options
-
- -h, --help Display help information
+Express is a _high performance_ [Sinatra](http://sinatrarb.com) inspired web framework for [nodejs](http://nodejs.org).
+ var app = express.createServer();
+
+ app.get('/', function(req, res){
+ res.send('Hello World');
+ });
@@ -0,0 +1,3 @@
+ </div>
+ </body>
+</html>
View
@@ -0,0 +1,35 @@
+<html>
+ <head>
+ <title>Express - node web framework</title>
+ <style>
+ body {
+ margin: 0;
+ font: 14px/1.2 "Lucida Grande", "Helvetica Nueue", Arial, sans-serif;
+ text-align: center;
+ }
+ #header {
+ padding: 15px 40px;
+ border-bottom: 1px solid #EDEBC9;
+ background: #FFFAE5 url(http://www.sencha.com/favicon.ico) no-repeat 15px 50%;
+ text-align: left;
+ }
+ #container {
+ margin: 0 auto;
+ padding: 15px 40px;
+ width: 900px;
+ text-align: left;
+ }
+ h2 {
+ font-size: 30px;
+ }
+ pre {
+ margin: 20px;
+ padding: 20px;
+ border: 1px solid #eee;
+ color: #222;
+ }
+ </style>
+ </head>
+ <body>
+ <div id="header"><strong>Sencha</strong> labs</div>
+ <div id="container">
View
@@ -1,6 +1,43 @@
-<div class='mp'>
+<html>
+ <head>
+ <title>Express - node web framework</title>
+ <style>
+ body {
+ margin: 0;
+ font: 14px/1.2 "Lucida Grande", "Helvetica Nueue", Arial, sans-serif;
+ text-align: center;
+ }
+ #header {
+ padding: 15px 40px;
+ border-bottom: 1px solid #EDEBC9;
+ background: #FFFAE5 url(http://www.sencha.com/favicon.ico) no-repeat 15px 50%;
+ text-align: left;
+ }
+ #container {
+ margin: 0 auto;
+ padding: 15px 40px;
+ width: 900px;
+ text-align: left;
+ }
+ h2 {
+ font-size: 30px;
+ }
+ pre {
+ margin: 20px;
+ padding: 20px;
+ border: 1px solid #eee;
+ color: #222;
+ }
+ </style>
+ </head>
+ <body>
+ <div id="header"><strong>Sencha</strong> labs</div>
+ <div id="container"><div class='mp'>
<h2 id="Migration-Guide">Migration Guide</h2>
<p>todo</p>
</div>
+ </div>
+ </body>
+</html>

0 comments on commit 29641ae

Please sign in to comment.