added custom titles + lots of fixes and tweaks...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2022-10-03 02:35:14 +03:00
parent 50458ccaa9
commit 807a6df56d
4 changed files with 37 additions and 16 deletions

View File

@ -36,9 +36,9 @@ function(text, show_brackets=true, skip){
if(l[0] == '\\'){
return l.slice(1) }
var path = l[0] == '[' ?
l.slice(1, -1)
: l
var path = (l[0] == '[' ?
l.slice(1, -1)
: l)
var i = [].slice.call(arguments).slice(-2)[0]
// XXX HACK check if we are inside a tag...
@ -49,7 +49,7 @@ function(text, show_brackets=true, skip){
return skip.indexOf(l) < 0 ?
('<a '
+'class="wikiword" '
+'href="#'+ path +'" '
+'href="#'+ path.replace(/"/g, '%22') +'" '
+'bracketed="'+ (show_brackets && l[0] == '[' ? 'yes' : 'no') +'" '
//+'onclick="event.preventDefault(); go($(this).attr(\'href\').slice(1))" '
+'>'

View File

@ -122,7 +122,7 @@ object.Constructor('BasePage', {
return context.index },
//*/
},
resolvePathVars: function(path, context={}){
resolvePathVars: function(path='', context={}){
var that = this
return pwpath.normalize(
Object.entries(this.path_vars)
@ -1847,6 +1847,8 @@ module.System = {
text: '@include(.:$ARGS isolated join="@source(file-separator)")' },
_view: {
text: object.doc`
<slot pre/>
<slot header>
<a href="#/list">&#9776</a>
<a href="#<slot parent>../</slot>">&#x21D1;</a>
@ -1855,15 +1857,12 @@ module.System = {
<a href="#@source(s ./path/!)/edit">&#9998;</a>
</slot>
<hr>
<slot content></slot>
<hr>
<slot footer></slot>
<!-- fill slots defaults -->
<slot content hidden>
<slot title><h1>@source(./title)</h1></slot>
<slot content>
<h1><slot title>@source(./title)</slot></h1>
@include(.:$ARGS join="@source(file-separator)" recursive="")
</slot>` },
</slot>
<hr>
<slot footer/>` },
// XXX add join...
_raw: {
text: '@quote(.)' },
@ -1912,6 +1911,10 @@ module.System = {
edit: {
// XXX not sure if we should use .title or .name here...
text: object.doc`
<slot pre>
<title>@source(../title) (edit)</title>
</slot>
<slot parent>../..</slot>
<slot location>@source(../location/!)</slot>
@ -1976,6 +1979,9 @@ module.System = {
text: `@include("../**/path:@(all)" join="@source(line-separator)")`},
info: {
text: object.doc`
<slot pre>
<title>@source(../title) (info)</title>
</slot>
<slot title>
<h1><a href="#..">@source(../title)</a></h1>
</slot>

View File

@ -220,7 +220,9 @@ module = {
'string') },
basename: function(path){
path = this.split(path)
return path.length == 1 ?
return path.length == 0 ?
''
: path.length == 1 ?
path[0]
: (path.at(-1) == '' ?
path.at(-2)
@ -228,7 +230,7 @@ module = {
dirname: function(path){
path = this.split(path)
path = path.length == 1 ?
'.'
'/'
: path.length == 2 ?
path[0]
: (path.at(-1) == '' ?
@ -344,6 +346,9 @@ module = {
yield* this.paths(path.concat(page), seen) }} },
names: function(path='/'){
path = path == '' ?
'/'
: path
path = this.normalize(path, 'string')
var name = path == '/' ?
this.ROOT_PAGE

View File

@ -30,6 +30,10 @@ body {
font-size: 1.1em;
}
h1:empty {
display: none;
}
a {
text-decoration: none;
}
@ -304,7 +308,13 @@ require(['./browser'], function(browser){
// stop spinner...
stopSpinner()
// handle title...
document.querySelector('title').innerHTML = `${this.title} &mdash; pWiki`
// NOTE: we set the global title to either the last <title>
// tag value or the attr .title
var titles = [...document.querySelectorAll('title')]
titles[0].innerHTML =
`${titles.length > 1 ?
titles.at(-1).innerHTML
: this.title} &mdash; pWiki`
// scroll to anchor element...
this.hash
&& this.dom