mirror of
https://github.com/flynx/pWiki.git
synced 2025-12-19 01:21:38 +00:00
several bugfixes + added [s]tring quoting -- @include(s ..)/@source(s ..)
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
9219794848
commit
56bf5c7592
@ -855,7 +855,7 @@ object.Constructor('Page', BasePage, {
|
|||||||
.call(this, Object.fromEntries(Object.entries(quote)), null, state)
|
.call(this, Object.fromEntries(Object.entries(quote)), null, state)
|
||||||
|
|
||||||
// local filters...
|
// local filters...
|
||||||
if(body){
|
if(body != null){
|
||||||
// expand the body...
|
// expand the body...
|
||||||
var ast = expand ?
|
var ast = expand ?
|
||||||
this.__parser__.expand(this, body, state)
|
this.__parser__.expand(this, body, state)
|
||||||
@ -903,9 +903,10 @@ object.Constructor('Page', BasePage, {
|
|||||||
// At the moment nested recursion is checked in a fast but
|
// At the moment nested recursion is checked in a fast but
|
||||||
// not 100% correct manner focusing on path depth and ignoring
|
// not 100% correct manner focusing on path depth and ignoring
|
||||||
// the context, this potentially can lead to false positives.
|
// the context, this potentially can lead to false positives.
|
||||||
|
// XXX need a way to make encode option transparent...
|
||||||
include: Macro(
|
include: Macro(
|
||||||
['src', 'recursive', 'join',
|
['src', 'recursive', 'join',
|
||||||
['strict', 'nonstrict', 'isolated']],
|
['s', 'strict', 'nonstrict', 'isolated']],
|
||||||
async function*(args, body, state, key='included', handler){
|
async function*(args, body, state, key='included', handler){
|
||||||
var macro = 'include'
|
var macro = 'include'
|
||||||
if(typeof(args) == 'string'){
|
if(typeof(args) == 'string'){
|
||||||
@ -927,6 +928,7 @@ object.Constructor('Page', BasePage, {
|
|||||||
var isolated = args.isolated
|
var isolated = args.isolated
|
||||||
var strict = args.strict
|
var strict = args.strict
|
||||||
&& !args.nonstrict
|
&& !args.nonstrict
|
||||||
|
var strquotes = args.s
|
||||||
var join = args.join
|
var join = args.join
|
||||||
&& await base.parse(args.join, state)
|
&& await base.parse(args.join, state)
|
||||||
|
|
||||||
@ -989,6 +991,11 @@ object.Constructor('Page', BasePage, {
|
|||||||
// load the included page...
|
// load the included page...
|
||||||
var res = await handler.call(page, full, state)
|
var res = await handler.call(page, full, state)
|
||||||
depends.add(full)
|
depends.add(full)
|
||||||
|
res = strquotes ?
|
||||||
|
res
|
||||||
|
.replace(/["']/g, function(c){
|
||||||
|
return '%'+ c.charCodeAt().toString(16) })
|
||||||
|
: res
|
||||||
|
|
||||||
// NOTE: we only track recursion down and not sideways...
|
// NOTE: we only track recursion down and not sideways...
|
||||||
seen.delete(full)
|
seen.delete(full)
|
||||||
@ -1006,7 +1013,7 @@ object.Constructor('Page', BasePage, {
|
|||||||
source: Macro(
|
source: Macro(
|
||||||
// XXX should this have the same args as include???
|
// XXX should this have the same args as include???
|
||||||
['src', 'recursive', 'join',
|
['src', 'recursive', 'join',
|
||||||
['strict', 'nonstrict', 'isolated']],
|
['s', 'strict', 'nonstrict', 'isolated']],
|
||||||
//['src'],
|
//['src'],
|
||||||
async function*(args, body, state){
|
async function*(args, body, state){
|
||||||
var that = this
|
var that = this
|
||||||
@ -1845,7 +1852,7 @@ module.System = {
|
|||||||
<a href="#<slot parent>../</slot>">⇑</a>
|
<a href="#<slot parent>../</slot>">⇑</a>
|
||||||
[<slot location>@source(./location/!)</slot>]
|
[<slot location>@source(./location/!)</slot>]
|
||||||
<a href="javascript:refresh()">⟳</a>
|
<a href="javascript:refresh()">⟳</a>
|
||||||
<a href="#@source(./path/!)/edit">✎</a>
|
<a href="#@source(s ./path/!)/edit">✎</a>
|
||||||
</slot>
|
</slot>
|
||||||
<hr>
|
<hr>
|
||||||
<slot content></slot>
|
<slot content></slot>
|
||||||
@ -1891,13 +1898,13 @@ module.System = {
|
|||||||
+'<h1 '
|
+'<h1 '
|
||||||
+'contenteditable '
|
+'contenteditable '
|
||||||
// XXX need to make this savable...
|
// XXX need to make this savable...
|
||||||
+'oninput="saveLiveContent(\'@source(./path)/name\')">'
|
+'oninput="saveLiveContent(\'@source(s ./path)/name\')">'
|
||||||
+'@source(./name)'
|
+'@source(./name)'
|
||||||
+'</h1>'
|
+'</h1>'
|
||||||
+'<pre class="editor" '
|
+'<pre class="editor" '
|
||||||
+'wikiwords="no" '
|
+'wikiwords="no" '
|
||||||
+'contenteditable '
|
+'contenteditable '
|
||||||
+'oninput="saveLiveContent(\'@source(./path)\', this.innerText)">'
|
+'oninput="saveLiveContent(\'@source(s ./path)\', this.innerText)">'
|
||||||
+'<quote filter="quote-tags" src="."/>'
|
+'<quote filter="quote-tags" src="."/>'
|
||||||
+'</pre>'
|
+'</pre>'
|
||||||
+'</macro>'},
|
+'</macro>'},
|
||||||
@ -1912,13 +1919,13 @@ module.System = {
|
|||||||
<macro src=".." join="@source(file-separator)">
|
<macro src=".." join="@source(file-separator)">
|
||||||
<h1 class="title-editor"
|
<h1 class="title-editor"
|
||||||
contenteditable
|
contenteditable
|
||||||
oninput="saveContent(\'@source(./path)/title\', this.innerText)">
|
oninput="saveContent(\'@source(s ./path)/title\', this.innerText)">
|
||||||
@source(./title)
|
@source(./title)
|
||||||
</h1>
|
</h1>
|
||||||
<pre class="editor"
|
<pre class="editor"
|
||||||
wikiwords="no"
|
wikiwords="no"
|
||||||
contenteditable
|
contenteditable
|
||||||
oninput="saveLiveContent(\'@source(./path)\', this.innerText)"
|
oninput="saveLiveContent(\'@source(s ./path)\', this.innerText)"
|
||||||
><quote filter="quote-tags" src="."/></pre>
|
><quote filter="quote-tags" src="."/></pre>
|
||||||
</macro>
|
</macro>
|
||||||
</slot>`},
|
</slot>`},
|
||||||
@ -1932,11 +1939,11 @@ module.System = {
|
|||||||
text: object.doc`
|
text: object.doc`
|
||||||
<slot header>
|
<slot header>
|
||||||
<a href="#/list">☰</a>
|
<a href="#/list">☰</a>
|
||||||
<a href="#@source(../../path)/list">⇑</a>
|
<a href="#@source(s ../../path)/list">⇑</a>
|
||||||
@source(../path)
|
@source(../path)
|
||||||
</slot>
|
</slot>
|
||||||
<macro src="../*:@(all)" join="@source(line-separator)">
|
<macro src="../*:@(all)" join="@source(line-separator)">
|
||||||
<a href="#@source(./path)">@source(./name)</a>
|
<a href="#@source(s ./path)">@source(./name)</a>
|
||||||
<sup>
|
<sup>
|
||||||
<macro src="./isAction">
|
<macro src="./isAction">
|
||||||
a
|
a
|
||||||
@ -1945,9 +1952,9 @@ module.System = {
|
|||||||
</else>
|
</else>
|
||||||
</macro>
|
</macro>
|
||||||
</sup>
|
</sup>
|
||||||
(<a href="#@source(./path)/list">@include(./*/length/!)</a>)
|
(<a href="#@source(s ./path)/list">@include(./*/length/!)</a>)
|
||||||
|
|
||||||
<a href="#@source(./path)/delete">×</a>
|
<a href="#@source(s ./path)/delete">×</a>
|
||||||
</macro>` },
|
</macro>` },
|
||||||
// XXX this is really slow...
|
// XXX this is really slow...
|
||||||
tree: {
|
tree: {
|
||||||
@ -1956,9 +1963,9 @@ module.System = {
|
|||||||
<macro src="../*:@(all)">
|
<macro src="../*:@(all)">
|
||||||
<div>
|
<div>
|
||||||
<div class="item">
|
<div class="item">
|
||||||
<a href="#@source(./path)">@source(./name)</a>
|
<a href="#@source(s ./path)">@source(./title)</a>
|
||||||
<a class="show-on-hover" href="#@source(./path)/info">🛈</a>
|
<a class="show-on-hover" href="#@source(s ./path)/info">🛈</a>
|
||||||
<a class="show-on-hover" href="#@source(./path)/delete">×</a>
|
<a class="show-on-hover" href="#@source(s ./path)/delete">×</a>
|
||||||
</div>
|
</div>
|
||||||
<div style="padding-left: 30px">
|
<div style="padding-left: 30px">
|
||||||
@include("./tree:@(all)")
|
@include("./tree:@(all)")
|
||||||
@ -1970,11 +1977,11 @@ module.System = {
|
|||||||
info: {
|
info: {
|
||||||
text: object.doc`
|
text: object.doc`
|
||||||
Path: [@source(../path) ]
|
Path: [@source(../path) ]
|
||||||
(<a href="#@source(../path)/edit">edit</a>)<br>
|
(<a href="#@source(s ../path)/edit">edit</a>)<br>
|
||||||
Resolved path: [@source(../resolved)]
|
Resolved path: [@source(../resolved)]
|
||||||
(<a href="#@source(../resolved)/edit">edit</a>)<br>
|
(<a href="#@source(s ../resolved)/edit">edit</a>)<br>
|
||||||
Referrer: [@source(../referrer)]
|
Referrer: [@source(../referrer)]
|
||||||
(<a href="#@source(../referrer)/edit">edit</a>)<br>
|
(<a href="#@source(s ../referrer)/edit">edit</a>)<br>
|
||||||
Args: <args/><br>
|
Args: <args/><br>
|
||||||
|
|
||||||
type: @source(../type)<br>
|
type: @source(../type)<br>
|
||||||
@ -2141,11 +2148,13 @@ module.Templates = {
|
|||||||
<slot header><content/><a href="#./$NOW/edit">🗎</a></slot>
|
<slot header><content/><a href="#./$NOW/edit">🗎</a></slot>
|
||||||
<macro src="*:@(all)" join="<br>">
|
<macro src="*:@(all)" join="<br>">
|
||||||
<div class="item">
|
<div class="item">
|
||||||
<a href="#@source(./path)/edit">@source(./title)</a>
|
<a href="#@source(s ./path)/edit">@source(./title)</a>
|
||||||
<a class="show-on-hover" href="#@source(./path)/info">🛈</a>
|
<a class="show-on-hover" href="#@source(s ./path)/info">🛈</a>
|
||||||
<a class="show-on-hover" href="#@source(./path)/delete">×</a>
|
<a class="show-on-hover" href="#@source(s ./path)/delete">×</a>
|
||||||
</div>
|
</div>
|
||||||
</macro>` },
|
</macro>` },
|
||||||
|
// XXX this is not resolved...
|
||||||
|
'FlatNotes/.templates/EmptyPage': {text: ' '},
|
||||||
}
|
}
|
||||||
|
|
||||||
var Test =
|
var Test =
|
||||||
|
|||||||
@ -52,14 +52,14 @@ module = {
|
|||||||
// XXX EXPERIMENTAL
|
// XXX EXPERIMENTAL
|
||||||
encode: function(str){
|
encode: function(str){
|
||||||
return str
|
return str
|
||||||
.replace(/[#:*%'"]/g,
|
.replace(/[#:*%]/g,
|
||||||
function(s){
|
function(s){
|
||||||
return '%'+s.charCodeAt().toString(16) }) },
|
return '%'+s.charCodeAt().toString(16) }) },
|
||||||
decode: function(str){
|
decode: function(str){
|
||||||
return decodeURIComponent(str) },
|
return decodeURIComponent(str) },
|
||||||
encodeElem: function(str){
|
encodeElem: function(str){
|
||||||
return str
|
return str
|
||||||
.replace(/[#:*%'"\\\/]/g,
|
.replace(/[#:*%\\\/]/g,
|
||||||
function(s){
|
function(s){
|
||||||
return '%'+s.charCodeAt().toString(16) }) },
|
return '%'+s.charCodeAt().toString(16) }) },
|
||||||
decodeElem: function(str){
|
decodeElem: function(str){
|
||||||
|
|||||||
@ -178,6 +178,9 @@ var SAVE_LIVE_QUEUE = {}
|
|||||||
|
|
||||||
var saveLiveContent =
|
var saveLiveContent =
|
||||||
function(path, text){
|
function(path, text){
|
||||||
|
path = path
|
||||||
|
.replace(/%22/g, '"')
|
||||||
|
.replace(/%27/g, "'")
|
||||||
SAVE_LIVE_QUEUE[path] = text
|
SAVE_LIVE_QUEUE[path] = text
|
||||||
// clear editor page cache...
|
// clear editor page cache...
|
||||||
pwiki.cache = null }
|
pwiki.cache = null }
|
||||||
@ -185,6 +188,9 @@ function(path, text){
|
|||||||
var SAVE_QUEUE = {}
|
var SAVE_QUEUE = {}
|
||||||
var saveContent =
|
var saveContent =
|
||||||
function(path, text){
|
function(path, text){
|
||||||
|
path = path
|
||||||
|
.replace(/%22/g, '"')
|
||||||
|
.replace(/%27/g, "'")
|
||||||
SAVE_QUEUE[path] = text
|
SAVE_QUEUE[path] = text
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,13 +6,6 @@
|
|||||||
* - fs store/export in browser or a simple way to export/import...
|
* - fs store/export in browser or a simple way to export/import...
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* XXX BUG titles containing quotes break things...
|
|
||||||
* this works:
|
|
||||||
* await pwiki.get('/FlatNotes/* /delete').raw
|
|
||||||
* opening/editing/deleting from ui breaks -- macro issue??
|
|
||||||
* ...seems to be at least a problem with macros eating up quotes...
|
|
||||||
* do not see how we can resolve this issue transparently in any
|
|
||||||
* way other than disallowing quotes...
|
|
||||||
* XXX BUG: for some reason deleting and refreshing takes ~2x as long as
|
* XXX BUG: for some reason deleting and refreshing takes ~2x as long as
|
||||||
* refreshing...
|
* refreshing...
|
||||||
* to reproduce:
|
* to reproduce:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user