Comparing version 0.1.2 to 0.2.0
@@ -1,4 +0,4 @@ | ||
// Generated by CoffeeScript 1.6.3 | ||
// Generated by CoffeeScript 1.7.1 | ||
(function() { | ||
var Liquid, MONTHS, MONTH_ABBRS, Promise, WEEKDAYS, WEEKDAY_ABBRS, engine, formatDate, highlight, md, | ||
var Liquid, MONTHS, MONTH_ABBRS, Promise, WEEKDAYS, WEEKDAY_ABBRS, engine, highlight, isString, md, toObjectString, toString, | ||
__hasProp = {}.hasOwnProperty, | ||
@@ -24,59 +24,18 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, | ||
formatDate = function(input, format) { | ||
var pad; | ||
toObjectString = Object.prototype.toString; | ||
isString = function(input) { | ||
return toObjectString.call(input) === "[object String]"; | ||
}; | ||
toString = function(input) { | ||
if (input == null) { | ||
return ""; | ||
} else if (isString(input)) { | ||
return input; | ||
} else if (typeof input.toString === "function") { | ||
return input.toString(); | ||
} else { | ||
return toObjectString.call(input); | ||
} | ||
pad = function(str, chr, width) { | ||
var len; | ||
str = '' + str; | ||
len = Math.max(0, width - str.length); | ||
return Array(len + 1).join(chr) + str; | ||
}; | ||
return format.replace(/%([a-zA-Z])/g, function(m, f) { | ||
var days, offset, prefix, _ref; | ||
switch (f) { | ||
case 'a': | ||
return WEEKDAY_ABBRS[input.getDay()]; | ||
case 'A': | ||
return WEEKDAYS[input.getDay()]; | ||
case 'b': | ||
return MONTH_ABBRS[input.getMonth()]; | ||
case 'B': | ||
return MONTHS[input.getMonth()]; | ||
case 'd': | ||
return pad(input.getDate(), '0', 2); | ||
case 'e': | ||
return input.getDate(); | ||
case 'H': | ||
return pad(input.getHours(), '0', 2); | ||
case 'I': | ||
return pad(input.getHours() % 12, '0', 2); | ||
case 'j': | ||
days = (+input - (new Date(input.getFullYear(), 0, 1))) / 1000 / 60 / 60 / 24; | ||
return pad(days, '0', 3); | ||
case 'm': | ||
return pad(input.getMonth() + 1, '0', 2); | ||
case 'M': | ||
return pad(input.getMinutes(), '0', 2); | ||
case 'p': | ||
return (_ref = input.getHours() >= 12) != null ? _ref : { | ||
'PM': 'AM' | ||
}; | ||
case 'S': | ||
return pad(input.getSeconds(), '0', 2); | ||
case 'w': | ||
return input.getDay(); | ||
case 'y': | ||
return input.getFullYear() / 100; | ||
case 'Y': | ||
return input.getFullYear(); | ||
case 'z': | ||
offset = -input.getTimezoneOffset() / 60; | ||
prefix = offset >= 0 ? '+' : '-'; | ||
return prefix + pad(offset, '0', 2) + '00'; | ||
default: | ||
return f; | ||
} | ||
}); | ||
}; | ||
@@ -118,3 +77,3 @@ | ||
engine.registerTag("highlight", (function() { | ||
var HighlightBlock, _ref; | ||
var HighlightBlock; | ||
return HighlightBlock = (function(_super) { | ||
@@ -124,4 +83,3 @@ __extends(HighlightBlock, _super); | ||
function HighlightBlock() { | ||
_ref = HighlightBlock.__super__.constructor.apply(this, arguments); | ||
return _ref; | ||
return HighlightBlock.__super__.constructor.apply(this, arguments); | ||
} | ||
@@ -222,20 +180,14 @@ | ||
engine.registerFilter({ | ||
capitalize: function(input) { | ||
return input && input.replace(/^([a-z])/, function(m, chr) { | ||
return chr.toUpperCase(); | ||
}); | ||
}, | ||
date: formatDate, | ||
engine.registerFilters({ | ||
date_to_xmlschema: function(input) { | ||
return formatDate(input, '%Y-%m-%dT%H:%M:%S%z').replace(/00$/, ':00'); | ||
return this.date(input, '%Y-%m-%dT%H:%M:%S%z').replace(/00$/, ':00'); | ||
}, | ||
date_to_rfc822: function(input) { | ||
return formatDate(input, '%a, %d %b %Y %H:%M:%S %z'); | ||
return this.date(input, '%a, %d %b %Y %H:%M:%S %z'); | ||
}, | ||
date_to_string: function(input) { | ||
return formatDate(input, '%d %b %Y'); | ||
return this.date(input, '%d %b %Y'); | ||
}, | ||
date_to_long_string: function(input) { | ||
return formatDate(input, '%d %B %Y'); | ||
return this.date(input, '%d %B %Y'); | ||
}, | ||
@@ -270,3 +222,3 @@ xml_escape: function(input) { | ||
markdownify: function(input) { | ||
return md(input); | ||
return md(toString(input)); | ||
}, | ||
@@ -279,4 +231,3 @@ jsonify: function(input) { | ||
engine.extParse = function(src, importer) { | ||
var baseTemplate, deferred, depth, stack, walker, | ||
_this = this; | ||
var baseTemplate, deferred, depth, stack, walker; | ||
if (!src) { | ||
@@ -313,22 +264,24 @@ throw new Error('Empty liquid template source'); | ||
}; | ||
walker(stack[0], function(err) { | ||
var rootTemplate, subTemplates; | ||
if (err) { | ||
return deferred.reject(err); | ||
} | ||
rootTemplate = stack[0], subTemplates = 2 <= stack.length ? __slice.call(stack, 1) : []; | ||
subTemplates.forEach(function(subTemplate) { | ||
var k, rootTemplateBlocks, subTemplateBlocks, v, _ref, _results; | ||
subTemplateBlocks = subTemplate.exportedBlocks || {}; | ||
rootTemplateBlocks = rootTemplate.exportedBlocks || {}; | ||
_results = []; | ||
for (k in subTemplateBlocks) { | ||
if (!__hasProp.call(subTemplateBlocks, k)) continue; | ||
v = subTemplateBlocks[k]; | ||
_results.push((_ref = rootTemplateBlocks[k]) != null ? _ref.replace(v) : void 0); | ||
walker(stack[0], (function(_this) { | ||
return function(err) { | ||
var rootTemplate, subTemplates; | ||
if (err) { | ||
return deferred.reject(err); | ||
} | ||
return _results; | ||
}); | ||
return deferred.resolve(rootTemplate); | ||
}); | ||
rootTemplate = stack[0], subTemplates = 2 <= stack.length ? __slice.call(stack, 1) : []; | ||
subTemplates.forEach(function(subTemplate) { | ||
var k, rootTemplateBlocks, subTemplateBlocks, v, _ref, _results; | ||
subTemplateBlocks = subTemplate.exportedBlocks || {}; | ||
rootTemplateBlocks = rootTemplate.exportedBlocks || {}; | ||
_results = []; | ||
for (k in subTemplateBlocks) { | ||
if (!__hasProp.call(subTemplateBlocks, k)) continue; | ||
v = subTemplateBlocks[k]; | ||
_results.push((_ref = rootTemplateBlocks[k]) != null ? _ref.replace(v) : void 0); | ||
} | ||
return _results; | ||
}); | ||
return deferred.resolve(rootTemplate); | ||
}; | ||
})(this)); | ||
return deferred.promise; | ||
@@ -335,0 +288,0 @@ }; |
@@ -10,3 +10,3 @@ 'use strict'; | ||
var PAGE_FORMATS = ['.md', '.html'] | ||
var PAGE_FORMATS = ['.md', '.html', '.xml'] | ||
@@ -40,3 +40,4 @@ | ||
this.dest = path.join(this.site.dest, this.site.baseurl.slice(1), this.path.replace(/\.\w+$/, '.html')) | ||
this.dest = path.join(this.site.dest, this.site.baseurl.slice(1), | ||
this.path.replace(/\.\w+$/, this.ext == '.md' ? '.html' : this.ext)) | ||
} | ||
@@ -43,0 +44,0 @@ |
@@ -108,3 +108,3 @@ 'use strict'; | ||
} | ||
else if (/\.(md|html)$/.test(fpath)) { | ||
else if (/\.(md|html|xml)$/.test(fpath)) { | ||
page = new Page({ fpath: fpath, site: site }) | ||
@@ -111,0 +111,0 @@ if (page.valid) site.pages.push(page) |
@@ -5,3 +5,2 @@ 'use strict'; | ||
var yaml = require('yaml-js') | ||
var fs = require('fs') | ||
var mkdirp = require('mkdirp').sync | ||
@@ -15,3 +14,3 @@ var engine = require('../liquid') | ||
var readFile = Promise.promisify(fs.readFile) | ||
var fs = Promise.promisifyAll(require('fs')) | ||
@@ -26,5 +25,5 @@ | ||
Promise.some([ | ||
readFile(includePath, site.encoding), | ||
readFile(includePath + '.md', site.encoding), | ||
readFile(includePath + '.html', site.encoding) | ||
fs.readFileAsync(includePath, site.encoding), | ||
fs.readFileAsync(includePath + '.md', site.encoding), | ||
fs.readFileAsync(includePath + '.html', site.encoding) | ||
], 1) | ||
@@ -50,3 +49,3 @@ .then(function(results) { | ||
if (!page.layoutWas) page.layoutWas = page.layout | ||
if (!page.layout || page.layout_ == page.layout) { | ||
if (!page.layout || page.layout == 'nil' || page.layout_ == page.layout) { | ||
// Finished layout renderring, restore the original layout of current page | ||
@@ -126,2 +125,3 @@ page.layout = page.layoutWas | ||
page.content = page.contentWas | ||
return page | ||
}) | ||
@@ -128,0 +128,0 @@ .catch(function(err) { |
{ | ||
"name": "darko", | ||
"version": "0.1.2", | ||
"version": "0.2.0", | ||
"repository": { | ||
@@ -9,3 +9,3 @@ "type": "git", | ||
"dependencies": { | ||
"liquid-node": "0.2.0", | ||
"liquid-node": "~1.0.0", | ||
"lodash": "~2.4.1", | ||
@@ -26,2 +26,5 @@ "markit": "~0.1.0", | ||
}, | ||
"scripts": { | ||
"test": "mocha test/**/*.js" | ||
}, | ||
"devDependencies": { | ||
@@ -28,0 +31,0 @@ "mocha": "~1.17.0", |
@@ -30,3 +30,3 @@ # Darko | ||
Now point your browser to <http://localhost:4100>. | ||
Now point your browser to <http://localhost:4000>. | ||
@@ -36,3 +36,3 @@ If you're working on project repos and there's no CNAME used, there must be a | ||
name is `my-project`, you'll need to point your browser to | ||
<http://localhost:4100/my-project>. | ||
<http://localhost:4000/my-project>. | ||
@@ -39,0 +39,0 @@ ## Why? |
@@ -1,2 +0,2 @@ | ||
var should = require('should') | ||
require('should') | ||
var Liquid = require('../').Liquid | ||
@@ -6,3 +6,3 @@ | ||
function liquid(tpl, data) { | ||
return Liquid.Template.extParse(tpl).then(function(template) { | ||
return Liquid.extParse(tpl).then(function(template) { | ||
return template.render(data) | ||
@@ -9,0 +9,0 @@ }) |
@@ -5,3 +5,3 @@ var path = require('path') | ||
var util = require('..').util | ||
var should = require('should') | ||
require('should') | ||
@@ -38,7 +38,3 @@ | ||
site.write() | ||
.fail(function(err) { | ||
util.error('Generation failed because of:') | ||
util.error(err.stack) | ||
}) | ||
.done(function() { | ||
.then(function() { | ||
util.log('Generating', '... done') | ||
@@ -48,3 +44,7 @@ fs.existsSync(site.dest).should.be.ok | ||
}) | ||
.catch(function(err) { | ||
util.error('Generation failed because of:') | ||
util.error(err.stack) | ||
}) | ||
}) | ||
}) |
@@ -1,2 +0,2 @@ | ||
var should = require('should') | ||
require('should') | ||
var path = require('path') | ||
@@ -3,0 +3,0 @@ var Site = require('..').Site |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
47
92655
1083
+ Addedliquid-node@1.0.0(transitive)
+ Addedstrftime@0.8.4(transitive)
- Removedasap@2.0.6(transitive)
- Removedasync@3.2.6(transitive)
- Removedcoffee-script@1.4.0(transitive)
- Removedliquid-node@0.2.0(transitive)
- Removedpop-iterate@1.0.1(transitive)
- Removedq@2.0.3(transitive)
- Removedunderscore@1.13.7(transitive)
- Removedweak-map@1.0.8(transitive)
Updatedliquid-node@~1.0.0