Open the main page when clicking on the widget

This commit is contained in:
dtonon
2024-08-13 19:29:12 +02:00
parent 2959005222
commit d68ce0daba
8 changed files with 81 additions and 55 deletions

View File

@@ -108,6 +108,7 @@ templ calendarEventTemplate(params CalendarPageParams, isEmbed bool) {
if isEmbed {
@embeddedPageTemplate(
params.Event,
params.NeventNaked,
isEmbed,
) {
@calendarEventInnerBlock(params)

View File

@@ -2,6 +2,7 @@ package main
templ embeddedPageTemplate(
event EnhancedEvent,
NeventNaked string,
isEmbed bool,
) {
<!DOCTYPE html>
@@ -15,7 +16,10 @@ templ embeddedPageTemplate(
href="/njump/static/tailwind-bundle.min.css"
/>
</head>
<body class="relative bg-white text-gray-600 dark:bg-neutral-900 dark:text-neutral-50 print:text-black sm:items-center sm:justify-center">
<body
class="relative bg-white text-gray-600 dark:bg-neutral-900 dark:text-neutral-50 print:text-black sm:items-center sm:justify-center cursor-pointer"
event-data={ templ.JSONString(NeventNaked) }
>
<style> ::-webkit-scrollbar { display: none; } </style>
<div class="mx-auto w-full max-w-screen-2xl justify-between gap-10 overflow-visible px-4 pb-4 pt-4 print:w-full sm:w-11/12 md:w-10/12 lg:w-9/12">
@authorHeaderTemplate(event.author)
@@ -50,6 +54,14 @@ for (var i = 0; i < links.length; i++) {
links[i].setAttribute('target', '_blank');
}
// Open the njump page if the target is not a link
document.onclick = function(event) {
if (event.target.tagName.toLowerCase() !== 'a') {
const neventNaked = JSON.parse(document.body.getAttribute('event-data'));
window.open("/" + neventNaked, '_blank');
}
};
window.addEventListener('load', function () {
var contentHeight = document.body.scrollHeight
window.parent.postMessage({height: contentHeight}, '*')

View File

@@ -13,13 +13,13 @@ templ embeddedProfileTemplate(params ProfilePageParams) {
/>
</head>
<body
class="relative bg-white text-gray-600 dark:bg-neutral-900 dark:text-neutral-50 print:text-black"
class="relative bg-white text-gray-600 dark:bg-neutral-900 dark:text-neutral-50 print:text-black cursor-pointer"
npub-data={ templ.JSONString(params.Metadata.Npub()) }
>
<style> ::-webkit-scrollbar { display: none; } </style>
<div
class="mx-auto w-full max-w-screen-2xl justify-between gap-10 overflow-visible px-4 pb-4 pt-4 print:w-full sm:w-11/12 md:w-10/12 lg:w-9/12"
>
<a href={ templ.URL("/" + params.Metadata.Npub()) } target="_new" class="no-underline">
<div class="w-full break-words">
<div class="w-full break-words print:w-full">
<header class="mb-4 max-w-full">
@@ -77,7 +77,7 @@ templ embeddedProfileTemplate(params ProfilePageParams) {
</div>
<div class="-ml-4 mb-6 h-1.5 w-1/3 bg-zinc-100 dark:bg-zinc-700 sm:-ml-2.5"></div>
</div>
</a>
<div class="text-sm leading-3 text-neutral-400">
This note has been published on Nostr and is embedded via Njump,
<a href="/" target="_new" class="underline">learn more</a>
@@ -100,6 +100,14 @@ for (var i = 0; i < links.length; i++) {
links[i].setAttribute('target', '_blank');
}
// Open the njump page if the target is not a link
document.onclick = function(event) {
if (event.target.tagName.toLowerCase() !== 'a') {
const npub = JSON.parse(document.body.getAttribute('npub-data'));
window.open("/" + npub, '_blank');
}
};
window.addEventListener('load', function () {
var contentHeight = document.body.scrollHeight
window.parent.postMessage({height: contentHeight}, '*')

View File

@@ -43,6 +43,7 @@ templ fileMetadataTemplate(params FileMetadataPageParams, isEmbed bool) {
if isEmbed {
@embeddedPageTemplate(
params.Event,
params.NeventNaked,
isEmbed,
) {
@fileMetadataInnerBlock(params)

View File

@@ -57,6 +57,7 @@ templ liveEventTemplate(params LiveEventPageParams, isEmbed bool) {
if isEmbed {
@embeddedPageTemplate(
params.Event,
params.NeventNaked,
isEmbed,
) {
@liveEventInnerBlock(params)

View File

@@ -23,6 +23,7 @@ templ liveEventMessageTemplate(params LiveEventMessagePageParams, isEmbed bool)
if isEmbed {
@embeddedPageTemplate(
params.Event,
params.NeventNaked,
isEmbed,
) {
@liveEventMessageInnerBlock(params)

View File

@@ -37,6 +37,7 @@ templ noteTemplate(params NotePageParams, isEmbed bool) {
if isEmbed {
@embeddedPageTemplate(
params.Event,
params.NeventNaked,
isEmbed,
) {
@noteInnerBlock(params)

View File

@@ -26,6 +26,7 @@ templ wikiEventTemplate(params WikiPageParams, isEmbed bool) {
if isEmbed {
@embeddedPageTemplate(
params.Event,
params.NeventNaked,
isEmbed,
) {
@wikiInnerBlock(params)