Skip to content

Commit

Permalink
remove dead code, expose node fsapi
Browse files Browse the repository at this point in the history
  • Loading branch information
AJ ONeal committed Jan 13, 2015
1 parent 3235b6c commit 4b71063
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 38 deletions.
13 changes: 8 additions & 5 deletions desirae.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -242,7 +242,7 @@
, authors: arr.authors
});

desi.blogdir = blogdir;
//desi.blogdir = blogdir;
desi.originals = {};
desi.copies = {};

Expand Down Expand Up @@ -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));
28 changes: 1 addition & 27 deletions lib/deardesi-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
;
Expand Down Expand Up @@ -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
Expand All @@ -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 {};
Expand All @@ -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
Expand Down
14 changes: 9 additions & 5 deletions lib/frontmatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -82,7 +85,7 @@

if (fm) {
try {
yml = window.YAML.parse(fm);
yml = Desi.YAML.parse(fm);
} catch(e) {
//
}
Expand All @@ -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));
1 change: 1 addition & 0 deletions lib/fsapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down

0 comments on commit 4b71063

Please sign in to comment.