Fixes to run on Node 0.4+, and better Readme #22

Open
wants to merge 8 commits into
from
View
@@ -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/extjs/Connect.git
View
@@ -2,14 +2,49 @@
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 [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);
+
+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. It's packaged nicely now.
+Either manually install all the dependencies or use npm.
npm install wheat
For on the fly rendering of Graphviz graphs (DOT files), Graphviz will need to be [installed](http://www.graphviz.org/Download..php)
-That's it! Checkout the wheat branch of howtonode.org for an example of how to use the library.
-<http://github.com/creationix/howtonode.org>
+## 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
+
+ $> node app.js
+
+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
View
@@ -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');
@@ -46,20 +45,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) {
View
@@ -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 = {};
}
Oops, something went wrong.