diff --git a/bower.json b/bower.json
index b7bc489..4949cc4 100644
--- a/bower.json
+++ b/bower.json
@@ -35,6 +35,7 @@
"escape-string-regexp": "~1.0.2",
"marked": "~0.3.2",
"js-yaml": "~3.2.5",
- "path": "~3.46.1"
+ "path": "~3.46.1",
+ "forEachAsync": "~5.0.2"
}
}
diff --git a/deardesi.js b/deardesi.js
index 6801b0f..df6fbdd 100644
--- a/deardesi.js
+++ b/deardesi.js
@@ -9,7 +9,7 @@
, marked = exports.marked || require('marked')
, forEachAsync = exports.forEachAsync || require('foreachasync').forEachAsync
, sha1sum = exports.sha1sum || require('./lib/deardesi-node').sha1sum
- , frontmatter = exports.frontmatter || require('./lib/frontmatter').Frontmatter
+ , frontmatter = exports.Frontmatter || require('./lib/frontmatter').Frontmatter
, safeResolve = exports.safeResolve || require('./lib/deardesi-utils').safeResolve
, getStats = exports.getStats || require('./lib/deardesi-node').getStats
, getContents = exports.getContents || require('./lib/deardesi-node').getContents
diff --git a/index.html b/index.html
index 6878139..a948046 100644
--- a/index.html
+++ b/index.html
@@ -8,6 +8,7 @@
+
diff --git a/lib/deardesi-browser.js b/lib/deardesi-browser.js
index 511bf36..ef18786 100644
--- a/lib/deardesi-browser.js
+++ b/lib/deardesi-browser.js
@@ -1,13 +1,4 @@
/*jshint -W054 */
-var tmpglobal
- ;
-
-try {
- tmpglobal = new Function('return this')();
-} catch(e) {
- tmpglobal = window;
-}
-
;(function (exports) {
'use strict';
@@ -115,14 +106,89 @@ try {
exports.hashsum = hashsum;
exports.sha1sum = sha1sum;
-}('undefined' !== typeof exports && exports || tmpglobal));
+}('undefined' !== typeof exports && exports || window));
;(function () {
'use strict';
+ function request() {
+ }
+ request.get = function (url/*, query*/) {
+ // Return a new promise.
+ return new Promise(function(resolve, reject) {
+ // Do the usual XHR stuff
+ var req = new XMLHttpRequest()
+ ;
+
+ req.onload = function() {
+ // This is called even on 404 etc
+ // so check the status
+ if (200 === req.status) {
+ // Resolve the promise with the response text
+ resolve(req.response);
+ }
+ else {
+ // Otherwise reject with the status text
+ // which will hopefully be a meaningful error
+ reject(Error(req.statusText));
+ }
+ };
+
+ // Handle network errors
+ req.onerror = function() {
+ reject(Error("Network Error"));
+ };
+
+ // Make the request
+ req.open('GET', url);
+ req.send();
+ });
+ };
+ request.post = function (url/*, query*/, body) {
+ // Return a new promise.
+ return new Promise(function(resolve, reject) {
+ // Do the usual XHR stuff
+ var req = new XMLHttpRequest()
+ ;
+
+ req.onload = function() {
+ // This is called even on 404 etc
+ // so check the status
+ if (200 === req.status) {
+ // Resolve the promise with the response text
+ resolve(req.response);
+ }
+ else {
+ // Otherwise reject with the status text
+ // which will hopefully be a meaningful error
+ reject(Error(req.statusText));
+ }
+ };
+
+ // Handle network errors
+ req.onerror = function() {
+ reject(Error("Network Error"));
+ };
+
+ req.open('POST', url);
+ req.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
+ // Make the request
+ req.send(JSON.stringify(body, null, ' '));
+ });
+ };
+
+ exports.getCollectionMeta = function (collections) {
+ return request.post('/api/fs/walk?_method=GET&dotfiles=true&extensions=md,markdown,jade,htm,html', {
+ dirs: collections
+ }).then(function (resp) {
+ return JSON.parse(resp.responseText);
+ });
+ };
+ /*
exports.getStats
exports.getContents
exports.getMetaCache
exports.getContentCache
+ */
//require('./db').create(path.join(_dirname, 'db.json'))
-}());
+}('undefined' !== typeof exports && exports || window));
diff --git a/lib/frontmatter.js b/lib/frontmatter.js
index 17be626..8c10b7f 100644
--- a/lib/frontmatter.js
+++ b/lib/frontmatter.js
@@ -96,7 +96,8 @@
};
}
- exports.Frontmatter.Frontmatter = exports.Frontmatter = {};
+ exports.Frontmatter = exports.Frontmatter = {};
+ exports.Frontmatter.Frontmatter = exports.Frontmatter;
exports.Frontmatter.readText = readFrontMatter;
exports.Frontmatter.separateText = separateText;
exports.Frontmatter.parse = parseText;
diff --git a/lib/verify-config.js b/lib/verify-config.js
index 01f1314..fd1bf52 100644
--- a/lib/verify-config.js
+++ b/lib/verify-config.js
@@ -1,56 +1,58 @@
-'use strict';
+;(function (exports) {
+ 'use strict';
-module.export.verify = function (conf) {
- if (!conf.NuhohSpec) {
- throw new Error("missing key NuhohSpec");
- }
-
- if (!conf.production) {
- throw new Error("missing key production");
- }
-
- if (!conf.production.canonical_url) {
- throw new Error("missing key production.canonical_url");
- }
-
- if (!conf.production.base_path) {
- throw new Error("missing key production.base_path");
- }
-
- if (!conf.development) {
- throw new Error("missing key development");
- }
-
- if (!conf.development.compiled_path) {
- throw new Error("missing key development.compiled_path");
- }
-
- if (!Array.isArray(conf.collections)) {
- if (conf.posts) {
- console.error("Please indent and nest 'posts' under the key 'collection' to continue");
+ exports.verifyConfig = function (conf) {
+ if (!conf.NuhohSpec) {
+ throw new Error("missing key NuhohSpec");
}
- throw new Error("missing key 'collections'.");
- }
- if (!conf.themes) {
- if (conf.twitter) {
- console.error("Please indent and nest 'twitter' under the key 'themes' to continue");
+ if (!conf.production) {
+ throw new Error("missing key production");
}
- throw new Error("missing key 'themes'");
- }
- if (!conf.themes.default) {
- if (conf.twitter) {
- console.error("Please set themes.default to 'twitter'");
+ if (!conf.production.canonical_url) {
+ throw new Error("missing key production.canonical_url");
}
- throw new Error("missing key 'themes.default'");
- }
- if (!conf.root) {
- throw new Error("missing key root");
- }
+ if (!conf.production.base_path) {
+ throw new Error("missing key production.base_path");
+ }
- if (!conf.widgets) {
- throw new Error("missing key root");
- }
-};
+ if (!conf.development) {
+ throw new Error("missing key development");
+ }
+
+ if (!conf.development.compiled_path) {
+ throw new Error("missing key development.compiled_path");
+ }
+
+ if (!Array.isArray(conf.collections)) {
+ if (conf.posts) {
+ console.error("Please indent and nest 'posts' under the key 'collection' to continue");
+ }
+ throw new Error("missing key 'collections'.");
+ }
+
+ if (!conf.themes) {
+ if (conf.twitter) {
+ console.error("Please indent and nest 'twitter' under the key 'themes' to continue");
+ }
+ throw new Error("missing key 'themes'");
+ }
+
+ if (!conf.themes.default) {
+ if (conf.twitter) {
+ console.error("Please set themes.default to 'twitter'");
+ }
+ throw new Error("missing key 'themes.default'");
+ }
+
+ if (!conf.root) {
+ throw new Error("missing key root");
+ }
+
+ if (!conf.widgets) {
+ throw new Error("missing key root");
+ }
+ };
+}('undefined' !== typeof exports && exports || window));