Bluesky app fork with some witchin' additions 💫

embedr: improved HTML snippet, with links (#3559)

authored by bnewbold.net and committed by

GitHub f265d65a 4b699483

+12 -4
+12 -4
bskyweb/cmd/embedr/snippet.go
··· 23 return "", err 24 } 25 26 - const tpl = `<blockquote class="bluesky-embed" data-bluesky-uri="{{ .PostURI }}" data-bluesky-cid="{{ .PostCID }}"><p{{ if .PostLang }} lang="{{ .PostLang }}"{{ end }}>{{ .PostText }}</p>&mdash; {{ .PostAuthor }} {{ .PostIndexedAt }}</blockquote><script async src="{{ .WidgetURL }}" charset="utf-8"></script>` 27 28 t, err := template.New("snippet").Parse(tpl) 29 if err != nil { 30 log.Error("template parse error", "err", err) 31 return "", err 32 } 33 34 var lang string ··· 41 } else { 42 authorName = fmt.Sprintf("@%s", postView.Author.Handle) 43 } 44 - fmt.Println(postView.Uri) 45 - fmt.Println(fmt.Sprintf("%s", postView.Uri)) 46 data := struct { 47 PostURI template.URL 48 PostCID string ··· 50 PostText string 51 PostAuthor string 52 PostIndexedAt string 53 WidgetURL template.URL 54 }{ 55 PostURI: template.URL(postView.Uri), ··· 57 PostLang: lang, 58 PostText: post.Text, 59 PostAuthor: authorName, 60 - PostIndexedAt: postView.IndexedAt, // TODO: createdAt? 61 WidgetURL: template.URL("https://embed.bsky.app/static/embed.js"), 62 } 63
··· 23 return "", err 24 } 25 26 + const tpl = `<blockquote class="bluesky-embed" data-bluesky-uri="{{ .PostURI }}" data-bluesky-cid="{{ .PostCID }}"><p{{ if .PostLang }} lang="{{ .PostLang }}"{{ end }}>{{ .PostText }}</p>&mdash; <a href="{{ .ProfileURL }}">{{ .PostAuthor }}</a> <a href="{{ .PostURL }}">{{ .PostIndexedAt }}</a></blockquote><script async src="{{ .WidgetURL }}" charset="utf-8"></script>` 27 28 t, err := template.New("snippet").Parse(tpl) 29 if err != nil { 30 log.Error("template parse error", "err", err) 31 return "", err 32 + } 33 + 34 + sortAt := postView.IndexedAt 35 + createdAt, err := syntax.ParseDatetime(post.CreatedAt) 36 + if nil == err && createdAt.String() < sortAt { 37 + sortAt = createdAt.String() 38 } 39 40 var lang string ··· 47 } else { 48 authorName = fmt.Sprintf("@%s", postView.Author.Handle) 49 } 50 data := struct { 51 PostURI template.URL 52 PostCID string ··· 54 PostText string 55 PostAuthor string 56 PostIndexedAt string 57 + ProfileURL template.URL 58 + PostURL template.URL 59 WidgetURL template.URL 60 }{ 61 PostURI: template.URL(postView.Uri), ··· 63 PostLang: lang, 64 PostText: post.Text, 65 PostAuthor: authorName, 66 + PostIndexedAt: sortAt, 67 + ProfileURL: template.URL(fmt.Sprintf("https://bsky.app/profile/%s?ref_src=embed", aturi.Authority())), 68 + PostURL: template.URL(fmt.Sprintf("https://bsky.app/profile/%s/post/%s?ref_src=embed", aturi.Authority(), aturi.RecordKey())), 69 WidgetURL: template.URL("https://embed.bsky.app/static/embed.js"), 70 } 71