From 244a752ae13d1c6087976bb9d807bd7f1924c6c0 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Sun, 28 Jan 2024 23:54:28 +0000 Subject: [PATCH] Some wiki link fixes. Not enough. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4815 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- apps/wiki.json | 2 +- apps/wiki/handler.js | 6 ++++-- apps/wiki/tf-wiki-doc.js | 8 +++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/wiki.json b/apps/wiki.json index 14dc08d6..493364eb 100644 --- a/apps/wiki.json +++ b/apps/wiki.json @@ -1,5 +1,5 @@ { "type": "tildefriends-app", "emoji": "📝", - "previous": "&qrcrBeaWg89ikgql9hXdr68krkg+5NZkmwTbpodEW4U=.sha256" + "previous": "&/wl8HE2jZShRXTYEVYRrK3pjHwi41Wbxl9HoSJaQP6Y=.sha256" } \ No newline at end of file diff --git a/apps/wiki/handler.js b/apps/wiki/handler.js index c0fe3b93..244bb336 100644 --- a/apps/wiki/handler.js +++ b/apps/wiki/handler.js @@ -10,7 +10,9 @@ function markdown(md) { while ((event = walker.next())) { let node = event.node; if (event.entering) { - if (node.type === 'link') { + if (node.destination?.startsWith('&')) { + node.destination = '/' + node.destination + '/view?filename=' + node.firstChild?.literal; + } else if (node.type === 'link') { if (node.destination.indexOf(':') == -1 && node.destination.indexOf('/') == -1) { node.destination = `${node.destination}`; @@ -57,7 +59,7 @@ async function main() {

${wiki_name}: ${wiki_doc_name}

${markdown(md)}
`, - content_type: 'text/html', + content_type: 'text/html; charset=utf-8', status_code: 200, }); } else { diff --git a/apps/wiki/tf-wiki-doc.js b/apps/wiki/tf-wiki-doc.js index e6acc075..18158942 100644 --- a/apps/wiki/tf-wiki-doc.js +++ b/apps/wiki/tf-wiki-doc.js @@ -28,15 +28,13 @@ class TfWikiDocElement extends LitElement { while ((event = walker.next())) { let node = event.node; if (event.entering) { - if (node.type === 'link') { + if (node.destination?.startsWith('&')) { + node.destination = '/' + node.destination + '/view?filename=' + node.firstChild?.literal; + } else if (node.type === 'link') { if (node.destination.indexOf(':') == -1 && node.destination.indexOf('/') == -1) { node.destination = `#${this.wiki?.name}/${node.destination}`; } - } else if (node.type == 'image') { - if (node.destination.startsWith('&')) { - node.destination = '/' + node.destination + '/view'; - } } } }