mirror of
https://github.com/flynx/pWiki.git
synced 2025-12-18 00:51:38 +00:00
added base templates + cleanup + fixes...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
3e39ff8228
commit
3fb79baea2
@ -51,8 +51,11 @@ Promise.all([
|
|||||||
store.next.update(
|
store.next.update(
|
||||||
pwpath.sanitize(pwpath.SYSTEM_PATH),
|
pwpath.sanitize(pwpath.SYSTEM_PATH),
|
||||||
Object.create(basestore.BaseStore).load(page.System)),
|
Object.create(basestore.BaseStore).load(page.System)),
|
||||||
|
store.next.update('.templates',
|
||||||
|
Object.create(basestore.BaseStore).load(page.Templates)),
|
||||||
store.update('.config',
|
store.update('.config',
|
||||||
Object.create(basestore.BaseStore).load(page.Config)),
|
Object.create(basestore.BaseStore).load(page.Config)),
|
||||||
|
|
||||||
store.update('Test',
|
store.update('Test',
|
||||||
Object.create(basestore.BaseStore).load(page.Test)),
|
Object.create(basestore.BaseStore).load(page.Test)),
|
||||||
|
|
||||||
|
|||||||
@ -226,20 +226,12 @@ object.Constructor('BasePage', {
|
|||||||
to
|
to
|
||||||
: '../'+to) },
|
: '../'+to) },
|
||||||
|
|
||||||
/*/ XXX TITLE / EXPERIMENTAL...
|
// XXX TITLE / EXPERIMENTAL...
|
||||||
// NOTE: .__title is intentionally not persistent...
|
|
||||||
__title: undefined,
|
|
||||||
get title(){
|
|
||||||
return this.__title
|
|
||||||
?? this.name },
|
|
||||||
set title(value){
|
|
||||||
this.__title = value
|
|
||||||
this.__update__({title: value}) },
|
|
||||||
//*/
|
|
||||||
get title(){
|
get title(){
|
||||||
return pwpath.decodeElem(this.name) },
|
return pwpath.decodeElem(this.name) },
|
||||||
set title(value){
|
set title(value){
|
||||||
this.name = pwpath.encodeElem(value) },
|
this.name = pwpath.encodeElem(value) },
|
||||||
|
//*/
|
||||||
|
|
||||||
get isPattern(){
|
get isPattern(){
|
||||||
return this.path.includes('*') },
|
return this.path.includes('*') },
|
||||||
@ -1529,7 +1521,7 @@ object.Constructor('Page', BasePage, {
|
|||||||
throw new Error('NOT FOUND ERROR: '+ this.location) }
|
throw new Error('NOT FOUND ERROR: '+ this.location) }
|
||||||
|
|
||||||
var path = pwpath.split(this.path)
|
var path = pwpath.split(this.path)
|
||||||
path.at(-1)[0] == '_'
|
;(path.at(-1) ?? '')[0] == '_'
|
||||||
|| path.push(this.PAGE_TEMPLATE)
|
|| path.push(this.PAGE_TEMPLATE)
|
||||||
var tpl = pwpath.join(path)
|
var tpl = pwpath.join(path)
|
||||||
var tpl_name = path.pop()
|
var tpl_name = path.pop()
|
||||||
@ -1756,20 +1748,6 @@ object.Constructor('pWikiPageElement', Page, {
|
|||||||
object.parentProperty(pWikiPageElement.prototype, 'location')
|
object.parentProperty(pWikiPageElement.prototype, 'location')
|
||||||
.set.call(this, value) },
|
.set.call(this, value) },
|
||||||
|
|
||||||
/*/ XXX this is not persistent, is this what we want???
|
|
||||||
// XXX should this default to .path or to .name???
|
|
||||||
get title(){
|
|
||||||
return this.dom.getAttribute('title')
|
|
||||||
|| (this.dom.querySelector('h1') || {}).innerText
|
|
||||||
|| this.path
|
|
||||||
|| object.parentProperty(pWikiPageElement.prototype, 'title')
|
|
||||||
.get.call(this) },
|
|
||||||
set title(value){
|
|
||||||
this.dom.setAttribute('title', value)
|
|
||||||
object.parentProperty(pWikiPageElement.prototype, 'title')
|
|
||||||
.set.call(this, value) },
|
|
||||||
//*/
|
|
||||||
|
|
||||||
// events...
|
// events...
|
||||||
//
|
//
|
||||||
__pWikiLoadedDOMEvent: new Event('pwikiloaded'),
|
__pWikiLoadedDOMEvent: new Event('pwikiloaded'),
|
||||||
@ -1837,21 +1815,21 @@ module.System = {
|
|||||||
text: '@include(.:$ARGS isolated join="@source(file-separator)")' },
|
text: '@include(.:$ARGS isolated join="@source(file-separator)")' },
|
||||||
_view: {
|
_view: {
|
||||||
text: object.doc`
|
text: object.doc`
|
||||||
<slot name="header">
|
<slot header>
|
||||||
<a href="#/list">☰</a>
|
<a href="#/list">☰</a>
|
||||||
<a href="#<slot name=parent>../</slot>">⇑</a>
|
<a href="#<slot parent>../</slot>">⇑</a>
|
||||||
[<slot name="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(./path/!)/edit">✎</a>
|
||||||
</slot>
|
</slot>
|
||||||
<hr>
|
<hr>
|
||||||
<slot name="content"></slot>
|
<slot content></slot>
|
||||||
<hr>
|
<hr>
|
||||||
<slot name="footer"></slot>
|
<slot footer></slot>
|
||||||
|
|
||||||
<!-- fill slots defaults -->
|
<!-- fill slots defaults -->
|
||||||
<slot name="content" hidden>
|
<slot content hidden>
|
||||||
<slot name=title><h1>@source(./title)</h1></slot>
|
<slot title><h1>@source(./title)</h1></slot>
|
||||||
@include(.:$ARGS join="@source(file-separator)" recursive="")
|
@include(.:$ARGS join="@source(file-separator)" recursive="")
|
||||||
</slot>` },
|
</slot>` },
|
||||||
// XXX add join...
|
// XXX add join...
|
||||||
@ -1868,8 +1846,8 @@ module.System = {
|
|||||||
_edit: {
|
_edit: {
|
||||||
text:
|
text:
|
||||||
'@include(PageTemplate)'
|
'@include(PageTemplate)'
|
||||||
+'<slot name="header">@source(./path)</slot>'
|
+'<slot header>@source(./path)</slot>'
|
||||||
+'<slot name="content">'
|
+'<slot content>'
|
||||||
+'<macro src="." join="@source(file-separator)">'
|
+'<macro src="." join="@source(file-separator)">'
|
||||||
+'<pre class="editor" '
|
+'<pre class="editor" '
|
||||||
+'wikiwords="no" '
|
+'wikiwords="no" '
|
||||||
@ -1902,10 +1880,10 @@ module.System = {
|
|||||||
edit: {
|
edit: {
|
||||||
// XXX not sure if we should use .title or .name here...
|
// XXX not sure if we should use .title or .name here...
|
||||||
text: object.doc`
|
text: object.doc`
|
||||||
<slot name="parent">../..</slot>
|
<slot parent>../..</slot>
|
||||||
<slot name="location">@source(../location/!)</slot>
|
<slot location>@source(../location/!)</slot>
|
||||||
|
|
||||||
<slot name="content">
|
<slot content>
|
||||||
<macro src=".." join="@source(file-separator)">
|
<macro src=".." join="@source(file-separator)">
|
||||||
<h1 class="title-editor"
|
<h1 class="title-editor"
|
||||||
contenteditable
|
contenteditable
|
||||||
@ -1927,7 +1905,7 @@ module.System = {
|
|||||||
|
|
||||||
list: {
|
list: {
|
||||||
text: object.doc`
|
text: object.doc`
|
||||||
<slot name="header">
|
<slot header>
|
||||||
<a href="#/list">☰</a>
|
<a href="#/list">☰</a>
|
||||||
<a href="#@source(../../path)/list">⇑</a>
|
<a href="#@source(../../path)/list">⇑</a>
|
||||||
@source(../path)
|
@source(../path)
|
||||||
@ -1949,7 +1927,7 @@ module.System = {
|
|||||||
// XXX this is really slow...
|
// XXX this is really slow...
|
||||||
tree: {
|
tree: {
|
||||||
text: object.doc`
|
text: object.doc`
|
||||||
<slot name=title></slot>
|
<slot title/>
|
||||||
<macro src="../*:@(all)">
|
<macro src="../*:@(all)">
|
||||||
<div>
|
<div>
|
||||||
<div class="item">
|
<div class="item">
|
||||||
@ -2007,29 +1985,14 @@ module.System = {
|
|||||||
|
|
||||||
PageTemplate: {
|
PageTemplate: {
|
||||||
text: object.doc`
|
text: object.doc`
|
||||||
<slot name="header">@source(./path)/_edit</slot>
|
<slot header>@source(./path)/_edit</slot>
|
||||||
<hr>
|
<hr>
|
||||||
<slot name="content"></slot>
|
<slot content></slot>
|
||||||
<hr>
|
<hr>
|
||||||
<slot name="footer"></slot> ` },
|
<slot footer></slot> ` },
|
||||||
QuoteActionPage: {
|
QuoteActionPage: {
|
||||||
text: '[ native code ]' },
|
text: '[ native code ]' },
|
||||||
|
|
||||||
// XXX should this be in templates???
|
|
||||||
// XXX for some reason this does not list files...
|
|
||||||
FlatNotes: {
|
|
||||||
text: object.doc`
|
|
||||||
<slot name=title></slot>
|
|
||||||
<slot name="header"><content/><a href="#./$NOW/edit">🗎</a></slot>
|
|
||||||
<macro src="*:@(all)" join="<br>">
|
|
||||||
<div class="item">
|
|
||||||
<a href="#@source(./path)/edit">@source(./title)</a>
|
|
||||||
<a class="show-on-hover" href="#@source(./path)/info">🛈</a>
|
|
||||||
<a class="show-on-hover" href="#@source(./path)/delete">×</a>
|
|
||||||
</div>
|
|
||||||
</macro>` },
|
|
||||||
|
|
||||||
|
|
||||||
// page actions...
|
// page actions...
|
||||||
//
|
//
|
||||||
|
|
||||||
@ -2040,6 +2003,7 @@ module.System = {
|
|||||||
var time = Date.now() - t
|
var time = Date.now() - t
|
||||||
console.log('RENDER TIME:', time)
|
console.log('RENDER TIME:', time)
|
||||||
return object.doc`
|
return object.doc`
|
||||||
|
<slot title/>
|
||||||
Time to render: ${time}ms <br>
|
Time to render: ${time}ms <br>
|
||||||
<hr>
|
<hr>
|
||||||
${text}`},
|
${text}`},
|
||||||
@ -2132,12 +2096,27 @@ module.System = {
|
|||||||
return '' },
|
return '' },
|
||||||
// XXX copy/...
|
// XXX copy/...
|
||||||
|
|
||||||
// XXX System/back
|
|
||||||
// XXX System/forward
|
|
||||||
// XXX System/sort
|
// XXX System/sort
|
||||||
// XXX System/reverse
|
// XXX System/reverse
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var Templates =
|
||||||
|
module.Templates = {
|
||||||
|
// XXX should this be in templates???
|
||||||
|
// XXX for some reason this does not list files...
|
||||||
|
FlatNotes: {
|
||||||
|
text: object.doc`
|
||||||
|
<slot title/>
|
||||||
|
<slot header><content/><a href="#./$NOW/edit">🗎</a></slot>
|
||||||
|
<macro src="*:@(all)" join="<br>">
|
||||||
|
<div class="item">
|
||||||
|
<a href="#@source(./path)/edit">@source(./title)</a>
|
||||||
|
<a class="show-on-hover" href="#@source(./path)/info">🛈</a>
|
||||||
|
<a class="show-on-hover" href="#@source(./path)/delete">×</a>
|
||||||
|
</div>
|
||||||
|
</macro>` },
|
||||||
|
}
|
||||||
|
|
||||||
var Test =
|
var Test =
|
||||||
module.Test = {
|
module.Test = {
|
||||||
// XXX do we support this???
|
// XXX do we support this???
|
||||||
|
|||||||
@ -36,8 +36,7 @@ module = {
|
|||||||
// NOTE: if a path here is relative it is also searched relative to
|
// NOTE: if a path here is relative it is also searched relative to
|
||||||
// the target path.
|
// the target path.
|
||||||
SEARCH_PATHS: [
|
SEARCH_PATHS: [
|
||||||
//'./Theme/CLI',
|
'.templates',
|
||||||
'./Templates',
|
|
||||||
],
|
],
|
||||||
|
|
||||||
// System path...
|
// System path...
|
||||||
|
|||||||
@ -25,6 +25,10 @@
|
|||||||
* levels:
|
* levels:
|
||||||
* - memory
|
* - memory
|
||||||
* - persistent (???)
|
* - persistent (???)
|
||||||
|
* XXX IDEA: macros: might be fun to be able to use certain pages as
|
||||||
|
* macros...
|
||||||
|
* ...this might even extend to all macros being actions in something
|
||||||
|
* like /.system/macros/...
|
||||||
* XXX might also be a good idea to investigate a .tree directory index
|
* XXX might also be a good idea to investigate a .tree directory index
|
||||||
* as a supplement to .paths()
|
* as a supplement to .paths()
|
||||||
* XXX Q: can we access fs from a pwa???
|
* XXX Q: can we access fs from a pwa???
|
||||||
@ -508,6 +512,8 @@ Promise.all([
|
|||||||
store.next.update(
|
store.next.update(
|
||||||
pwpath.sanitize(pwpath.SYSTEM_PATH),
|
pwpath.sanitize(pwpath.SYSTEM_PATH),
|
||||||
Object.create(basestore.BaseStore).load(page.System)),
|
Object.create(basestore.BaseStore).load(page.System)),
|
||||||
|
store.next.update('.templates',
|
||||||
|
Object.create(basestore.BaseStore).load(page.Templates)),
|
||||||
store.update('.config',
|
store.update('.config',
|
||||||
Object.create(basestore.BaseStore).load(page.Config)),
|
Object.create(basestore.BaseStore).load(page.Config)),
|
||||||
])
|
])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user