mirror of
https://github.com/flynx/pWiki.git
synced 2025-12-17 08:31:38 +00:00
now html reserved chars can be used in paths...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
350c272437
commit
fd82fc26a6
@ -7,6 +7,12 @@
|
|||||||
(function(require){ var module={} // make module AMD/node compatible...
|
(function(require){ var module={} // make module AMD/node compatible...
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
var pwpath = require('../path')
|
||||||
|
|
||||||
|
|
||||||
|
/*********************************************************************/
|
||||||
|
|
||||||
var WIKIWORD_PATTERN =
|
var WIKIWORD_PATTERN =
|
||||||
RegExp('('+[
|
RegExp('('+[
|
||||||
// /some/path | ./some/path | ../some/path | >>/some/path
|
// /some/path | ./some/path | ../some/path | >>/some/path
|
||||||
@ -87,8 +93,8 @@ function(elem){
|
|||||||
|| text.parentNode.nodeName.toLowerCase() == 'script'
|
|| text.parentNode.nodeName.toLowerCase() == 'script'
|
||||||
|| (text.parentNode.getAttribute('wikiwords') ?? '').toLowerCase() == 'no'){
|
|| (text.parentNode.getAttribute('wikiwords') ?? '').toLowerCase() == 'no'){
|
||||||
return }
|
return }
|
||||||
var t = text.nodeValue
|
var t = pwpath.quoteHTML(text.nodeValue)
|
||||||
var n = setWikiWords(text.nodeValue)
|
var n = setWikiWords(t)
|
||||||
if(t != n){
|
if(t != n){
|
||||||
tmp.innerHTML = n
|
tmp.innerHTML = n
|
||||||
text.replaceWith(...tmp.childNodes) } }) }
|
text.replaceWith(...tmp.childNodes) } }) }
|
||||||
|
|||||||
@ -238,7 +238,6 @@ object.Constructor('BasePage', {
|
|||||||
to
|
to
|
||||||
: '../'+to) },
|
: '../'+to) },
|
||||||
|
|
||||||
// XXX TITLE / EXPERIMENTAL...
|
|
||||||
get title(){
|
get title(){
|
||||||
return pwpath.decodeElem(this.name) },
|
return pwpath.decodeElem(this.name) },
|
||||||
set title(value){
|
set title(value){
|
||||||
@ -1126,7 +1125,7 @@ object.Constructor('Page', BasePage, {
|
|||||||
// XXX need a way to escape macros -- i.e. include </quote> in a quoted text...
|
// XXX need a way to escape macros -- i.e. include </quote> in a quoted text...
|
||||||
quote: Macro(
|
quote: Macro(
|
||||||
['src', 'filter', 'text', 'join',
|
['src', 'filter', 'text', 'join',
|
||||||
['expandactions']],
|
['s', 'expandactions']],
|
||||||
async function*(args, body, state){
|
async function*(args, body, state){
|
||||||
var src = args.src //|| args[0]
|
var src = args.src //|| args[0]
|
||||||
var base = this.get(this.path.split(/\*/).shift())
|
var base = this.get(this.path.split(/\*/).shift())
|
||||||
@ -1145,6 +1144,8 @@ object.Constructor('Page', BasePage, {
|
|||||||
var expandactions =
|
var expandactions =
|
||||||
args.expandactions
|
args.expandactions
|
||||||
?? true
|
?? true
|
||||||
|
// XXX EXPERIMENTAL
|
||||||
|
var strquotes = args.s
|
||||||
|
|
||||||
var depends = state.depends =
|
var depends = state.depends =
|
||||||
state.depends
|
state.depends
|
||||||
@ -1180,6 +1181,11 @@ object.Constructor('Page', BasePage, {
|
|||||||
&& await page.type == 'action') ?
|
&& await page.type == 'action') ?
|
||||||
base.get(this.QUOTE_ACTION_PAGE).raw
|
base.get(this.QUOTE_ACTION_PAGE).raw
|
||||||
: await page.raw
|
: await page.raw
|
||||||
|
text = strquotes ?
|
||||||
|
text
|
||||||
|
.replace(/["']/g, function(c){
|
||||||
|
return '%'+ c.charCodeAt().toString(16) })
|
||||||
|
: text
|
||||||
|
|
||||||
page.path
|
page.path
|
||||||
&& depends.add(page.path)
|
&& depends.add(page.path)
|
||||||
@ -1665,12 +1671,25 @@ object.Constructor('Page', BasePage, {
|
|||||||
...module.BasePage.prototype.actions,
|
...module.BasePage.prototype.actions,
|
||||||
|
|
||||||
'!': true,
|
'!': true,
|
||||||
|
// XXX EXPERIMENTAL...
|
||||||
|
quote: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// XXX should this be .raw or .parse()???
|
||||||
'!': Object.assign(
|
'!': Object.assign(
|
||||||
function(){
|
function(){
|
||||||
return this.get('..:$ARGS', {energetic: true}).raw },
|
return this.get('..:$ARGS', {energetic: true}).raw },
|
||||||
{energetic: true}),
|
{energetic: true}),
|
||||||
|
// XXX EXPERIMENTAL...
|
||||||
|
// XXX this is html/web specific, should it be here???
|
||||||
|
// ...
|
||||||
|
// XXX should this be .raw or .parse()???
|
||||||
|
quote: function(){
|
||||||
|
return this.get('..:$ARGS').raw//parse()
|
||||||
|
.then(function(res){
|
||||||
|
return res instanceof Array ?
|
||||||
|
res.map(pwpath.quoteHTML)
|
||||||
|
: pwpath.quoteHTML(res) }) },
|
||||||
|
|
||||||
|
|
||||||
// events...
|
// events...
|
||||||
@ -1692,6 +1711,7 @@ object.Constructor('Page', BasePage, {
|
|||||||
// NOTE: .__debug_last_render_state is mainly exposed for introspection
|
// NOTE: .__debug_last_render_state is mainly exposed for introspection
|
||||||
// and debugging, set comment it out to disable...
|
// and debugging, set comment it out to disable...
|
||||||
//__debug_last_render_state: undefined,
|
//__debug_last_render_state: undefined,
|
||||||
|
// XXX should this handle pattern paths???
|
||||||
parse: async function(text, state){
|
parse: async function(text, state){
|
||||||
var that = this
|
var that = this
|
||||||
text = await text
|
text = await text
|
||||||
@ -2061,6 +2081,7 @@ object.Constructor('pWikiPageElement', Page, {
|
|||||||
hash: true,
|
hash: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
// NOTE: setting location will reset .hash set it directly via either
|
// NOTE: setting location will reset .hash set it directly via either
|
||||||
// one of:
|
// one of:
|
||||||
// .location = [path, hash]
|
// .location = [path, hash]
|
||||||
@ -2161,7 +2182,7 @@ module.System = {
|
|||||||
<a href="#/list">☰</a>
|
<a href="#/list">☰</a>
|
||||||
<a href="#<slot parent>../</slot>">⇑</a>
|
<a href="#<slot parent>../</slot>">⇑</a>
|
||||||
<!-- XXX make this editable... -->
|
<!-- XXX make this editable... -->
|
||||||
[<slot location>@source(./location/!)</slot>]
|
[<slot location>@source(./location/!/quote)</slot>]
|
||||||
<a href="javascript:refresh()">⟳</a>
|
<a href="javascript:refresh()">⟳</a>
|
||||||
<slot edit>
|
<slot edit>
|
||||||
<a href="#@source(s ./path/!)/edit">✎</a>
|
<a href="#@source(s ./path/!)/edit">✎</a>
|
||||||
@ -2175,7 +2196,7 @@ module.System = {
|
|||||||
<!-- NOTE: this is not included directly to enable client code to
|
<!-- NOTE: this is not included directly to enable client code to
|
||||||
set slots that are defined after the content... -->
|
set slots that are defined after the content... -->
|
||||||
<slot content>
|
<slot content>
|
||||||
<h1><slot title>@source(./title/!)</slot></h1>
|
<h1><slot title>@source(./title/!/quote)</slot></h1>
|
||||||
@include(.:$ARGS join="@source(file-separator)" recursive="")
|
@include(.:$ARGS join="@source(file-separator)" recursive="")
|
||||||
</slot>
|
</slot>
|
||||||
` },
|
` },
|
||||||
@ -2207,15 +2228,15 @@ module.System = {
|
|||||||
/*/
|
/*/
|
||||||
_edit: {
|
_edit: {
|
||||||
text:
|
text:
|
||||||
'@source(./path/!)'
|
'@source(./path/!/quote)'
|
||||||
+'<hr>'
|
+'<hr>'
|
||||||
+'<macro src="." join="@source(file-separator)">'
|
+'<macro src="." join="@source(file-separator)">'
|
||||||
+'<h1 '
|
+'<h1 '
|
||||||
+'wikiwords="no" '
|
+'wikiwords="no" '
|
||||||
+'contenteditable '
|
+'contenteditable '
|
||||||
// XXX need to make this savable...
|
// XXX need to make this savable...
|
||||||
+'oninput="saveLiveContent(\'@source(s ./path)/name\')">'
|
+'oninput="saveContent(\'@source(s ./path)/name\', this.innerText)">'
|
||||||
+'@source(./name)'
|
+'@source(./title/quote)'
|
||||||
+'</h1>'
|
+'</h1>'
|
||||||
+'<pre class="editor" '
|
+'<pre class="editor" '
|
||||||
+'wikiwords="no" '
|
+'wikiwords="no" '
|
||||||
@ -2233,7 +2254,7 @@ module.System = {
|
|||||||
wikiwords="no"
|
wikiwords="no"
|
||||||
contenteditable
|
contenteditable
|
||||||
oninput="saveContent(\'@source(s ./path)/title\', this.innerText)">
|
oninput="saveContent(\'@source(s ./path)/title\', this.innerText)">
|
||||||
@source(./title)
|
@source(./title/quote)
|
||||||
</span>
|
</span>
|
||||||
</h1>
|
</h1>
|
||||||
</macro>
|
</macro>
|
||||||
@ -2253,7 +2274,7 @@ module.System = {
|
|||||||
<title>@source(../title) (edit)</title>
|
<title>@source(../title) (edit)</title>
|
||||||
</slot>
|
</slot>
|
||||||
<slot parent>../..</slot>
|
<slot parent>../..</slot>
|
||||||
<slot location>@source(../location/!)</slot>
|
<slot location>@source(../location/!/quote)</slot>
|
||||||
<slot edit/>
|
<slot edit/>
|
||||||
<slot content>
|
<slot content>
|
||||||
<macro editor src=".."/>
|
<macro editor src=".."/>
|
||||||
@ -2326,7 +2347,7 @@ module.System = {
|
|||||||
</slot>
|
</slot>
|
||||||
<macro src="../*:$ARGS" join="@source(line-separator)">
|
<macro src="../*:$ARGS" join="@source(line-separator)">
|
||||||
@var(path "@source(s ./path)")
|
@var(path "@source(s ./path)")
|
||||||
<a href="#@var(path)">@source(./name)</a>
|
<a href="#@var(path)">@source(./name/quote)</a>
|
||||||
<sup>
|
<sup>
|
||||||
<macro src="./isAction">
|
<macro src="./isAction">
|
||||||
a
|
a
|
||||||
@ -2356,7 +2377,7 @@ module.System = {
|
|||||||
@var(path "@source(s ./path)")
|
@var(path "@source(s ./path)")
|
||||||
<div>
|
<div>
|
||||||
<div class="item">
|
<div class="item">
|
||||||
<a class="tree-page-title" href="#@var(path)">@source(./title)</a>
|
<a class="tree-page-title" href="#@var(path)">@source(./title/quote)</a>
|
||||||
<a class="show-on-hover" href="#@var(path)/info">🛈</a>
|
<a class="show-on-hover" href="#@var(path)/info">🛈</a>
|
||||||
<a class="show-on-hover"
|
<a class="show-on-hover"
|
||||||
href="javascript:pwiki.delete('@var(path)')"
|
href="javascript:pwiki.delete('@var(path)')"
|
||||||
@ -2394,16 +2415,16 @@ module.System = {
|
|||||||
info: {
|
info: {
|
||||||
text: object.doc`
|
text: object.doc`
|
||||||
<slot pre>
|
<slot pre>
|
||||||
<title>@source(../title) (info)</title>
|
<title>@source(../title/quote) (info)</title>
|
||||||
</slot>
|
</slot>
|
||||||
<slot title>
|
<slot title>
|
||||||
<h1><a href="#..">@source(../title)</a></h1>
|
<h1><a href="#..">@source(../title/quote)</a></h1>
|
||||||
</slot>
|
</slot>
|
||||||
|
|
||||||
Path: [@source(../path) ]
|
Path: [@source(../path/quote)]
|
||||||
(<a href="#../edit">edit</a>)<br>
|
(<a href="#../edit">edit</a>)<br>
|
||||||
Resolved path: [/@source(../resolved)]<br>
|
Resolved path: [/@source(../resolved/quote)]<br>
|
||||||
Referrer: [@source(../referrer)]<br>
|
Referrer: [@source(../referrer/quote)]<br>
|
||||||
Args: <args/><br>
|
Args: <args/><br>
|
||||||
|
|
||||||
type: @source(../type)<br>
|
type: @source(../type)<br>
|
||||||
@ -2453,10 +2474,10 @@ module.System = {
|
|||||||
<slot title/>
|
<slot title/>
|
||||||
<div class="error">
|
<div class="error">
|
||||||
<div class="msg" wikiwords="no">ParseError: @(msg "no message")</div>
|
<div class="msg" wikiwords="no">ParseError: @(msg "no message")</div>
|
||||||
Page: [@(path "@source(./path)")]
|
Page: [@(path "@source(./path/quote)")]
|
||||||
</div> `,},
|
</div> `,},
|
||||||
RecursionError: {
|
RecursionError: {
|
||||||
text: 'RECURSION ERROR: @source(../path)' },
|
text: 'RECURSION ERROR: @source(../path/quote)' },
|
||||||
NotFoundError: {
|
NotFoundError: {
|
||||||
//text: 'NOT FOUND ERROR: @source(./path)' },
|
//text: 'NOT FOUND ERROR: @source(./path)' },
|
||||||
text: object.doc`
|
text: object.doc`
|
||||||
@ -2469,20 +2490,20 @@ module.System = {
|
|||||||
<b>Nested pages:</b><br>
|
<b>Nested pages:</b><br>
|
||||||
<div style="padding-left: 30px">
|
<div style="padding-left: 30px">
|
||||||
<macro src="./*:$ARGS" join="<br>" else="@slot(nested)">
|
<macro src="./*:$ARGS" join="<br>" else="@slot(nested)">
|
||||||
<a href="#@source(s ./path)">@source(./title)</a>
|
<a href="#@source(s ./path)">@source(./title/quote)</a>
|
||||||
</macro>
|
</macro>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</slot>` },
|
</slot>` },
|
||||||
NotFoundTemplateError: {
|
NotFoundTemplateError: {
|
||||||
text: 'NOT FOUND TEMPLATE ERROR: @source(../path)' },
|
text: 'NOT FOUND TEMPLATE ERROR: @source(../path/quote)' },
|
||||||
|
|
||||||
DeletingPage: {
|
DeletingPage: {
|
||||||
text: 'Deleting: @source(../path)' },
|
text: 'Deleting: @source(../path/quote)' },
|
||||||
|
|
||||||
PageTemplate: {
|
PageTemplate: {
|
||||||
text: object.doc`
|
text: object.doc`
|
||||||
<slot header>@source(./path)/_edit</slot>
|
<slot header>@source(./path/quote)/edit</slot>
|
||||||
<hr>
|
<hr>
|
||||||
<slot content></slot>
|
<slot content></slot>
|
||||||
<hr>
|
<hr>
|
||||||
@ -2509,11 +2530,6 @@ module.System = {
|
|||||||
<hr>
|
<hr>
|
||||||
${text}`},
|
${text}`},
|
||||||
|
|
||||||
// XXX REMOVE WHEN NOT NEEDED...
|
|
||||||
TEST: function(){
|
|
||||||
console.log('TEST')
|
|
||||||
return 'TEST' },
|
|
||||||
|
|
||||||
// XXX EXPERIMENTAL -- page types...
|
// XXX EXPERIMENTAL -- page types...
|
||||||
isAction: async function(){
|
isAction: async function(){
|
||||||
return await this.get('..').type == 'action' ?
|
return await this.get('..').type == 'action' ?
|
||||||
@ -2600,7 +2616,7 @@ module.Templates = {
|
|||||||
<macro src="*:$ARGS">
|
<macro src="*:$ARGS">
|
||||||
@var(path "@source(s ./path)")
|
@var(path "@source(s ./path)")
|
||||||
<div class="item">
|
<div class="item">
|
||||||
<a href="#@var(path)/edit">@source(./title)</a>
|
<a href="#@var(path)/edit">@source(./title/quote)</a>
|
||||||
<a class="show-on-hover" href="#@var(path)/info">🛈</a>
|
<a class="show-on-hover" href="#@var(path)/info">🛈</a>
|
||||||
<a class="show-on-hover"
|
<a class="show-on-hover"
|
||||||
href="javascript:pwiki.delete('@var(path)')"
|
href="javascript:pwiki.delete('@var(path)')"
|
||||||
|
|||||||
@ -385,10 +385,12 @@ var refresh = async function(){
|
|||||||
history.scrollRestoration = 'manual'
|
history.scrollRestoration = 'manual'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
// start loading pWiki...
|
// start loading pWiki...
|
||||||
require(['./browser'], function(browser){
|
require(['./browser'], function(browser){
|
||||||
var pwiki = window.pwiki = browser.pwiki
|
var pwiki = window.pwiki = browser.pwiki
|
||||||
|
//var pwpath = window.path = browser.pwpath
|
||||||
pwiki.dom = document.querySelector('#pWiki')
|
pwiki.dom = document.querySelector('#pWiki')
|
||||||
|
|
||||||
// handle location.hash/history (both directions)
|
// handle location.hash/history (both directions)
|
||||||
|
|||||||
@ -38,12 +38,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* XXX BUG? can't use < and > (both?) in page title...
|
* XXX .parse(..): should we handle pattern paths and lists of text???
|
||||||
* ...can't seem to delete these pages -- seems to be a template problem...
|
|
||||||
* ...one of the issues is that we are reading .innerHTML and it gets
|
|
||||||
* all html reserved chars ("&<>") converted into enteties...
|
|
||||||
* ...another issue is that the entities get converted back in some
|
|
||||||
* cases wrecking havoc with links...
|
|
||||||
* XXX parser: error handling: add line number + context... (???)
|
* XXX parser: error handling: add line number + context... (???)
|
||||||
* XXX BUG: parser:
|
* XXX BUG: parser:
|
||||||
* This will break:
|
* This will break:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user