xonecas.io
818
Du

dustymarkdown / commit 8bfce59

rewrote builder into a module

xonecas2011-06-02 8bfce59c5a9771d518b3fca9a6310435e23f11e0 parent 01803c9

150 files changed

This diff is too big to show in full. The first 1000 lines are below, and every file is listed with its counts.

htdocs/about.html+25−3
@@ -1,5 +1,27 @@
1-<!doctype html><!--[if lt IE 7]> <html class="no-js ie6" lang="en"> <![endif]--><!--[if IE 7]> <html class="no-js ie7" lang="en"> <![endif]--><!--[if IE 8]> <html class="no-js ie8" lang="en"> <![endif]--><!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]--><head><meta charset="utf-8"><title>Dusty Markdown</title><meta name="description" content="simple command line content manager"><meta name="author" content="@xonecas"><meta name="viewport" content="width=device-width, in …
1+<!doctype html>
2+<!--[if lt IE 7]> <html class="no-js ie6" lang="en"> <![endif]-->
3+<!--[if IE 7]> <html class="no-js ie7" lang="en"> <![endif]-->
4+<!--[if IE 8]> <html class="no-js ie8" lang="en"> <![endif]-->
5+<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
6+<head>
7+ <meta charset="utf-8">
28
3-<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with deskto …
9+ <title>Dusty Markdown</title>
10+
11+ <meta name="description" content="simple command line content manager">
12+ <meta name="author" content="@xonecas">
13+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
14+
15+ <link rel="stylesheet" href="css/style.css">
16+ <link href='http://fonts.googleapis.com/css?family=Oswald' rel='stylesheet' type='text/css'>
17+
18+</head>
19+
20+<body>
21+ <header>{header|s}</header>
22+ <section id="main">
23+ {example|s}
24+ </section>
25+</body>
26+</html>
427
5-<p>Click <a href="/">here</a> to go back.</p></section><script src="js/libs/ender.js"></script><script src="js/script.js"></script><!-- simple uniques and page requests tracker, see server.js --><script>Modernizr.localstorage || document.write('<script src="js/libs/storage.js">\x3C/script>')</script><script>var s = localStorage, key = s.getItem('key');if (key === null) { key = +new Date(); s.setItem('key', key); };$.ajax('/track?key='+key);</script></body></html>
htdocs/index.html+35−62
@@ -1,73 +1,46 @@
1-<!doctype html><!--[if lt IE 7]> <html class="no-js ie6" lang="en"> <![endif]--><!--[if IE 7]> <html class="no-js ie7" lang="en"> <![endif]--><!--[if IE 8]> <html class="no-js ie8" lang="en"> <![endif]--><!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]--><head><meta charset="utf-8"><title>Dusty Markdown</title><meta name="description" content="simple command line content manager"><meta name="author" content="@xonecas"><meta name="viewport" content="width=device-width, in …
2- <p>This project is the new content manager under <a href="http://xonecas.com">xonecas.com</a>.
3- It's very minimal and light, developer friendly. The idea
4- is that you can write the dynamic content in markdown and
5- use dust to combine static and dynamic.</p>
6-</blockquote>
1+<!doctype html>
2+<!--[if lt IE 7]> <html class="no-js ie6" lang="en"> <![endif]-->
3+<!--[if IE 7]> <html class="no-js ie7" lang="en"> <![endif]-->
4+<!--[if IE 8]> <html class="no-js ie8" lang="en"> <![endif]-->
5+<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
6+<head>
7+ <meta charset="utf-8">
78
8-<h2>This app is only possible thanks to:</h2>
9+ <title>Dusty Markdown</title>
910
10-<ul>
11-<li>HTML5 Boilerplate</li>
12-<li>Dust.js</li>
13-<li>Markdown</li>
14-</ul>
11+ <meta name="description" content="simple command line content manager">
12+ <meta name="author" content="@xonecas">
13+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
1514
16-<h3>The gist:</h3>
15+ <link rel="stylesheet" href="css/style.css">
16+ <link href='http://fonts.googleapis.com/css?family=Oswald' rel='stylesheet' type='text/css'>
1717
18-<p>So the build.js file grabs the source files you write and
19-compiles them into static assets (@TODO add compression
20-and concatenation). The way it knows what to do with your
21-files is because it expects a specific folder/naming
22-convention.</p>
2318
24-<p>This app is the example of that convention:</p>
19+ <script src="js/libs/modernizr.js"></script>
2520
26-<pre><code> root/
27- build.js // compiler
28- server.js // static asset provider
21+</head>
2922
30- templates/ // home to your pages/views
31- index.dust // root of the app
32- pagename.dust // pagename becomes
33- // http://server/pagename
23+<body>
24+ <header>
25+ {header|s}
26+ </header>
27+ <section id="main" class="center">
28+ {about|s}
29+ </section>
30+ <footer class="center">
31+ </footer>
3432
35- markdown/ // where your content goes
36- keyname.md // you can refer to this in
37- // your template using {keyname}
38- section_keyname.md // you can refer to several
39- // keynames using {#section}
40- htdocs/ // your static content
41- ...
42- ... // organize it how you want it
43- // just remember that the .html
44- // files are created by build.js
45- // so don't edit them by hand
46-</code></pre>
4733
48-<p>The default htdocs folder is from HTML5 Boilerplate and so is
49-the static file server. One difference is that this app uses
50-Ender for the js library, but you're welcome to change it.
51-There is also a very simple unique visitors/request counter.</p>
34+ <script src="js/libs/jquery.js"></script>
35+ <script src="js/script.js"></script>
5236
53-<p>See the example page <a href="/about">here</a>.</p>
37+ <!-- simple uniques and page requests tracker, see server.js -->
38+ <script>Modernizr.localstorage || document.write('<script src="js/libs/storage.js">\x3C/script>')</script>
39+ <script>
40+ var s = localStorage, key = s.getItem('key');
41+ if (key === null) { key = +new Date(); s.setItem('key', key); };
42+ $.get('/track?key='+key);
43+ </script>
5444
55-<h2>Dependencies</h2>
56-
57-<ul>
58-<li><code>npm install connect dust node-markdown</code></li>
59-</ul>
60-
61-<h2>More docs:</h2>
62-
63-<ul>
64-<li><a href="http://h5bp.com/"><em>HTML5 Boilerplate</em> →</a></li>
65-<li><a href="http://akdubya.github.com/dustjs/"><em>Dust</em> →</a></li>
66-<li><a href="http://daringfireball.net/projects/markdown/basics"><em>Markdown</em> →</a></li>
67-</ul></section><footer class="center"><h3>Thu, 28 of April, 2011</h3>
68-
69-<p>This is an example entry so that I now it's working.</p> <h3>Thu, 28 of April, 2011</h3>
70-
71-<p>First cleaned up. Added defult pages. Things look pretty now.</p> <h3>Thu, 29 of April, 2011</h3>
72-
73-<p>Added more documentation.</p> </footer><script src="js/libs/jquery.js"></script><script src="js/script.js"></script><!-- simple uniques and page requests tracker, see server.js --><script>Modernizr.localstorage || document.write('<script src="js/libs/storage.js">\x3C/script>')</script><script>var s = localStorage, key = s.getItem('key');if (key === null) { key = +new Date(); s.setItem('key', key); };$.get('/track?key='+key);</script></body></html>
45+</body>
46+</html>
lib/build.js+135−0
@@ -0,0 +1,135 @@
1+// modules
2+var fs = require('fs'),
3+ dust = require('dust'),
4+ markdown = require("node-markdown").Markdown;
5+
6+// helper functions
7+// read files from directory
8+function fetch (path, ext, cb) {
9+ var readFiles = [];
10+
11+ fs.readdir(path, function (err, files) {
12+ if (err) return cb(err);
13+
14+ var len = files.length;
15+
16+ !function reader (i) {
17+ var filename = files[i],
18+ re = new RegExp("\\."+ ext +"$");
19+
20+ if (i === len)
21+ return cb(null, readFiles);
22+
23+ else if (re.test(filename)) {
24+ fs.readFile(path + filename, 'utf8', function (err, src) {
25+ if (err) return cb(err);
26+
27+ readFiles.push({
28+ "name": filename,
29+ "src": src
30+ });
31+ reader(i+1);
32+ });
33+ }
34+ else
35+ reader(i+1);
36+ } (0);
37+
38+ });
39+}
40+
41+function write (path, files, cb) {
42+ var len = files.length;
43+ !function writer (i) {
44+ if (i === len)
45+ return cb(null);
46+ else {
47+ var file = files[i];
48+ fs.writeFile(path + file.name, file.src, "utf8", function (err) {
49+ if (err) return cb(err);
50+
51+ writer(i+1);
52+ });
53+ }
54+ } (0);
55+}
56+
57+function marky (cb) {
58+ // fecth mardown files
59+ fetch("./markdown/", "md", function (err, files) {
60+ if (err) return cb(err);
61+
62+ var content = {};
63+ // parse markdown
64+ files.forEach(function (file, index) {
65+ var name = file.name.replace(/\..+$/, "");
66+ content[name] = markdown(file.src);
67+ });
68+
69+ cb(null, content);
70+ });
71+}
72+
73+function dusty (content, cb) {
74+ // fecth html file templates
75+ fetch("./htdocs/", "html", function (err, files) {
76+ // compile the templates
77+ files.forEach(function (file, index) {
78+ console.log(file);
79+ var c = dust.compile(file.src, file.name);
80+ dust.loadSource(c);
81+ });
82+
83+ // dust
84+ var len = files.length;
85+ !function duster (i) {
86+ if (i === len)
87+ return cb(null, files);
88+
89+ else {
90+ var file = files[i];
91+ dust.render(file.name, content, function (err, html) {
92+ if (err) return cb(err);
93+
94+ file.src = html;
95+
96+ duster(i+1);
97+ });
98+ }
99+ } (0);
100+ });
101+}
102+
103+module.exports = function (prod, hint) {
104+ // mardown
105+ marky(function (err, content) {
106+ if (err) throw err;
107+ // dust
108+ dusty(content, function (err, htmlFiles) {
109+ if (err) throw err;
110+ // write them down
111+ write("./static/", htmlFiles, function (err) {
112+ if (err) throw err;
113+ console.log("* HTML files complete.");
114+ });
115+ });
116+ });
117+}
118+
119+ // fecth css files
120+ // compress them
121+ // write the files
122+
123+ // fecth the js files
124+ // optional jshint
125+ // minify files
126+ // concatenate in this order:
127+ // /libs/*
128+ // plugins.js
129+
130+
131+
132+
133+
134+
135+
lib/old_build.js+133−0
@@ -1,4 +1,137 @@
11
2+// modules
3+var fs = require('fs'),
4+ dust = require('dust'),
5+ markdown = require("node-markdown").Markdown;
6+
7+// helper functions
8+// read files from directory
9+function fetch (path, ext, cb) {
10+ var readFiles = [];
11+
12+ fs.readdir(path, function (err, files) {
13+ if (err) return cb(err);
14+
15+ var len = files.length;
16+
17+ !function reader (i) {
18+ if (i === len)
19+ return cb(null, readFiles);
20+
21+ var filename = files[i],
22+ re = new RegExp("\\."+ ext +"$");
23+
24+ else if (re.test(filename)) {
25+ fs.readFile(path + filename, 'utf8', function (err, src) {
26+ if (err) return cb(err);
27+
28+ readFiles.push({
29+ "name": filename,
30+ "src": src
31+ });
32+ reader(i+1);
33+ });
34+ }
35+ else
36+ reader(i+1);
37+ } (0);
38+
39+ });
40+}
41+
42+function write (path, files, cb) {
43+ var len = files.length;
44+ !function writer (i) {
45+ if (i === len)
46+ return cb(null);
47+ else {
48+ var file = files[i];
49+ fs.writeFile(path + file.name, file.src, "utf8", function (err) {
50+ if (err) return cb(err);
51+
52+ writer(i+1);
53+ });
54+ }
55+ } (0);
56+}
57+
58+function marky (cb) {
59+ // fecth mardown files
60+ fetch("./markdown", "md", function (err, files) {
61+ if (err) return cb(err);
62+
63+ var content = {};
64+ // parse markdown
65+ files.forEach(function (file, index) {
66+ var name = file.name.replace(/\..+$/, "");
67+ content[name] = markdown(file.src);
68+ });
69+
70+ cb(null, content);
71+ });
72+}
73+
74+function dusty (content, cb) {
75+ // fecth html file templates
76+ fecth("./htdocs/", "html", function (err, files) {
77+ // compile the templates
78+ files.forEach(function (file, index) {
79+ var c = dust.compile(file.src, file.name);
80+ dust.loadSource(c);
81+ });
82+
83+ // dust
84+ var len = files.length;
85+ !function duster (i) {
86+ if (i === len)
87+ return cb(null, files);
88+
89+ else {
90+ var file = files[i];
91+ dust.render(file.name, content, function (err, html) {
92+ if (err) return cb(err);
93+
94+ file.src = html;
95+
96+ duster(i+1);
97+ });
98+ }
99+ } (0);
100+ });
101+}
102+
103+module.exports = function (prod, hint) {
104+ // mardown
105+ marky(function (err, content) {
106+ if (err) throw err;
107+ // dust
108+ dusty(content, function (err, htmlFiles) {
109+ if (err) throw err;
110+ // write them down
111+ write("./static/", htmlFiles, function (err) {
112+ if (err) throw err;
113+ console.log("* HTML files complete.");
114+ });
115+}
116+ // fecth css files
117+ // compress them
118+ // write the files
119+
120+ // fecth the js files
121+ // optional jshint
122+ // minify files
123+ // concatenate in this order:
124+ // /libs/*
125+ // plugins.js
126+
127+
128+
129+
130+
131+
132+
133+
134+
2135 // compile markdown and create static files
3136
4137 var fs = require('fs'),
markdown/changelog_1.md+0−3
@@ -1,3 +0,0 @@
1-### Thu, 28 of April, 2011
2-
3-First cleaned up. Added defult pages. Things look pretty now.
markdown/changelog_2.md+0−3
@@ -1,3 +0,0 @@
1-### Thu, 28 of April, 2011
2-
3-This is an example entry so that I now it's working.
markdown/changelog_3.md+0−4
@@ -1,4 +0,0 @@
1-
2-### Thu, 29 of April, 2011
3-
4-Added more documentation.
node_modules/connect/.npmignore+11−0
@@ -0,0 +1,11 @@
1+*.markdown
2+*.md
3+.git*
4+Makefile
5+benchmarks/
6+docs/
7+examples/
8+install.sh
9+support/
10+test/
11+.DS_Store
node_modules/connect/LICENSE+24−0
@@ -0,0 +1,24 @@
1+(The MIT License)
2+
3+Copyright (c) 2010 Sencha Inc.
4+Copyright (c) 2011 LearnBoost
5+Copyright (c) 2011 TJ Holowaychuk
6+
7+Permission is hereby granted, free of charge, to any person obtaining
8+a copy of this software and associated documentation files (the
9+'Software'), to deal in the Software without restriction, including
10+without limitation the rights to use, copy, modify, merge, publish,
11+distribute, sublicense, and/or sell copies of the Software, and to
12+permit persons to whom the Software is furnished to do so, subject to
13+the following conditions:
14+
15+The above copyright notice and this permission notice shall be
16+included in all copies or substantial portions of the Software.
17+
18+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
19+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
node_modules/connect/index.js+2−0
@@ -0,0 +1,2 @@
1+
2+module.exports = require('./lib/connect');
node_modules/connect/lib/connect.js+106−0
@@ -0,0 +1,106 @@
1+
2+/*!
3+ * Connect
4+ * Copyright(c) 2010 Sencha Inc.
5+ * Copyright(c) 2011 TJ Holowaychuk
6+ * MIT Licensed
7+ */
8+
9+/**
10+ * Module dependencies.
11+ */
12+
13+var HTTPServer = require('./http').Server
14+ , HTTPSServer = require('./https').Server
15+ , fs = require('fs');
16+
17+// node patches
18+
19+require('./patch');
20+
21+// expose createServer() as the module
22+
23+exports = module.exports = createServer;
24+
25+/**
26+ * Framework version.
27+ */
28+
29+exports.version = '1.4.2';
30+
31+/**
32+ * Initialize a new `connect.HTTPServer` with the middleware
33+ * passed to this function. When an object is passed _first_,
34+ * we assume these are the tls options, and return a `connect.HTTPSServer`.
35+ *
36+ * Examples:
37+ *
38+ * An example HTTP server, accepting several middleware.
39+ *
40+ * var server = connect.createServer(
41+ * connect.logger()
42+ * , connect.static(__dirname + '/public')
43+ * );
44+ *
45+ * An HTTPS server, utilizing the same middleware as above.
46+ *
47+ * var server = connect.createServer(
48+ * { key: key, cert: cert }
49+ * , connect.logger()
50+ * , connect.static(__dirname + '/public')
51+ * );
52+ *
53+ * Alternatively with connect 1.0 we may omit `createServer()`.
54+ *
55+ * connect(
56+ * connect.logger()
57+ * , connect.static(__dirname + '/public')
58+ * ).listen(3000);
59+ *
60+ * @param {Object|Function} ...
61+ * @return {Server}
62+ * @api public
63+ */
64+
65+function createServer() {
66+ if ('object' == typeof arguments[0]) {
67+ return new HTTPSServer(arguments[0], Array.prototype.slice.call(arguments, 1));
68+ } else {
69+ return new HTTPServer(Array.prototype.slice.call(arguments));
70+ }
71+};
72+
73+// support connect.createServer()
74+
75+exports.createServer = createServer;
76+
77+// auto-load getters
78+
79+exports.middleware = {};
80+
81+/**
82+ * Auto-load bundled middleware with getters.
83+ */
84+
85+fs.readdirSync(__dirname + '/middleware').forEach(function(filename){
86+ if (/\.js$/.test(filename)) {
87+ var name = filename.substr(0, filename.lastIndexOf('.'));
88+ exports.middleware.__defineGetter__(name, function(){
89+ return require('./middleware/' + name);
90+ });
91+ }
92+});
93+
94+// expose utils
95+
96+exports.utils = require('./utils');
97+
98+// expose getters as first-class exports
99+
100+exports.utils.merge(exports, exports.middleware);
101+
102+// expose constructors
103+
104+exports.HTTPServer = HTTPServer;
105+exports.HTTPSServer = HTTPSServer;
106+
node_modules/connect/lib/http.js+218−0
@@ -0,0 +1,218 @@
1+
2+/*!
3+ * Connect - HTTPServer
4+ * Copyright(c) 2010 Sencha Inc.
5+ * Copyright(c) 2011 TJ Holowaychuk
6+ * MIT Licensed
7+ */
8+
9+/**
10+ * Module dependencies.
11+ */
12+
13+var http = require('http')
14+ , parse = require('url').parse
15+ , assert = require('assert');
16+
17+// environment
18+
19+var env = process.env.NODE_ENV || 'development';
20+
21+/**
22+ * Initialize a new `Server` with the given `middleware`.
23+ *
24+ * Examples:
25+ *
26+ * var server = connect.createServer(
27+ * connect.favicon()
28+ * , connect.logger()
29+ * , connect.static(__dirname + '/public')
30+ * );
31+ *
32+ * @params {Array} middleware
33+ * @return {Server}
34+ * @api public
35+ */
36+
37+var Server = exports.Server = function HTTPServer(middleware) {
38+ this.stack = [];
39+ middleware.forEach(function(fn){
40+ this.use(fn);
41+ }, this);
42+ http.Server.call(this, this.handle);
43+};
44+
45+/**
46+ * Inherit from `http.Server.prototype`.
47+ */
48+
49+Server.prototype.__proto__ = http.Server.prototype;
50+
51+/**
52+ * Utilize the given middleware `handle` to the given `route`,
53+ * defaulting to _/_. This "route" is the mount-point for the
54+ * middleware, when given a value other than _/_ the middleware
55+ * is only effective when that segment is present in the request's
56+ * pathname.
57+ *
58+ * For example if we were to mount a function at _/admin_, it would
59+ * be invoked on _/admin_, and _/admin/settings_, however it would
60+ * not be invoked for _/_, or _/posts_.
61+ *
62+ * This is effectively the same as passing middleware to `connect.createServer()`,
63+ * however provides a progressive api.
64+ *
65+ * Examples:
66+ *
67+ * var server = connect.createServer();
68+ * server.use(connect.favicon());
69+ * server.use(connect.logger());
70+ * server.use(connect.static(__dirname + '/public'));
71+ *
72+ * If we wanted to prefix static files with _/public_, we could
73+ * "mount" the `static()` middleware:
74+ *
75+ * server.use('/public', connect.static(__dirname + '/public'));
76+ *
77+ * This api is chainable, meaning the following is valid:
78+ *
79+ * connect.createServer()
80+ * .use(connect.favicon())
81+ * .use(connect.logger())
82+ * .use(connect.static(__dirname + '/public'))
83+ * .listen(3000);
84+ *
85+ * @param {String|Function} route or handle
86+ * @param {Function} handle
87+ * @return {Server}
88+ * @api public
89+ */
90+
91+Server.prototype.use = function(route, handle){
92+ this.route = '/';
93+
94+ // default route to '/'
95+ if ('string' != typeof route) {
96+ handle = route;
97+ route = '/';
98+ }
99+
100+ // multiples
101+ if (arguments.length > 2) {
102+ return Array.prototype.slice.call(arguments, 1).forEach(function(fn){
103+ this.use(route, fn);
104+ }, this);
105+ }
106+
107+ // wrap sub-apps
108+ if ('function' == typeof handle.handle) {
109+ var server = handle;
110+ server.route = route;
111+ handle = function(req, res, next) {
112+ server.handle(req, res, next);
113+ };
114+ }
115+
116+ // wrap vanilla http.Servers
117+ if (handle instanceof http.Server) {
118+ handle = handle.listeners('request')[0];
119+ }
120+
121+ // normalize route to not trail with slash
122+ if ('/' == route[route.length - 1]) {
123+ route = route.substr(0, route.length - 1);
124+ }
125+
126+ // add the middleware
127+ this.stack.push({ route: route, handle: handle });
128+
129+ // allow chaining
130+ return this;
131+};
132+
133+/**
134+ * Handle server requests, punting them down
135+ * the middleware stack.
136+ *
137+ * @api private
138+ */
139+
140+Server.prototype.handle = function(req, res, out) {
141+ var writeHead = res.writeHead
142+ , stack = this.stack
143+ , removed = ''
144+ , index = 0;
145+
146+ function next(err) {
147+ req.url = removed + req.url;
148+ req.originalUrl = req.originalUrl || req.url;
149+ removed = '';
150+
151+ var layer = stack[index++];
152+
153+ // all done
154+ if (!layer) {
155+ // but wait! we have a parent
156+ if (out) return out(err);
157+
158+ // otherwise send a proper error message to the browser.
159+ if (err) {
160+ var msg = 'production' == env
161+ ? 'Internal Server Error'
162+ : err.stack || err.toString();
163+
164+ // output to stderr in a non-test env
165+ if ('test' != env) console.error(err.stack || err.toString());
166+
167+ res.statusCode = 500;
168+ res.setHeader('Content-Type', 'text/plain');
169+ res.end(msg);
170+ } else {
171+ res.statusCode = 404;
172+ res.setHeader('Content-Type', 'text/plain');
173+ res.end('Cannot ' + req.method + ' ' + req.url);
174+ }
175+ return;
176+ }
177+
178+ try {
179+ var pathname = parse(req.url).pathname;
180+ if (undefined == pathname) pathname = '/';
181+
182+ // skip this layer if the route doesn't match.
183+ if (0 != pathname.indexOf(layer.route)) return next(err);
184+
185+ var nextChar = pathname[layer.route.length];
186+ if (nextChar && '/' != nextChar && '.' != nextChar) return next(err);
187+
188+ // Call the layer handler
189+ // Trim off the part of the url that matches the route
190+ removed = layer.route;
191+ req.url = req.url.substr(removed.length);
192+
193+ // Ensure leading slash
194+ if ('/' != req.url[0]) req.url = '/' + req.url;
195+
196+ var arity = layer.handle.length;
197+ if (err) {
198+ if (arity === 4) {
199+ layer.handle(err, req, res, next);
200+ } else {
201+ next(err);
202+ }
203+ } else if (arity < 4) {
204+ layer.handle(req, res, next);
205+ } else {
206+ next();
207+ }
208+ } catch (e) {
209+ if (e instanceof assert.AssertionError) {
210+ console.error(e.stack + '\n');
211+ next(e);
212+ } else {
213+ next(e);
214+ }
215+ }
216+ }
217+ next();
218+};
node_modules/connect/lib/https.js+47−0
@@ -0,0 +1,47 @@
1+
2+/*!
3+ * Connect - HTTPServer
4+ * Copyright(c) 2010 Sencha Inc.
5+ * Copyright(c) 2011 TJ Holowaychuk
6+ * MIT Licensed
7+ */
8+
9+/**
10+ * Module dependencies.
11+ */
12+
13+var HTTPServer = require('./http').Server
14+ , https = require('https');
15+
16+/**
17+ * Initialize a new `Server` with the given
18+ *`options` and `middleware`. The HTTPS api
19+ * is identical to the [HTTP](http.html) server,
20+ * however TLS `options` must be provided before
21+ * passing in the optional middleware.
22+ *
23+ * @params {Object} options
24+ * @params {Array} middleawre
25+ * @return {Server}
26+ * @api public
27+ */
28+
29+var Server = exports.Server = function HTTPSServer(options, middleware) {
30+ this.stack = [];
31+ middleware.forEach(function(fn){
32+ this.use(fn);
33+ }, this);
34+ https.Server.call(this, options, this.handle);
35+};
36+
37+/**
38+ * Inherit from `http.Server.prototype`.
39+ */
40+
41+Server.prototype.__proto__ = https.Server.prototype;
42+
43+// mixin HTTPServer methods
44+
45+Object.keys(HTTPServer.prototype).forEach(function(method){
46+ Server.prototype[method] = HTTPServer.prototype[method];
47+});
node_modules/connect/lib/index.js+41−0
@@ -0,0 +1,41 @@
1+
2+/**
3+ * # Connect
4+ *
5+ * Connect is a middleware framework for node,
6+ * shipping with over 11 bundled middleware and a rich choice of
7+ * [3rd-party middleware](https://github.com/senchalabs/connect/wiki).
8+ *
9+ * Installation:
10+ *
11+ * $ npm install connect
12+ *
13+ * API:
14+ *
15+ * - [connect](connect.html) general
16+ * - [http](http.html) http server
17+ * - [https](https.html) https server
18+ *
19+ * Middleware:
20+ *
21+ * - [logger](middleware-logger.html) request logger with custom format support
22+ * - [basicAuth](middleware-basicAuth.html) basic http authentication
23+ * - [bodyParser](middleware-bodyParser.html) extensible request body parser
24+ * - [cookieParser](middleware-cookieParser.html) cookie parser
25+ * - [session](middleware-session.html) session management support with bundled [MemoryStore](middleware-session-memory.html)
26+ * - [compiler](middleware-compiler.html) static asset compiler (sass, less, coffee-script, etc)
27+ * - [methodOverride](middleware-methodOverride.html) faux HTTP method support
28+ * - [responseTime](middleware-responseTime.html) calculates response-time and exposes via X-Response-Time
29+ * - [router](middleware-router.html) provides rich Sinatra / Express-like routing
30+ * - [static](middleware-static.html) streaming static file server supporting `Range` and more
31+ * - [vhost](middleware-vhost.html) virtual host sub-domain mapping middleware
32+ * - [favicon](middleware-favicon.html) efficient favicon server (with default icon)
33+ * - [limit](middleware-limit.html) limit the bytesize of request bodies
34+ * - [profiler](middleware-profiler.html) request profiler reporting response-time, memory usage, etc
35+ *
36+ * Internals:
37+ *
38+ * - connect [utilities](utils.html)
39+ * - node monkey [patches](patch.html)
40+ *
41+ */
node_modules/connect/lib/middleware/basicAuth.js+93−0
@@ -0,0 +1,93 @@
1+
2+/*!
3+ * Connect - basicAuth
4+ * Copyright(c) 2010 Sencha Inc.
5+ * Copyright(c) 2011 TJ Holowaychuk
6+ * MIT Licensed
7+ */
8+
9+/**
10+ * Module dependencies.
11+ */
12+
13+var utils = require('../utils')
14+ , unauthorized = utils.unauthorized
15+ , badRequest = utils.badRequest;
16+
17+/**
18+ * Enfore basic authentication by providing a `callback(user, pass)`,
19+ * which must return `true` in order to gain access. Alternatively an async
20+ * method is provided as well, invoking `callback(user, pass, callback)`. Populates
21+ * `req.remoteUser`. The final alternative is simply passing username / password
22+ * strings.
23+ *
24+ * Examples:
25+ *
26+ * connect(connect.basicAuth('username', 'password'));
27+ *
28+ * connect(
29+ * connect.basicAuth(function(user, pass){
30+ * return 'tj' == user & 'wahoo' == pass;
31+ * })
32+ * );
33+ *
34+ * connect(
35+ * connect.basicAuth(function(user, pass, fn){
36+ * User.authenticate({ user: user, pass: pass }, fn);
37+ * })
38+ * );
39+ *
40+ * @param {Function|String} callback or username
41+ * @param {String} realm
42+ * @api public
43+ */
44+
45+module.exports = function basicAuth(callback, realm) {
46+ var username, password;
47+
48+ // user / pass strings
49+ if ('string' == typeof callback) {
50+ username = callback;
51+ password = realm;
52+ if ('string' != typeof password) throw new Error('password argument required');
53+ realm = arguments[2];
54+ callback = function(user, pass){
55+ return user == username && pass == password;
56+ }
57+ }
58+
59+ realm = realm || 'Authorization Required';
60+
61+ return function(req, res, next) {
62+ var authorization = req.headers.authorization;
63+
64+ if (req.remoteUser) return next();
65+ if (!authorization) return unauthorized(res, realm);
66+
67+ var parts = authorization.split(' ')
68+ , scheme = parts[0]
69+ , credentials = new Buffer(parts[1], 'base64').toString().split(':');
70+
71+ if ('Basic' != scheme) return badRequest(res);
72+
73+ // async
74+ if (callback.length >= 3) {
75+ var pause = utils.pause(req);
76+ callback(credentials[0], credentials[1], function(err, user){
77+ if (err || !user) return unauthorized(res, realm);
78+ req.remoteUser = user;
79+ next();
80+ pause.resume();
81+ });
82+ // sync
83+ } else {
84+ if (callback(credentials[0], credentials[1])) {
85+ req.remoteUser = credentials[0];
86+ next();
87+ } else {
88+ unauthorized(res, realm);
89+ }
90+ }
91+ }
92+};
93+
node_modules/connect/lib/middleware/bodyParser.js+91−0
@@ -0,0 +1,91 @@
1+
2+/*!
3+ * Connect - bodyParser
4+ * Copyright(c) 2010 Sencha Inc.
5+ * Copyright(c) 2011 TJ Holowaychuk
6+ * MIT Licensed
7+ */
8+
9+/**
10+ * Module dependencies.
11+ */
12+
13+var qs = require('qs');
14+
15+/**
16+ * Extract the mime type from the given request's
17+ * _Content-Type_ header.
18+ *
19+ * @param {IncomingMessage} req
20+ * @return {String}
21+ * @api private
22+ */
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/lib/middleware/compiler.js+163−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/lib/middleware/cookieParser.js+46−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/lib/middleware/errorHandler.js+100−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/lib/middleware/favicon.js+76−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/lib/middleware/limit.js+78−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/lib/middleware/logger.js+169−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/lib/middleware/methodOverride.js+38−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/lib/middleware/profiler.js+100−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/lib/middleware/responseTime.js+34−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/lib/middleware/router.js+379−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/lib/middleware/session.js+345−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/lib/middleware/session/cookie.js+126−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/lib/middleware/session/memory.js+131−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/lib/middleware/session/session.js+137−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/lib/middleware/session/store.js+59−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/lib/middleware/static.js+216−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/lib/middleware/vhost.js+44−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/lib/patch.js+51−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/lib/public/error.html+13−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/lib/public/favicon.ico+0−0
Binary file, not shown.
node_modules/connect/lib/public/style.css+61−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/lib/utils.js+405−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/node_modules/qs/.gitmodules+6−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/node_modules/qs/History.md+36−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/node_modules/qs/Makefile+7−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/node_modules/qs/Readme.md+38−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/node_modules/qs/benchmark.js+32−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/node_modules/qs/examples.js+39−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/node_modules/qs/index.js+2−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/node_modules/qs/lib/querystring.js+123−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/node_modules/qs/package.json+9−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/node_modules/qs/support/expresso/.gitignore+3−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/node_modules/qs/support/expresso/.gitmodules+3−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/node_modules/qs/support/expresso/History.md+128−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/node_modules/qs/support/expresso/Makefile+53−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/node_modules/qs/support/expresso/Readme.md+61−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/node_modules/qs/support/expresso/bin/expresso+856−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/node_modules/qs/support/expresso/docs/api.html+1080−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/node_modules/qs/support/expresso/docs/index.html+377−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/node_modules/qs/support/expresso/docs/index.md+290−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/node_modules/qs/support/expresso/docs/layout/foot.html+3−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/node_modules/qs/support/expresso/docs/layout/head.html+42−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/node_modules/qs/support/expresso/lib/bar.js+4−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/node_modules/qs/support/expresso/lib/foo.js+16−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/node_modules/qs/support/expresso/package.json+12−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/node_modules/qs/support/expresso/test/assert.test.js+91−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/node_modules/qs/support/expresso/test/async.test.js+12−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/node_modules/qs/support/expresso/test/bar.test.js+13−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/node_modules/qs/support/expresso/test/foo.test.js+14−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/node_modules/qs/support/expresso/test/http.test.js+146−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/node_modules/qs/support/expresso/test/serial/async.test.js+39−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/node_modules/qs/support/expresso/test/serial/http.test.js+48−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/node_modules/qs/support/should/.gitmodules+3−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/node_modules/qs/support/should/History.md+22−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/node_modules/qs/support/should/Makefile+6−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/node_modules/qs/support/should/Readme.md+248−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/node_modules/qs/support/should/examples/runner.js+53−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/node_modules/qs/support/should/index.js+2−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/node_modules/qs/support/should/lib/eql.js+91−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/node_modules/qs/support/should/lib/should.js+548−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/node_modules/qs/support/should/package.json+8−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/node_modules/qs/support/should/test/should.test.js+358−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/node_modules/qs/test/querystring.test.js+133−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/package.json+22−0
Cut short: this commit's diff is over 1000 lines.
node_modules/connect/test.js+13−0
Cut short: this commit's diff is over 1000 lines.
node_modules/dust/.gitignore+1−0
Cut short: this commit's diff is over 1000 lines.
node_modules/dust/LICENSE+19−0
Cut short: this commit's diff is over 1000 lines.
node_modules/dust/Makefile+78−0
Cut short: this commit's diff is over 1000 lines.
node_modules/dust/README.md+51−0
Cut short: this commit's diff is over 1000 lines.
node_modules/dust/TODO+3−0
Cut short: this commit's diff is over 1000 lines.
node_modules/dust/benchmark/index.html+161−0
Cut short: this commit's diff is over 1000 lines.
node_modules/dust/benchmark/server.js+33−0
Cut short: this commit's diff is over 1000 lines.
node_modules/dust/benchmark/suites/dust_suite.js+111−0
Cut short: this commit's diff is over 1000 lines.
node_modules/dust/benchmark/suites/handlebars_suite.js+101−0
Cut short: this commit's diff is over 1000 lines.
node_modules/dust/benchmark/suites/jquery_suite.js+84−0
Cut short: this commit's diff is over 1000 lines.
node_modules/dust/benchmark/suites/mustache_suite.js+97−0
Cut short: this commit's diff is over 1000 lines.
node_modules/dust/benchmark/uubench.js+107−0
Cut short: this commit's diff is over 1000 lines.
node_modules/dust/dist/dust-core-0.3.0.js+522−0
Cut short: this commit's diff is over 1000 lines.
node_modules/dust/dist/dust-core-0.3.0.min.js+21−0
Cut short: this commit's diff is over 1000 lines.
node_modules/dust/dist/dust-full-0.3.0.js+3209−0
Cut short: this commit's diff is over 1000 lines.
node_modules/dust/dist/dust-full-0.3.0.min.js+61−0
Cut short: this commit's diff is over 1000 lines.
node_modules/dust/docs/about.md+14−0
Cut short: this commit's diff is over 1000 lines.
node_modules/dust/docs/api.md+310−0
Cut short: this commit's diff is over 1000 lines.
node_modules/dust/docs/build.js+68−0
Cut short: this commit's diff is over 1000 lines.
node_modules/dust/docs/index.css+203−0
Cut short: this commit's diff is over 1000 lines.
node_modules/dust/docs/index.dust.html+95−0
Cut short: this commit's diff is over 1000 lines.
node_modules/dust/docs/index.js+181−0
Cut short: this commit's diff is over 1000 lines.
node_modules/dust/docs/select.dust.html+5−0
Cut short: this commit's diff is over 1000 lines.
node_modules/dust/docs/syntax.md+286−0
Cut short: this commit's diff is over 1000 lines.
node_modules/dust/index.html+1078−0
Cut short: this commit's diff is over 1000 lines.
node_modules/dust/lib/compiler.js+319−0
Cut short: this commit's diff is over 1000 lines.
node_modules/dust/lib/dust.js+514−0
Cut short: this commit's diff is over 1000 lines.
node_modules/dust/lib/parser.js+2368−0
Cut short: this commit's diff is over 1000 lines.
node_modules/dust/lib/server.js+20−0
Cut short: this commit's diff is over 1000 lines.
node_modules/dust/package.json+11−0
Cut short: this commit's diff is over 1000 lines.
node_modules/dust/src/build.js+12−0
Cut short: this commit's diff is over 1000 lines.
node_modules/dust/src/dust.pegjs+118−0
Cut short: this commit's diff is over 1000 lines.
node_modules/dust/test/core.js+83−0
Cut short: this commit's diff is over 1000 lines.
node_modules/dust/test/examples.js+318−0
Cut short: this commit's diff is over 1000 lines.
node_modules/dust/test/server.js+35−0
Cut short: this commit's diff is over 1000 lines.
node_modules/dust/test/uutest.js+104−0
Cut short: this commit's diff is over 1000 lines.
node_modules/dust/vendor/beautify.js+1085−0
Cut short: this commit's diff is over 1000 lines.
node_modules/dust/vendor/ecma.js+60−0
Cut short: this commit's diff is over 1000 lines.
node_modules/dust/vendor/hijs.js+93−0
Cut short: this commit's diff is over 1000 lines.
node_modules/dust/vendor/jquery.min.js+154−0
Cut short: this commit's diff is over 1000 lines.
node_modules/dust/vendor/jsdump.js+163−0
Cut short: this commit's diff is over 1000 lines.
node_modules/dust/vendor/showdown.js+1296−0
Cut short: this commit's diff is over 1000 lines.
node_modules/mime/LICENSE+19−0
Cut short: this commit's diff is over 1000 lines.
node_modules/mime/README.md+54−0
Cut short: this commit's diff is over 1000 lines.
node_modules/mime/index.js+1−0
Cut short: this commit's diff is over 1000 lines.
node_modules/mime/mime.js+89−0
Cut short: this commit's diff is over 1000 lines.
node_modules/mime/mime.types+1479−0
Cut short: this commit's diff is over 1000 lines.
node_modules/mime/node.types+7−0
Cut short: this commit's diff is over 1000 lines.
node_modules/mime/package.json+11−0
Cut short: this commit's diff is over 1000 lines.
node_modules/mime/test.js+74−0
Cut short: this commit's diff is over 1000 lines.
node_modules/node-markdown/LICENSE+38−0
Cut short: this commit's diff is over 1000 lines.
node_modules/node-markdown/README.md+25−0
Cut short: this commit's diff is over 1000 lines.
node_modules/node-markdown/examples/test.js+12−0
Cut short: this commit's diff is over 1000 lines.
node_modules/node-markdown/lib/markdown.js+106−0
Cut short: this commit's diff is over 1000 lines.
node_modules/node-markdown/lib/vendor/showdown/compressed/showdown.js+419−0
Cut short: this commit's diff is over 1000 lines.
node_modules/node-markdown/lib/vendor/showdown/example/showdown-gui.html+720−0
Cut short: this commit's diff is over 1000 lines.
node_modules/node-markdown/lib/vendor/showdown/example/showdown-gui.js+349−0
Cut short: this commit's diff is over 1000 lines.
node_modules/node-markdown/lib/vendor/showdown/example/showdown.js+1296−0
Cut short: this commit's diff is over 1000 lines.
node_modules/node-markdown/lib/vendor/showdown/license.txt+34−0
Cut short: this commit's diff is over 1000 lines.
node_modules/node-markdown/lib/vendor/showdown/perlMarkdown/Markdown License.txt+30−0
Cut short: this commit's diff is over 1000 lines.
node_modules/node-markdown/lib/vendor/showdown/perlMarkdown/Markdown-1.0.2b2.pl+1509−0
Cut short: this commit's diff is over 1000 lines.
node_modules/node-markdown/lib/vendor/showdown/perlMarkdown/Markdown-1.0.2b7.pl+1642−0
Cut short: this commit's diff is over 1000 lines.
node_modules/node-markdown/lib/vendor/showdown/perlMarkdown/readme.txt+13−0
Cut short: this commit's diff is over 1000 lines.
node_modules/node-markdown/lib/vendor/showdown/readme.txt+156−0
Cut short: this commit's diff is over 1000 lines.
node_modules/node-markdown/lib/vendor/showdown/src/showdown.js+1299−0
Cut short: this commit's diff is over 1000 lines.
node_modules/node-markdown/package.json+26−0
Cut short: this commit's diff is over 1000 lines.
server.js+8−88
Cut short: this commit's diff is over 1000 lines.
templates/about.dust+0−40
Cut short: this commit's diff is over 1000 lines.
templates/index.dust+0−47
Cut short: this commit's diff is over 1000 lines.