Comparing version 0.6.1 to 0.6.2
14
index.js
@@ -0,19 +1,11 @@ | ||
// blake - generate site | ||
var generate = require('./lib/generate.js') | ||
, join = require('path').join | ||
, getProps = require('./lib/getProps.js') | ||
module.exports = function (source, target) { | ||
var config = require(join(source, 'config.js')) | ||
, paths = require('./lib/paths.js')(source, target, config) | ||
, templates = require('./lib/templates.js')(paths.templates) | ||
, views = config.views | ||
var props = getProps(source, target) | ||
var props = { | ||
templates: templates | ||
, views: views | ||
, paths: paths | ||
} | ||
return generate(props) | ||
} |
@@ -0,1 +1,2 @@ | ||
// generate - generate and write artifacts | ||
@@ -11,4 +12,5 @@ | ||
, read = reader(props).read | ||
, currentFilename = null | ||
, ended = false | ||
, count = 0 | ||
, queue = [] | ||
@@ -24,11 +26,24 @@ stream.writable = true | ||
ended = true | ||
} | ||
if (count < 1) { | ||
stream.write = function (filename) { | ||
queue.push(filename) | ||
work() | ||
return true | ||
} | ||
function work () { | ||
var filename = queue[0] | ||
if (filename === currentFilename) { | ||
return | ||
} | ||
if (!filename && ended) { | ||
stream.emit('end') | ||
return | ||
} | ||
} | ||
stream.write = function (filename) { | ||
count++ | ||
currentFilename = filename | ||
read(filename, function (err, item) { | ||
@@ -38,17 +53,10 @@ bake(item, function (err) { | ||
stream.emit('error', err) | ||
} | ||
} | ||
stream.emit('data', item.path) | ||
count-- | ||
if (ended) { | ||
stream.end() | ||
return true | ||
} | ||
stream.resume() | ||
queue.shift() | ||
work() | ||
}) | ||
}) | ||
return false | ||
} | ||
@@ -55,0 +63,0 @@ |
@@ -0,1 +1,2 @@ | ||
// getItem - create and return source item | ||
@@ -39,5 +40,7 @@ | ||
header.title = header.title || null | ||
header.date = header.date ? new Date(header.date) : new Date() | ||
header.path = header.path | ||
|| path.dirname(filename).split(paths.posts)[1] | ||
|| null | ||
@@ -44,0 +47,0 @@ item.header = header |
{ | ||
"name": "blake", | ||
"description": "Simple, blog aware infrastructure to generate static sites", | ||
"version": "0.6.1", | ||
"version": "0.6.2", | ||
"homepage": "http://michaelnisi.github.com/blake/", | ||
@@ -30,16 +30,18 @@ "repository": { | ||
"dependencies": { | ||
"mkdirp": "", | ||
"fstream": "", | ||
"lru-cache": "", | ||
"prettydate": "", | ||
"event-stream": "", | ||
"cop": "", | ||
"popfun": "" | ||
"mkdirp": "0.3.x", | ||
"fstream": "0.1.x", | ||
"lru-cache": "2.1.x", | ||
"prettydate": "0.0.x", | ||
"event-stream": "3.0.x", | ||
"cop": "0.2.x", | ||
"popfun": "0.1.x" | ||
}, | ||
"devDependencies": { | ||
"tap": "", | ||
"rimraf": "" | ||
"tap": "0.3.x", | ||
"rimraf": "2.0.x", | ||
"jade": "0.27.x", | ||
"markdown": "0.4.x" | ||
}, | ||
"engines": { | ||
"node": ">=0.4.0" | ||
"node": ">=0.6.0" | ||
}, | ||
@@ -46,0 +48,0 @@ "license": "MIT", |
@@ -191,3 +191,3 @@ # blake - generate site | ||
Input data with this header, located at 'source_directory/data/posts/2012/03/example.md`, would produce `2012/03/article.html`. | ||
Input data with this header, located at `source_directory/data/posts/2012/03/example.md`, would produce `2012/03/article.html`. | ||
@@ -194,0 +194,0 @@ An input file can consist of just a header (without content) to generate, for example, an RSS feed. |
var test = require('tap').test | ||
, copy = require('../lib/copy.js') | ||
, join = require('path').join | ||
, fs = require('fs') | ||
, rimraf = require('rimraf') | ||
, source = '../example/blake-site/resources' | ||
, target = '/tmp/blake-test' | ||
, target = '/tmp/blake-' + Math.floor(Math.random() * (1<<24)) | ||
, fstream = require('fstream') | ||
@@ -18,4 +19,4 @@ , es = require('event-stream') | ||
var paths = [ | ||
'/tmp/blake-test/css/style.css' | ||
, '/tmp/blake-test/img/bg.png' | ||
join(target, 'css', 'style.css') | ||
, join(target, 'img', 'bg.png') | ||
] | ||
@@ -22,0 +23,0 @@ |
var test = require('tap').test | ||
, getItem = require('../lib/getItem.js') | ||
, strftime = require('prettydate').strftime | ||
, path = require('path') | ||
, readFileSync = require('fs').readFileSync | ||
, props = require('./props.js') | ||
, paths = props().paths | ||
, target = paths.target | ||
, config = require('./config.js') | ||
, target = config.target | ||
, props = config.props | ||
, paths = props.paths | ||
test('read', function (t) { | ||
var filename = 'source/data/about.md' | ||
var filename = path.join(paths.data, 'index.md') | ||
, file = readFileSync(filename) | ||
var header = { | ||
title: 'About The Troubled Programmer' | ||
, template: 'about.jade' | ||
, date: new Date('2012-04-08') | ||
, name: 'about.html' | ||
, path: undefined | ||
} | ||
, item = getItem(props, filename, file.toString()) | ||
, header = item.header | ||
var item = getItem(props(), filename, file.toString()) | ||
t.deepEqual(item.header, header, 'should be expected header') | ||
t.ok(item.body, 'should have a body') | ||
t.equal(item.path, target + '/about.html', 'should be correct path') | ||
t.equal(item.title, header.title, 'should be header title') | ||
t.equal(header.template, 'index.jade') | ||
t.equal(header.name, 'index.html') | ||
t.equal(header.title, null) | ||
t.ok(header.date instanceof Date, 'should be instance of Date') | ||
t.equal(header.path, null) | ||
t.end() | ||
}) | ||
t.ok(item.body.length, 'should have body') | ||
t.equal(item.title, null) | ||
t.equal(item.name, 'index.html') | ||
t.same(item.date, header.date) | ||
t.equal(item.pubDate, strftime(header.date, '%a, %d %b %Y %T %z')) | ||
t.equal(item.dateString, header.date.toDateString()) | ||
t.ok(item.template instanceof Buffer, 'should be instance of Buffer') | ||
t.equal(item.title, header.title) | ||
t.equal(item.link, 'index.html') | ||
t.ok(typeof item.bake === 'function', 'should be function type') | ||
t.equal(item.name, 'index.html') | ||
t.equal(item.path, path.join(target, header.name)) | ||
test('article', function (t) { | ||
var filename = 'source/data/posts/2012/double-negative.md' | ||
, file = readFileSync(filename) | ||
, item = getItem(props(), filename, file.toString()) | ||
, link = '2012/05/double-negative.html' | ||
, path = target + '/2012/05/double-negative.html' | ||
t.equal(item.link, link, 'should be correct link') | ||
t.equal(item.path, path, 'should be correct path') | ||
t.end() | ||
}) |
var test = require('tap').test | ||
, path = require('path') | ||
, reader = require('../lib/read.js') | ||
, getProps = require('./props.js') | ||
, read = reader(getProps()).read | ||
, config = require('./config.js') | ||
, props = config.props | ||
, read = reader(props).read | ||
test('file', function (t) { | ||
read('source/data/about.md', function (err, item) { | ||
test('read file', function (t) { | ||
read(path.join(props.paths.data, 'index.md'), function (err, item) { | ||
t.ok(item.header, 'should have header') | ||
@@ -14,4 +16,6 @@ t.ok(item.body, 'should have body') | ||
test('directory', function (t) { | ||
read('source/data/posts', function (err, items) { | ||
test('read directory', function (t) { | ||
t.end() | ||
read(props.paths.data, function (err, items) { | ||
items.forEach(function (item) { | ||
@@ -18,0 +22,0 @@ t.ok(item.header, 'should have header') |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 7 instances in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
1
14
30922
4
34
545
+ Addedcop@0.2.5(transitive)
+ Addedevent-stream@3.0.20(transitive)
+ Addedfstream@0.1.31(transitive)
+ Addedgraceful-fs@3.0.12(transitive)
+ Addedlru-cache@2.1.0(transitive)
+ Addedmkdirp@0.3.5(transitive)
+ Addednatives@1.1.6(transitive)
+ Addedpopfun@0.1.2(transitive)
+ Addedsplit@0.2.10(transitive)
+ Addedstream-combiner@0.0.4(transitive)
+ Addedthrough@2.2.7(transitive)
- Removedcop@1.0.0(transitive)
- Removedcore-util-is@1.0.3(transitive)
- Removedevent-stream@4.0.1(transitive)
- Removedfstream@1.0.12(transitive)
- Removedgraceful-fs@4.2.11(transitive)
- Removedisarray@1.0.0(transitive)
- Removedlru-cache@11.0.2(transitive)
- Removedmkdirp@3.0.1(transitive)
- Removedpopfun@1.0.0(transitive)
- Removedprocess-nextick-args@2.0.1(transitive)
- Removedreadable-stream@2.3.8(transitive)
- Removedsafe-buffer@5.1.2(transitive)
- Removedsplit@1.0.1(transitive)
- Removedstream-combiner@0.2.2(transitive)
- Removedstring_decoder@1.1.1(transitive)
- Removedutil-deprecate@1.0.2(transitive)
Updatedcop@0.2.x
Updatedevent-stream@3.0.x
Updatedfstream@0.1.x
Updatedlru-cache@2.1.x
Updatedmkdirp@0.3.x
Updatedpopfun@0.1.x
Updatedprettydate@0.0.x