From 83fa488b8d248cdaca3480ce64d7d01b8dec2cc4 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Wed, 19 Jan 2022 02:37:39 +0000 Subject: [PATCH] Fix links to user IDs. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3776 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- apps/cory/index.json | 2 +- apps/cory/index/index.html | 1 + apps/cory/index/tf-message.js | 6 +----- apps/cory/index/tf-shared.js | 19 +++++++++++++++++++ apps/cory/index/tf.js | 9 +-------- 5 files changed, 23 insertions(+), 14 deletions(-) create mode 100644 apps/cory/index/tf-shared.js diff --git a/apps/cory/index.json b/apps/cory/index.json index ffcf0459..0acd1f9c 100644 --- a/apps/cory/index.json +++ b/apps/cory/index.json @@ -1 +1 @@ -{"type":"tildefriends-app","files":{"app.js":"&uXK7Jr1DcwfxabWjUOHVsElPbSyBB35bSrNSElnUlik=.sha256","index.html":"&k3P9dC0mRkGgSfykSKd+EAwUVIwQBJDBeTrqCq0JsOE=.sha256","vue-material.js":"&K5cdLqXYCENPak/TCINHQhyJhpS4G9DlZHGwoh/LF2g=.sha256","tf-user.js":"&DdJwZYEo7AqFyutYMvEjykoVXxdHVog0UXye6Sbo0TU=.sha256","tf-message.js":"&ZQuSBy1K3iASz/NVEa8ILA6aOefHZUmBa/Ddpcl7ZyI=.sha256","tf.js":"&21MCe6snZ7V+XGPIusw4lFgW6dDcSQlgM0m3Aebf3vI=.sha256","commonmark.min.js":"&EP0OeR9zyLwZannz+0ga4s9AGES2RLvvIIQYHqqV6+k=.sha256","vue.js":"&g1wvA+yHl1sVC+eufTsg9If7ZeVyMTBU+h0tks7ZNzE=.sha256","vue-material-theme-default-dark.css":"&RP2nr+2CR18BpHHw5ST9a5GJUCOG9n0G2kuGkcQioWE=.sha256","vue-material.min.css":"&kGbUM2QgFSyHZRzqQb0b+0S3EVIlZ0AXpdiAVjIhou8=.sha256","roboto.css":"&jJv43Om673mQO5JK0jj7714s5E+5Yrf82H6LcDx7wUs=.sha256","material-icons.css":"&a28PdcVvgq/DxyIvJAx/e+ZOEtOuHnr3kjLWKyzH11M=.sha256"}} \ No newline at end of file +{"type":"tildefriends-app","files":{"app.js":"&uXK7Jr1DcwfxabWjUOHVsElPbSyBB35bSrNSElnUlik=.sha256","index.html":"&eY9aBHpnmbMTXXnbzv9gxxXvJp8O5NpcqulQxdnsW/s=.sha256","vue-material.js":"&K5cdLqXYCENPak/TCINHQhyJhpS4G9DlZHGwoh/LF2g=.sha256","tf-user.js":"&DdJwZYEo7AqFyutYMvEjykoVXxdHVog0UXye6Sbo0TU=.sha256","tf-message.js":"&3dPiSNYjoJE3zn1oTT1SBhbvkW9MHr7ZUDxUJiBI1Ss=.sha256","tf.js":"&qaMkoT5UElfhFNFcDLimlm3asDLaYytsypoz7CJh9q0=.sha256","commonmark.min.js":"&EP0OeR9zyLwZannz+0ga4s9AGES2RLvvIIQYHqqV6+k=.sha256","vue.js":"&g1wvA+yHl1sVC+eufTsg9If7ZeVyMTBU+h0tks7ZNzE=.sha256","vue-material-theme-default-dark.css":"&RP2nr+2CR18BpHHw5ST9a5GJUCOG9n0G2kuGkcQioWE=.sha256","vue-material.min.css":"&kGbUM2QgFSyHZRzqQb0b+0S3EVIlZ0AXpdiAVjIhou8=.sha256","roboto.css":"&jJv43Om673mQO5JK0jj7714s5E+5Yrf82H6LcDx7wUs=.sha256","material-icons.css":"&a28PdcVvgq/DxyIvJAx/e+ZOEtOuHnr3kjLWKyzH11M=.sha256","tf-shared.js":"&Vi9pHWY2Dh6+cJlX0lLa4gxrC7VlkeWaU0fQidwzaQ0=.sha256"}} \ No newline at end of file diff --git a/apps/cory/index/index.html b/apps/cory/index/index.html index 92dd9d36..1f549f00 100644 --- a/apps/cory/index/index.html +++ b/apps/cory/index/index.html @@ -8,6 +8,7 @@ + diff --git a/apps/cory/index/tf-message.js b/apps/cory/index/tf-message.js index 31d01ee3..7e30eea6 100644 --- a/apps/cory/index/tf-message.js +++ b/apps/cory/index/tf-message.js @@ -19,11 +19,7 @@ Vue.component('tf-message', { } }, methods: { - markdown: function(md) { - var reader = new commonmark.Parser({safe: true}); - var writer = new commonmark.HtmlRenderer(); - return writer.render(reader.parse(md)); - }, + markdown: markdown, set_reply: function() { g_data.reply_root = this.content_json.root || this.message.id; g_data.reply_branch = this.message.id; diff --git a/apps/cory/index/tf-shared.js b/apps/cory/index/tf-shared.js new file mode 100644 index 00000000..801c1a78 --- /dev/null +++ b/apps/cory/index/tf-shared.js @@ -0,0 +1,19 @@ +"use strict"; + +function markdown(md) { + var reader = new commonmark.Parser({safe: true}); + var writer = new commonmark.HtmlRenderer(); + var parsed = reader.parse(md); + var walker = parsed.walker(); + var event, node; + while ((event = walker.next())) { + node = event.node; + if (event.entering && node.type == 'link') { + if (node.destination.startsWith('@') && + node.destination.endsWith('.ed25519')) { + node.destination = '#' + node.destination; + } + } + } + return writer.render(parsed); +} \ No newline at end of file diff --git a/apps/cory/index/tf.js b/apps/cory/index/tf.js index 766be2d5..3a65a219 100644 --- a/apps/cory/index/tf.js +++ b/apps/cory/index/tf.js @@ -194,14 +194,7 @@ window.addEventListener('load', function() { return undefined; } }, - markdown: function(md) { - if (!md) { - return; - } - var reader = new commonmark.Parser({safe: true}); - var writer = new commonmark.HtmlRenderer(); - return writer.render(reader.parse(md)); - }, + markdown: markdown, refresh: function() { window.parent.postMessage({refresh: true}, '*'); },