Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions .gitmodules

This file was deleted.

41 changes: 38 additions & 3 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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
24 changes: 13 additions & 11 deletions lib/wheat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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) {
Expand Down
6 changes: 4 additions & 2 deletions lib/wheat/prettify.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
}
Expand Down
Loading