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