From d825bb1eea3542ff92cb258408460214dbd47048 Mon Sep 17 00:00:00 2001 From: Mickael Daniel Date: Fri, 17 Dec 2010 23:48:55 +0100 Subject: [PATCH 1/7] Added theme support to allow the use of different themes (found in /skin dir.) --- lib/wheat.js | 23 ++- lib/wheat/renderers.js | 441 +++++++++++++++++++++-------------------- lib/wheat/tools.js | 18 +- 3 files changed, 248 insertions(+), 234 deletions(-) diff --git a/lib/wheat.js b/lib/wheat.js index 0b6776f..99f432e 100644 --- a/lib/wheat.js +++ b/lib/wheat.js @@ -46,20 +46,23 @@ function handleRoute(req, res, next, renderer, match) { renderer.apply(null, match.concat([callback])); } -module.exports = function setup(repo) { +module.exports = function setup(repo, o) { + // Set up configuration in necessary modules + var r = Renderers(o || {theme: ''}); + // Initialize the Git Filesystem Git(repo || process.cwd()); // Set up our routes - addRoute(/^\/()$/, Renderers.index); - addRoute(/^\/()feed.xml$/, Renderers.feed); - addRoute(/^\/([a-f0-9]{40})\/([a-z0-9_-]+)$/, Renderers.article); - addRoute(/^\/([a-f0-9]{40})\/(.+\.dot)$/, Renderers.dotFile); - addRoute(/^\/([a-f0-9]{40})\/(.+\.[a-z]{2,4})$/, Renderers.staticFile); - addRoute(/^\/()([a-z0-9_-]+)$/, Renderers.article); - addRoute(/^\/()(.+\.dot)$/, Renderers.dotFile); - addRoute(/^\/()(.+\.[a-z]{2,4})$/, Renderers.staticFile); - addRoute(/^\/()category\/([\%\.a-z0-9_-]+)$/, Renderers.categoryIndex); + addRoute(/^\/()$/, r.index); + addRoute(/^\/()feed.xml$/, r.feed); + addRoute(/^\/([a-f0-9]{40})\/([a-z0-9_-]+)$/, r.article); + addRoute(/^\/([a-f0-9]{40})\/(.+\.dot)$/, r.dotFile); + addRoute(/^\/([a-f0-9]{40})\/(.+\.[a-z]{2,4})$/, r.staticFile); + addRoute(/^\/()([a-z0-9_-]+)$/, r.article); + addRoute(/^\/()(.+\.dot)$/, r.dotFile); + addRoute(/^\/()(.+\.[a-z]{2,4})$/, r.staticFile); + addRoute(/^\/()category\/([\%\.a-z0-9_-]+)$/, r.categoryIndex); return function handle(req, res, next) { diff --git a/lib/wheat/renderers.js b/lib/wheat/renderers.js index 1340a75..2fdd66d 100644 --- a/lib/wheat/renderers.js +++ b/lib/wheat/renderers.js @@ -41,240 +41,247 @@ function execPipe(command, args, data, callback) { child.stdin.end(); } -// This writes proper headers for caching and conditional gets -// Also gzips content if it's text based and stable. -function postProcess(headers, buffer, version, path, callback) { - Step( - function buildHeaders() { - if (!headers["Content-Type"]) { - headers["Content-Type"] = "text/html; charset=utf-8"; - } - var date = new Date().toUTCString(); - headers["Date"] = date; - headers["Server"] = "Wheat (node.js)"; - if (version === 'fs') { - delete headers["Cache-Control"]; - } else { - headers["ETag"] = MD5.md5(version + ":" + path + ":" + date); - } - - if (/html/.test(headers["Content-Type"])) { - buffer = Tools.stringToBuffer((buffer+"").replace(/
[^<]+<\/code><\/pre>/g,
-          function applyHighlight(code) {
-            var code = code.match(/([\s\S]+)<\/code>/)[1];
-            code = Prettify.prettyPrintOne(code)
-            return "
" + code + "
"; - } - )); - } +var Renderers = module.exports = (function(o) { - headers["Content-Length"] = buffer.length; + var config = o || {theme: ''}; + + var tools = Tools(config); + + // This writes proper headers for caching and conditional gets + // Also gzips content if it's text based and stable. + function postProcess(headers, buffer, version, path, callback) { + Step( + function buildHeaders() { + if (!headers["Content-Type"]) { + headers["Content-Type"] = "text/html; charset=utf-8"; + } + var date = new Date().toUTCString(); + headers["Date"] = date; + headers["Server"] = "Wheat (node.js)"; + if (version === 'fs') { + delete headers["Cache-Control"]; + } else { + headers["ETag"] = MD5.md5(version + ":" + path + ":" + date); + } - return { - headers: headers, - buffer: buffer - }; - }, - callback - ); -} + if (/html/.test(headers["Content-Type"])) { + buffer = tools.stringToBuffer((buffer+"").replace(/
[^<]+<\/code><\/pre>/g,
+            function applyHighlight(code) {
+              var code = code.match(/([\s\S]+)<\/code>/)[1];
+              code = Prettify.prettyPrintOne(code)
+              return "
" + code + "
"; + } + )); + } -function insertSnippets(markdown, snippets, callback) { - Step( - function () { - Tools.compileTemplate('snippet', this); - }, - function (err, snippetTemplate) { - if (err) { callback(err); return; } - snippets.forEach(function (snippet) { - var html = snippetTemplate({snippet: snippet}); - markdown = markdown.replace(snippet.original, html); - }); - return markdown; - }, - callback - ) -} + headers["Content-Length"] = buffer.length; -var Renderers = module.exports = { - index: Git.safe(function index(version, callback) { - Step( - function getHead() { - Git.getHead(this); - }, - function loadData(err, head) { - if (err) { callback(err); return; } - Data.articles(version, this.parallel()); - Git.readFile(head, "description.markdown", this.parallel()); - Data.categories(version, this.parallel()); - }, - function applyTemplate(err, articles, description, categories) { - if (err) { callback(err); return; } - Tools.render("index", { - articles: articles, - description: description, - categories: categories - }, this); - }, - function callPostProcess(err, buffer) { - if (err) { callback(err); return; } - postProcess({ - "Cache-Control": "public, max-age=3600" - }, buffer, version, "index", this); + return { + headers: headers, + buffer: buffer + }; }, callback ); - }), + }; - feed: Git.safe(function feed(version, callback) { - var articles; + function insertSnippets(markdown, snippets, callback) { Step( - function loadData() { - Data.fullArticles(version, this); - }, - function (err, data) { - if (err) { callback(err); return; } - articles = data; - var group = this.group(); - articles.forEach(function (article) { - insertSnippets(article.markdown, article.snippets, group()); - }); + function () { + tools.compileTemplate('snippet', this); }, - function applyTemplate(err, markdowns) { + function (err, snippetTemplate) { if (err) { callback(err); return; } - markdowns.forEach(function (markdown, i) { - articles[i].markdown = markdown; + snippets.forEach(function (snippet) { + var html = snippetTemplate({snippet: snippet}); + markdown = markdown.replace(snippet.original, html); }); - Tools.render("feed.xml", { - articles: articles - }, this, true); - }, - function finish(err, buffer) { - if (err) { callback(err); return; } - postProcess({ - "Content-Type":"application/rss+xml", - "Cache-Control": "public, max-age=3600" - }, buffer, version, "feed.xml", this); + return markdown; }, callback - ); - }), + ) + }; + + return { + index: Git.safe(function index(version, callback) { + Step( + function getHead() { + Git.getHead(this); + }, + function loadData(err, head) { + if (err) { callback(err); return; } + Data.articles(version, this.parallel()); + Git.readFile(head, "description.markdown", this.parallel()); + Data.categories(version, this.parallel()); + }, + function applyTemplate(err, articles, description, categories) { + if (err) { callback(err); return; } + tools.render("index", { + articles: articles, + description: description, + categories: categories + }, this); + }, + function callPostProcess(err, buffer) { + if (err) { callback(err); return; } + postProcess({ + "Cache-Control": "public, max-age=3600" + }, buffer, version, "index", this); + }, + callback + ); + }), - article: Git.safe(function renderArticle(version, name, callback) { - var article, description; - Step( - function loadData() { - Git.getHead(this.parallel()); - Data.fullArticle(version, name, this.parallel()); - }, - function (err, head, props) { - if (err) { callback(err); return; } - article = props; - insertSnippets(article.markdown, article.snippets, this.parallel()); - Git.readFile(head, "description.markdown", this.parallel()); - }, - function applyTemplate(err, markdown, description) { - if (err) { callback(err); return; } - article.markdown = markdown; - Tools.render("article", { - title: article.title, - article: article, - author: article.author, - description: description - }, this); - }, - function finish(err, buffer) { - if (err) { callback(err); return; } - postProcess({ - "Cache-Control": "public, max-age=3600" - }, buffer, version, name, this); - }, - callback - ); - }), + feed: Git.safe(function feed(version, callback) { + var articles; + Step( + function loadData() { + Data.fullArticles(version, this); + }, + function (err, data) { + if (err) { callback(err); return; } + articles = data; + var group = this.group(); + articles.forEach(function (article) { + insertSnippets(article.markdown, article.snippets, group()); + }); + }, + function applyTemplate(err, markdowns) { + if (err) { callback(err); return; } + markdowns.forEach(function (markdown, i) { + articles[i].markdown = markdown; + }); + tools.render("feed.xml", { + articles: articles + }, this, true); + }, + function finish(err, buffer) { + if (err) { callback(err); return; } + postProcess({ + "Content-Type":"application/rss+xml", + "Cache-Control": "public, max-age=3600" + }, buffer, version, "feed.xml", this); + }, + callback + ); + }), - categoryIndex: Git.safe(function index(version, category, callback) { - Step( - function getHead() { - Git.getHead(this); - }, - function loadData(err, head) { - if (err) { callback(err); return; } - Data.articles(version, this.parallel()); - Git.readFile(head, "description.markdown", this.parallel()); - Data.categories(version, this.parallel()); - }, - function applyTemplate(err, articles, description, categories) { - if (err) { callback(err); return; } + article: Git.safe(function renderArticle(version, name, callback) { + var article, description; + Step( + function loadData() { + Git.getHead(this.parallel()); + Data.fullArticle(version, name, this.parallel()); + }, + function (err, head, props) { + if (err) { callback(err); return; } + article = props; + insertSnippets(article.markdown, article.snippets, this.parallel()); + Git.readFile(head, "description.markdown", this.parallel()); + }, + function applyTemplate(err, markdown, description) { + if (err) { callback(err); return; } + article.markdown = markdown; + tools.render("article", { + title: article.title, + article: article, + author: article.author, + description: description + }, this); + }, + function finish(err, buffer) { + if (err) { callback(err); return; } + postProcess({ + "Cache-Control": "public, max-age=3600" + }, buffer, version, name, this); + }, + callback + ); + }), + + categoryIndex: Git.safe(function index(version, category, callback) { + Step( + function getHead() { + Git.getHead(this); + }, + function loadData(err, head) { + if (err) { callback(err); return; } + Data.articles(version, this.parallel()); + Git.readFile(head, "description.markdown", this.parallel()); + Data.categories(version, this.parallel()); + }, + function applyTemplate(err, articles, description, categories) { + if (err) { callback(err); return; } - var articlesForCategory = articles.reduce(function (start, element){ - return element.categories && element.categories.indexOf(category) >= 0 ? start.concat(element) : start; - }, []); + var articlesForCategory = articles.reduce(function (start, element){ + return element.categories && element.categories.indexOf(category) >= 0 ? start.concat(element) : start; + }, []); - Tools.render("index", { - articles: articlesForCategory, - description: description, - categories: categories - }, this); - }, - function callPostProcess(err, buffer) { - if (err) { callback(err); return; } - postProcess({ - "Cache-Control": "public, max-age=3600" - }, buffer, version, "index", this); - }, - callback - ); - }), + tools.render("index", { + articles: articlesForCategory, + description: description, + categories: categories + }, this); + }, + function callPostProcess(err, buffer) { + if (err) { callback(err); return; } + postProcess({ + "Cache-Control": "public, max-age=3600" + }, buffer, version, "index", this); + }, + callback + ); + }), - staticFile: Git.safe(function staticFile(version, path, callback) { - Step( - function loadPublicFiles() { - Git.readFile(version, "skin/public/" + path, this); - }, - function loadArticleFiles(err, data) { - if (err) { - Git.readFile(version, "articles/" + path, this); - } - return data; - }, - function processFile(err, string) { - if (err) { callback(err); return; } - var headers = { - "Content-Type": Mime.type(path), - "Cache-Control": "public, max-age=32000000" - }; - var buffer = new Buffer(string.length); - buffer.write(string, 'binary'); - postProcess(headers, buffer, version, path, this); - }, - callback - ); - }), + staticFile: Git.safe(function staticFile(version, path, callback) { + Step( + function loadPublicFiles() { + Git.readFile(version, "skin/" + config.theme + "/public/" + path, this); + }, + function loadArticleFiles(err, data) { + if (err) { + Git.readFile(version, "articles/" + path, this); + } + return data; + }, + function processFile(err, string) { + if (err) { callback(err); return; } + var headers = { + "Content-Type": Mime.type(path), + "Cache-Control": "public, max-age=32000000" + }; + var buffer = new Buffer(string.length); + buffer.write(string, 'binary'); + postProcess(headers, buffer, version, path, this); + }, + callback + ); + }), - dotFile: Git.safe(function dotFile(version, path, callback) { - Step( - function loadPublicFiles() { - Git.readFile(version, "skin/public/" + path, this); - }, - function loadArticleFiles(err, data) { - if (err) { - Git.readFile(version, "articles/" + path, this); - } - return data; - }, - function processFile(err, data) { - if (err) { callback(err); return; } - execPipe("dot", ["-Tpng"], data, this); - }, - function finish(err, buffer) { - if (err) { callback(err); return; } - postProcess({ - "Content-Type": "image/png", - "Cache-Control": "public, max-age=32000000" - }, buffer, version, path, this); - }, - callback - ); - }) -} + dotFile: Git.safe(function dotFile(version, path, callback) { + Step( + function loadPublicFiles() { + Git.readFile(version, "skin/" + config.theme + "/public/" + path, this); + }, + function loadArticleFiles(err, data) { + if (err) { + Git.readFile(version, "articles/" + path, this); + } + return data; + }, + function processFile(err, data) { + if (err) { callback(err); return; } + execPipe("dot", ["-Tpng"], data, this); + }, + function finish(err, buffer) { + if (err) { callback(err); return; } + postProcess({ + "Content-Type": "image/png", + "Cache-Control": "public, max-age=32000000" + }, buffer, version, path, this); + }, + callback + ); + }) + }; +}); diff --git a/lib/wheat/tools.js b/lib/wheat/tools.js index cb0b4ee..26b8efd 100644 --- a/lib/wheat/tools.js +++ b/lib/wheat/tools.js @@ -4,7 +4,8 @@ var Sys = require('sys'), Markdown = require('./markdown'), MD5 = require('./md5'), Buffer = require('buffer').Buffer, - Git = require('git-fs'); + Git = require('git-fs'), + config = {}; function pad(num, count) { count = count || 2; @@ -125,7 +126,7 @@ function stringToBuffer(string) { var loadTemplate = Git.safe(function loadTemplate(version, name, callback) { Step( function loadHaml() { - Git.readFile(version, "skin/" + name + ".haml", this); + Git.readFile(version, "skin/" + config.theme + "/" + name + ".haml", this); }, function compileTemplate(err, haml) { if (err) { callback(err); return; } @@ -184,8 +185,11 @@ function render(name, data, callback, partial) { ) } -module.exports = { - stringToBuffer: stringToBuffer, - compileTemplate: compileTemplate, - render: render -}; +module.exports = (function(o){ + config = o || {theme: ''}; + return { + stringToBuffer: stringToBuffer, + compileTemplate: compileTemplate, + render: render + }; +}); From d068851043358d2d575ee3a38b69e745a874674f Mon Sep 17 00:00:00 2001 From: Florian Traverse Date: Sat, 26 Feb 2011 14:24:03 +0100 Subject: [PATCH 2/7] Fixes for Node 0.4+ --- .gitmodules | 2 +- lib/wheat.js | 1 - lib/wheat/prettify.js | 6 ++++-- lib/wheat/renderers.js | 21 ++++++++++++++------- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/.gitmodules b/.gitmodules index f15e159..66cc24f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -15,4 +15,4 @@ url = git://github.com/creationix/proto.git [submodule "lib/wheat/connectpkg"] path = lib/wheat/connectpkg - url = git://github.com/extjs/Connect.git + url = git://github.com/senchalabs/Connect.git diff --git a/lib/wheat.js b/lib/wheat.js index 99f432e..1e88a34 100644 --- a/lib/wheat.js +++ b/lib/wheat.js @@ -19,7 +19,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - require.paths.unshift(__dirname + "/wheat"); require('proto'); diff --git a/lib/wheat/prettify.js b/lib/wheat/prettify.js index 5187a63..4b9cde8 100644 --- a/lib/wheat/prettify.js +++ b/lib/wheat/prettify.js @@ -55,13 +55,15 @@ // JSLint declarations /*global console, document, navigator, setTimeout, window */ +var window = window ||{}; +window.console = console||{log:function(){}, warn:function(){}, trace:function(){}}; -if (typeof window === 'undefined') { +/*if (typeof window === 'undefined') { window = GLOBAL; if (typeof require === 'function') { window.console = console; } -} +}*/ if (typeof navigator === 'undefined') { navigator = {}; } diff --git a/lib/wheat/renderers.js b/lib/wheat/renderers.js index 2fdd66d..c5e65df 100644 --- a/lib/wheat/renderers.js +++ b/lib/wheat/renderers.js @@ -5,7 +5,7 @@ var Git = require('git-fs'), Prettify = require('./prettify'), MD5 = require('./md5'), ChildProcess = require('child_process'), - Mime = require('connect/utils').mime, + Mime = require('connect').utils.mime, Step = require('step'); // Execute a child process, feed it a buffer and get a new buffer filtered. @@ -19,6 +19,9 @@ function execPipe(command, args, data, callback) { child.stderr.addListener('data', function onStderr(buffer) { stderr[stderr.length] = buffer; }); + child.addListener('error', function onExit(err) { + callback(err); + }); child.addListener('exit', function onExit(code) { if (code > 0) { callback(new Error(stderr.join(""))); @@ -33,10 +36,14 @@ function execPipe(command, args, data, callback) { callback(null, buffer); } }); - if (typeof data === 'string') { - child.stdin.write(data, "binary"); - } else { - child.stdin.write(data); + try { + if (typeof data === 'string') { + child.stdin.write(data, "binary"); + } else { + child.stdin.write(data); + } + } catch(e) { + (errCallback||callback)(e); } child.stdin.end(); } @@ -271,10 +278,10 @@ var Renderers = module.exports = (function(o) { }, function processFile(err, data) { if (err) { callback(err); return; } - execPipe("dot", ["-Tpng"], data, this); + execPipe("dot", ["-Tpng"], data, this); }, function finish(err, buffer) { - if (err) { callback(err); return; } + if (err) { errCallback(err); return; } postProcess({ "Content-Type": "image/png", "Cache-Control": "public, max-age=32000000" From 0a99db2d7e340d11ae29a580bf41871091e0d7dd Mon Sep 17 00:00:00 2001 From: Florian Traverse Date: Sat, 26 Feb 2011 14:25:38 +0100 Subject: [PATCH 3/7] No submodules, use npm install instead --- .gitmodules | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 .gitmodules diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 66cc24f..0000000 --- a/.gitmodules +++ /dev/null @@ -1,18 +0,0 @@ -[submodule "lib/wheat/node-git"] - path = lib/wheat/node-git - url = git://github.com/creationix/node-git.git -[submodule "lib/wheat/step"] - path = lib/wheat/step - url = git://github.com/creationix/step.git -[submodule "lib/wheat/haml-js"] - path = lib/wheat/haml-js - url = git://github.com/creationix/haml-js.git -[submodule "lib/wheat/node-router"] - path = lib/wheat/node-router - url = git://github.com/creationix/node-router.git -[submodule "lib/wheat/proto"] - path = lib/wheat/proto - url = git://github.com/creationix/proto.git -[submodule "lib/wheat/connectpkg"] - path = lib/wheat/connectpkg - url = git://github.com/senchalabs/Connect.git From e4782fe7a0c53a26c88d3335deb4b05796fd8931 Mon Sep 17 00:00:00 2001 From: Florian Traverse Date: Sat, 26 Feb 2011 15:00:47 +0100 Subject: [PATCH 4/7] Added some documentation in readme :) --- README.markdown | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 2ba48b3..f60cb1a 100644 --- a/README.markdown +++ b/README.markdown @@ -2,12 +2,39 @@ Wheat is a blogging engine that reads a git repo full of markdown articles and presents them as a website. +Wheat engine takes a local git repository path as a parameter + + var wheat = require('wheat')("/path/to/my/repo"); + // wheat is now a function which handles request and return response: + // wheat(req/*request*/, res/*response*/, next /*next handler to call for this request*/) + +Here's an example using Connect ( npm install connect ) to start a server, adapted from https://github.com/creationix/howtonode.org/blob/master/app.js : + + var Connect = require('connect'); + + var repository = "/path/to/my/repo", + port = 3000; + + Connect.createServer( + Connect.logger(), + Connect.conditionalGet(), + Connect.favicon(), + Connect.cache(), + Connect.gzip(), + require('wheat')(repository) + ).listen(port); + ## How to Install -Either manually install all the dependencies or use npm. It's packaged nicely now. +Either manually install all the dependencies or use npm. npm install wheat +## Full example of how to use wheat : + $> npm install wheat + $> git clone https://github.com/creationix/howtonode.org.git + $> cd howtonode.org + $> node app.js That's it! Checkout the wheat branch of howtonode.org for an example of how to use the library. From 6b031fefb16d5f54186b68eefce036f5698e5822 Mon Sep 17 00:00:00 2001 From: Florian Traverse Date: Sat, 26 Feb 2011 15:30:22 +0100 Subject: [PATCH 5/7] Small fix --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 22144d7..0080812 100644 --- a/README.markdown +++ b/README.markdown @@ -43,4 +43,4 @@ Now just run it, and open your browser on [your host, port 3000](http://127.0.0. $> node app.js -That's it! \ No newline at end of file +That's it! From 9f5452445bdaf963c535ddef08f8ed5da6463792 Mon Sep 17 00:00:00 2001 From: Florian Traverse Date: Sat, 26 Feb 2011 15:37:18 +0100 Subject: [PATCH 6/7] Fixed Markdown --- README.markdown | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/README.markdown b/README.markdown index 0080812..5a3e53c 100644 --- a/README.markdown +++ b/README.markdown @@ -10,18 +10,18 @@ Wheat engine takes a local git repository path as a parameter Here's an example using Connect ( npm install connect ) to start a server, adapted from [howtonode.org repo app.js](https://github.com/creationix/howtonode.org/blob/master/app.js) : - var Connect = require('connect'); - - var repository = "/path/to/my/repo"; - - Connect.createServer( - Connect.logger(), - Connect.conditionalGet(), - Connect.favicon(), - Connect.cache(), - Connect.gzip(), - require('wheat')(repository) - ).listen(3000); + var Connect = require('connect'); + + var repository = "/path/to/my/repo"; + + Connect.createServer( + Connect.logger(), + Connect.conditionalGet(), + Connect.favicon(), + Connect.cache(), + Connect.gzip(), + require('wheat')(repository) + ).listen(3000); ## How to Install @@ -37,7 +37,7 @@ For on the fly rendering of Graphviz graphs (DOT files), Graphviz will need to b $> git clone https://github.com/creationix/howtonode.org.git $> cd howtonode.org -Then edit app.js and add ".listen(3000);" at the end of "Connect.createServer", see above. +Then edit app.js and add ".listen(3000);" at the end of "Connect.createServer", see above example using connect. Now just run it, and open your browser on [your host, port 3000](http://127.0.0.1:3000) From cb393a51bb7d1246e650fbd5fb49ec0bb9b1e7b8 Mon Sep 17 00:00:00 2001 From: Florian Traverse Date: Sat, 26 Feb 2011 15:49:40 +0100 Subject: [PATCH 7/7] Improved Readme ! --- README.markdown | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.markdown b/README.markdown index 5a3e53c..b24d3d1 100644 --- a/README.markdown +++ b/README.markdown @@ -23,6 +23,8 @@ Here's an example using Connect ( npm install connect ) to start a server, adapt require('wheat')(repository) ).listen(3000); +You may also be interested in using [Cluster](http://learnboost.github.com/cluster/) ( npm install cluster )to run the blog in a reliable way (just don't listen to the port directly, pass the Connect server to Cluster, add the cluster plugin you want, and start !). + ## How to Install Either manually install all the dependencies or use npm. @@ -32,15 +34,17 @@ Either manually install all the dependencies or use npm. For on the fly rendering of Graphviz graphs (DOT files), Graphviz will need to be [installed](http://www.graphviz.org/Download..php) -## Full example of how to use wheat, using howtonode.org [repository](http://github.com/creationix/howtonode.org) for skin/articles/... : +## Quick start using howtonode.org [repository](http://github.com/creationix/howtonode.org) for content : $> npm install wheat $> git clone https://github.com/creationix/howtonode.org.git $> cd howtonode.org Then edit app.js and add ".listen(3000);" at the end of "Connect.createServer", see above example using connect. -Now just run it, and open your browser on [your host, port 3000](http://127.0.0.1:3000) +Now just run it $> node app.js -That's it! +Open your browser on [your host, port 3000](http://127.0.0.1:3000). That's it! + +Note: Viewing any article using DOT files will crash the server if you don't have GraphViz (see above) installed