New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

darko

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

darko - npm Package Compare versions

Comparing version

to
0.1.0

History.md

4

lib/parsers/data.js

@@ -1,2 +0,2 @@

var yaml = require('js-yaml')
var yaml = require('yaml-js')
var path = require('path')

@@ -14,3 +14,3 @@ var fs = require('fs')

if (path.extname(entry) === '.yml') {
obj[path.basename(entry, '.yml')] = yaml.safeLoad(
obj[path.basename(entry, '.yml')] = yaml.load(
fs.readFileSync(path.join(dir, entry), site.encoding)

@@ -17,0 +17,0 @@ )

var fs = require('fs')
var yaml = require('js-yaml')
var yaml = require('yaml-js')
var path = require('path')

@@ -35,5 +35,5 @@ var _ = require('lodash')

this.url = '/' + (this.path.indexOf(path.sep) >= 0 ? path.dirname(this.path) : '')
this.url = '/' + (this.path.indexOf(path.sep) >= 0 && path.dirname(this.path))
this.dest = path.join(this.site.dest, this.path.replace(/\.\w+$/, '.html'))
this.dest = path.join(this.site.dest, this.site.baseurl.slice(1), this.path.replace(/\.\w+$/, '.html'))
}

@@ -40,0 +40,0 @@

@@ -1,2 +0,2 @@

var yaml = require('js-yaml')
var yaml = require('yaml-js')
var path = require('path')

@@ -6,5 +6,6 @@ var fs = require('fs')

var util = require('../util')
var debug = require('debug')('darko')
var PTN_POST_FILE = /(\d{4}-\d{2}-\d{2})-([-\w]+?)(\.\w+)$/
var PTN_POST_FILE = /(\d{4}-\d{2}-\d{2})-([^\\]+?)(\.\w+)$/

@@ -15,2 +16,7 @@

var m = fpath.match(PTN_POST_FILE)
if (!m) {
debug('Ignored ' + path.relative(attrs.site.cwd, attrs.fpath))
return
}
var date = m[1].split('-')

@@ -37,3 +43,4 @@

this.content = parts.slice(2).join('---').trim()
this.excerpt = this.content.slice(0, this.content.indexOf('\n\n'))
var caret = this.content.indexOf('\n\n')
this.excerpt = caret > 0 ? this.content.slice(0, caret) : this.content
}

@@ -88,3 +95,3 @@ else {

this.dest = path.join(this.site.dest, this.url)
this.dest = path.join(this.site.dest, this.site.baseurl.slice(1), this.url)
if (path.extname(this.dest) !== '.html') {

@@ -91,0 +98,0 @@ this.dest = this.dest.replace(/\/?$/, '/index.html')

var fs = require('fs')
var yaml = require('js-yaml')
var yaml = require('yaml-js')
var _ = require('lodash')

@@ -31,3 +31,5 @@ var Q = require('q')

this.cwd = path.resolve(process.cwd(), attrs.cwd || './')
this.dest = path.resolve(this.cwd, attrs.dest || './_site')
this.dest = attrs.dest ?
path.resolve(process.cwd(), attrs.dest) :
path.join(this.cwd, '_site')
this.includeDrafts = attrs.includeDrafts

@@ -47,6 +49,10 @@ this.includeFuture = attrs.includeFuture

if (fs.existsSync(config)) {
_.extend(site, yaml.safeLoad(fs.readFileSync(config, site.encoding)))
var content = fs.readFileSync(config, site.encoding)
_.extend(site, yaml.load(content))
}
})
// Make sure baseurl is not null
this.baseurl = this.baseurl || ''
this.posts = []

@@ -149,2 +155,21 @@ this.pages = []

function batch(arr, size, fn) {
var offset = 0
var length = arr.length
var limit = size
function _batch(offset, limit) {
return Q.all(arr.slice(offset, limit).map(fn))
.then(function() {
if (limit <= length) {
offset = limit
limit += size
return _batch(offset, limit)
}
})
}
return _batch(offset, limit)
}
Site.prototype.write = function() {

@@ -157,21 +182,2 @@ var site = this

function batch(arr, size, fn) {
var offset = 0
var length = arr.length
var limit = size
function _batch(offset, limit) {
return Q.all(arr.slice(offset, limit).map(fn))
.then(function() {
if (limit <= length) {
offset = limit
limit += size
return _batch(offset, limit)
}
})
}
return _batch(offset, limit)
}
return batch(this.staticFiles, 10, function(fpath) {

@@ -184,2 +190,7 @@ return writeStatic(fpath, site)

Site.prototype.writeP = function() {
return batch(this.posts, 10, writeTemplated)
.then(batch(this.pages, 10, writeTemplated))
}
// These two functions are a little dangerous because assigning functions in

@@ -186,0 +197,0 @@ // this way makes the `this` value in them become uncertain.

@@ -12,3 +12,3 @@ var path = require('path')

var rpath = path.relative(site.cwd, fpath)
var dest = path.resolve(site.dest, rpath)
var dest = path.resolve(site.dest, site.baseurl.slice(1), rpath)

@@ -15,0 +15,0 @@ debug('Coping file ' + rpath)

var path = require('path')
var yaml = require('js-yaml')
var yaml = require('yaml-js')
var fs = require('fs')

@@ -4,0 +4,0 @@ var mkdirp = require('mkdirp').sync

{
"name": "darko",
"version": "0.0.2",
"version": "0.1.0",
"dependencies": {
"liquid-node": "~0.1.2",
"js-yaml": "~3.0.1",
"lodash": "~2.4.1",

@@ -14,3 +13,4 @@ "markit": "~0.1.0",

"highlight.js": "~7.5.0",
"debug": "~0.7.4"
"debug": "~0.7.4",
"yaml-js": "0.0.8"
},

@@ -17,0 +17,0 @@ "bin": {

@@ -19,2 +19,16 @@ var path = require('path')

site.pages.should.not.be.empty
var postLinks = site.posts.map(function(po) {
return po.url
})
postLinks.should.contain('/catus/ham.html')
postLinks.should.contain('/felis/egg.html')
// _posts/baz should not be published because it has the published property
// set to false in the YAML front mattter.
postLinks.should.not.contain('/baz.html')
// _drafts/bad should not be published because it is in the drafts folder.
postLinks.should.not.contain('/bad.html')
})

@@ -21,0 +35,0 @@

Sorry, the diff of this file is not supported yet