Comparing version 0.0.2 to 0.0.3
var routes = { index : require('./lib/index') | ||
, error : require('./lib/error') | ||
, js : require('./lib/sendfile') | ||
, css : require('./lib/sendfile') | ||
, images : require('./lib/sendfile') | ||
} | ||
@@ -11,3 +13,4 @@ | ||
if (route == undefined) { | ||
route = routes['error'] | ||
route = routes['index'] | ||
path[2] = path[1] | ||
} | ||
@@ -19,3 +22,3 @@ | ||
function split_params (params) { | ||
if (params == undefined) { | ||
if (params == undefined || params == '/') { | ||
return ['','index'] | ||
@@ -22,0 +25,0 @@ } |
module.exports = reroute | ||
var template = require('./template') | ||
, md = require("github-flavored-markdown").parse | ||
, fs = require('fs') | ||
, siteConfig = require('./siteConfig') | ||
@@ -10,3 +13,20 @@ function reroute (req, res, path) { | ||
function view (req, res, path) { | ||
res.send(template.process('index', {title: 'Thom Blake - Computer Ethics'})) | ||
var name = path[2] || 'index' | ||
, filename = siteConfig.contentRoot + '/' + name + '.md' | ||
, content | ||
try { | ||
content = fs.readFileSync(filename, 'utf8') | ||
} | ||
catch (e) { | ||
} | ||
if (!content) { | ||
filename = siteConfig.contentRoot + '/404.md' | ||
content = fs.readFileSync(filename, 'utf8') | ||
} | ||
res.send(template.process('index', { title: 'Thom Blake - Computer Ethics' | ||
, root: '/blog' | ||
, content: md(content) | ||
} )) | ||
} |
@@ -7,2 +7,3 @@ module.exports = reroute | ||
, css : 'css/' | ||
, images : 'images' | ||
} | ||
@@ -22,4 +23,4 @@ | ||
else { | ||
res.sendfile(siteConfig.htdocsRoot + route + filename.input) | ||
res.sendfile(siteConfig.htdocsRoot + '/' + route + filename.input) | ||
} | ||
} |
@@ -0,5 +1,12 @@ | ||
var path = require('path') | ||
, siteRoot = path.resolve(__dirname, '..') | ||
, templateRoot = path.resolve(siteRoot, 'templates') | ||
, htdocsRoot = path.resolve(siteRoot, 'htdocs') | ||
, contentRoot = path.resolve(siteRoot, 'content') | ||
module.exports = | ||
{ siteRoot: '/m/nserver/blog/' | ||
, templateRoot: this.siteRoot + 'templates/' | ||
, htdocsRoot: this.siteRoot + 'htdocs/' | ||
{ siteRoot: siteRoot | ||
, templateRoot: templateRoot | ||
, htdocsRoot: htdocsRoot | ||
, contentRoot: contentRoot | ||
} |
@@ -9,7 +9,2 @@ var siteConfig = require('./siteConfig') | ||
, error : function() { return '404 not found' } | ||
, bugs : function() { return readTemplate('bugs') } | ||
, ingredients : function() { return readTemplate('ingredients') } | ||
, lists : function() { return readTemplate('lists') } | ||
, recipes : function() { return readTemplate('recipes') } | ||
, units : function() { return readTemplate('units') } | ||
} | ||
@@ -27,3 +22,3 @@ | ||
function readTemplate (name) { | ||
var filename = siteConfig.templateRoot + name + '.jt' | ||
var filename = siteConfig.templateRoot + '/' + name + '.jt' | ||
return fs.readFileSync(filename, 'utf8') | ||
@@ -30,0 +25,0 @@ } |
@@ -5,3 +5,3 @@ { "name": "blog" | ||
, "keywords" : [ "nserver", "blog" ] | ||
, "version" : "0.0.2" | ||
, "version" : "0.0.3" | ||
, "repository" : | ||
@@ -20,3 +20,4 @@ { "type" : "git" | ||
, "nserver-util" : "*" | ||
, "github-flavored-markdown" : "*" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 1 instance in 1 package
5459
14
153
3
4
2
+ Addedgithub-flavored-markdown@*
+ Addedgithub-flavored-markdown@1.0.1(transitive)