Added --reset option; improved editing for pages.
h3rald h3rald@h3rald.com
Sun, 15 Mar 2015 18:17:06 +0100
9 files changed,
67 insertions(+),
31 deletions(-)
M
app/js/modules/document.js
→
app/js/modules/document.js
@@ -21,7 +21,7 @@ vm.doc = Doc.get(vm.id());
vm.doc.then(function(doc){ vm.content = doc.data; vm.tags = doc.tags; - }); + }, vm.flashError); }; vm.tags = []; switch (vm.action) {@@ -70,9 +70,7 @@ var put = function(id){
Doc.put(doc, vm.contentType()).then(function(){ LS.flash({type: "success", content: "Document saved successfully."}); m.route("/document/view/"+id); - }, function(obj){ - vm.showFlash({type: "warning", content: obj.error}); - }); + }, vm.flashError); }; if (vm.action === "create") { doc.id = "app/"+vm.id();@@ -93,7 +91,7 @@ if (confirm(msg)) {
Doc.delete(vm.id()).then(function(){ LS.flash({type: "success", content: "Document '"+vm.id()+"' deleted successfully."}); m.route("/info"); - }); + }, vm.flashError); } else { m.route("/document/view/"+vm.id()); }@@ -126,13 +124,13 @@ var titleLeft = vm.id();
var titleRight = m("span.pull-right", vm.tags.map(function(t){return u.taglink(t);})); if (vm.action === "create"){ titleLeft = m("span", ["app/",m("input", { - placeholder: "Specify document ID...", + placeholder: "Document ID", onchange: m.withAttr("value", vm.id), size: 35, value: vm.id() })]); titleRight = m("span.pull-right", [m("input", { - placeholder: "Specify content type...", + placeholder: "Content Type", onchange: m.withAttr("value", vm.contentType), size: 25, value: vm.contentType()@@ -140,6 +138,25 @@ })]);
} var title = m("span",[titleLeft, titleRight]); return m("div", [ + m(".row", [u.toolbar({links: vm.tools()})]), + m(".row", [u.panel({title: title, content:app.editor.view(vm)})]) + ]); + }; + + u.layout(app.document); +}());); + }; + + u.layout(app.document); +}());leLeft, titleRight]); + return m("div", [ + m(".row", [u.toolbar({links: vm.tools()})]), + m(".row", [u.panel({title: title, content:app.editor.view(vm)})]) + ]); + }; + + u.layout(app.document); +}()); return m("div", [ m(".row", [u.toolbar({links: vm.tools()})]), m(".row", [u.panel({title: title, content:app.editor.view(vm)})]) ]);
M
app/js/modules/guide.js
→
app/js/modules/guide.js
@@ -6,11 +6,19 @@
// Guide Module app.guide = {vm: {}}; app.guide.vm.init = function() { - this.id = m.route.param("id"); - this.content = Page.get(this.id); + var vm = this; + vm.id = m.prop(m.route.param("id")); + vm.content = Page.get(vm.id()); + vm.edit = function(){ + m.route("/document/edit/app/md/"+vm.id()+".md"); + }; + vm.links = m.prop([{action: vm.edit, title: "Edit", icon: "edit"}]); }; app.guide.main = function(){ - return m("article.row", m.trust(app.guide.vm.content())); + return m("article.row", [ + u.toolbar({links: app.guide.vm.links()}), + m.trust(app.guide.vm.content()) + ]); }; u.layout(app.guide);
M
app/js/utils.js
→
app/js/utils.js
@@ -21,6 +21,9 @@ LS.flash(obj);
mod.vm.flash(u.flash()); LS.flash = m.prop(); }; + mod.vm.flashError = function(obj){ + mod.vm.showFlash({type: "warning", content: obj.error}); + }; }; mod.view = function(ctrl){@@ -110,4 +113,4 @@ return function(xhr) {
xhr.setRequestHeader("Content-Type", contentType); }; }; -}()); +}());
M
app/md/overview.md
→
app/md/overview.md
@@ -21,13 +21,14 @@ #### Multiformat documents
#### Document Tagging -#### Fulltext Search +#### Full-text Search -#### REST HTTP API +#### RESTful HTTP API #### Directory Bulk Import/Export +#### Directory Mirroring + ### Architecture --> ![LiteStore Architecture](images/litestore_arch.png) <- - +![LiteStore Architecture](images/litestore_arch.png)
M
lib/cli.nim
→
lib/cli.nim
@@ -19,6 +19,7 @@ directory = ""
readonly = false logLevel = lvlInfo mirror = false + reset = false var f = newStringStream(cfgfile) if f != nil:@@ -59,16 +60,17 @@ Usage:
LS [-p:<port> -a:<address>] [<file>] [--import:<directory> | --export:<directory> | --delete:<directory>] Options: - -a, --address Specify address (default: 0.0.0.0). - -d, --delete Delete the previously-imported specified directory. - --export Export the previously-imported specified directory to the current directory. - -h, --help Display this message. - --import Import the specified directory (Store all its contents). - -l, --log Specify the log level: debug, info, warn, error, fatal, none (default: info) - -p, --port Specify port number (default: 9500). - -r, --readonly Allow only data retrieval operations. - -m, --mirror Import the specified directory, run server and mirror database changes to filesystem. - -v, --version Display the program version. + -a, --address Specify address (default: 127.0.0.1). + -d, --delete Delete the previously-imported specified directory. + --export Export the previously-imported specified directory to the current directory. + -h, --help Display this message. + --import Import the specified directory (Store all its contents). + -l, --log Specify the log level: debug, info, warn, error, fatal, none (default: info) + -p, --port Specify port number (default: 9500). + -r, --readonly Allow only data retrieval operations. + -m, --mirror Import the specified directory, run server and mirror database changes to filesystem. + --reset If --mirror is specified, resets (deletes) any previously imported directory data. + -v, --version Display the program version. """ for kind, key, val in getOpt():@@ -101,6 +103,8 @@ fail(104, "Directory to mirror not specified.")
operation = opRun directory = val mirror = true + of "reset": + reset = true of "export": if val == "": fail(105, "Directory to export not specified.")@@ -136,6 +140,7 @@ LS.readonly = readonly
LS.appname = appname LS.favicon = favicon LS.mirror = mirror +LS.reset = reset # Initialize loggers
M
lib/core.nim
→
lib/core.nim
@@ -235,11 +235,12 @@ store.db.exec(SQL_DELETE_DOCUMENTS_BY_TAG, "$dir:"&dir)
store.db.exec(SQL_DELETE_SEARCHCONTENTS_BY_TAG, "$dir:"&dir) store.db.exec(SQL_DELETE_TAGS_BY_TAG, "$dir:"&dir) -proc mountDir*(store: var Datastore, dir:string) = +proc mountDir*(store: var Datastore, dir:string, reset=false) = if not dir.dirExists: raise newException(EDirectoryNotFound, "Directory '$1' not found." % dir) - store.deleteDir(dir) - store.importDir(dir) + if reset: + store.deleteDir(dir) + store.importDir(dir) store.mirror = dir proc destroyDocumentsByTag*(store: Datastore, tag: string): int64 =
M
lib/types.nim
→
lib/types.nim
@@ -39,6 +39,7 @@ readonly*: bool
appname*: string appversion*: string favicon*:string + reset*: bool Response* = tuple[ code: HttpCode, content: string,
M
litestore.nim
→
litestore.nim
@@ -33,7 +33,7 @@ try:
LS.store = LS.file.openDatastore() if LS.mirror: try: - LS.store.mountDir(LS.directory) + LS.store.mountDir(LS.directory, LS.reset) except: echo(getCurrentExceptionMsg()) fail(202, "Unable to mount directory '$1'" % [LS.directory])