remove dead code, expose node fsapi
This commit is contained in:
parent
3235b6c182
commit
4b71063637
13
desirae.js
13
desirae.js
|
@ -230,10 +230,10 @@
|
|||
// read config and such
|
||||
Desi.init = function (desi) {
|
||||
// config.yml, data.yml, site.yml, authors
|
||||
return PromiseA.all([fsapi.getBlogdir(), fsapi.getAllConfigFiles()]).then(function (plop) {
|
||||
var blogdir = plop[0]
|
||||
, arr = plop[1]
|
||||
;
|
||||
return PromiseA.all([fsapi.getAllConfigFiles()/*, fsapi.getBlogdir()*/]).then(function (plop) {
|
||||
var arr = plop[0]
|
||||
//, blogdir = plop[1]
|
||||
;
|
||||
|
||||
console.info('loaded config, data, caches, partials');
|
||||
console.log({
|
||||
|
@ -242,7 +242,7 @@
|
|||
, authors: arr.authors
|
||||
});
|
||||
|
||||
desi.blogdir = blogdir;
|
||||
//desi.blogdir = blogdir;
|
||||
desi.originals = {};
|
||||
desi.copies = {};
|
||||
|
||||
|
@ -1093,5 +1093,8 @@
|
|||
});
|
||||
};
|
||||
|
||||
if (!exports.window && !exports.window.Mustache) {
|
||||
Desi.fsapi = require('./lib/fsapi');
|
||||
}
|
||||
exports.Desi = Desi.Desi = Desi;
|
||||
}('undefined' !== typeof exports && exports || window));
|
||||
|
|
|
@ -225,12 +225,6 @@
|
|||
});
|
||||
};
|
||||
|
||||
fsapi.getConfig = function () {
|
||||
return request.get('/config.yml').then(function (resp) {
|
||||
return exports.YAML.parse(resp);
|
||||
});
|
||||
};
|
||||
|
||||
fsapi.getConfigs = function (confs) {
|
||||
var opts = { extensions: ['yml', 'yaml', 'json'], dotfiles: false, contents: true, sha1sum: true }
|
||||
;
|
||||
|
@ -323,11 +317,6 @@
|
|||
return partials;
|
||||
});
|
||||
};
|
||||
fsapi.getBlogdir = function () {
|
||||
return request.get('/api/fs').then(function (resp) {
|
||||
return JSON.parse(resp);
|
||||
});
|
||||
};
|
||||
fsapi.getAllConfigFiles = function () {
|
||||
return fsapi.getConfigs(['config.yml', 'site.yml', 'authors']).then(function (results) {
|
||||
var authors = results.authors
|
||||
|
@ -339,14 +328,8 @@
|
|||
});
|
||||
};
|
||||
|
||||
fsapi.getData = function () {
|
||||
return request.get('/data.yml').then(function (resp) {
|
||||
return exports.YAML.parse(resp);
|
||||
});
|
||||
};
|
||||
|
||||
fsapi.getCache = function () {
|
||||
return request.get('/cache.json').then(function (resp) {
|
||||
return request.get('/api/fs/static/cache.json').then(function (resp) {
|
||||
return JSON.parse(resp);
|
||||
}).catch(function (/*e*/) {
|
||||
return {};
|
||||
|
@ -355,15 +338,6 @@
|
|||
});
|
||||
};
|
||||
|
||||
fsapi.getPartials = function () {
|
||||
return request.get('/partials.yml').then(function (resp) {
|
||||
var partials = exports.YAML.parse(resp)
|
||||
;
|
||||
|
||||
return partials;
|
||||
});
|
||||
};
|
||||
|
||||
fsapi.copy = function (files) {
|
||||
var body = { files: files };
|
||||
body = JSON.stringify(body); // this is more or less instant for a few MiB of posts
|
||||
|
|
|
@ -2,9 +2,12 @@
|
|||
;(function (exports) {
|
||||
'use strict';
|
||||
|
||||
window.YAML = window.YAML || {};
|
||||
window.YAML.parse = exports.jsyaml.load || require('jsyaml').load;
|
||||
window.YAML.stringify = exports.jsyaml.dump || require('jsyaml').dump;
|
||||
var Desi = {}
|
||||
;
|
||||
|
||||
Desi.YAML = {};
|
||||
Desi.YAML.parse = (exports.jsyaml || require('js-yaml')).load;
|
||||
Desi.YAML.stringify = (exports.jsyaml || require('js-yaml')).dump;
|
||||
|
||||
function readFrontMatter(text) {
|
||||
var lines
|
||||
|
@ -82,7 +85,7 @@
|
|||
|
||||
if (fm) {
|
||||
try {
|
||||
yml = window.YAML.parse(fm);
|
||||
yml = Desi.YAML.parse(fm);
|
||||
} catch(e) {
|
||||
//
|
||||
}
|
||||
|
@ -95,9 +98,10 @@
|
|||
};
|
||||
}
|
||||
|
||||
exports.Frontmatter = exports.Frontmatter = {};
|
||||
exports.Frontmatter = {};
|
||||
exports.Frontmatter.Frontmatter = exports.Frontmatter;
|
||||
exports.Frontmatter.readText = readFrontMatter;
|
||||
exports.Frontmatter.separateText = separateText;
|
||||
exports.Frontmatter.parse = parseText;
|
||||
exports.Frontmatter.YAML = Desi.YAML;
|
||||
}('undefined' !== typeof exports && exports || window));
|
||||
|
|
|
@ -363,3 +363,4 @@ module.exports.getfs = getfs;
|
|||
module.exports.putfs = putfs;
|
||||
module.exports.walkDir = walkDir;
|
||||
module.exports.walkDirs = walkDirs;
|
||||
module.exports.fsapi = module.exports;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"name": "desirae",
|
||||
"version": "0.1.0",
|
||||
"description": "An in-browser knockoff of the Ruhoh static blog generator. (similar to Jekyll, Octopress, Nanoc, etc)",
|
||||
"main": "server.js",
|
||||
"main": "desirae.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue