getting more browser-ready-tastic
This commit is contained in:
parent
a44478de87
commit
cc3f24daf0
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
<script src="./bower_components/marked/lib/marked.js"></script>
|
||||
<script src="./bower_components/js-yaml/dist/js-yaml.js"></script>
|
||||
<script src="./bower_components/path/path.js"></script>
|
||||
<script src="./bower_components/forEachAsync/forEachAsync.js"></script>
|
||||
|
||||
<!-- Libs -->
|
||||
<script src="./lib/deardesi-utils.js"></script>
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Reference in New Issue