diff --git a/desirae.js b/desirae.js index 5bdc480..fd60c01 100644 --- a/desirae.js +++ b/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)); diff --git a/lib/deardesi-browser.js b/lib/deardesi-browser.js index 50c6e37..824171d 100644 --- a/lib/deardesi-browser.js +++ b/lib/deardesi-browser.js @@ -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 diff --git a/lib/frontmatter.js b/lib/frontmatter.js index 12dd688..a0a3911 100644 --- a/lib/frontmatter.js +++ b/lib/frontmatter.js @@ -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)); diff --git a/lib/fsapi.js b/lib/fsapi.js index a08eba1..d05cbd0 100644 --- a/lib/fsapi.js +++ b/lib/fsapi.js @@ -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; diff --git a/package.json b/package.json index 41855d3..1eab101 100644 --- a/package.json +++ b/package.json @@ -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" },