all repos — litestore @ e40b403dbbd176bd2131e9da26e6d178b44207a8

A minimalist nosql document store.

Updated documentation.
h3rald h3rald@h3rald.com
Thu, 18 Aug 2022 13:24:12 +0200
commit

e40b403dbbd176bd2131e9da26e6d178b44207a8

parent

5ef1d616781387609215f626fb997ed74b1ef760

3 files changed, 178 insertions(+), 79 deletions(-)

jump to
M build_guidebuild_guide

@@ -17,6 +17,7 @@ md/api.md

md/api_info.md md/api_dir.md md/api_docs.md + md/api_assets.md md/api_tags.md md/api_indexes.md md/api_stores.md
M src/admin/js/components/navbar.jssrc/admin/js/components/navbar.js

@@ -1,66 +1,164 @@

-(function(){ +(function () { 'use strict'; var app = window.LS || (window.LS = {}); var u = app.utils; app.navlinks = { - controller: function(args){ + controller: function (args) { var vm = {}; var caret = "<i class='fa fa-angle-right'></i> "; - vm.activelink = function(url){ - return (m.route().match(new RegExp("^\/"+url))) ? "active" : ""; + vm.activelink = function (url) { + return (m.route().match(new RegExp("^\/" + url))) ? "active" : ""; }; - vm.guidelinks = [ - {path: "/guide/overview", title: "Overview"}, - {path: "/guide/use-cases", title: caret+"Use Cases"}, - {path: "/guide/architecture", title: caret+"Architecture"}, - {path: "/guide/data_model", title: caret+"Data Model"}, - {path: "/guide/getting-started", title: "Getting Started"}, - {path: "/guide/usage", title: "Usage"}, - {path: "/guide/auth", title: "Authorization"}, - {path: "/guide/configuration-file", title: "Configuration File"}, - {path: "/guide/middleware", title: "Middleware"}, - {path: "/guide/global-js-objects", title: caret+"Global JavaScript Objects"}, - {path: "/guide/system-documents", title: "System Documents"}, - {path: "/guide/multiple-stores", title: "Multiple Data Stores"}, - {path: "/guide/admin_app", title: "Administration App"}, - {path: "/guide/api", title: "HTTP API Reference"}, - {path: "/guide/api_info", title: caret+"info (LiteStore Information)"}, - {path: "/guide/api_dir", title: caret+"dir (LiteStore Directory)"}, - {path: "/guide/api_docs", title: caret+"docs (LiteStore Documents)"}, - {path: "/guide/api_tags", title: caret+"tags (LiteStore Tags)"}, - {path: "/guide/api_indexes", title: caret+"indexes (LiteStore Indexes)"}, - {path: "/guide/api_stores", title: caret+"stores (LiteStore Stores)"}, - {path: "/guide/nim-api", title: "Nim API Reference"}, - {path: "/guide/nim-api_high", title: caret+"High-Level Nim API"}, - {path: "/guide/nim-api_low", title: caret+"Low-Level Nim API"}, - {path: "/guide/credits", title: "Credits"} + vm.guidelinks = [{ + path: "/guide/overview", + title: "Overview" + }, + { + path: "/guide/use-cases", + title: caret + "Use Cases" + }, + { + path: "/guide/architecture", + title: caret + "Architecture" + }, + { + path: "/guide/data_model", + title: caret + "Data Model" + }, + { + path: "/guide/getting-started", + title: "Getting Started" + }, + { + path: "/guide/usage", + title: "Usage" + }, + { + path: "/guide/auth", + title: "Authorization" + }, + { + path: "/guide/configuration-file", + title: "Configuration File" + }, + { + path: "/guide/middleware", + title: "Middleware" + }, + { + path: "/guide/global-js-objects", + title: caret + "Global JavaScript Objects" + }, + { + path: "/guide/system-documents", + title: "System Documents" + }, + { + path: "/guide/multiple-stores", + title: "Multiple Data Stores" + }, + { + path: "/guide/admin_app", + title: "Administration App" + }, + { + path: "/guide/api", + title: "HTTP API Reference" + }, + { + path: "/guide/api_info", + title: caret + "info (LiteStore Information)" + }, + { + path: "/guide/api_dir", + title: caret + "dir (LiteStore Directory)" + }, + { + path: "/guide/api_docs", + title: caret + "docs (LiteStore Documents)" + }, + { + path: "/guide/api_assets", + title: caret + "assets (LiteStore Assets)" + }, + { + path: "/guide/api_tags", + title: caret + "tags (LiteStore Tags)" + }, + { + path: "/guide/api_indexes", + title: caret + "indexes (LiteStore Indexes)" + }, + { + path: "/guide/api_stores", + title: caret + "stores (LiteStore Stores)" + }, + { + path: "/guide/nim-api", + title: "Nim API Reference" + }, + { + path: "/guide/nim-api_high", + title: caret + "High-Level Nim API" + }, + { + path: "/guide/nim-api_low", + title: caret + "Low-Level Nim API" + }, + { + path: "/guide/credits", + title: "Credits" + } ]; - vm.taglinks = function(info){ - return info.tags.map(function(tag){ + vm.taglinks = function (info) { + return info.tags.map(function (tag) { var key = Object.keys(tag)[0]; - return {path: "/tags/"+key, title: key+" ("+tag[key]+")"}; + return { + path: "/tags/" + key, + title: key + " (" + tag[key] + ")" + }; }); }; return vm; }, - view: function(ctrl){ + view: function (ctrl) { var links = [ - m("li", {class: ctrl.activelink("info")}, [m("a", {href: "/info", config: m.route}, - [m("i.fa.fa-info-circle"), " Info"])]), - u.dropdown({title: "Guide", icon:"fa-book", links: ctrl.guidelinks, active: ctrl.activelink("guide")}), - u.dropdown({title: "Tags", icon:"fa-tags", links: ctrl.taglinks(app.system), active: ctrl.activelink("tags")})]; + m("li", { + class: ctrl.activelink("info") + }, [m("a", { + href: "/info", + config: m.route + }, + [m("i.fa.fa-info-circle"), " Info"])]), + u.dropdown({ + title: "Guide", + icon: "fa-book", + links: ctrl.guidelinks, + active: ctrl.activelink("guide") + }), + u.dropdown({ + title: "Tags", + icon: "fa-tags", + links: ctrl.taglinks(app.system), + active: ctrl.activelink("tags") + }) + ]; if (!app.system.read_only) { - links.push(m("li", - {class: ctrl.activelink("new")}, [m("a", {href: "/document/create/", config: m.route}, - [m("i.fa.fa-plus-circle"), " New"])])); + links.push(m("li", { + class: ctrl.activelink("new") + }, [m("a", { + href: "/document/create/", + config: m.route + }, + [m("i.fa.fa-plus-circle"), " New"])])); } return m("ul.nav.navbar-nav", links); } }; app.navheader = { - view: function(ctrl, args) { + view: function (ctrl, args) { return m(".navbar-header", [ m("button.navbar-toggle.collapsed[data-toggle='collapse'][data-target='#nav-collapse'][type='button']", [ m("span.sr-only", "Toggle navigation"),

@@ -68,56 +166,57 @@ m("span.icon-bar"),

m("span.icon-bar"), m("span.icon-bar") ]), - m("a.navbar-brand", {href: "/", config:m.route}, "LiteStore Admin") + m("a.navbar-brand", { + href: "/", + config: m.route + }, "LiteStore Admin") ]); } }; app.searchbox = { - controller: function() { - var vm = {}; + controller: function () { + var vm = {}; vm.query = m.prop(""); - vm.keySearch = function(el, isInitialized, context){ + vm.keySearch = function (el, isInitialized, context) { if (isInitialized) return; - $(el).keypress(function(event){ + $(el).keypress(function (event) { if (isInitialized) return; vm.query($(el).val()); - if (event.which == 13){ + if (event.which == 13) { vm.search(); return false; } }); }; - vm.search = function(){ - m.route("/search/"+vm.query()); + vm.search = function () { + m.route("/search/" + vm.query()); }; return vm; }, - view: function(ctrl, args) { + view: function (ctrl, args) { return m("form.navbar-form.navbar-right[role='search']", [ - m(".input-group", [ - m("input.form-control", { - type:"text", - placeholder:"Search...", - onchange: m.withAttr("value", ctrl.query), - config: ctrl.keySearch, - value: ctrl.query() - }), - m("span.input-group-btn", - m("button.btn.btn-default", - { - type: "button", - onclick: ctrl.search - }, - [m("i.fa.fa-search")])) - ]) - ] - ); + m(".input-group", [ + m("input.form-control", { + type: "text", + placeholder: "Search...", + onchange: m.withAttr("value", ctrl.query), + config: ctrl.keySearch, + value: ctrl.query() + }), + m("span.input-group-btn", + m("button.btn.btn-default", { + type: "button", + onclick: ctrl.search + }, + [m("i.fa.fa-search")])) + ]) + ]); } }; app.navbar = { - view: function(ctrl, args) { + view: function (ctrl, args) { return m("nav.navbar.navbar-inverse.navbar-fixed-top", [ m(".container-fluid", [ m.component(app.navheader),

@@ -129,4 +228,4 @@ ])

]); } }; -}());+}());
M src/admin/md/api_assets.mdsrc/admin/md/api_assets.md

@@ -6,7 +6,7 @@ >

> This resource has been introduced in version 5 of the LiteStore API. Assets represents another way to query LiteStore Documents. All documents can also be retrieved via `/assets/` instead of docs, but when doing so: -* a non-row version of the document will always be returned +* a non-raw version of the document will always be returned * when querying a folder without specifying a document ID, LiteStore will attempt to retrieve an `index.html` or `index.htm` file within that folder This is particularly useful when your documents have been imported from the filesystem and you need to effectively serve files.

@@ -45,14 +45,14 @@ Access-Control-Allow-Origin: *

Server: LiteStore/1.12.0 ``` -#### OPTIONS docs/:folder/ +#### OPTIONS assets/:folder/ Returns the allowed HTTP verbs for this resource. ##### Example ``` -$ curl -i -X OPTIONS 'http://127.0.0.1:9500/docs/test/' +$ curl -i -X OPTIONS 'http://127.0.0.1:9500/assets/test/' HTTP/1.1 200 OK Content-Length: 0 Access-Control-Allow-Methods: GET,OPTIONS

@@ -70,23 +70,22 @@

#### GET assets/:folder/ -Retrieves a list of documents in JSON format starting with the specified folder path (it must end with '/'). - +Retrieves the file `assets/:folder/index.html` or `assets/:folder/index.htm` if not found. #### GET assets/:id -Retrieves the specified document. By default the response is returned in the document's content type; however, it is possible to retrieve the raw document (including metadata) in JSON format by setting the **raw** query string option to true. +Retrieves the specified document. The response is returned in the document's content type (even for JSON files). -##### Example: original content type +##### Example ``` -$ curl -i 'http://127.0.0.1:9500/docs/test' +$ curl -i 'http://127.0.0.1:9500/docs/test.txt' HTTP/1.1 200 OK Content-Length: 24 Content-Type: text/plain Access-Control-Allow-Headers: Content-Type Access-Control-Allow-Origin: * -Server: LiteStore/1.0.3 +Server: LiteStore/1.12.0 This is a test document. ```