Skip to content

Commit

Permalink
Added additional route handling and rendering for full author pages.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Godfrey committed Aug 21, 2013
1 parent 9fe1d57 commit 64e1ffd
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/wheat.js
Expand Up @@ -65,6 +65,8 @@ module.exports = function setup(repo, authorName) {
// Set up our routes
addRoute(/^\/()$/, partial(Renderers.index, undefined, authorName, undefined));
addRoute(/^\/()feed.xml$/, Renderers.feed);
addRoute(/^\/()author$/, partial(Renderers.author, undefined, authorName, undefined));
addRoute(/^\/()author\/([a-z0-9_-]+)$/, Renderers.author);
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);
Expand All @@ -73,7 +75,6 @@ module.exports = function setup(repo, authorName) {
addRoute(/^\/()(.+\.[a-z]{2,4})$/, Renderers.staticFile);
addRoute(/^\/()category\/([\%\.a-z0-9_-]+)$/, Renderers.categoryIndex);


return function handle(req, res, next) {
var url = Url.parse(req.url);
for (var i = 0, l = routes.length; i < l; i++) {
Expand Down
29 changes: 29 additions & 0 deletions lib/wheat/renderers.js
Expand Up @@ -204,6 +204,35 @@ var Renderers = module.exports = {
);
}),

author: Git.safe(function renderAuthor(version, name, callback) {
var author, description;
Step(
function loadData() {
Git.getHead(this.parallel());
Data.author(version, name.replace('-', ' '), this.parallel());
},
function (err, head, props) {
if (err) { callback(err); return; }
author = props;
Git.readFile(head, "description.markdown", this.parallel());
},
function applyTemplate(err, description) {
if (err) { callback(err); return; }
Tools.render("author", {
author: 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() {
Expand Down

0 comments on commit 64e1ffd

Please sign in to comment.