mirror of
https://github.com/aljazceru/njump.git
synced 2025-12-17 14:24:27 +01:00
Open the main page when clicking on the widget
This commit is contained in:
@@ -108,6 +108,7 @@ templ calendarEventTemplate(params CalendarPageParams, isEmbed bool) {
|
|||||||
if isEmbed {
|
if isEmbed {
|
||||||
@embeddedPageTemplate(
|
@embeddedPageTemplate(
|
||||||
params.Event,
|
params.Event,
|
||||||
|
params.NeventNaked,
|
||||||
isEmbed,
|
isEmbed,
|
||||||
) {
|
) {
|
||||||
@calendarEventInnerBlock(params)
|
@calendarEventInnerBlock(params)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
templ embeddedPageTemplate(
|
templ embeddedPageTemplate(
|
||||||
event EnhancedEvent,
|
event EnhancedEvent,
|
||||||
|
NeventNaked string,
|
||||||
isEmbed bool,
|
isEmbed bool,
|
||||||
) {
|
) {
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
@@ -15,7 +16,10 @@ templ embeddedPageTemplate(
|
|||||||
href="/njump/static/tailwind-bundle.min.css"
|
href="/njump/static/tailwind-bundle.min.css"
|
||||||
/>
|
/>
|
||||||
</head>
|
</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>
|
<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">
|
<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)
|
@authorHeaderTemplate(event.author)
|
||||||
@@ -50,6 +54,14 @@ for (var i = 0; i < links.length; i++) {
|
|||||||
links[i].setAttribute('target', '_blank');
|
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 () {
|
window.addEventListener('load', function () {
|
||||||
var contentHeight = document.body.scrollHeight
|
var contentHeight = document.body.scrollHeight
|
||||||
window.parent.postMessage({height: contentHeight}, '*')
|
window.parent.postMessage({height: contentHeight}, '*')
|
||||||
|
|||||||
@@ -13,13 +13,13 @@ templ embeddedProfileTemplate(params ProfilePageParams) {
|
|||||||
/>
|
/>
|
||||||
</head>
|
</head>
|
||||||
<body
|
<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>
|
<style> ::-webkit-scrollbar { display: none; } </style>
|
||||||
<div
|
<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"
|
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">
|
||||||
<div class="w-full break-words print:w-full">
|
<div class="w-full break-words print:w-full">
|
||||||
<header class="mb-4 max-w-full">
|
<header class="mb-4 max-w-full">
|
||||||
@@ -77,7 +77,7 @@ templ embeddedProfileTemplate(params ProfilePageParams) {
|
|||||||
</div>
|
</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 class="-ml-4 mb-6 h-1.5 w-1/3 bg-zinc-100 dark:bg-zinc-700 sm:-ml-2.5"></div>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
|
||||||
<div class="text-sm leading-3 text-neutral-400">
|
<div class="text-sm leading-3 text-neutral-400">
|
||||||
This note has been published on Nostr and is embedded via Njump,
|
This note has been published on Nostr and is embedded via Njump,
|
||||||
<a href="/" target="_new" class="underline">learn more</a>
|
<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');
|
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 () {
|
window.addEventListener('load', function () {
|
||||||
var contentHeight = document.body.scrollHeight
|
var contentHeight = document.body.scrollHeight
|
||||||
window.parent.postMessage({height: contentHeight}, '*')
|
window.parent.postMessage({height: contentHeight}, '*')
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ templ fileMetadataTemplate(params FileMetadataPageParams, isEmbed bool) {
|
|||||||
if isEmbed {
|
if isEmbed {
|
||||||
@embeddedPageTemplate(
|
@embeddedPageTemplate(
|
||||||
params.Event,
|
params.Event,
|
||||||
|
params.NeventNaked,
|
||||||
isEmbed,
|
isEmbed,
|
||||||
) {
|
) {
|
||||||
@fileMetadataInnerBlock(params)
|
@fileMetadataInnerBlock(params)
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ templ liveEventTemplate(params LiveEventPageParams, isEmbed bool) {
|
|||||||
if isEmbed {
|
if isEmbed {
|
||||||
@embeddedPageTemplate(
|
@embeddedPageTemplate(
|
||||||
params.Event,
|
params.Event,
|
||||||
|
params.NeventNaked,
|
||||||
isEmbed,
|
isEmbed,
|
||||||
) {
|
) {
|
||||||
@liveEventInnerBlock(params)
|
@liveEventInnerBlock(params)
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ templ liveEventMessageTemplate(params LiveEventMessagePageParams, isEmbed bool)
|
|||||||
if isEmbed {
|
if isEmbed {
|
||||||
@embeddedPageTemplate(
|
@embeddedPageTemplate(
|
||||||
params.Event,
|
params.Event,
|
||||||
|
params.NeventNaked,
|
||||||
isEmbed,
|
isEmbed,
|
||||||
) {
|
) {
|
||||||
@liveEventMessageInnerBlock(params)
|
@liveEventMessageInnerBlock(params)
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ templ noteTemplate(params NotePageParams, isEmbed bool) {
|
|||||||
if isEmbed {
|
if isEmbed {
|
||||||
@embeddedPageTemplate(
|
@embeddedPageTemplate(
|
||||||
params.Event,
|
params.Event,
|
||||||
|
params.NeventNaked,
|
||||||
isEmbed,
|
isEmbed,
|
||||||
) {
|
) {
|
||||||
@noteInnerBlock(params)
|
@noteInnerBlock(params)
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ templ wikiEventTemplate(params WikiPageParams, isEmbed bool) {
|
|||||||
if isEmbed {
|
if isEmbed {
|
||||||
@embeddedPageTemplate(
|
@embeddedPageTemplate(
|
||||||
params.Event,
|
params.Event,
|
||||||
|
params.NeventNaked,
|
||||||
isEmbed,
|
isEmbed,
|
||||||
) {
|
) {
|
||||||
@wikiInnerBlock(params)
|
@wikiInnerBlock(params)
|
||||||
|
|||||||
Reference in New Issue
Block a user