Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Route handling and rendering for "full" author pages. #50

Open
wants to merge 9 commits into from

1 participant

Mike Godfrey
Mike Godfrey

Additional features/modifications to the excellent Wheat blogging engine that attempt to make it an equally compelling option for personal blog sites as it is for community blog sites.

  • Add additional route handling and rendering for full author pages. -Allow authors to further promote themselves by optionally specifying lists of languages, tools and interests - implemented as headers in author markdown documents and delimited by ";".
  • Make category display case insensitive.

For an example of a full author page please see http://godders83.com/author/Mike-Godfrey.

Mike Godfrey

Hi creationix, Wheat is the first project on Github I have successfully forked and made changes too. So this is also my first pull request - hope I've done it all correctly and you have time to review it in amongst all your commitments to JsGit. Many thanks, Mike Godfrey.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 19, 2013
  1. Mike Godfrey
Commits on Aug 20, 2013
  1. Mike Godfrey
Commits on Aug 21, 2013
  1. Mike Godfrey
Commits on Aug 23, 2013
  1. Mike Godfrey
  2. Mike Godfrey

    Removed stupid ability to specify a "site" author for display through

    crudbetter authored
    index.renderer - didn't make sense for what Wheat is.
  3. Mike Godfrey
Commits on Aug 28, 2013
  1. Mike Godfrey

    Moved away from using ';' as a delimiter for any markdown header to

    crudbetter authored
    specific 'languages', 'tools' and 'interests' headers for author.
  2. Mike Godfrey

    Guarded against any of 'languages', 'tools' or 'interests' headers not

    crudbetter authored
    being provided in author markdown.
Commits on Aug 31, 2013
  1. Mike Godfrey
This page is out of date. Refresh to see the latest.
19 README.markdown
View
@@ -1,15 +1,8 @@
-# Wheat
+## Fork details
-Wheat is a blogging engine that reads a git repo full of markdown articles and presents them as a website.
+Additional features/modifications to the excellent Wheat blogging engine that attempt to make it an equally compelling option for personal blog sites as it is for community blog sites.
-## How to Install
-
-Either manually install all the dependencies or use npm. It's packaged nicely now.
-
- 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>
+Planned features/modifications:
+* Add additional route handling and rendering for full author pages.
+* Allow authors to further promote themselves by optionally specifying lists of languages, tools and interests - implemented as headers in author markdown documents and delimited by ";".
+* Make category display case insensitive.
2  lib/wheat.js
View
@@ -59,7 +59,7 @@ module.exports = function setup(repo) {
addRoute(/^\/()(.+\.dot)$/, Renderers.dotFile);
addRoute(/^\/()(.+\.[a-z]{2,4})$/, Renderers.staticFile);
addRoute(/^\/()category\/([\%\.a-z0-9_-]+)$/, Renderers.categoryIndex);
-
+ addRoute(/^\/()author\/([A-Za-z0-9_-]+)$/, Renderers.author);
return function handle(req, res, next) {
var url = Url.parse(req.url);
5 lib/wheat/data.js
View
@@ -296,6 +296,11 @@ var Data = module.exports = {
function finish(err, props) {
if (err) { callback(err); return; }
props.name = name;
+
+ ['languages', 'tools', 'interests'].forEach(function(element) {
+ if (props[element]) props[element] = props[element].split(';');
+ });
+
return props;
},
callback
35 lib/wheat/renderers.js
View
@@ -115,14 +115,14 @@ var Renderers = module.exports = {
if (err) { callback(err); return; }
Data.articles(version, this.parallel());
Git.readFile(head, "description.markdown", this.parallel());
- Data.categories(version, 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
+ categories: categories
}, this);
},
function callPostProcess(err, buffer) {
@@ -202,6 +202,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() {
@@ -217,7 +246,7 @@ var Renderers = module.exports = {
if (err) { callback(err); return; }
var articlesForCategory = articles.reduce(function (start, element){
- return element.categories && element.categories.indexOf(category) >= 0 ? start.concat(element) : start;
+ return element.categories && element.categories.join(",").toLowerCase().indexOf(category) >= 0 ? start.concat(element) : start;
}, []);
Tools.render("index", {
Something went wrong with that request. Please try again.