From ac0482d7f5bd4c7f5b97f7faf7bcf3b2d90d8839 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Fri, 25 Feb 2022 18:24:48 +0000 Subject: [PATCH] Show images inline. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3844 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- apps/cory/index.json | 2 +- apps/cory/index/app.js | 3 +-- apps/cory/index/tf-shared.js | 20 +++++++++++++------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/apps/cory/index.json b/apps/cory/index.json index d00972d1..82342902 100644 --- a/apps/cory/index.json +++ b/apps/cory/index.json @@ -1 +1 @@ -{"type":"tildefriends-app","files":{"app.js":"&iSr0GObnkNKOpDGUkCikfwI7XI4mg6E3YNazCHSza2A=.sha256","index.html":"&xCI4SATYvlJkVX5EdlRROoDSMWlajF+wDFrWSUYZqd8=.sha256","vue-material.js":"&K5cdLqXYCENPak/TCINHQhyJhpS4G9DlZHGwoh/LF2g=.sha256","tf-user.js":"&DdJwZYEo7AqFyutYMvEjykoVXxdHVog0UXye6Sbo0TU=.sha256","tf-message.js":"&kIpc5B2dt4oefsTgNASz2cVte3WRO0k2NCYJYRzu/MA=.sha256","tf.js":"&WvteLAg4G92YOUO3/B36kmar5lqFq8Pil4rsy7uFNDY=.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":"&+qPP3g4CAUlkt8K4iBCZ+F5Fy6N7fu6MggvSVss2juE=.sha256"}} \ No newline at end of file +{"type":"tildefriends-app","files":{"app.js":"&xynMjji35hfaE7anTfEM8uAg33s4Y2ffkbq1rPU4dqY=.sha256","index.html":"&xCI4SATYvlJkVX5EdlRROoDSMWlajF+wDFrWSUYZqd8=.sha256","vue-material.js":"&K5cdLqXYCENPak/TCINHQhyJhpS4G9DlZHGwoh/LF2g=.sha256","tf-user.js":"&DdJwZYEo7AqFyutYMvEjykoVXxdHVog0UXye6Sbo0TU=.sha256","tf-message.js":"&kIpc5B2dt4oefsTgNASz2cVte3WRO0k2NCYJYRzu/MA=.sha256","tf.js":"&WvteLAg4G92YOUO3/B36kmar5lqFq8Pil4rsy7uFNDY=.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":"&X+zVM6t/QOUF/s0mqWWUWD7tMjzcCaflTy3a8zFAEH8=.sha256"}} \ No newline at end of file diff --git a/apps/cory/index/app.js b/apps/cory/index/app.js index 59df9cb6..7bed31f1 100644 --- a/apps/cory/index/app.js +++ b/apps/cory/index/app.js @@ -232,8 +232,7 @@ async function getRecentPostIds(db, id, ids, limit) { "WHERE "+ " rowid > ? AND "+ " rowid <= ? AND "+ - " author IN (" + ids_batch.map(x => '?').join(", ") + ") AND "+ - " json_extract(content, '$.type') = 'post' "+ + " author IN (" + ids_batch.map(x => '?').join(", ") + ") "+ "ORDER BY timestamp DESC LIMIT ?", [].concat([f.rowid, row_id_max], ids_batch, [limit]), function(row) { diff --git a/apps/cory/index/tf-shared.js b/apps/cory/index/tf-shared.js index 7c7f1212..31f7900e 100644 --- a/apps/cory/index/tf-shared.js +++ b/apps/cory/index/tf-shared.js @@ -8,13 +8,19 @@ function markdown(md) { 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; - } else if (node.destination.startsWith('%') && - node.destination.endsWith('.sha256')) { - node.destination = '#' + node.destination; + if (event.entering) { + if (node.type == 'link') { + if (node.destination.startsWith('@') && + node.destination.endsWith('.ed25519')) { + node.destination = '#' + node.destination; + } else if (node.destination.startsWith('%') && + node.destination.endsWith('.sha256')) { + node.destination = '#' + node.destination; + } + } else if (node.type == 'image') { + if (node.destination.startsWith('&')) { + node.destination = '/' + node.destination + '/view'; + } } } }