all repos — litestore @ 32d015b820d63217659c2c4ff40a5e2182695670

A minimalist nosql document store.

Implemented file upload; other fixes and improvements.
* Closes #9.
h3rald h3rald@h3rald.com
Sun, 12 Apr 2015 15:14:27 +0200
commit

32d015b820d63217659c2c4ff40a5e2182695670

parent

e701cfec4b07f654ee64dda0d58f8378acfbfd7e

M admin/index.htmladmin/index.html

@@ -11,7 +11,7 @@ </head>

<body> <script src="js/vendor/jquery.min.js"> </script> <script src="js/vendor/marked.min.js"></script> - <script src="js/vendor/mithril.min.js"></script> + <script src="js/vendor/mithril.js"></script> <script src="js/vendor/bootstrap.min.js"> </script> <script src="js/vendor/ace/ace.js"> </script> <script src="js/vendor/ace/mode-batchfile.js"> </script>

@@ -32,8 +32,9 @@ <script src="js/vendor/ace/ext-settings_menu.js"> </script>

<script src="js/vendor/ace/ext-statusbar.js"> </script> <script src="js/utils.js"> </script> <script src="js/models.js"> </script> - <script src="js/components.js"> </script> - <script src="js/navbar.js"> </script> + <script src="js/components/navbar.js"> </script> + <script src="js/components/uploader.js"> </script> + <script src="js/components/editor.js"> </script> <script src="js/modules/info.js"> </script> <script src="js/modules/tags.js"> </script> <script src="js/modules/guide.js"> </script>
M admin/js/components.jsadmin/js/components/editor.js

@@ -60,4 +60,4 @@ app.editor.view = function(obj) {

return m(".editor.panel.panal-default", {config: app.editor.config(obj)}, obj.content); }; -}()); +}());
A admin/js/components/uploader.js

@@ -0,0 +1,101 @@

+/* + * Dependencies: + * - models.js + * - utils.js + */ +(function(){ + 'use strict'; + var app = window.LS || (window.LS = {}); + var u = LS.utils; + + app.uploader = function(docid){ + + var uploader = {vm: {}}; + var vm = uploader.vm; + + vm.docid = m.prop(docid); + vm.file = m.prop(); + vm.id = u.guid(); + vm.modalId = "#upload-"+vm.id+"-modal"; + vm.btnId = "#upload-"+vm.id+"-btn"; + vm.reader = new FileReader(); + vm.contents = m.prop(); + vm.isText = m.prop(false); + + vm.reader.onloadstart = function() { + vm.contents(""); + $(uploader.vm.modalId).find(".btn-primary").attr("disabled", true); + }; + + vm.reader.onloadend = function() { + vm.contents(vm.reader.result); + $(uploader.vm.modalId).find(".btn-primary").removeAttr("disabled"); + }; + + vm.save = function() { + var doc = {id: vm.docid()}; + doc.data = vm.contents().split(',')[1]; + if (vm.isText()) { + doc.data = window.atob(doc.data); + } + return Doc.put(doc, vm.file().type).then(uploader.onSuccess, uploader.onFailure); + }; + + uploader.config = function(obj){ + return function(element, isInitialized, context){ + $(element).change(function(event){ + vm.file(element.files[0]); + if (vm.reader.readyState != 1) { + vm.reader.readAsDataURL(vm.file()); + } + }); + }; + }; + + uploader.showModal = function() { + return u.showModal(uploader.vm.modalId); + }; + + uploader.onSuccess = function(data){ + // Callback + }; + uploader.onFailure = function(data){ + // Callback + }; + + uploader.view = function(){ + var config = { + title: "Upload Document", + id: "upload-"+vm.id+"-modal", + action: vm.save, + actionText: "Upload", + content: m("div", [ + m(".form-group", [ + m("label", "Document ID"), + m("input.form-control", { + placeholder: "Enter document ID", + onchange: m.withAttr("value", vm.docid), + size: 35, + disabled: (docid === "") ? false : true, + value: vm.docid() + }) + ]), + m(".form-group", [ + m("label", "File"), + m("input.form-control#upload-"+vm.id+"-btn", {type:"file", config: uploader.config(vm)}), + m("p.help-block", "Select a file to upload as document.") + ]), + m(".checkbox", [ + m("label", [ + m("input", {type: "checkbox", value: vm.isText(), onchange: m.withAttr("value", vm.isText)}), + "Text File" + ]), + m("p.help-block", "Select if the file to upload contains textual content.") + ]) + ]) + }; + return u.modal(config); + }; + return uploader; + }; +}());
M admin/js/models.jsadmin/js/models.js

@@ -66,6 +66,16 @@ config: xhrcfg

}); }; + Doc.upload = function(doc) { + console.log("Doc.put - Uploading Document:", doc); + return m.request({ + method: "PUT", + url: "/v1/docs/"+doc.id, + data: doc.data, + serialize: function(data) {return data} + }); + }; + Doc.patch = function(id, updatedTags){ return Doc.get(id).then(function(doc){ var tags = doc.tags;
M admin/js/modules/document.jsadmin/js/modules/document.js

@@ -14,6 +14,7 @@ vm.readOnly = true;

vm.contentType = m.prop(""); vm.updatedTags = m.prop(""); vm.content = ""; + vm.uploader = new app.uploader(vm.id() || ""); vm.binary = false; vm.image = false; vm.tags = [];

@@ -58,7 +59,7 @@ // View document in editor

vm.viewDocument = function(){ if (vm.ext === "md" && vm.id().match(new RegExp("^"+vm.dir+"\/md\/"))) { // If editing a documentation page, go back to the guide. - m.route("/guide/"+vm.id().replace(/\.md$/, "").replace(new Regexp("^"+vm.dir+"\/md\/"), "")); + m.route("/guide/"+vm.id().replace(/\.md$/, "").replace(new RegExp("^"+vm.dir+"\/md\/"), "")); } else { m.route("/document/view/"+vm.id()); }

@@ -101,7 +102,11 @@ // Delete Document

vm.delete = function(){ Doc.delete(vm.id()).then(function(){ LS.flash({type: "success", content: "Document '"+vm.id()+"' deleted successfully."}); - m.route("/info"); + // Tags may be changed, update infos + Info.get().then(function(info){ + app.system = info; + m.route("/info"); + }); }, vm.flashError); };

@@ -127,6 +132,20 @@ });

}, vm.flashError); }; + // File uploader callbacks. + vm.uploader.onSuccess = function(data){ + vm.id(data.id); + LS.flash({type: "success", content: "Document '"+vm.id()+"' uploader successfully."}); + Info.get().then(function(info){ + app.system = info; + vm.viewDocument(); + }); + }; + + vm.uploader.onFailure = function(data){ + vm.flashError; + }; + // Populate tools based on current action vm.tools = function(){ if (app.system.read_only) {

@@ -139,6 +158,7 @@ cfg.contentId = "#edit-tags-popover";

var tools = []; switch (vm.action){ case "view": + tools.push({title: "Upload", icon: "upload", action: vm.uploader.showModal()}); if (!vm.binary) { tools.push({title: "Edit Content", icon: "edit", action: vm.edit}); }

@@ -146,6 +166,7 @@ tools.push({title: "Edit Tags", icon: "tags", action: u.showModal("#edit-tags-modal")});

tools.push({title: "Delete", icon: "trash", action: u.showModal("#delete-document-modal")}); break; default: + tools.push({title: "Upload", icon: "upload", action: vm.uploader.showModal()}); tools.push({title: "Save", icon: "save", action: vm.save}); tools.push({title: "Cancel", icon: "times-circle", action: vm.cancel}); }

@@ -199,7 +220,10 @@ value: vm.id()

})]); titleRight = m("span.pull-right", [m("input", { placeholder: "Content Type", - onchange: m.withAttr("value", vm.contentType), + onchange: m.withAttr("value", function(value){ + vm.contentType(value); + vm.uploader.vm.contentType(value); + }), size: 25, value: vm.contentType() })]);

@@ -211,7 +235,9 @@ } else {

panelContent = app.editor.view(vm); } var title = m("span",[titleLeft, titleRight]); + return m("div", [ + vm.uploader.view(), u.modal(deleteDialogCfg), u.modal(editTagsDialogCfg), m(".row", [u.toolbar({links: vm.tools()})]),
M admin/js/modules/guide.jsadmin/js/modules/guide.js

@@ -10,7 +10,7 @@ var vm = this;

vm.id = m.prop(m.route.param("id")); vm.content = Page.get(vm.id()).then(function(content){return content}, vm.flashError); vm.edit = function(){ - m.route("/document/edit/app/md/"+vm.id()+".md"); + m.route("/document/edit/"+app.system.directory+"/md/"+vm.id()+".md"); }; vm.links = app.system.read_only ? m.prop([]) : m.prop([{action: vm.edit, title: "Edit", icon: "edit"}]); };
M admin/js/modules/info.jsadmin/js/modules/info.js

@@ -16,7 +16,7 @@ return m("li", [m("span", title+": "), m("strong", content)]);

} }; var readonly = info.read_only ? m("span.label.label-success", "Yes") : m("span.label.label-danger", "No"); - var infolist = m(".col-md-6", [m("ul.list-unstyled", [ + var infolist = m(".col-sm-6", [m("ul.list-unstyled", [ li("Version", info.version), li("Size", info.size), li("Mounted Directory", info.directory, info.directory.length===0),

@@ -25,7 +25,7 @@ li("Read-Only", readonly),

li("Total Documents", m("span.badge", info.total_documents)), li("Total Tags", m("span.badge", info.total_tags)), ])]); - var logo = m(".col-md-6", [m("img", {src: "images/litestore.png"})]); + var logo = m(".col-sm-6", [m("img", {src: "images/litestore.png"})]); var taglist = m("ul.list-unstyled", info.tags.map(function(tag){ var key = Object.keys(tag)[0]; return m("li", [u.tagbutton(key, tag[key])]);
M admin/js/utils.jsadmin/js/utils.js

@@ -4,6 +4,15 @@ var app = window.LS || (window.LS = {});

var u = app.utils = {}; + // http://byronsalau.com/blog/how-to-create-a-guid-uuid-in-javascript/ + u.guid = function(){ + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { + var r = Math.random()*16|0, v = c === 'x' ? r : (r&0x3|0x8); + return v.toString(16); + }); + }; + + u.markdown = function(s) { var hs = new marked.Renderer(); var md = new marked.Renderer();
A admin/js/vendor/mithril.js

@@ -0,0 +1,1066 @@

+var m = (function app(window, undefined) { + var OBJECT = "[object Object]", ARRAY = "[object Array]", STRING = "[object String]", FUNCTION = "function"; + var type = {}.toString; + var parser = /(?:(^|#|\.)([^#\.\[\]]+))|(\[.+?\])/g, attrParser = /\[(.+?)(?:=("|'|)(.*?)\2)?\]/; + var voidElements = /^(AREA|BASE|BR|COL|COMMAND|EMBED|HR|IMG|INPUT|KEYGEN|LINK|META|PARAM|SOURCE|TRACK|WBR)$/; + + // caching commonly used variables + var $document, $location, $requestAnimationFrame, $cancelAnimationFrame; + + // self invoking function needed because of the way mocks work + function initialize(window){ + $document = window.document; + $location = window.location; + $cancelAnimationFrame = window.cancelAnimationFrame || window.clearTimeout; + $requestAnimationFrame = window.requestAnimationFrame || window.setTimeout; + } + + initialize(window); + + + /** + * @typedef {String} Tag + * A string that looks like -> div.classname#id[param=one][param2=two] + * Which describes a DOM node + */ + + /** + * + * @param {Tag} The DOM node tag + * @param {Object=[]} optional key-value pairs to be mapped to DOM attrs + * @param {...mNode=[]} Zero or more Mithril child nodes. Can be an array, or splat (optional) + * + */ + function m() { + var args = [].slice.call(arguments); + var hasAttrs = args[1] != null && type.call(args[1]) === OBJECT && !("tag" in args[1]) && !("subtree" in args[1]); + var attrs = hasAttrs ? args[1] : {}; + var classAttrName = "class" in attrs ? "class" : "className"; + var cell = {tag: "div", attrs: {}}; + var match, classes = []; + if (type.call(args[0]) != STRING) throw new Error("selector in m(selector, attrs, children) should be a string") + while (match = parser.exec(args[0])) { + if (match[1] === "" && match[2]) cell.tag = match[2]; + else if (match[1] === "#") cell.attrs.id = match[2]; + else if (match[1] === ".") classes.push(match[2]); + else if (match[3][0] === "[") { + var pair = attrParser.exec(match[3]); + cell.attrs[pair[1]] = pair[3] || (pair[2] ? "" :true) + } + } + if (classes.length > 0) cell.attrs[classAttrName] = classes.join(" "); + + + var children = hasAttrs ? args.slice(2) : args.slice(1); + if (children.length === 1 && type.call(children[0]) === ARRAY) { + cell.children = children[0] + } + else { + cell.children = children + } + + for (var attrName in attrs) { + if (attrName === classAttrName) { + var className = cell.attrs[attrName] + cell.attrs[attrName] = (className && attrs[attrName] ? className + " " : className || "") + attrs[attrName]; + } + else cell.attrs[attrName] = attrs[attrName] + } + return cell + } + function build(parentElement, parentTag, parentCache, parentIndex, data, cached, shouldReattach, index, editable, namespace, configs) { + //`build` is a recursive function that manages creation/diffing/removal of DOM elements based on comparison between `data` and `cached` + //the diff algorithm can be summarized as this: + //1 - compare `data` and `cached` + //2 - if they are different, copy `data` to `cached` and update the DOM based on what the difference is + //3 - recursively apply this algorithm for every array and for the children of every virtual element + + //the `cached` data structure is essentially the same as the previous redraw's `data` data structure, with a few additions: + //- `cached` always has a property called `nodes`, which is a list of DOM elements that correspond to the data represented by the respective virtual element + //- in order to support attaching `nodes` as a property of `cached`, `cached` is *always* a non-primitive object, i.e. if the data was a string, then cached is a String instance. If data was `null` or `undefined`, cached is `new String("")` + //- `cached also has a `configContext` property, which is the state storage object exposed by config(element, isInitialized, context) + //- when `cached` is an Object, it represents a virtual element; when it's an Array, it represents a list of elements; when it's a String, Number or Boolean, it represents a text node + + //`parentElement` is a DOM element used for W3C DOM API calls + //`parentTag` is only used for handling a corner case for textarea values + //`parentCache` is used to remove nodes in some multi-node cases + //`parentIndex` and `index` are used to figure out the offset of nodes. They're artifacts from before arrays started being flattened and are likely refactorable + //`data` and `cached` are, respectively, the new and old nodes being diffed + //`shouldReattach` is a flag indicating whether a parent node was recreated (if so, and if this node is reused, then this node must reattach itself to the new parent) + //`editable` is a flag that indicates whether an ancestor is contenteditable + //`namespace` indicates the closest HTML namespace as it cascades down from an ancestor + //`configs` is a list of config functions to run after the topmost `build` call finishes running + + //there's logic that relies on the assumption that null and undefined data are equivalent to empty strings + //- this prevents lifecycle surprises from procedural helpers that mix implicit and explicit return statements (e.g. function foo() {if (cond) return m("div")} + //- it simplifies diffing code + //data.toString() is null if data is the return value of Console.log in Firefox + try {if (data == null || data.toString() == null) data = "";} catch (e) {data = ""} + if (data.subtree === "retain") return cached; + var cachedType = type.call(cached), dataType = type.call(data); + if (cached == null || cachedType !== dataType) { + if (cached != null) { + if (parentCache && parentCache.nodes) { + var offset = index - parentIndex; + var end = offset + (dataType === ARRAY ? data : cached.nodes).length; + clear(parentCache.nodes.slice(offset, end), parentCache.slice(offset, end)) + } + else if (cached.nodes) clear(cached.nodes, cached) + } + cached = new data.constructor; + if (cached.tag) cached = {}; //if constructor creates a virtual dom element, use a blank object as the base cached node instead of copying the virtual el (#277) + cached.nodes = [] + } + + if (dataType === ARRAY) { + //recursively flatten array + for (var i = 0, len = data.length; i < len; i++) { + if (type.call(data[i]) === ARRAY) { + data = data.concat.apply([], data); + i-- //check current index again and flatten until there are no more nested arrays at that index + len = data.length + } + } + + var nodes = [], intact = cached.length === data.length, subArrayCount = 0; + + //keys algorithm: sort elements without recreating them if keys are present + //1) create a map of all existing keys, and mark all for deletion + //2) add new keys to map and mark them for addition + //3) if key exists in new list, change action from deletion to a move + //4) for each key, handle its corresponding action as marked in previous steps + var DELETION = 1, INSERTION = 2 , MOVE = 3; + var existing = {}, unkeyed = [], shouldMaintainIdentities = false; + for (var i = 0; i < cached.length; i++) { + if (cached[i] && cached[i].attrs && cached[i].attrs.key != null) { + shouldMaintainIdentities = true; + existing[cached[i].attrs.key] = {action: DELETION, index: i} + } + } + + var guid = 0 + for (var i = 0, len = data.length; i < len; i++) { + if (data[i] && data[i].attrs && data[i].attrs.key != null) { + for (var j = 0, len = data.length; j < len; j++) { + if (data[j] && data[j].attrs && data[j].attrs.key == null) data[j].attrs.key = "__mithril__" + guid++ + } + break + } + } + + if (shouldMaintainIdentities) { + var keysDiffer = false + if (data.length != cached.length) keysDiffer = true + else for (var i = 0, cachedCell, dataCell; cachedCell = cached[i], dataCell = data[i]; i++) { + if (cachedCell.attrs && dataCell.attrs && cachedCell.attrs.key != dataCell.attrs.key) { + keysDiffer = true + break + } + } + + if (keysDiffer) { + for (var i = 0, len = data.length; i < len; i++) { + if (data[i] && data[i].attrs) { + if (data[i].attrs.key != null) { + var key = data[i].attrs.key; + if (!existing[key]) existing[key] = {action: INSERTION, index: i}; + else existing[key] = { + action: MOVE, + index: i, + from: existing[key].index, + element: cached.nodes[existing[key].index] || $document.createElement("div") + } + } + } + } + var actions = [] + for (var prop in existing) actions.push(existing[prop]) + var changes = actions.sort(sortChanges); + var newCached = new Array(cached.length) + newCached.nodes = cached.nodes.slice() + + for (var i = 0, change; change = changes[i]; i++) { + if (change.action === DELETION) { + clear(cached[change.index].nodes, cached[change.index]); + newCached.splice(change.index, 1) + } + if (change.action === INSERTION) { + var dummy = $document.createElement("div"); + dummy.key = data[change.index].attrs.key; + parentElement.insertBefore(dummy, parentElement.childNodes[change.index] || null); + newCached.splice(change.index, 0, {attrs: {key: data[change.index].attrs.key}, nodes: [dummy]}) + newCached.nodes[change.index] = dummy + } + + if (change.action === MOVE) { + if (parentElement.childNodes[change.index] !== change.element && change.element !== null) { + parentElement.insertBefore(change.element, parentElement.childNodes[change.index] || null) + } + newCached[change.index] = cached[change.from] + newCached.nodes[change.index] = change.element + } + } + cached = newCached; + } + } + //end key algorithm + + for (var i = 0, cacheCount = 0, len = data.length; i < len; i++) { + //diff each item in the array + var item = build(parentElement, parentTag, cached, index, data[i], cached[cacheCount], shouldReattach, index + subArrayCount || subArrayCount, editable, namespace, configs); + if (item === undefined) continue; + if (!item.nodes.intact) intact = false; + if (item.$trusted) { + //fix offset of next element if item was a trusted string w/ more than one html element + //the first clause in the regexp matches elements + //the second clause (after the pipe) matches text nodes + subArrayCount += (item.match(/<[^\/]|\>\s*[^<]/g) || [0]).length + } + else subArrayCount += type.call(item) === ARRAY ? item.length : 1; + cached[cacheCount++] = item + } + if (!intact) { + //diff the array itself + + //update the list of DOM nodes by collecting the nodes from each item + for (var i = 0, len = data.length; i < len; i++) { + if (cached[i] != null) nodes.push.apply(nodes, cached[i].nodes) + } + //remove items from the end of the array if the new array is shorter than the old one + //if errors ever happen here, the issue is most likely a bug in the construction of the `cached` data structure somewhere earlier in the program + for (var i = 0, node; node = cached.nodes[i]; i++) { + if (node.parentNode != null && nodes.indexOf(node) < 0) clear([node], [cached[i]]) + } + if (data.length < cached.length) cached.length = data.length; + cached.nodes = nodes + } + } + else if (data != null && dataType === OBJECT) { + if (!data.attrs) data.attrs = {}; + if (!cached.attrs) cached.attrs = {}; + + var dataAttrKeys = Object.keys(data.attrs) + var hasKeys = dataAttrKeys.length > ("key" in data.attrs ? 1 : 0) + //if an element is different enough from the one in cache, recreate it + if (data.tag != cached.tag || dataAttrKeys.join() != Object.keys(cached.attrs).join() || data.attrs.id != cached.attrs.id || (m.redraw.strategy() == "all" && cached.configContext && cached.configContext.retain !== true) || (m.redraw.strategy() == "diff" && cached.configContext && cached.configContext.retain === false)) { + if (cached.nodes.length) clear(cached.nodes); + if (cached.configContext && typeof cached.configContext.onunload === FUNCTION) cached.configContext.onunload() + } + if (type.call(data.tag) != STRING) return; + + var node, isNew = cached.nodes.length === 0; + if (data.attrs.xmlns) namespace = data.attrs.xmlns; + else if (data.tag === "svg") namespace = "http://www.w3.org/2000/svg"; + else if (data.tag === "math") namespace = "http://www.w3.org/1998/Math/MathML"; + if (isNew) { + if (data.attrs.is) node = namespace === undefined ? $document.createElement(data.tag, data.attrs.is) : $document.createElementNS(namespace, data.tag, data.attrs.is); + else node = namespace === undefined ? $document.createElement(data.tag) : $document.createElementNS(namespace, data.tag); + cached = { + tag: data.tag, + //set attributes first, then create children + attrs: hasKeys ? setAttributes(node, data.tag, data.attrs, {}, namespace) : data.attrs, + children: data.children != null && data.children.length > 0 ? + build(node, data.tag, undefined, undefined, data.children, cached.children, true, 0, data.attrs.contenteditable ? node : editable, namespace, configs) : + data.children, + nodes: [node] + }; + if (cached.children && !cached.children.nodes) cached.children.nodes = []; + //edge case: setting value on <select> doesn't work before children exist, so set it again after children have been created + if (data.tag === "select" && data.attrs.value) setAttributes(node, data.tag, {value: data.attrs.value}, {}, namespace); + parentElement.insertBefore(node, parentElement.childNodes[index] || null) + } + else { + node = cached.nodes[0]; + if (hasKeys) setAttributes(node, data.tag, data.attrs, cached.attrs, namespace); + cached.children = build(node, data.tag, undefined, undefined, data.children, cached.children, false, 0, data.attrs.contenteditable ? node : editable, namespace, configs); + cached.nodes.intact = true; + if (shouldReattach === true && node != null) parentElement.insertBefore(node, parentElement.childNodes[index] || null) + } + //schedule configs to be called. They are called after `build` finishes running + if (typeof data.attrs["config"] === FUNCTION) { + var context = cached.configContext = cached.configContext || {retain: (m.redraw.strategy() == "diff") || undefined}; + + // bind + var callback = function(data, args) { + return function() { + return data.attrs["config"].apply(data, args) + } + }; + configs.push(callback(data, [node, !isNew, context, cached])) + } + } + else if (typeof data != FUNCTION) { + //handle text nodes + var nodes; + if (cached.nodes.length === 0) { + if (data.$trusted) { + nodes = injectHTML(parentElement, index, data) + } + else { + nodes = [$document.createTextNode(data)]; + if (!parentElement.nodeName.match(voidElements)) parentElement.insertBefore(nodes[0], parentElement.childNodes[index] || null) + } + cached = "string number boolean".indexOf(typeof data) > -1 ? new data.constructor(data) : data; + cached.nodes = nodes + } + else if (cached.valueOf() !== data.valueOf() || shouldReattach === true) { + nodes = cached.nodes; + if (!editable || editable !== $document.activeElement) { + if (data.$trusted) { + clear(nodes, cached); + nodes = injectHTML(parentElement, index, data) + } + else { + //corner case: replacing the nodeValue of a text node that is a child of a textarea/contenteditable doesn't work + //we need to update the value property of the parent textarea or the innerHTML of the contenteditable element instead + if (parentTag === "textarea") parentElement.value = data; + else if (editable) editable.innerHTML = data; + else { + if (nodes[0].nodeType === 1 || nodes.length > 1) { //was a trusted string + clear(cached.nodes, cached); + nodes = [$document.createTextNode(data)] + } + parentElement.insertBefore(nodes[0], parentElement.childNodes[index] || null); + nodes[0].nodeValue = data + } + } + } + cached = new data.constructor(data); + cached.nodes = nodes + } + else cached.nodes.intact = true + } + + return cached + } + function sortChanges(a, b) {return a.action - b.action || a.index - b.index} + function setAttributes(node, tag, dataAttrs, cachedAttrs, namespace) { + for (var attrName in dataAttrs) { + var dataAttr = dataAttrs[attrName]; + var cachedAttr = cachedAttrs[attrName]; + if (!(attrName in cachedAttrs) || (cachedAttr !== dataAttr)) { + cachedAttrs[attrName] = dataAttr; + try { + //`config` isn't a real attributes, so ignore it + if (attrName === "config" || attrName == "key") continue; + //hook event handlers to the auto-redrawing system + else if (typeof dataAttr === FUNCTION && attrName.indexOf("on") === 0) { + node[attrName] = autoredraw(dataAttr, node) + } + //handle `style: {...}` + else if (attrName === "style" && dataAttr != null && type.call(dataAttr) === OBJECT) { + for (var rule in dataAttr) { + if (cachedAttr == null || cachedAttr[rule] !== dataAttr[rule]) node.style[rule] = dataAttr[rule] + } + for (var rule in cachedAttr) { + if (!(rule in dataAttr)) node.style[rule] = "" + } + } + //handle SVG + else if (namespace != null) { + if (attrName === "href") node.setAttributeNS("http://www.w3.org/1999/xlink", "href", dataAttr); + else if (attrName === "className") node.setAttribute("class", dataAttr); + else node.setAttribute(attrName, dataAttr) + } + //handle cases that are properties (but ignore cases where we should use setAttribute instead) + //- list and form are typically used as strings, but are DOM element references in js + //- when using CSS selectors (e.g. `m("[style='']")`), style is used as a string, but it's an object in js + else if (attrName in node && !(attrName === "list" || attrName === "style" || attrName === "form" || attrName === "type" || attrName === "width" || attrName === "height")) { + //#348 don't set the value if not needed otherwise cursor placement breaks in Chrome + if (tag !== "input" || node[attrName] !== dataAttr) node[attrName] = dataAttr + } + else node.setAttribute(attrName, dataAttr) + } + catch (e) { + //swallow IE's invalid argument errors to mimic HTML's fallback-to-doing-nothing-on-invalid-attributes behavior + if (e.message.indexOf("Invalid argument") < 0) throw e + } + } + //#348 dataAttr may not be a string, so use loose comparison (double equal) instead of strict (triple equal) + else if (attrName === "value" && tag === "input" && node.value != dataAttr) { + node.value = dataAttr + } + } + return cachedAttrs + } + function clear(nodes, cached) { + for (var i = nodes.length - 1; i > -1; i--) { + if (nodes[i] && nodes[i].parentNode) { + try {nodes[i].parentNode.removeChild(nodes[i])} + catch (e) {} //ignore if this fails due to order of events (see http://stackoverflow.com/questions/21926083/failed-to-execute-removechild-on-node) + cached = [].concat(cached); + if (cached[i]) unload(cached[i]) + } + } + if (nodes.length != 0) nodes.length = 0 + } + function unload(cached) { + if (cached.configContext && typeof cached.configContext.onunload === FUNCTION) { + cached.configContext.onunload(); + cached.configContext.onunload = null + } + if (cached.children) { + if (type.call(cached.children) === ARRAY) { + for (var i = 0, child; child = cached.children[i]; i++) unload(child) + } + else if (cached.children.tag) unload(cached.children) + } + } + function injectHTML(parentElement, index, data) { + var nextSibling = parentElement.childNodes[index]; + if (nextSibling) { + var isElement = nextSibling.nodeType != 1; + var placeholder = $document.createElement("span"); + if (isElement) { + parentElement.insertBefore(placeholder, nextSibling || null); + placeholder.insertAdjacentHTML("beforebegin", data); + parentElement.removeChild(placeholder) + } + else nextSibling.insertAdjacentHTML("beforebegin", data) + } + else parentElement.insertAdjacentHTML("beforeend", data); + var nodes = []; + while (parentElement.childNodes[index] !== nextSibling) { + nodes.push(parentElement.childNodes[index]); + index++ + } + return nodes + } + function autoredraw(callback, object) { + return function(e) { + e = e || event; + m.redraw.strategy("diff"); + m.startComputation(); + try {return callback.call(object, e)} + finally { + endFirstComputation() + } + } + } + + var html; + var documentNode = { + appendChild: function(node) { + if (html === undefined) html = $document.createElement("html"); + if ($document.documentElement && $document.documentElement !== node) { + $document.replaceChild(node, $document.documentElement) + } + else $document.appendChild(node); + this.childNodes = $document.childNodes + }, + insertBefore: function(node) { + this.appendChild(node) + }, + childNodes: [] + }; + var nodeCache = [], cellCache = {}; + m.render = function(root, cell, forceRecreation) { + var configs = []; + if (!root) throw new Error("Please ensure the DOM element exists before rendering a template into it."); + var id = getCellCacheKey(root); + var isDocumentRoot = root === $document; + var node = isDocumentRoot || root === $document.documentElement ? documentNode : root; + if (isDocumentRoot && cell.tag != "html") cell = {tag: "html", attrs: {}, children: cell}; + if (cellCache[id] === undefined) clear(node.childNodes); + if (forceRecreation === true) reset(root); + cellCache[id] = build(node, null, undefined, undefined, cell, cellCache[id], false, 0, null, undefined, configs); + for (var i = 0, len = configs.length; i < len; i++) configs[i]() + }; + function getCellCacheKey(element) { + var index = nodeCache.indexOf(element); + return index < 0 ? nodeCache.push(element) - 1 : index + } + + m.trust = function(value) { + value = new String(value); + value.$trusted = true; + return value + }; + + function gettersetter(store) { + var prop = function() { + if (arguments.length) store = arguments[0]; + return store + }; + + prop.toJSON = function() { + return store + }; + + return prop + } + + m.prop = function (store) { + //note: using non-strict equality check here because we're checking if store is null OR undefined + if (((store != null && type.call(store) === OBJECT) || typeof store === FUNCTION) && typeof store.then === FUNCTION) { + return propify(store) + } + + return gettersetter(store) + }; + + var roots = [], modules = [], controllers = [], lastRedrawId = null, lastRedrawCallTime = 0, computePostRedrawHook = null, prevented = false, topModule; + var FRAME_BUDGET = 16; //60 frames per second = 1 call per 16 ms + m.module = function(root, module) { + if (!root) throw new Error("Please ensure the DOM element exists before rendering a template into it."); + var index = roots.indexOf(root); + if (index < 0) index = roots.length; + var isPrevented = false; + if (controllers[index] && typeof controllers[index].onunload === FUNCTION) { + var event = { + preventDefault: function() {isPrevented = true} + }; + controllers[index].onunload(event) + } + if (!isPrevented) { + m.redraw.strategy("all"); + m.startComputation(); + roots[index] = root; + var currentModule = topModule = module = module || {}; + var controller = new (module.controller || function() {}); + //controllers may call m.module recursively (via m.route redirects, for example) + //this conditional ensures only the last recursive m.module call is applied + if (currentModule === topModule) { + controllers[index] = controller; + modules[index] = module + } + endFirstComputation(); + return controllers[index] + } + }; + m.redraw = function(force) { + //lastRedrawId is a positive number if a second redraw is requested before the next animation frame + //lastRedrawID is null if it's the first redraw and not an event handler + if (lastRedrawId && force !== true) { + //when setTimeout: only reschedule redraw if time between now and previous redraw is bigger than a frame, otherwise keep currently scheduled timeout + //when rAF: always reschedule redraw + if (new Date - lastRedrawCallTime > FRAME_BUDGET || $requestAnimationFrame === window.requestAnimationFrame) { + if (lastRedrawId > 0) $cancelAnimationFrame(lastRedrawId); + lastRedrawId = $requestAnimationFrame(redraw, FRAME_BUDGET) + } + } + else { + redraw(); + lastRedrawId = $requestAnimationFrame(function() {lastRedrawId = null}, FRAME_BUDGET) + } + }; + m.redraw.strategy = m.prop(); + var blank = function() {return ""} + function redraw() { + for (var i = 0, root; root = roots[i]; i++) { + if (controllers[i]) { + m.render(root, modules[i].view ? modules[i].view(controllers[i]) : blank()) + } + } + //after rendering within a routed context, we need to scroll back to the top, and fetch the document title for history.pushState + if (computePostRedrawHook) { + computePostRedrawHook(); + computePostRedrawHook = null + } + lastRedrawId = null; + lastRedrawCallTime = new Date; + m.redraw.strategy("diff") + } + + var pendingRequests = 0; + m.startComputation = function() {pendingRequests++}; + m.endComputation = function() { + pendingRequests = Math.max(pendingRequests - 1, 0); + if (pendingRequests === 0) m.redraw() + }; + var endFirstComputation = function() { + if (m.redraw.strategy() == "none") { + pendingRequests-- + m.redraw.strategy("diff") + } + else m.endComputation(); + } + + m.withAttr = function(prop, withAttrCallback) { + return function(e) { + e = e || event; + var currentTarget = e.currentTarget || this; + withAttrCallback(prop in currentTarget ? currentTarget[prop] : currentTarget.getAttribute(prop)) + } + }; + + //routing + var modes = {pathname: "", hash: "#", search: "?"}; + var redirect = function() {}, routeParams, currentRoute; + m.route = function() { + //m.route() + if (arguments.length === 0) return currentRoute; + //m.route(el, defaultRoute, routes) + else if (arguments.length === 3 && type.call(arguments[1]) === STRING) { + var root = arguments[0], defaultRoute = arguments[1], router = arguments[2]; + redirect = function(source) { + var path = currentRoute = normalizeRoute(source); + if (!routeByValue(root, router, path)) { + m.route(defaultRoute, true) + } + }; + var listener = m.route.mode === "hash" ? "onhashchange" : "onpopstate"; + window[listener] = function() { + var path = $location[m.route.mode] + if (m.route.mode === "pathname") path += $location.search + if (currentRoute != normalizeRoute(path)) { + redirect(path) + } + }; + computePostRedrawHook = setScroll; + window[listener]() + } + //config: m.route + else if (arguments[0].addEventListener || arguments[0].attachEvent) { + var element = arguments[0]; + var isInitialized = arguments[1]; + var context = arguments[2]; + element.href = (m.route.mode !== 'pathname' ? $location.pathname : '') + modes[m.route.mode] + this.attrs.href; + if (element.addEventListener) { + element.removeEventListener("click", routeUnobtrusive); + element.addEventListener("click", routeUnobtrusive) + } + else { + element.detachEvent("onclick", routeUnobtrusive); + element.attachEvent("onclick", routeUnobtrusive) + } + } + //m.route(route, params) + else if (type.call(arguments[0]) === STRING) { + var oldRoute = currentRoute; + currentRoute = arguments[0]; + var args = arguments[1] || {} + var queryIndex = currentRoute.indexOf("?") + var params = queryIndex > -1 ? parseQueryString(currentRoute.slice(queryIndex + 1)) : {} + for (var i in args) params[i] = args[i] + var querystring = buildQueryString(params) + var currentPath = queryIndex > -1 ? currentRoute.slice(0, queryIndex) : currentRoute + if (querystring) currentRoute = currentPath + (currentPath.indexOf("?") === -1 ? "?" : "&") + querystring; + + var shouldReplaceHistoryEntry = (arguments.length === 3 ? arguments[2] : arguments[1]) === true || oldRoute === arguments[0]; + + if (window.history.pushState) { + computePostRedrawHook = function() { + window.history[shouldReplaceHistoryEntry ? "replaceState" : "pushState"](null, $document.title, modes[m.route.mode] + currentRoute); + setScroll() + }; + redirect(modes[m.route.mode] + currentRoute) + } + else { + $location[m.route.mode] = currentRoute + redirect(modes[m.route.mode] + currentRoute) + } + } + }; + m.route.param = function(key) { + if (!routeParams) throw new Error("You must call m.route(element, defaultRoute, routes) before calling m.route.param()") + return routeParams[key] + }; + m.route.mode = "search"; + function normalizeRoute(route) { + return route.slice(modes[m.route.mode].length) + } + function routeByValue(root, router, path) { + routeParams = {}; + + var queryStart = path.indexOf("?"); + if (queryStart !== -1) { + routeParams = parseQueryString(path.substr(queryStart + 1, path.length)); + path = path.substr(0, queryStart) + } + + // Get all routes and check if there's + // an exact match for the current path + var keys = Object.keys(router); + var index = keys.indexOf(path); + if(index !== -1){ + m.module(root, router[keys [index]]); + return true; + } + + for (var route in router) { + if (route === path) { + m.module(root, router[route]); + return true + } + + var matcher = new RegExp("^" + route.replace(/:[^\/]+?\.{3}/g, "(.*?)").replace(/:[^\/]+/g, "([^\\/]+)") + "\/?$"); + + if (matcher.test(path)) { + path.replace(matcher, function() { + var keys = route.match(/:[^\/]+/g) || []; + var values = [].slice.call(arguments, 1, -2); + for (var i = 0, len = keys.length; i < len; i++) routeParams[keys[i].replace(/:|\./g, "")] = decodeURIComponent(values[i]) + m.module(root, router[route]) + }); + return true + } + } + } + function routeUnobtrusive(e) { + e = e || event; + if (e.ctrlKey || e.metaKey || e.which === 2) return; + if (e.preventDefault) e.preventDefault(); + else e.returnValue = false; + var currentTarget = e.currentTarget || e.srcElement; + var args = m.route.mode === "pathname" && currentTarget.search ? parseQueryString(currentTarget.search.slice(1)) : {}; + while (currentTarget && currentTarget.nodeName.toUpperCase() != "A") currentTarget = currentTarget.parentNode + m.route(currentTarget[m.route.mode].slice(modes[m.route.mode].length), args) + } + function setScroll() { + if (m.route.mode != "hash" && $location.hash) $location.hash = $location.hash; + else window.scrollTo(0, 0) + } + function buildQueryString(object, prefix) { + var duplicates = {} + var str = [] + for (var prop in object) { + var key = prefix ? prefix + "[" + prop + "]" : prop + var value = object[prop] + var valueType = type.call(value) + var pair = (value === null) ? encodeURIComponent(key) : + valueType === OBJECT ? buildQueryString(value, key) : + valueType === ARRAY ? value.reduce(function(memo, item) { + if (!duplicates[key]) duplicates[key] = {} + if (!duplicates[key][item]) { + duplicates[key][item] = true + return memo.concat(encodeURIComponent(key) + "=" + encodeURIComponent(item)) + } + return memo + }, []).join("&") : + encodeURIComponent(key) + "=" + encodeURIComponent(value) + if (value !== undefined) str.push(pair) + } + return str.join("&") + } + function parseQueryString(str) { + var pairs = str.split("&"), params = {}; + for (var i = 0, len = pairs.length; i < len; i++) { + var pair = pairs[i].split("="); + var key = decodeURIComponent(pair[0]) + var value = pair.length == 2 ? decodeURIComponent(pair[1]) : null + if (params[key] != null) { + if (type.call(params[key]) !== ARRAY) params[key] = [params[key]] + params[key].push(value) + } + else params[key] = value + } + return params + } + m.route.buildQueryString = buildQueryString + m.route.parseQueryString = parseQueryString + + function reset(root) { + var cacheKey = getCellCacheKey(root); + clear(root.childNodes, cellCache[cacheKey]); + cellCache[cacheKey] = undefined + } + + m.deferred = function () { + var deferred = new Deferred(); + deferred.promise = propify(deferred.promise); + return deferred + }; + function propify(promise, initialValue) { + var prop = m.prop(initialValue); + promise.then(prop); + prop.then = function(resolve, reject) { + return propify(promise.then(resolve, reject), initialValue) + }; + return prop + } + //Promiz.mithril.js | Zolmeister | MIT + //a modified version of Promiz.js, which does not conform to Promises/A+ for two reasons: + //1) `then` callbacks are called synchronously (because setTimeout is too slow, and the setImmediate polyfill is too big + //2) throwing subclasses of Error cause the error to be bubbled up instead of triggering rejection (because the spec does not account for the important use case of default browser error handling, i.e. message w/ line number) + function Deferred(successCallback, failureCallback) { + var RESOLVING = 1, REJECTING = 2, RESOLVED = 3, REJECTED = 4; + var self = this, state = 0, promiseValue = 0, next = []; + + self["promise"] = {}; + + self["resolve"] = function(value) { + if (!state) { + promiseValue = value; + state = RESOLVING; + + fire() + } + return this + }; + + self["reject"] = function(value) { + if (!state) { + promiseValue = value; + state = REJECTING; + + fire() + } + return this + }; + + self.promise["then"] = function(successCallback, failureCallback) { + var deferred = new Deferred(successCallback, failureCallback); + if (state === RESOLVED) { + deferred.resolve(promiseValue) + } + else if (state === REJECTED) { + deferred.reject(promiseValue) + } + else { + next.push(deferred) + } + return deferred.promise + }; + + function finish(type) { + state = type || REJECTED; + next.map(function(deferred) { + state === RESOLVED && deferred.resolve(promiseValue) || deferred.reject(promiseValue) + }) + } + + function thennable(then, successCallback, failureCallback, notThennableCallback) { + if (((promiseValue != null && type.call(promiseValue) === OBJECT) || typeof promiseValue === FUNCTION) && typeof then === FUNCTION) { + try { + // count protects against abuse calls from spec checker + var count = 0; + then.call(promiseValue, function(value) { + if (count++) return; + promiseValue = value; + successCallback() + }, function (value) { + if (count++) return; + promiseValue = value; + failureCallback() + }) + } + catch (e) { + m.deferred.onerror(e); + promiseValue = e; + failureCallback() + } + } else { + notThennableCallback() + } + } + + function fire() { + // check if it's a thenable + var then; + try { + then = promiseValue && promiseValue.then + } + catch (e) { + m.deferred.onerror(e); + promiseValue = e; + state = REJECTING; + return fire() + } + thennable(then, function() { + state = RESOLVING; + fire() + }, function() { + state = REJECTING; + fire() + }, function() { + try { + if (state === RESOLVING && typeof successCallback === FUNCTION) { + promiseValue = successCallback(promiseValue) + } + else if (state === REJECTING && typeof failureCallback === "function") { + promiseValue = failureCallback(promiseValue); + state = RESOLVING + } + } + catch (e) { + m.deferred.onerror(e); + promiseValue = e; + return finish() + } + + if (promiseValue === self) { + promiseValue = TypeError(); + finish() + } + else { + thennable(then, function () { + finish(RESOLVED) + }, finish, function () { + finish(state === RESOLVING && RESOLVED) + }) + } + }) + } + } + m.deferred.onerror = function(e) { + if (type.call(e) === "[object Error]" && !e.constructor.toString().match(/ Error/)) throw e + }; + + m.sync = function(args) { + var method = "resolve"; + function synchronizer(pos, resolved) { + return function(value) { + results[pos] = value; + if (!resolved) method = "reject"; + if (--outstanding === 0) { + deferred.promise(results); + deferred[method](results) + } + return value + } + } + + var deferred = m.deferred(); + var outstanding = args.length; + var results = new Array(outstanding); + if (args.length > 0) { + for (var i = 0; i < args.length; i++) { + args[i].then(synchronizer(i, true), synchronizer(i, false)) + } + } + else deferred.resolve([]); + + return deferred.promise + }; + function identity(value) {return value} + + function ajax(options) { + if (options.dataType && options.dataType.toLowerCase() === "jsonp") { + var callbackKey = "mithril_callback_" + new Date().getTime() + "_" + (Math.round(Math.random() * 1e16)).toString(36); + var script = $document.createElement("script"); + + window[callbackKey] = function(resp) { + script.parentNode.removeChild(script); + options.onload({ + type: "load", + target: { + responseText: resp + } + }); + window[callbackKey] = undefined + }; + + script.onerror = function(e) { + script.parentNode.removeChild(script); + + options.onerror({ + type: "error", + target: { + status: 500, + responseText: JSON.stringify({error: "Error making jsonp request"}) + } + }); + window[callbackKey] = undefined; + + return false + }; + + script.onload = function(e) { + return false + }; + + script.src = options.url + + (options.url.indexOf("?") > 0 ? "&" : "?") + + (options.callbackKey ? options.callbackKey : "callback") + + "=" + callbackKey + + "&" + buildQueryString(options.data || {}); + $document.body.appendChild(script) + } + else { + var xhr = new window.XMLHttpRequest; + xhr.open(options.method, options.url, true, options.user, options.password); + xhr.onreadystatechange = function() { + if (xhr.readyState === 4) { + if (xhr.status >= 200 && xhr.status < 300) options.onload({type: "load", target: xhr}); + else options.onerror({type: "error", target: xhr}) + } + }; + if (options.serialize === JSON.stringify && options.data && options.method !== "GET") { + xhr.setRequestHeader("Content-Type", "application/json; charset=utf-8") + } + if (options.deserialize === JSON.parse) { + xhr.setRequestHeader("Accept", "application/json, text/*"); + } + if (typeof options.config === FUNCTION) { + var maybeXhr = options.config(xhr, options); + if (maybeXhr != null) xhr = maybeXhr + } + + var data = options.method === "GET" || !options.data ? "" : options.data + if (data && (type.call(data) != STRING && data.constructor != window.FormData)) { + throw "Request data should be either be a string or FormData. Check the `serialize` option in `m.request`"; + } + xhr.send(data); + return xhr + } + } + function bindData(xhrOptions, data, serialize) { + if (xhrOptions.method === "GET" && xhrOptions.dataType != "jsonp") { + var prefix = xhrOptions.url.indexOf("?") < 0 ? "?" : "&"; + var querystring = buildQueryString(data); + xhrOptions.url = xhrOptions.url + (querystring ? prefix + querystring : "") + } + else xhrOptions.data = serialize(data); + return xhrOptions + } + function parameterizeUrl(url, data) { + var tokens = url.match(/:[a-z]\w+/gi); + if (tokens && data) { + for (var i = 0; i < tokens.length; i++) { + var key = tokens[i].slice(1); + url = url.replace(tokens[i], data[key]); + delete data[key] + } + } + return url + } + + m.request = function(xhrOptions) { + if (xhrOptions.background !== true) m.startComputation(); + var deferred = new Deferred(); + var isJSONP = xhrOptions.dataType && xhrOptions.dataType.toLowerCase() === "jsonp"; + var serialize = xhrOptions.serialize = isJSONP ? identity : xhrOptions.serialize || JSON.stringify; + var deserialize = xhrOptions.deserialize = isJSONP ? identity : xhrOptions.deserialize || JSON.parse; + var extract = xhrOptions.extract || function(xhr) { + return xhr.responseText.length === 0 && deserialize === JSON.parse ? null : xhr.responseText + }; + xhrOptions.url = parameterizeUrl(xhrOptions.url, xhrOptions.data); + xhrOptions = bindData(xhrOptions, xhrOptions.data, serialize); + xhrOptions.onload = xhrOptions.onerror = function(e) { + try { + e = e || event; + var unwrap = (e.type === "load" ? xhrOptions.unwrapSuccess : xhrOptions.unwrapError) || identity; + var response = unwrap(deserialize(extract(e.target, xhrOptions)), e.target); + if (e.type === "load") { + if (type.call(response) === ARRAY && xhrOptions.type) { + for (var i = 0; i < response.length; i++) response[i] = new xhrOptions.type(response[i]) + } + else if (xhrOptions.type) response = new xhrOptions.type(response) + } + deferred[e.type === "load" ? "resolve" : "reject"](response) + } + catch (e) { + m.deferred.onerror(e); + deferred.reject(e) + } + if (xhrOptions.background !== true) m.endComputation() + }; + ajax(xhrOptions); + deferred.promise = propify(deferred.promise, xhrOptions.initialValue); + return deferred.promise + }; + + //testing API + m.deps = function(mock) { + initialize(window = mock || window); + return window; + }; + //for internal testing only, do not use `m.deps.factory` + m.deps.factory = app; + + return m +})(typeof window != "undefined" ? window : {}); + +if (typeof module != "undefined" && module !== null && module.exports) module.exports = m; +else if (typeof define === "function" && define.amd) define(function() {return m});
D admin/js/vendor/mithril.min.js

@@ -1,8 +0,0 @@

-/* -Mithril v0.1.30 -http://github.com/lhorie/mithril.js -(c) Leo Horie -License: MIT -*/ -var m=function a(b,c){function d(a){C=a.document,D=a.location,F=a.cancelAnimationFrame||a.clearTimeout,E=a.requestAnimationFrame||a.setTimeout}function e(){var a,b=[].slice.call(arguments),c=!(null==b[1]||K.call(b[1])!==G||"tag"in b[1]||"subtree"in b[1]),d=c?b[1]:{},e="class"in d?"class":"className",f={tag:"div",attrs:{}},g=[];if(K.call(b[0])!=I)throw new Error("selector in m(selector, attrs, children) should be a string");for(;a=L.exec(b[0]);)if(""===a[1]&&a[2])f.tag=a[2];else if("#"===a[1])f.attrs.id=a[2];else if("."===a[1])g.push(a[2]);else if("["===a[3][0]){var h=M.exec(a[3]);f.attrs[h[1]]=h[3]||(h[2]?"":!0)}g.length>0&&(f.attrs[e]=g.join(" "));var i=c?b[2]:b[1];f.children=K.call(i)===H?i:b.slice(c?2:1);for(var j in d)j===e?""!==d[j]&&(f.attrs[j]=(f.attrs[j]||"")+" "+d[j]):f.attrs[j]=d[j];return f}function f(a,b,d,e,j,l,m,n,o,p,q){if((null==j||null==j.toString())&&(j=""),"retain"===j.subtree)return l;var r=K.call(l),s=K.call(j);if(null==l||r!==s){if(null!=l)if(d&&d.nodes){var t=n-e,u=t+(s===H?j:l.nodes).length;i(d.nodes.slice(t,u),d.slice(t,u))}else l.nodes&&i(l.nodes,l);l=new j.constructor,l.tag&&(l={}),l.nodes=[]}if(s===H){for(var v=0,w=j.length;w>v;v++)K.call(j[v])===H&&(j=j.concat.apply([],j),v--);for(var x=[],y=l.length===j.length,z=0,A=1,B=2,D=3,E={},F=[],L=!1,v=0;v<l.length;v++)l[v]&&l[v].attrs&&null!=l[v].attrs.key&&(L=!0,E[l[v].attrs.key]={action:A,index:v});if(L){j.indexOf(null)>-1&&(j=j.filter(function(a){return null!=a}));var M=!1;if(j.length!=l.length)M=!0;else for(var O,P,v=0;O=l[v],P=j[v];v++)if(O.attrs&&P.attrs&&O.attrs.key!=P.attrs.key){M=!0;break}if(M){for(var v=0,w=j.length;w>v;v++)if(j[v]&&j[v].attrs)if(null!=j[v].attrs.key){var Q=j[v].attrs.key;E[Q]=E[Q]?{action:D,index:v,from:E[Q].index,element:l.nodes[E[Q].index]||C.createElement("div")}:{action:B,index:v}}else F.push({index:v,element:a.childNodes[v]||C.createElement("div")});var R=[];for(var S in E)R.push(E[S]);for(var T,U=R.sort(g),V=new Array(l.length),v=0;T=U[v];v++){if(T.action===A&&(i(l[T.index].nodes,l[T.index]),V.splice(T.index,1)),T.action===B){var W=C.createElement("div");W.key=j[T.index].attrs.key,a.insertBefore(W,a.childNodes[T.index]||null),V.splice(T.index,0,{attrs:{key:j[T.index].attrs.key},nodes:[W]})}T.action===D&&(a.childNodes[T.index]!==T.element&&null!==T.element&&a.insertBefore(T.element,a.childNodes[T.index]||null),V[T.index]=l[T.from])}for(var v=0,w=F.length;w>v;v++){var T=F[v];a.insertBefore(T.element,a.childNodes[T.index]||null),V[T.index]=l[T.index]}l=V,l.nodes=new Array(a.childNodes.length);for(var X,v=0;X=a.childNodes[v];v++)l.nodes[v]=X}}for(var v=0,Y=0,w=j.length;w>v;v++){var Z=f(a,b,l,n,j[v],l[Y],m,n+z||z,o,p,q);Z!==c&&(Z.nodes.intact||(y=!1),z+=Z.$trusted?(Z.match(/<[^\/]|\>\s*[^<]/g)||[]).length:K.call(Z)===H?Z.length:1,l[Y++]=Z)}if(!y){for(var v=0,w=j.length;w>v;v++)null!=l[v]&&x.push.apply(x,l[v].nodes);for(var $,v=0;$=l.nodes[v];v++)null!=$.parentNode&&x.indexOf($)<0&&i([$],[l[v]]);j.length<l.length&&(l.length=j.length),l.nodes=x}}else if(null!=j&&s===G){j.attrs||(j.attrs={}),l.attrs||(l.attrs={});var _=Object.keys(j.attrs),ab=_.length>("key"in j.attrs?1:0);if((j.tag!=l.tag||_.join()!=Object.keys(l.attrs).join()||j.attrs.id!=l.attrs.id)&&(l.nodes.length&&i(l.nodes),l.configContext&&typeof l.configContext.onunload===J&&l.configContext.onunload()),K.call(j.tag)!=I)return;var $,bb=0===l.nodes.length;if(j.attrs.xmlns?p=j.attrs.xmlns:"svg"===j.tag?p="http://www.w3.org/2000/svg":"math"===j.tag&&(p="http://www.w3.org/1998/Math/MathML"),bb?($=j.attrs.is?p===c?C.createElement(j.tag,j.attrs.is):C.createElementNS(p,j.tag,j.attrs.is):p===c?C.createElement(j.tag):C.createElementNS(p,j.tag),l={tag:j.tag,attrs:ab?h($,j.tag,j.attrs,{},p):j.attrs,children:null!=j.children&&j.children.length>0?f($,j.tag,c,c,j.children,l.children,!0,0,j.attrs.contenteditable?$:o,p,q):j.children,nodes:[$]},l.children&&!l.children.nodes&&(l.children.nodes=[]),"select"===j.tag&&j.attrs.value&&h($,j.tag,{value:j.attrs.value},{},p),a.insertBefore($,a.childNodes[n]||null)):($=l.nodes[0],ab&&h($,j.tag,j.attrs,l.attrs,p),l.children=f($,j.tag,c,c,j.children,l.children,!1,0,j.attrs.contenteditable?$:o,p,q),l.nodes.intact=!0,m===!0&&null!=$&&a.insertBefore($,a.childNodes[n]||null)),typeof j.attrs.config===J){var cb=l.configContext=l.configContext||{},db=function(a,b){return function(){return a.attrs.config.apply(a,b)}};q.push(db(j,[$,!bb,cb,l]))}}else if(typeof s!=J){var x;0===l.nodes.length?(j.$trusted?x=k(a,n,j):(x=[C.createTextNode(j)],a.nodeName.match(N)||a.insertBefore(x[0],a.childNodes[n]||null)),l="string number boolean".indexOf(typeof j)>-1?new j.constructor(j):j,l.nodes=x):l.valueOf()!==j.valueOf()||m===!0?(x=l.nodes,o&&o===C.activeElement||(j.$trusted?(i(x,l),x=k(a,n,j)):"textarea"===b?a.value=j:o?o.innerHTML=j:((1===x[0].nodeType||x.length>1)&&(i(l.nodes,l),x=[C.createTextNode(j)]),a.insertBefore(x[0],a.childNodes[n]||null),x[0].nodeValue=j)),l=new j.constructor(j),l.nodes=x):l.nodes.intact=!0}return l}function g(a,b){return a.action-b.action||a.index-b.index}function h(a,b,c,d,e){for(var f in c){var g=c[f],h=d[f];if(f in d&&h===g)"value"===f&&"input"===b&&a.value!=g&&(a.value=g);else{d[f]=g;try{if("config"===f||"key"==f)continue;if(typeof g===J&&0===f.indexOf("on"))a[f]=l(g,a);else if("style"===f&&null!=g&&K.call(g)===G){for(var i in g)(null==h||h[i]!==g[i])&&(a.style[i]=g[i]);for(var i in h)i in g||(a.style[i]="")}else null!=e?"href"===f?a.setAttributeNS("http://www.w3.org/1999/xlink","href",g):"className"===f?a.setAttribute("class",g):a.setAttribute(f,g):f in a&&"list"!==f&&"style"!==f&&"form"!==f&&"type"!==f?("input"!==b||a[f]!==g)&&(a[f]=g):a.setAttribute(f,g)}catch(j){if(j.message.indexOf("Invalid argument")<0)throw j}}}return d}function i(a,b){for(var c=a.length-1;c>-1;c--)if(a[c]&&a[c].parentNode){try{a[c].parentNode.removeChild(a[c])}catch(d){}b=[].concat(b),b[c]&&j(b[c])}0!=a.length&&(a.length=0)}function j(a){if(a.configContext&&typeof a.configContext.onunload===J&&a.configContext.onunload(),a.children)if(K.call(a.children)===H)for(var b,c=0;b=a.children[c];c++)j(b);else a.children.tag&&j(a.children)}function k(a,b,c){var d=a.childNodes[b];if(d){var e=1!=d.nodeType,f=C.createElement("span");e?(a.insertBefore(f,d||null),f.insertAdjacentHTML("beforebegin",c),a.removeChild(f)):d.insertAdjacentHTML("beforebegin",c)}else a.insertAdjacentHTML("beforeend",c);for(var g=[];a.childNodes[b]!==d;)g.push(a.childNodes[b]),b++;return g}function l(a,b){return function(c){c=c||event,e.redraw.strategy("diff"),e.startComputation();try{return a.call(b,c)}finally{ab()}}}function m(a){var b=Q.indexOf(a);return 0>b?Q.push(a)-1:b}function n(a){var b=function(){return arguments.length&&(a=arguments[0]),a};return b.toJSON=function(){return a},b}function o(){for(var a,b="all"===e.redraw.strategy(),c=0;a=T[c];c++)V[c]&&e.render(a,U[c].view?U[c].view(V[c]):$(),b);Y&&(Y(),Y=null),W=null,X=new Date,e.redraw.strategy("diff")}function p(a){return a.slice(db[e.route.mode].length)}function q(a,b,c){bb={};var d=c.indexOf("?");-1!==d&&(bb=u(c.substr(d+1,c.length)),c=c.substr(0,d));for(var f in b){if(f===c)return e.module(a,b[f]),!0;var g=new RegExp("^"+f.replace(/:[^\/]+?\.{3}/g,"(.*?)").replace(/:[^\/]+/g,"([^\\/]+)")+"/?$");if(g.test(c))return c.replace(g,function(){for(var c=f.match(/:[^\/]+/g)||[],d=[].slice.call(arguments,1,-2),g=0,h=c.length;h>g;g++)bb[c[g].replace(/:|\./g,"")]=decodeURIComponent(d[g]);e.module(a,b[f])}),!0}}function r(a){if(a=a||event,!a.ctrlKey&&!a.metaKey&&2!==a.which){a.preventDefault?a.preventDefault():a.returnValue=!1;var b=a.currentTarget||this,c="pathname"===e.route.mode&&b.search?u(b.search.slice(1)):{};e.route(b[e.route.mode].slice(db[e.route.mode].length),c)}}function s(){"hash"!=e.route.mode&&D.hash?D.hash=D.hash:b.scrollTo(0,0)}function t(a,b){var c=[];for(var d in a){var e=b?b+"["+d+"]":d,f=a[d],g=K.call(f),h=null!=f&&g===G?t(f,e):g===H?f.map(function(a){return encodeURIComponent(e+"[]")+"="+encodeURIComponent(a)}).join("&"):encodeURIComponent(e)+"="+encodeURIComponent(f);c.push(h)}return c.join("&")}function u(a){for(var b=a.split("&"),c={},d=0,e=b.length;e>d;d++){var f=b[d].split("=");c[decodeURIComponent(f[0])]=f[1]?decodeURIComponent(f[1]):""}return c}function v(a){var b=m(a);i(a.childNodes,R[b]),R[b]=c}function w(a){var b=e.prop();return a.then(b),b.then=function(b,c){return w(a.then(b,c))},b}function x(a,b){function c(a){l=a||j,n.map(function(a){l===i&&a.resolve(m)||a.reject(m)})}function d(a,b,c,d){if((null!=m&&K.call(m)===G||typeof m===J)&&typeof a===J)try{var f=0;a.call(m,function(a){f++||(m=a,b())},function(a){f++||(m=a,c())})}catch(g){e.deferred.onerror(g),m=g,c()}else d()}function f(){var j;try{j=m&&m.then}catch(n){return e.deferred.onerror(n),m=n,l=h,f()}d(j,function(){l=g,f()},function(){l=h,f()},function(){try{l===g&&typeof a===J?m=a(m):l===h&&"function"==typeof b&&(m=b(m),l=g)}catch(f){return e.deferred.onerror(f),m=f,c()}m===k?(m=TypeError(),c()):d(j,function(){c(i)},c,function(){c(l===g&&i)})})}var g=1,h=2,i=3,j=4,k=this,l=0,m=0,n=[];k.promise={},k.resolve=function(a){return l||(m=a,l=g,f()),this},k.reject=function(a){return l||(m=a,l=h,f()),this},k.promise.then=function(a,b){var c=new x(a,b);return l===i?c.resolve(m):l===j?c.reject(m):n.push(c),c.promise}}function y(a){return a}function z(a){if(!a.dataType||"jsonp"!==a.dataType.toLowerCase()){var d=new b.XMLHttpRequest;if(d.open(a.method,a.url,!0,a.user,a.password),d.onreadystatechange=function(){4===d.readyState&&(d.status>=200&&d.status<300?a.onload({type:"load",target:d}):a.onerror({type:"error",target:d}))},a.serialize===JSON.stringify&&a.data&&"GET"!==a.method&&d.setRequestHeader("Content-Type","application/json; charset=utf-8"),a.deserialize===JSON.parse&&d.setRequestHeader("Accept","application/json, text/*"),typeof a.config===J){var e=a.config(d,a);null!=e&&(d=e)}var f="GET"!==a.method&&a.data?a.data:"";if(f&&K.call(f)!=I&&f.constructor!=b.FormData)throw"Request data should be either be a string or FormData. Check the `serialize` option in `m.request`";return d.send(f),d}var g="mithril_callback_"+(new Date).getTime()+"_"+Math.round(1e16*Math.random()).toString(36),h=C.createElement("script");b[g]=function(d){h.parentNode.removeChild(h),a.onload({type:"load",target:{responseText:d}}),b[g]=c},h.onerror=function(){return h.parentNode.removeChild(h),a.onerror({type:"error",target:{status:500,responseText:JSON.stringify({error:"Error making jsonp request"})}}),b[g]=c,!1},h.onload=function(){return!1},h.src=a.url+(a.url.indexOf("?")>0?"&":"?")+(a.callbackKey?a.callbackKey:"callback")+"="+g+"&"+t(a.data||{}),C.body.appendChild(h)}function A(a,b,c){if("GET"===a.method&&"jsonp"!=a.dataType){var d=a.url.indexOf("?")<0?"?":"&",e=t(b);a.url=a.url+(e?d+e:"")}else a.data=c(b);return a}function B(a,b){var c=a.match(/:[a-z]\w+/gi);if(c&&b)for(var d=0;d<c.length;d++){var e=c[d].slice(1);a=a.replace(c[d],b[e]),delete b[e]}return a}var C,D,E,F,G="[object Object]",H="[object Array]",I="[object String]",J="function",K={}.toString,L=/(?:(^|#|\.)([^#\.\[\]]+))|(\[.+?\])/g,M=/\[(.+?)(?:=("|'|)(.*?)\2)?\]/,N=/^(AREA|BASE|BR|COL|COMMAND|EMBED|HR|IMG|INPUT|KEYGEN|LINK|META|PARAM|SOURCE|TRACK|WBR)$/;d(b);var O,P={appendChild:function(a){O===c&&(O=C.createElement("html")),C.documentElement&&C.documentElement!==a?C.replaceChild(a,C.documentElement):C.appendChild(a),this.childNodes=C.childNodes},insertBefore:function(a){this.appendChild(a)},childNodes:[]},Q=[],R={};e.render=function(a,b,d){var e=[];if(!a)throw new Error("Please ensure the DOM element exists before rendering a template into it.");var g=m(a),h=a===C,j=h||a===C.documentElement?P:a;h&&"html"!=b.tag&&(b={tag:"html",attrs:{},children:b}),R[g]===c&&i(j.childNodes),d===!0&&v(a),R[g]=f(j,null,c,c,b,R[g],!1,0,null,c,e);for(var k=0,l=e.length;l>k;k++)e[k]()},e.trust=function(a){return a=new String(a),a.$trusted=!0,a},e.prop=function(a){return(null!=a&&K.call(a)===G||typeof a===J)&&typeof a.then===J?w(a):n(a)};var S,T=[],U=[],V=[],W=null,X=0,Y=null,Z=16;e.module=function(a,b){if(!a)throw new Error("Please ensure the DOM element exists before rendering a template into it.");var c=T.indexOf(a);0>c&&(c=T.length);var d=!1;if(V[c]&&typeof V[c].onunload===J){var f={preventDefault:function(){d=!0}};V[c].onunload(f)}if(!d){e.redraw.strategy("all"),e.startComputation(),T[c]=a;var g=S=b=b||{},h=new(b.controller||function(){});return g===S&&(V[c]=h,U[c]=b),ab(),V[c]}},e.redraw=function(a){W&&a!==!0?(new Date-X>Z||E===b.requestAnimationFrame)&&(W>0&&F(W),W=E(o,Z)):(o(),W=E(function(){W=null},Z))},e.redraw.strategy=e.prop();var $=function(){return""},_=0;e.startComputation=function(){_++},e.endComputation=function(){_=Math.max(_-1,0),0===_&&e.redraw()};var ab=function(){"none"==e.redraw.strategy()?(_--,e.redraw.strategy("diff")):e.endComputation()};e.withAttr=function(a,b){return function(c){c=c||event;var d=c.currentTarget||this;b(a in d?d[a]:d.getAttribute(a))}};var bb,cb,db={pathname:"",hash:"#",search:"?"},eb=function(){};return e.route=function(){if(0===arguments.length)return cb;if(3===arguments.length&&K.call(arguments[1])===I){var a=arguments[0],c=arguments[1],d=arguments[2];eb=function(b){var f=cb=p(b);q(a,d,f)||e.route(c,!0)};var f="hash"===e.route.mode?"onhashchange":"onpopstate";b[f]=function(){var a=D[e.route.mode];"pathname"===e.route.mode&&(a+=D.search),cb!=p(a)&&eb(a)},Y=s,b[f]()}else if(arguments[0].addEventListener){{var g=arguments[0];arguments[1],arguments[2]}g.href=("pathname"!==e.route.mode?D.pathname:"")+db[e.route.mode]+this.attrs.href,g.removeEventListener("click",r),g.addEventListener("click",r)}else if(K.call(arguments[0])===I){var h=cb;cb=arguments[0];var i=arguments[1]||{},j=cb.indexOf("?"),k=j>-1?u(cb.slice(j+1)):{};for(var l in i)k[l]=i[l];var m=t(k),n=j>-1?cb.slice(0,j):cb;m&&(cb=n+(-1===n.indexOf("?")?"?":"&")+m);var o=(3===arguments.length?arguments[2]:arguments[1])===!0||h===arguments[0];b.history.pushState?(Y=function(){b.history[o?"replaceState":"pushState"](null,C.title,db[e.route.mode]+cb),s()},eb(db[e.route.mode]+cb)):D[e.route.mode]=cb}},e.route.param=function(a){if(!bb)throw new Error("You must call m.route(element, defaultRoute, routes) before calling m.route.param()");return bb[a]},e.route.mode="search",e.deferred=function(){var a=new x;return a.promise=w(a.promise),a},e.deferred.onerror=function(a){if("[object Error]"===K.call(a)&&!a.constructor.toString().match(/ Error/))throw a},e.sync=function(a){function b(a,b){return function(e){return g[a]=e,b||(c="reject"),0===--f&&(d.promise(g),d[c](g)),e}}var c="resolve",d=e.deferred(),f=a.length,g=new Array(f);if(a.length>0)for(var h=0;h<a.length;h++)a[h].then(b(h,!0),b(h,!1));else d.resolve([]);return d.promise},e.request=function(a){a.background!==!0&&e.startComputation();var b=e.deferred(),c=a.dataType&&"jsonp"===a.dataType.toLowerCase(),d=a.serialize=c?y:a.serialize||JSON.stringify,f=a.deserialize=c?y:a.deserialize||JSON.parse,g=a.extract||function(a){return 0===a.responseText.length&&f===JSON.parse?null:a.responseText};return a.url=B(a.url,a.data),a=A(a,a.data,d),a.onload=a.onerror=function(c){try{c=c||event;var d=("load"===c.type?a.unwrapSuccess:a.unwrapError)||y,h=d(f(g(c.target,a)));if("load"===c.type)if(K.call(h)===H&&a.type)for(var i=0;i<h.length;i++)h[i]=new a.type(h[i]);else a.type&&(h=new a.type(h));b["load"===c.type?"resolve":"reject"](h)}catch(c){e.deferred.onerror(c),b.reject(c)}a.background!==!0&&e.endComputation()},z(a),b.promise(a.initialValue),b.promise},e.deps=function(a){return d(b=a||b),b},e.deps.factory=a,e}("undefined"!=typeof window?window:{});"undefined"!=typeof module&&null!==module&&module.exports?module.exports=m:"function"==typeof define&&define.amd&&define(function(){return m}); -//# sourceMappingURL=mithril.min.js.map
D admin/js/vendor/mithril.min.js.map

@@ -1,1 +0,0 @@

-{"version":3,"file":"mithril.min.js","sources":["mithril.js"],"names":["m","app","window","undefined","initialize","$document","document","$location","location","$cancelAnimationFrame","cancelAnimationFrame","clearTimeout","$requestAnimationFrame","requestAnimationFrame","setTimeout","match","args","slice","call","arguments","hasAttrs","type","OBJECT","attrs","classAttrName","cell","tag","classes","STRING","Error","parser","exec","id","push","pair","attrParser","length","join","children","ARRAY","attrName","build","parentElement","parentTag","parentCache","parentIndex","data","cached","shouldReattach","index","editable","namespace","configs","toString","subtree","cachedType","dataType","nodes","offset","end","clear","constructor","i","len","concat","apply","intact","subArrayCount","DELETION","INSERTION","MOVE","existing","unkeyed","shouldMaintainIdentities","key","action","indexOf","filter","x","keysDiffer","cachedCell","dataCell","from","element","createElement","childNodes","actions","prop","change","changes","sort","sortChanges","newCached","Array","splice","dummy","insertBefore","child","cacheCount","item","$trusted","node","parentNode","dataAttrKeys","Object","keys","hasKeys","configContext","onunload","FUNCTION","isNew","xmlns","is","createElementNS","setAttributes","contenteditable","value","context","callback","injectHTML","createTextNode","nodeName","voidElements","valueOf","activeElement","innerHTML","nodeType","nodeValue","a","b","dataAttrs","cachedAttrs","dataAttr","cachedAttr","autoredraw","rule","style","setAttributeNS","setAttribute","e","message","removeChild","unload","nextSibling","isElement","placeholder","insertAdjacentHTML","object","event","redraw","strategy","startComputation","endFirstComputation","getCellCacheKey","nodeCache","gettersetter","store","toJSON","root","forceRedraw","roots","controllers","render","modules","view","blank","computePostRedrawHook","lastRedrawId","lastRedrawCallTime","Date","normalizeRoute","route","modes","mode","routeByValue","router","path","routeParams","queryStart","parseQueryString","substr","module","matcher","RegExp","replace","test","values","decodeURIComponent","routeUnobtrusive","ctrlKey","metaKey","which","preventDefault","returnValue","currentTarget","this","search","setScroll","hash","scrollTo","buildQueryString","prefix","str","valueType","map","encodeURIComponent","pairs","split","params","reset","cacheKey","cellCache","propify","promise","then","resolve","reject","Deferred","successCallback","failureCallback","finish","state","REJECTED","next","deferred","RESOLVED","promiseValue","thennable","notThennableCallback","count","onerror","fire","REJECTING","RESOLVING","self","TypeError","identity","ajax","options","toLowerCase","xhr","XMLHttpRequest","open","method","url","user","password","onreadystatechange","readyState","status","onload","target","serialize","JSON","stringify","setRequestHeader","deserialize","parse","config","maybeXhr","FormData","send","callbackKey","getTime","Math","round","random","script","resp","responseText","error","src","body","appendChild","bindData","xhrOptions","querystring","parameterizeUrl","tokens","html","documentNode","documentElement","replaceChild","forceRecreation","isDocumentRoot","trust","String","topModule","FRAME_BUDGET","isPrevented","currentModule","controller","force","pendingRequests","endComputation","max","withAttr","withAttrCallback","getAttribute","currentRoute","pathname","redirect","defaultRoute","source","listener","addEventListener","href","removeEventListener","oldRoute","queryIndex","currentPath","shouldReplaceHistoryEntry","history","pushState","title","param","sync","synchronizer","pos","resolved","results","outstanding","request","background","isJSONP","extract","unwrap","unwrapSuccess","unwrapError","response","initialValue","deps","mock","factory","exports","define","amd"],"mappings":";;;;;;AAAA,GAAIA,GAAI,QAAUC,GAAIC,EAAQC,GAU7B,QA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WAAY,MAAO/U"}
M admin/md/getting-started.mdadmin/md/getting-started.md

@@ -1,7 +1,7 @@

## Getting Started -### Downloading Pre-build Binaries +### Downloading Pre-built Binaries ### Installing Using Nimble -### Building from Source +### Building from Source
M admin/md/overview.mdadmin/md/overview.md

@@ -1,19 +1,14 @@

## Overview -LiteStore is a self-contained, RESTful, multi-format document store written in [Nim](http://www.nim-lang.org). It aims to be a very simple and lightweight backend suitable for prototypes and testing REST APIs. - -> %note% -> Note -> -> This is a note. +LiteStore is a lightweight, self-contained, RESTful, multi-format document store server written in [Nim](http://www.nim-lang.org). It aims to be a very simple and lightweight backend ideal for prototyping and testing REST APIs and single-page applications. ### Rationale If you ever wanted to build a simple single-page application in your favorite framework, just to try something out or as a prototype, you inevitably had to answer the question _"What backend should I use?"_ -Sure, setting up a simple REST service using [Sinatra](http://www.sinatrarb.com) or [Express.js](http://expressjs.com) is not very hard, but if you want to distribute it, that will become a prerequisite for your app: you'll either distribute it with it, or install it beforehand on any machine you want to try your app on. Which is a shame, really, because single-page-applications are meant to be running anywhere _provided that they can access their backend_. +Sure, setting up a simple REST service using [Sinatra](http://www.sinatrarb.com) or [Express.js](http://expressjs.com) is not very hard, but if you want to distribute it, that backend will become a prerequisite for your app: you'll either distribute it with it, or install it beforehand on any machine you want to try your app on. Which is a shame, really, because single-page-applications are meant to be running anywhere _provided that they can access their backend_. -LiteStore aims to solve this problem. Using LiteStore, you only need to take _two files_ with you, at all times: +LiteStore aims to solve this problem. When you use LiteStore as the backend for your app, you only need to take _two files_ with you, at all times: * The [litestore](class:cmd) executable file for your platform of choice (that's about 2MB in size) * A datastore file

@@ -22,8 +17,12 @@ And yes, you can even store the code of your client-side application inside the datastore itself, along with your application data.

### Key Features +Despite being fairly small and self-contained, LiteStore comes with many useful features that are essential for many [use cases](#Use.Cases). + #### Multiformat documents +LiteStore can be used to store documents in virtually any format + #### Document Tagging #### Full-text Search

@@ -32,7 +31,17 @@ #### RESTful HTTP API

#### Directory Bulk Import/Export -#### Directory Mirroring +#### Directory Mounting and Mirroring + +### Use Cases + +#### SPA prototyping backend + +#### Personal Wiki/CMS backend + +#### Static site backend + +#### Lightweight file server ### Architecture
M admin/md/usage.mdadmin/md/usage.md

@@ -2,4 +2,4 @@ ## Usage

### Command Line Syntax -### Examples +### Examples
M lib/core.nimlib/core.nim

@@ -111,9 +111,10 @@ proc createDocument*(store: Datastore, id="", rawdata = "", contenttype = "text/plain", binary = -1, searchable = 1): string =

var id = id var contenttype = contenttype.replace(peg"""\;(.+)$""", "") # Strip charset for now var binary = checkIfBinary(binary, contenttype) + var searchable = searchable + if binary == 1: + searchable = 0 var data = rawdata - if binary == 1: - data = data.encode(data.len*2) if id == "": id = $genOid() # Store document

@@ -138,11 +139,13 @@ proc updateDocument*(store: Datastore, id: string, rawdata: string, contenttype = "text/plain", binary = -1, searchable = 1): string =

var contenttype = contenttype.replace(peg"""\;(.+)$""", "") # Strip charset for now var binary = checkIfBinary(binary, contenttype) var data = rawdata + var searchable = searchable if binary == 1: - data = data.encode(data.len*2) + searchable = 0 var res = store.db.execAffectedRows(SQL_UPDATE_DOCUMENT, data, contenttype, binary, searchable, currentTime(), id) if res > 0: - store.db.exec(SQL_UPDATE_SEARCHCONTENT, data.toPlainText, id) + if binary <= 0 and searchable >= 0: + store.db.exec(SQL_UPDATE_SEARCHCONTENT, data.toPlainText, id) if store.hasMirror and id.startsWith(store.mount): var filename = id.unixToNativePath if fileExists(filename):

@@ -213,6 +216,7 @@ var d_searchable = 1

if d_ct.isBinary: d_binary = 1 d_searchable = 0 + d_contents = d_contents.encode(d_contents.len*2) # Encode in Base64. discard store.createDocument(d_id, d_contents, d_ct, d_binary, d_searchable) store.db.exec(SQL_INSERT_TAG, "$dir:"&dir, d_id)