-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathtelegram_instant_view.templ
83 lines (79 loc) · 2.29 KB
/
telegram_instant_view.templ
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
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>
}