From 2681cdc7766864f0c77b40a095a71d657dc9f3a0 Mon Sep 17 00:00:00 2001 From: ansxor Date: Thu, 26 Dec 2024 08:36:23 -0500 Subject: [PATCH 1/4] added blog permalink --- src/Views/page.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Views/page.js b/src/Views/page.js index 97576a8..9b4e264 100644 --- a/src/Views/page.js +++ b/src/Views/page.js @@ -21,6 +21,7 @@ class PageView extends BaseView { }, requests: [ {type: 'content', fields: "*", query: `${field} = @key`}, + {name: 'Pcontent', type: 'content', fields: "*", query: `id = @content.parentId`}, {type: 'message', fields: "*", query: "contentId IN @content.id AND !notdeleted()", order: 'id_desc', limit: 30}, {name: 'Mpinned', type: 'message', fields: "*", query: "id IN @content.values.pinned"}, {type: 'user', fields: "*", query: "id IN @content.createUserId OR id IN @message.createUserId OR id IN @message.editUserId OR id IN @Mpinned.createUserId OR id IN @Mpinned.editUserId"}, @@ -90,7 +91,7 @@ class PageView extends BaseView { } }) } - Render({message, content:[page], Mpinned:pinned, user, watch}) { + Render({message, content:[page], Mpinned:pinned, user, watch, Pcontent:[parent]}) { this.page_id = page.id // header // @@ -100,6 +101,21 @@ class PageView extends BaseView { {icon:"✏️", label:"edit", href:"#editpage/"+page.id}, {icon:"🗂️", label:"childs", href:"#category/"+page.id}, ]) + + if (!OPTS.has('dev')) { + const domain = Req.server.split("/")[0] + let href = undefined + if (Object.hasOwn(page.values, "share") && page.values.share) { + href = `https://${domain}/share/${page.hash}`; + } else if (parent && Object.hasOwn(parent.values, "share") && parent.values.share && parent.literalType==="resource") { + href = `https://${domain}/share/${parent.hash}/${page.hash}`; + } + if (href) { + this.Slot.add_header_links([ + {icon:"🌐", label:"blog", href} + ]) + } + } // init components // Object.assign(Lp.users, user) From 3288acde1ffc1f495df9132833b640fe2d06f7f3 Mon Sep 17 00:00:00 2001 From: ansxor Date: Thu, 26 Dec 2024 08:47:57 -0500 Subject: [PATCH 2/4] added target parameter to header links --- src/Views/page.js | 2 +- src/navigate.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Views/page.js b/src/Views/page.js index 9b4e264..f7451c8 100644 --- a/src/Views/page.js +++ b/src/Views/page.js @@ -112,7 +112,7 @@ class PageView extends BaseView { } if (href) { this.Slot.add_header_links([ - {icon:"🌐", label:"blog", href} + {icon:"🌐", label:"blog", href, target: "_blank"} ]) } } diff --git a/src/navigate.js b/src/navigate.js index b18660a..1e20f72 100644 --- a/src/navigate.js +++ b/src/navigate.js @@ -66,6 +66,7 @@ class ViewSlot { for (let x of items) { let a = document.createElement('a') a.href = x.href + a.target = x['target'] ?? '_self' let lb = document.createElement('span') lb.textContent = x.label a.append(lb) From 3cb7c0cb892c999ecebf51a81307820063f38282 Mon Sep 17 00:00:00 2001 From: ansxor Date: Thu, 26 Dec 2024 14:19:02 -0500 Subject: [PATCH 3/4] change check for blog --- src/Views/page.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Views/page.js b/src/Views/page.js index f7451c8..30279c0 100644 --- a/src/Views/page.js +++ b/src/Views/page.js @@ -105,9 +105,9 @@ class PageView extends BaseView { if (!OPTS.has('dev')) { const domain = Req.server.split("/")[0] let href = undefined - if (Object.hasOwn(page.values, "share") && page.values.share) { + if (page.values.share) { href = `https://${domain}/share/${page.hash}`; - } else if (parent && Object.hasOwn(parent.values, "share") && parent.values.share && parent.literalType==="resource") { + } else if (parent?.values.share && parent?.literalType==="resource") { href = `https://${domain}/share/${parent.hash}/${page.hash}`; } if (href) { From 9a0f23cd146fd34fa25c9392f38387ddcbda7908 Mon Sep 17 00:00:00 2001 From: ansxor Date: Thu, 26 Dec 2024 14:22:36 -0500 Subject: [PATCH 4/4] no null coalescing for You --- src/navigate.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/navigate.js b/src/navigate.js index 1e20f72..bb89b8b 100644 --- a/src/navigate.js +++ b/src/navigate.js @@ -66,7 +66,7 @@ class ViewSlot { for (let x of items) { let a = document.createElement('a') a.href = x.href - a.target = x['target'] ?? '_self' + a.target = x['target'] || '_self' let lb = document.createElement('span') lb.textContent = x.label a.append(lb)