diff --git a/LICENSE b/LICENSE new file mode 100755 index 0000000..58e0b64 --- /dev/null +++ b/LICENSE @@ -0,0 +1,28 @@ +Copyright (c) 2016, Alex A. Naanou +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of guaranteeEvents nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + diff --git a/bootstrap.js b/bootstrap.js index 0657d0f..678ceea 100755 --- a/bootstrap.js +++ b/bootstrap.js @@ -1,3 +1,3 @@ // This file is generated automatically, all changes made here will be lost. -var Bootstrap = {"Templates":{"text":"

\r\nXXX Genereal template description...\r\n

\r\n\r\n\r\n\t
\r\n\t

\r\n\t\t@source(./path)\r\n\t

\r\n\t

\r\n\t\t

@quote(./raw)
\r\n\t

\r\n
\r\n\r\n\r\n\r\n"},"Doc/Macros":{"text":"# ![pWiki](img/pWiki-i.jpg) pWiki Macros\r\n\r\n## Syntax\r\n\r\nAny macro can be used in any of the two forms, either _inline_ or _HTML-like_.\r\n\r\nInline:\r\n```\r\n@macro-name(value)\r\n```\r\n\r\nHTML-style:\r\n```\r\n\r\n\r\n\r\n ...text...\r\n\r\n```\r\n\r\nThe two forms are almost identical, with the only difference being that the \r\ninline form does not support body text (note that some macros may provide\r\nthis functionality as an argument, namely `slot`).\r\n\r\nThe two forms exist to fill two distinct functions:\r\n- inline: compatible with attribute values and short\r\n- html-like: element-like, simpler when dealing with html\r\n\r\n\r\n\r\n### Escaping macros\r\n\r\nMacros can be escaped for inclusion in the page, the two types of macros \r\nare escaped a bit differently:\r\n\r\n- inline macros -- escaped by preceding with a `\\`\r\n\r\n ```\r\n \\\\@include(SomePage)\r\n ```\r\n\r\n Displayed in page as:\r\n\r\n \\@include(SomePage)\r\n\r\n _NOTE: if displayed on github, this will show an extra \"\\\" in both \r\n cases, this should be ignored as pWiki will consume the escaping \"\\\" \r\n in both the code example and the preview._\r\n\r\n\r\n- html-like macros -- escaped _the HTML way_\r\n\r\n ```\r\n <include src=\"SomePage\"\\>\r\n ```\r\n\r\n Displayed in page as:\r\n\r\n <include src=\"SomePage\"\\\\>\r\n\r\n\r\n\r\n\r\n## Macros\r\n\r\n### now ()\r\n\r\nGet current date in seconds since epoch, this is equivalet Javascript's\r\n`Date.now()`.\r\n\r\nThis is mostly used for automatically creating paths (see: todo / outline)\r\n\r\nThis is different from `$NOW` in path (see: Doc/Path) in that this gets \r\nthe date once per page load, i.e. the date changes on page load, while \r\n`$NOW` is set every time the path is used, i.e. on every click or script\r\nuse.\r\n\r\n**Example:**\r\n```\r\n\\@now()\r\n```\r\nWill produce: `@now()` \r\n\r\n_NOTE: when viewing from outside of pWiki, this should look like: `1471389217848`_\r\n\r\n\r\n\r\n### filter (name)\r\n\r\nEnable or disable a page filter.\r\n\r\nA filter is a way to transform the page source.\r\n\r\nArguments:\r\n- `name` -- filter name. If name is preceded with a '-' then it \r\nwill be forced off. This is useful for disabling _default_ filters, or \r\nfilters added previously in templates.\r\n\r\nFilters:\r\n- wikiword (default)\r\n- markdown\r\n\r\n**Example:**\r\n- `[./_edit]` -- _see the macro at the end of the page._\r\n\r\n\r\n\r\n### include (src isolated text)\r\n\r\nInclude a page. The included page is rendered independently from current\r\npage and is inserted as-is in macro body.\r\n\r\nNote that this will produce a `include` tag in the code that contains \r\nthe included page, this makes this tag not suitable for use anywhere \r\nbut an html element body.\r\n\r\nArguments:\r\n- `src` -- path to source page.\r\n- `isolated` -- prevent slots from included page from affecting the including page. \r\n- `text` -- is used when recursive include is detected and ignored otherwise.\r\n\r\n_For examples see `slot` macro exaples below._\r\n\r\n\r\n\r\n### source (src) / quote (src)\r\n\r\nInsert a page without rendering. This is similar to include but will not\r\nrender the page. \r\n\r\nThe difference between `source` and `quote` is:\r\n- _source_ includes the page as-is\r\n- _quotes_ escapes the page (i.e. _quotes_ it's source) for its code to \r\n display in the rendered HTML correctly.\r\n\r\nArguments:\r\n- `src` -- path to source page.\r\n\r\n**Example:**\r\n\r\n[Templates/\\_css] / [bootstrap css](bootstrap/Templates/_css.html):\r\n```\r\n@source(Templates/_css)\r\n```\r\n\r\n\r\n### slot (name text)\r\n\r\nDefine or fill a slot.\r\n\r\nFirst occurrence of a `name` will _define_ a slot and fill it with `text`.\r\nEach new occurrence of a name will change slot content.\r\n\r\n**Example:**\r\n\r\n[Templates/\\_view] / [bootstrap view](bootstrap/Templates/_view.html):\r\n```\r\n@source(Templates/_view)\r\n```\r\n\r\n[Templates/\\_edit] / [bootstrap edit](bootstrap/Templates/_edit.html):\r\n```\r\n@source(Templates/_edit)\r\n```\r\n\r\n\r\n### macro (name src sort) / else ()\r\n\r\nApply macro to source page and include the result.\r\n\r\nThis is similar to include but does not require a separate page.\r\n\r\nBoth `name` and `src` are optional.\r\n\r\nIf `name` is given a _named macro_ is defined. This macro can be later \r\nreferenced (used) by name. A named macro can be redefined/overridden.\r\n\r\nIf `src` is given a macro is applied to a specific page or range of pages\r\n(see: WikiPath).\r\n\r\nFor a macro to be useful it must have a body (`text`), either defined as\r\na named macro or in the current macro.\r\n\r\nArguments:\r\n- `name` -- macro name (optional).\r\n- `src` -- path to source page (optional).\r\n- `sort` -- space separated list of methods to use for item sorting\r\n\r\n\r\n`else` macro is applicable inside `macro`. it is used when the `src` path\r\nof `macro` matches no pages.\r\n\r\n**Example:**\r\n\r\n[Templates/pages] / [bootstrap pages](bootstrap/Templates/pages.html):\r\n```\r\n@source(Templates/pages)\r\n```\r\n\r\n\r\n\r\n\r\n"},"Doc/Path":{"text":"# ![pWiki](img/pWiki-i.jpg) pWiki Path\r\n\r\nXXX a Wiki is a set of pages, mostly top level pages, mosty titled in\r\nWikiWord style, pWiki follows this culture but does not restrict either \r\npage nesting or title formatting. But following this style is recommended.\r\n\r\nXXX write a set of recommendations...\r\n\r\n\r\n\r\n## Basic terminology\r\n\r\n**Path** \r\n_One or more strings (or parts) separated by \"/\" that identifies a view._\r\n\r\nWe call the last _part_ in a path sequence a _title_.\r\n\r\nWe call the sub-path without the _title_ a _basedir_ or simply _dir_.\r\n\r\nIn pWiki, there is no distinction between a page and a _directory_, thus\r\nwe do not use the later term, instead, we may use the term _sub-page_.\r\n\r\nPaths are case sensitive.\r\n\r\n\r\n**Page** \r\n_A set of data associated with a path._\r\n\r\nA page is identified by it's path, but this does not require every\r\nsub-path of that path to exist -- the full path is the identifier, not\r\na sequence of path parts.\r\n\r\nSome pages are _bootstrapped_, i.e. are predefined in pWiki, these pages\r\ncan be overridden but can not be removed.\r\n\r\n\r\n**View** \r\n_A path that resolves to a page that may or may not be at that specific\r\npath._\r\n\r\nA _view's_ path may match that of a specific page or may not match any\r\npage directly, but any view will resolve to a page via the _acquisition \r\nprocess_\r\n\r\nAny page is a view, every view resolves to a page, but not every view \r\nis a page.\r\n\r\n(see: _Page acquisiton_ below)\r\n\r\n\r\n**WikiWord** \r\n_XXX_\r\n\r\n\r\n## Page acquisition\r\n\r\npWiki path system differs from how traditional file system paths are \r\nhandled. In pWiki if a path does not reference a page directly (i.e. \r\nit's a _view_), a search is conducted to find an alternative page. This \r\nsearch is called _page acquisition_.\r\n\r\n**Acquisition process:** \r\n_A set of rules defining how a page is retrieved via a path._\r\n\r\n\r\nThis is used as a simple and uniform mechanism to:\r\n- Get default pages for specific situations \r\n Like [Templates/EmptyPage] to handle the _page not found_ condition.\r\n- define generic templates/pages accessible by multiple pages in path \r\n A good example would be the viewer used to show this page [Templates/\\_view]\r\n and all of it's _chrome_ like the path above and links in the footer \r\n (when viewing through pWiki)\r\n- Overload default templates/pages\r\n\r\n\r\n### The acquisition order/rules:\r\n\r\n1. if _path_ matches a specific page, target _page_ is found \r\n1. if _path_ does not match a page:\r\n 1. if _title_ matches a page in the parent _path_, _page_ is found\r\n 1. repeat until we either have a match or reach root (empty _basedir_)\r\n1. if no match is found, check if title exists in [Templates] in _basedir_\r\n1. if no match is found, check if title exists in [/System]\r\n1. if no match is found, repeat process for `EmptyPage` instead of _title_\r\n\r\n\r\n**Example:** \r\n\r\nFor path `Path/To/Page` the following paths are checked in order \r\nand the first matching page is returned:\r\n\r\n- _Check path as-is then go up:_\r\n - `Path/To/Page` \r\n - `Path/Page`\r\n - `Page`\r\n- _Check in `Templates`, in path and up:_\r\n - `Path/To/Templates/Page`\r\n - `Path/Templates/Page`\r\n - `Templates/Page`\r\n- _Check root `System`:_\r\n - `System/Page`\r\n- _Check `EmptyPage` in path, then in templates:_\r\n - `Path/To/EmptyPage`\r\n - `Path/EmptyPage`\r\n - `EmptyPage`\r\n - `Path/To/Templates/EmptyPage`\r\n - `Path/Templates/EmptyPage`\r\n - `Templates/EmptyPage` _(This is guaranteed to exist)_\r\n\r\n\r\n**Exceptions:**\r\n\r\n- `System/settings` is global and _can not be overloaded_ for use as \r\nsystem configuration. This is done for security reasons.\r\n\r\n\r\n\r\n## Default pages\r\n\r\nXXX\r\n\r\n- `Templates/EmptyPage`\r\n- `Templates/EmptyToDo`\r\n- `Templates/EmptyOutline`\r\n\r\n\r\n\r\n## Relative and absolute paths (\".\", \"..\" and \"/\")\r\n\r\nXXX\r\n\r\n\r\n\r\n## Path patterns (\"\\*\" and \"\\*\\*\")\r\n\r\nXXX\r\n\r\n\r\n\r\n## Path actions\r\n\r\nXXX path elements that perform actions on pages but do not actually \r\ncorrespond to actual pages.\r\n\r\n\r\n\r\n## Path variables\r\n\r\n### `$NOW`\r\n\r\nXXX\r\n\r\n_Also see the `\\@now()` macro: [Doc/Macros]._\r\n\r\n\r\n\r\n## WikiWord\r\n\r\nXXX not actualy part of the path spec but a way (culture) to define paths \r\nin pages + automatic link creation.\r\n\r\n\r\n\r\n\r\n"},"Doc/Templates":{"text":"XXX Document the template structure here XXX\r\n"},"System/style":{"text":"body {\r\n\tfont-family: /*worksans,*/ opensans, sans-serif;\r\n\r\n}\r\n\r\n.title img {\r\n\tvertical-align: middle;\r\n}\r\n\r\nh1, h2, h3 {\r\n\tborder-bottom: solid 1px rgba(0, 0, 0, 0.1);\r\n\tpadding-bottom: 5px;\r\n}\r\nh2, h3 {\r\n\tborder-bottom: solid 1px rgba(0, 0, 0, 0.05);\r\n}\r\n\r\n.raw,\r\n.text {\r\n\tdisplay: block;\r\n}\r\n\r\n.item.checked {\r\n\topacity: 0.3;\r\n}\r\n.item.checked:hover {\r\n\topacity: 0.8;\r\n}\r\n.item.checked .item-content * {\r\n\ttext-decoration: line-through;\r\n}\r\n\r\n.button {\r\n\ttext-decoration: none;\r\n}\r\n.button:last-child {\r\n\tmargin-right: 5px;\r\n}\r\n\r\n.separator~* {\r\n\tfloat: right;\r\n}\r\n\r\npre {\r\n\tdisplay: block;\r\n\tbackground-color: rgba(0, 0, 0, 0.05);\r\n\tpadding: 10px;\r\n\tpadding-bottom: 15px;\r\n\r\n\t-moz-tab-size: 4;\r\n\t-o-tab-size: 4;\r\n\ttab-size: 4;\r\n}\r\n\r\n.item:hover {\r\n\tbackground-color: rgba(0, 0, 0, 0.05);\r\n}\r\n.item .button {\r\n\tdisplay: none;\r\n}\r\n.item:hover .button {\r\n\tdisplay: inline-block;\r\n}\r\n\r\n.sort-handle {\r\n\topacity: 0.1;\r\n\tpadding-left: 5px;\r\n\tpadding-right: 5px;\r\n\tcursor: pointer;\r\n\ttext-decoration: none;\r\n}\r\n.item:hover .sort-handle {\r\n\topacity: 0.3;\r\n}\r\n.sort-placeholder {\r\n\tdisplay: block;\r\n}\r\n\r\n/* vim:set ts=4 sw=4 ft=css : */\r\n"},"Templates/all_pages":{"text":"\r\n\t
\r\n\t\t[@source(./path)]\r\n\t\t\r\n\t\t×\r\n\t
\r\n\t\r\n\t\tNo pages...\r\n\t\r\n
\r\n\r\n\r\n"},"Templates/EmptyOutline":{"text":"@include(./outline)\r\n"},"Templates/EmptyPage":{"text":"\r\n\r\nPage @include(./path) is empty.

\r\n\r\nLinks to this page:
\r\n@include(./links)

\r\n\r\n\r\n"},"Templates/EmptyToDo":{"text":"@include(./todo)\r\n"},"Templates/outline":{"text":"\r\n\r\n\r\n\t\r\n\r\n\r\n\r\n\t×\r\n\r\n\r\n\r\n
\r\n\t\r\n\t\t+\r\n\t\r\n
\r\n
\r\n\t\r\n\t\t
\r\n\t\t\t
\r\n\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t
\r\n\t\t\t
\r\n\t\t\t\t\r\n\t\t\t
\r\n\t\t
\r\n\t
\r\n
\r\n\r\n\r\n"},"Templates/pages":{"text":"\r\n\t
\r\n\t\t[@source(./path)]\r\n\t\t\r\n\t\t×\r\n\t
\r\n\t\r\n\t\tNo pages...\r\n\t\r\n
\r\n\r\n\r\n"},"Templates/todo":{"text":"\r\n\t\r\n\r\n\r\n\r\n\r\n\r\n"},"Templates/tree":{"text":"
\r\n\t\r\n\t\t
\r\n\t\t\t \r\n\t\t\t@source(./title)\r\n\t\t\t\r\n\t\t\t×\r\n\t\t
\r\n\t\t
\r\n\t\t\t\r\n\t\t
\r\n\t
\r\n
\r\n\r\n\r\n"},"Templates/_css":{"text":"\r\n"},"Templates/_edit":{"text":"\r\n\r\n(view)\r\n\r\n@source(../title)\r\n\r\n\r\n\t
\r\n
\r\n\r\n\r\n\r\n"},"Templates/_outline":{"text":"\r\n\r\n@source(../title)\r\n\r\n\r\n\t@include(../outline)\r\n\r\n\r\n\r\n"},"Templates/_todo":{"text":"\r\n\r\n@source(../title)\r\n\r\n\r\n\t@include(../todo)\r\n\r\n\r\n\r\n"},"Templates/_view":{"text":"\r\n@include(style/_css)\r\n\r\n
\r\n\t \r\n\r\n\t[@source(../path)]\r\n\r\n\t (edit) \r\n\r\n\t\r\n\r\n\t+\r\n
\r\n\r\n
\r\n\t

\r\n\t\t@source(../title)\r\n\t

\r\n
\r\n\r\n\r\n\t\r\n\r\n\r\n
\r\nhome\r\n\r\n\r\n"},"Doc/About":{"text":"# ![pWiki](img/pWiki-i.jpg) Portable Wiki (pWiki)\n\n_NOTE: the project is currently in prototype phase, thus while most things \nare likely to change, the implementation / API **will definitely** change! ;)_\n\n\n### Project goals / main features:\n\n- _Simple embeddable Wiki_\n\n To be used as a zero-workflow app documentation platform, i.e. \n documentation that can be created, edited, tweaked and updated in-app \n without requiring setting up and maintaining a write-convert-embed \n workflow.\n\n This was a requirement on the _ImageGrid.Viewer_ project and as a \n side-effect pWiki hosts it's own documentation too.\n\n- _Pluggable storage and synchronization_ mechanisms\n\n A set of tools and API's to enable data synchronization between pWiki\n instances.\n\n- _Self-hosted_ and flexible user interface\n\n The pWiki interface is implemented as a set of pWiki pages and \n templates within pWiki itself (see: [Templates] / [/bootstrap](bootstrap)), \n this enables the user to customize the look feel and to some extent \n the function of the interface from within pWiki, without touching the \n code.\n\n- pWiki _portable app_\n\n This is a simple note / todo / outline app.\n\n The pWiki app is a stand-alone instance of pWiki wrapped in an app \n supporting all major desktop as well as mobile platforms.\n\n The app serves the following goals:\n\n - a simple and functional note / todo / outline app (_obviously_)\n - an external/portable Wiki editor, as an alternative for \n in-target-app documentation editor with ability to seamlesly \n synchronize with the target app pWiki instance.\n - a stand-alone testing platform and reference implementation for \n pWiki components.\n\n\n### General Documentation:\n- [Doc/About] / [general info](README.md) -- This document.\n- [Doc/Path] / [bootstrap path](bootstrap/Doc/Path.md) -- Path mechanics.\n- [Doc/Macros] / [bootstrap macros](bootstrap/Doc/Macros.md) -- Macro documentation\n\n\n\n\n"},"WikiHome":{"text":"@include(Doc/About)"}} \ No newline at end of file +var Bootstrap = {"Templates":{"text":"

\r\nXXX Genereal template description...\r\n

\r\n\r\n\r\n\t
\r\n\t

\r\n\t\t@source(./path)\r\n\t

\r\n\t

\r\n\t\t

@quote(./raw)
\r\n\t

\r\n
\r\n\r\n\r\n\r\n"},"Doc/Macros":{"text":"# ![pWiki](img/pWiki-i.jpg) pWiki Macros\r\n\r\n## Syntax\r\n\r\nAny macro can be used in any of the two forms, either _inline_ or _HTML-like_.\r\n\r\nInline:\r\n```\r\n@macro-name(value)\r\n```\r\n\r\nHTML-style:\r\n```\r\n\r\n\r\n\r\n ...text...\r\n\r\n```\r\n\r\nThe two forms are almost identical, with the only difference being that the \r\ninline form does not support body text (note that some macros may provide\r\nthis functionality as an argument, namely `slot`).\r\n\r\nThe two forms exist to fill two distinct functions:\r\n- inline: compatible with attribute values and short\r\n- html-like: element-like, simpler when dealing with html\r\n\r\n\r\n\r\n### Escaping macros\r\n\r\nMacros can be escaped for inclusion in the page, the two types of macros \r\nare escaped a bit differently:\r\n\r\n- inline macros -- escaped by preceding with a `\\`\r\n\r\n ```\r\n \\\\@include(SomePage)\r\n ```\r\n\r\n Displayed in page as:\r\n\r\n \\@include(SomePage)\r\n\r\n _NOTE: if displayed on github, this will show an extra \"\\\" in both \r\n cases, this should be ignored as pWiki will consume the escaping \"\\\" \r\n in both the code example and the preview._\r\n\r\n\r\n- html-like macros -- escaped _the HTML way_\r\n\r\n ```\r\n <include src=\"SomePage\"\\>\r\n ```\r\n\r\n Displayed in page as:\r\n\r\n <include src=\"SomePage\"\\\\>\r\n\r\n\r\n\r\n\r\n## Macros\r\n\r\n### now ()\r\n\r\nGet current date in seconds since epoch, this is equivalet Javascript's\r\n`Date.now()`.\r\n\r\nThis is mostly used for automatically creating paths (see: todo / outline)\r\n\r\nThis is different from `$NOW` in path (see: Doc/Path) in that this gets \r\nthe date once per page load, i.e. the date changes on page load, while \r\n`$NOW` is set every time the path is used, i.e. on every click or script\r\nuse.\r\n\r\n**Example:**\r\n```\r\n\\@now()\r\n```\r\nWill produce: `@now()` \r\n\r\n_NOTE: when viewing from outside of pWiki, this should look like: `1471389217848`_\r\n\r\n\r\n\r\n### filter (name)\r\n\r\nEnable or disable a page filter.\r\n\r\nA filter is a way to transform the page source.\r\n\r\nArguments:\r\n- `name` -- filter name. If name is preceded with a '-' then it \r\nwill be forced off. This is useful for disabling _default_ filters, or \r\nfilters added previously in templates.\r\n\r\nFilters:\r\n- wikiword (default)\r\n- markdown\r\n\r\n**Example:**\r\n- `[./_edit]` -- _see the macro at the end of the page._\r\n\r\n\r\n\r\n### include (src isolated text)\r\n\r\nInclude a page. The included page is rendered independently from current\r\npage and is inserted as-is in macro body.\r\n\r\nNote that this will produce a `include` tag in the code that contains \r\nthe included page, this makes this tag not suitable for use anywhere \r\nbut an html element body.\r\n\r\nArguments:\r\n- `src` -- path to source page.\r\n- `isolated` -- prevent slots from included page from affecting the including page. \r\n- `text` -- is used when recursive include is detected and ignored otherwise.\r\n\r\n_For examples see `slot` macro exaples below._\r\n\r\n\r\n\r\n### source (src) / quote (src)\r\n\r\nInsert a page without rendering. This is similar to include but will not\r\nrender the page. \r\n\r\nThe difference between `source` and `quote` is:\r\n- _source_ includes the page as-is\r\n- _quotes_ escapes the page (i.e. _quotes_ it's source) for its code to \r\n display in the rendered HTML correctly.\r\n\r\nArguments:\r\n- `src` -- path to source page.\r\n\r\n**Example:**\r\n\r\n[Templates/\\_css] / [bootstrap css](bootstrap/Templates/_css.html):\r\n```\r\n@source(Templates/_css)\r\n```\r\n\r\n\r\n### slot (name text)\r\n\r\nDefine or fill a slot.\r\n\r\nFirst occurrence of a `name` will _define_ a slot and fill it with `text`.\r\nEach new occurrence of a name will change slot content.\r\n\r\n**Example:**\r\n\r\n[Templates/\\_view] / [bootstrap view](bootstrap/Templates/_view.html):\r\n```\r\n@source(Templates/_view)\r\n```\r\n\r\n[Templates/\\_edit] / [bootstrap edit](bootstrap/Templates/_edit.html):\r\n```\r\n@source(Templates/_edit)\r\n```\r\n\r\n\r\n### macro (name src sort) / else ()\r\n\r\nApply macro to source page and include the result.\r\n\r\nThis is similar to include but does not require a separate page.\r\n\r\nBoth `name` and `src` are optional.\r\n\r\nIf `name` is given a _named macro_ is defined. This macro can be later \r\nreferenced (used) by name. A named macro can be redefined/overridden.\r\n\r\nIf `src` is given a macro is applied to a specific page or range of pages\r\n(see: WikiPath).\r\n\r\nFor a macro to be useful it must have a body (`text`), either defined as\r\na named macro or in the current macro.\r\n\r\nArguments:\r\n- `name` -- macro name (optional).\r\n- `src` -- path to source page (optional).\r\n- `sort` -- space separated list of methods to use for item sorting\r\n\r\n\r\n`else` macro is applicable inside `macro`. it is used when the `src` path\r\nof `macro` matches no pages.\r\n\r\n**Example:**\r\n\r\n[Templates/pages] / [bootstrap pages](bootstrap/Templates/pages.html):\r\n```\r\n@source(Templates/pages)\r\n```\r\n\r\n\r\n\r\n\r\n"},"Doc/Path":{"text":"# ![pWiki](img/pWiki-i.jpg) pWiki Path\r\n\r\nXXX a Wiki is a set of pages, mostly top level pages, mosty titled in\r\nWikiWord style, pWiki follows this culture but does not restrict either \r\npage nesting or title formatting. But following this style is recommended.\r\n\r\nXXX write a set of recommendations...\r\n\r\n\r\n\r\n## Basic terminology\r\n\r\n**Path** \r\n_One or more strings (or parts) separated by \"/\" that identifies a view._\r\n\r\nWe call the last _part_ in a path sequence a _title_.\r\n\r\nWe call the sub-path without the _title_ a _basedir_ or simply _dir_.\r\n\r\nIn pWiki, there is no distinction between a page and a _directory_, thus\r\nwe do not use the later term, instead, we may use the term _sub-page_.\r\n\r\nPaths are case sensitive.\r\n\r\n\r\n**Page** \r\n_A set of data associated with a path._\r\n\r\nA page is identified by it's path, but this does not require every\r\nsub-path of that path to exist -- the full path is the identifier, not\r\na sequence of path parts.\r\n\r\nSome pages are _bootstrapped_, i.e. are predefined in pWiki, these pages\r\ncan be overridden but can not be removed.\r\n\r\n\r\n**View** \r\n_A path that resolves to a page that may or may not be at that specific\r\npath._\r\n\r\nA _view's_ path may match that of a specific page or may not match any\r\npage directly, but any view will resolve to a page via the _acquisition \r\nprocess_\r\n\r\nAny page is a view, every view resolves to a page, but not every view \r\nis a page.\r\n\r\n(see: _Page acquisiton_ below)\r\n\r\n\r\n**WikiWord** \r\n_XXX_\r\n\r\n\r\n## Page acquisition\r\n\r\npWiki path system differs from how traditional file system paths are \r\nhandled. In pWiki if a path does not reference a page directly (i.e. \r\nit's a _view_), a search is conducted to find an alternative page. This \r\nsearch is called _page acquisition_.\r\n\r\n**Acquisition process:** \r\n_A set of rules defining how a page is retrieved via a path._\r\n\r\n\r\nThis is used as a simple and uniform mechanism to:\r\n- Get default pages for specific situations \r\n Like [Templates/EmptyPage] to handle the _page not found_ condition.\r\n- define generic templates/pages accessible by multiple pages in path \r\n A good example would be the viewer used to show this page [Templates/\\_view]\r\n and all of it's _chrome_ like the path in the header and links in the \r\n footer (seen: when viewing through pWiki)\r\n- Overload default templates/pages\r\n\r\n\r\n### The acquisition order/rules:\r\n\r\n1. if _path_ matches a specific page, target _page_ is found \r\n1. if _path_ does not match a page:\r\n 1. if _title_ matches a page in the parent _path_, _page_ is found\r\n 1. repeat until we either have a match or reach root (empty _basedir_)\r\n1. if no match is found, check if title exists in [Templates] in _basedir_\r\n1. if no match is found, check if title exists in [/System]\r\n1. if no match is found, repeat process for `EmptyPage` instead of _title_\r\n\r\n\r\n**Example:** \r\n\r\nFor path `Path/To/Page` the following paths are checked in order \r\nand the first matching page is returned:\r\n\r\n- _Check path as-is then go up:_\r\n - `Path/To/Page` \r\n - `Path/Page`\r\n - `Page`\r\n- _Check in `Templates`, in path and up:_\r\n - `Path/To/Templates/Page`\r\n - `Path/Templates/Page`\r\n - `Templates/Page`\r\n- _Check root `System`:_\r\n - `System/Page`\r\n- _Check `EmptyPage` in path, then in templates:_\r\n - `Path/To/EmptyPage`\r\n - `Path/EmptyPage`\r\n - `EmptyPage`\r\n - `Path/To/Templates/EmptyPage`\r\n - `Path/Templates/EmptyPage`\r\n - `Templates/EmptyPage` _(This is guaranteed to exist)_\r\n\r\n\r\n**Exceptions:**\r\n\r\n- `System/settings` is global and _can not be overloaded_ for use as \r\nsystem configuration. This is done for security reasons.\r\n\r\n\r\n\r\n## Default pages\r\n\r\nXXX\r\n\r\n- `Templates/EmptyPage`\r\n- `Templates/EmptyToDo`\r\n- `Templates/EmptyOutline`\r\n\r\n\r\n\r\n## Relative and absolute paths (\".\", \"..\" and \"/\")\r\n\r\nXXX\r\n\r\n\r\n\r\n## Path patterns (\"\\*\" and \"\\*\\*\")\r\n\r\nXXX\r\n\r\n\r\n\r\n## Path actions\r\n\r\nXXX path elements that perform actions on pages but do not actually \r\ncorrespond to actual pages.\r\n\r\n\r\n\r\n## Path variables\r\n\r\n### `$NOW`\r\n\r\nXXX\r\n\r\n_Also see the `\\@now()` macro: [Doc/Macros]._\r\n\r\n\r\n\r\n## WikiWord\r\n\r\nXXX not actualy part of the path spec but a way (culture) to define paths \r\nin pages + automatic link creation.\r\n\r\n\r\n\r\n\r\n"},"Doc/Templates":{"text":"XXX Document the template structure here XXX\r\n"},"System/style":{"text":"body {\r\n\tfont-family: /*worksans,*/ opensans, sans-serif;\r\n\r\n}\r\n\r\n.title img {\r\n\tvertical-align: middle;\r\n}\r\n\r\nh1, h2, h3 {\r\n\tborder-bottom: solid 1px rgba(0, 0, 0, 0.1);\r\n\tpadding-bottom: 5px;\r\n}\r\nh2, h3 {\r\n\tborder-bottom: solid 1px rgba(0, 0, 0, 0.05);\r\n}\r\n\r\n.raw,\r\n.text {\r\n\tdisplay: block;\r\n}\r\n\r\n.item.checked {\r\n\topacity: 0.3;\r\n}\r\n.item.checked:hover {\r\n\topacity: 0.8;\r\n}\r\n.item.checked .item-content * {\r\n\ttext-decoration: line-through;\r\n}\r\n\r\n.button {\r\n\ttext-decoration: none;\r\n}\r\n.button:last-child {\r\n\tmargin-right: 5px;\r\n}\r\n\r\n.separator~* {\r\n\tfloat: right;\r\n}\r\n\r\npre {\r\n\tdisplay: block;\r\n\tbackground-color: rgba(0, 0, 0, 0.05);\r\n\tpadding: 10px;\r\n\tpadding-bottom: 15px;\r\n\r\n\t-moz-tab-size: 4;\r\n\t-o-tab-size: 4;\r\n\ttab-size: 4;\r\n}\r\n\r\n.item:hover {\r\n\tbackground-color: rgba(0, 0, 0, 0.05);\r\n}\r\n.item .button {\r\n\tdisplay: none;\r\n}\r\n.item:hover .button {\r\n\tdisplay: inline-block;\r\n}\r\n\r\n.sort-handle {\r\n\topacity: 0.1;\r\n\tpadding-left: 5px;\r\n\tpadding-right: 5px;\r\n\tcursor: pointer;\r\n\ttext-decoration: none;\r\n}\r\n.item:hover .sort-handle {\r\n\topacity: 0.3;\r\n}\r\n.sort-placeholder {\r\n\tdisplay: block;\r\n}\r\n\r\n/* vim:set ts=4 sw=4 ft=css : */\r\n"},"Templates/all_pages":{"text":"\r\n\t
\r\n\t\t[@source(./path)]\r\n\t\t\r\n\t\t×\r\n\t
\r\n\t\r\n\t\tNo pages...\r\n\t\r\n
\r\n\r\n\r\n"},"Templates/EmptyOutline":{"text":"@include(./outline)\r\n"},"Templates/EmptyPage":{"text":"\r\n\r\nPage @include(./path) is empty.

\r\n\r\nLinks to this page:
\r\n@include(./links)

\r\n\r\n\r\n"},"Templates/EmptyToDo":{"text":"@include(./todo)\r\n"},"Templates/macros":{"text":"\r\n\t×\r\n\r\n\r\n\r\n\r\n"},"Templates/outline":{"text":"\r\n\r\n\r\n\t\r\n\r\n\r\n\r\n\t×\r\n\r\n\r\n\r\n
\r\n\t\r\n\t\t+\r\n\t\r\n
\r\n
\r\n\t\r\n\t\t
\r\n\t\t\t
\r\n\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t
\r\n\t\t\t
\r\n\t\t\t\t\r\n\t\t\t
\r\n\t\t
\r\n\t
\r\n
\r\n\r\n\r\n"},"Templates/pages":{"text":"\r\n\t
\r\n\t\t[@source(./path)]\r\n\t\t\r\n\t\t×\r\n\t
\r\n\t\r\n\t\tNo pages...\r\n\t\r\n
\r\n\r\n\r\n"},"Templates/todo":{"text":"\r\n\t\r\n\r\n\r\n\r\n\r\n\r\n"},"Templates/tree":{"text":"
\r\n\t\r\n\t\t
\r\n\t\t\t \r\n\t\t\t@source(./title)\r\n\t\t\t\r\n\t\t\t×\r\n\t\t
\r\n\t\t
\r\n\t\t\t\r\n\t\t
\r\n\t
\r\n
\r\n\r\n\r\n"},"Templates/_css":{"text":"\r\n"},"Templates/_edit":{"text":"\r\n\r\n(view)\r\n\r\n@source(../title)\r\n\r\n\r\n\t
\r\n
\r\n\r\n\r\n\r\n"},"Templates/_outline":{"text":"\r\n\r\n@source(../title)\r\n\r\n\r\n\t@include(../outline)\r\n\r\n\r\n\r\n"},"Templates/_todo":{"text":"\r\n\r\n@source(../title)\r\n\r\n\r\n\t@include(../todo)\r\n\r\n\r\n\r\n"},"Templates/_view":{"text":"\r\n@include(style/_css)\r\n\r\n
\r\n\t \r\n\r\n\t[@source(../path)]\r\n\r\n\t (edit) \r\n\r\n\t\r\n\r\n\t+\r\n
\r\n\r\n
\r\n\t

\r\n\t\t@source(../title)\r\n\t

\r\n
\r\n\r\n\r\n\t\r\n\r\n\r\n
\r\nhome\r\n\r\n\r\n"},"Doc/About":{"text":"# ![pWiki](img/pWiki-i.jpg) Portable Wiki (pWiki)\n\n_NOTE: the project is currently in prototype phase, thus while most things \nare likely to change, the implementation / API **will definitely** change! ;)_\n\n\n### Project goals / main features:\n\n- _Simple embeddable Wiki_\n\n To be used as a zero-workflow app documentation platform, i.e. \n documentation that can be created, edited, tweaked and updated in-app \n without requiring setting up and maintaining a write-convert-embed \n workflow.\n\n This was a requirement on the _ImageGrid.Viewer_ project and as a \n side-effect pWiki hosts it's own documentation too.\n\n- _Pluggable storage and synchronization_ mechanisms\n\n A set of tools and API's to enable data synchronization between pWiki\n instances.\n\n- _Self-hosted_ and flexible user interface\n\n The pWiki interface is implemented as a set of pWiki pages and \n templates within pWiki itself (see: [Templates] / [/bootstrap](bootstrap)), \n this enables the user to customize the look feel and to some extent \n the function of the interface from within pWiki, without touching the \n code.\n\n- pWiki _portable app_\n\n This is a simple note / todo / outline app.\n\n The pWiki app is a stand-alone instance of pWiki wrapped in an app \n supporting all major desktop as well as mobile platforms.\n\n The app serves the following goals:\n\n - a simple and functional note / todo / outline app (_obviously_)\n - an external/portable Wiki editor, as an alternative for \n in-target-app documentation editor with ability to seamlesly \n synchronize with the target app pWiki instance.\n - a stand-alone testing platform and reference implementation for \n pWiki components.\n\n\n### General Documentation:\n- [Doc/About] / [general info](README.md) -- This document.\n- [Doc/Path] / [bootstrap path](bootstrap/Doc/Path.md) -- Path mechanics.\n- [Doc/Macros] / [bootstrap macros](bootstrap/Doc/Macros.md) -- Macro documentation\n\n\n\n\n"},"WikiHome":{"text":"@include(Doc/About)"}} \ No newline at end of file diff --git a/bootstrap/Doc/Path.md b/bootstrap/Doc/Path.md index a3bafca..35462db 100644 --- a/bootstrap/Doc/Path.md +++ b/bootstrap/Doc/Path.md @@ -68,8 +68,8 @@ This is used as a simple and uniform mechanism to: Like [Templates/EmptyPage] to handle the _page not found_ condition. - define generic templates/pages accessible by multiple pages in path A good example would be the viewer used to show this page [Templates/\_view] - and all of it's _chrome_ like the path above and links in the footer - (when viewing through pWiki) + and all of it's _chrome_ like the path in the header and links in the + footer (seen: when viewing through pWiki) - Overload default templates/pages diff --git a/bootstrap/Templates/outline.html b/bootstrap/Templates/outline.html index ffb702c..c0b0220 100644 --- a/bootstrap/Templates/outline.html +++ b/bootstrap/Templates/outline.html @@ -26,7 +26,7 @@
- +
diff --git a/wiki.js b/wiki.js index e85a2ce..0b2b876 100755 --- a/wiki.js +++ b/wiki.js @@ -123,6 +123,9 @@ var macro = { // XXX add support for sort and reverse attrs in all relavant macros // (see: macro for details) macro: { + "pwiki-comment": Macro('hide in pWiki', + [], + function(context, elem, state){ return '' }), now: Macro('Create a now id', [], function(context, elem, state){ return ''+Date.now() }), @@ -1509,23 +1512,31 @@ var Wiki = { __default_sort_methods__: ['path'], __sort_methods__: { title: function(a, b){ - return a.title < b.title ? -1 - : a.title > b.title ? 1 + return a.page.title < b.page.title ? -1 + : a.page.title > b.page.title ? 1 : 0 }, path: function(a, b){ - return a.path < b.path ? -1 - : a.path > b.path ? 1 + return a.page.path < b.page.path ? -1 + : a.page.path > b.page.path ? 1 : 0 }, // XXX checked: function(a, b){ // XXX chech if with similar states the order is kept.... - return a.checked == b.checked ? 0 - : a.checked ? 1 + return a.page.checked == b.page.checked ? 0 + : a.page.checked ? 1 : -1 }, // XXX date, ... + + // XXX use manual order and palce new items (not in order) at + // top/bottom (option)... + // XXX store the order in .__wiki_data + manual: function(a, b){ + // XXX + return 0 + }, }, // Sort siblings... @@ -1544,6 +1555,12 @@ var Wiki = { // NOTE: the next method is used iff the previous returns 0, // i.e. the items are equal. // + // To reverse a specific method, prepend it's name with "-", e.g. + // "title" will do the default ascending sort while "-title" will do + // a descending sort. + // This is different from the "reverse" method which will simply + // reverse the result. + // // NOTE: the sort is local to the returned object. // NOTE: the sorted object may loose sync form the actual wiki as the // list of siblings is cached. @@ -1591,13 +1608,22 @@ var Wiki = { var methods = (this.__order_by || this.__default_sort_methods__) .map(function(m){ + var reversed = m[0] == '-' + m = reversed ? m.slice(1) : m + if(m == 'reverse'){ reverse = !reverse return null } - return typeof(m) == typeof('str') ? that.__sort_methods__[m] + m = typeof(m) == typeof('str') ? that.__sort_methods__[m] : m instanceof Function ? m : null + + return m != null ? + (reversed ? + function(){ return -m.apply(this, arguments) } + : m) + : m }) .filter(function(m){ return !!m }) @@ -1612,13 +1638,17 @@ var Wiki = { return res } } - return 0 + // keep order if nothing else works... + return a.i - b.i } this.__order = this.__order - .map(function(t){ return that.get(t) }) + .map(function(t, i){ return { + i: i, + page: that.get(t), + } }) .sort(method) - .map(function(t){ return t.path }) + .map(function(t){ return t.page.path }) } reverse