mirror of
https://github.com/aljazceru/njump.git
synced 2025-12-17 06:14:22 +01:00
84 lines
2.3 KiB
Plaintext
84 lines
2.3 KiB
Plaintext
package main
|
|
|
|
import (
|
|
"html/template"
|
|
|
|
"github.com/nbd-wtf/go-nostr/sdk"
|
|
)
|
|
|
|
type TelegramInstantViewParams struct {
|
|
Video string
|
|
VideoType string
|
|
Image string
|
|
Summary template.HTML
|
|
Content template.HTML
|
|
Description string
|
|
Subject string
|
|
Metadata sdk.ProfileMetadata
|
|
AuthorLong string
|
|
CreatedAt string
|
|
ParentNevent string
|
|
}
|
|
|
|
templ telegramInstantViewTemplate(params TelegramInstantViewParams) {
|
|
<meta charset="UTF-8"/>
|
|
<!-- check https://nikstar.me/post/instant-view/ for more information on how this was set up -->
|
|
<!-- required stuff so telegram treats us like a medium.com article -->
|
|
<meta property="al:android:app_name" content="Medium"/>
|
|
<meta property="article:published_time" content={ params.CreatedAt }/>
|
|
<!-- stuff that goes in the actual telegram message preview -->
|
|
<meta property="og:site_name" content={ params.AuthorLong }/>
|
|
if params.Description != "" {
|
|
<meta property="og:description" content={ params.Description }/>
|
|
}
|
|
<!---->
|
|
if params.Image != "" {
|
|
<meta property="og:image" content={ params.Image }/>
|
|
}
|
|
<!---->
|
|
if params.Video != "" {
|
|
<meta property="og:video" content={ params.Video }/>
|
|
<meta property="og:video:secure_url" content={ params.Video }/>
|
|
<meta property="og:video:type" content={ "video/" + params.VideoType }/>
|
|
}
|
|
<!-- stuff that affects the content inside the preview window -->
|
|
<meta name="author" content={ params.Metadata.ShortName() + " on Nostr" }/>
|
|
<meta name="telegram:channel" content="@nostr_protocol"/>
|
|
<!-- basic content of the preview window -->
|
|
<article>
|
|
<h1>
|
|
if params.Subject != "" {
|
|
{ params.Subject }
|
|
} else {
|
|
<a href={ templ.URL("/" + params.Metadata.Npub()) }>
|
|
{ params.Metadata.ShortName() }
|
|
</a>
|
|
if params.ParentNevent == "" {
|
|
on Nostr:
|
|
} else {
|
|
on Nostr (reply):
|
|
}
|
|
}
|
|
</h1>
|
|
if params.ParentNevent != "" {
|
|
<aside>
|
|
in reply to{ " " }
|
|
@templ.Raw(replaceNostrURLsWithHTMLTags(nostrNoteNeventMatcher, "nostr:"+params.ParentNevent))
|
|
</aside>
|
|
}
|
|
<!---->
|
|
if params.Summary != "" {
|
|
<aside>
|
|
@templ.Raw(params.Summary)
|
|
</aside>
|
|
}
|
|
<!---->
|
|
@templ.Raw(params.Content)
|
|
if params.Subject != "" {
|
|
<aside>
|
|
<a href={ templ.URL("/" + params.Metadata.Npub()) }>{ params.Metadata.ShortName() }</a>
|
|
</aside>
|
|
}
|
|
</article>
|
|
}
|