Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

blake

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

blake - npm Package Compare versions

Comparing version 0.6.1 to 0.6.2

lib/getProps.js

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')

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc