mirror of
https://gitea.phreedom.club/localhost_frssoft/bloat.git
synced 2024-11-22 20:59:21 +02:00
Use local url for for mentioned users
This commit is contained in:
parent
3280af21ed
commit
889f8da496
|
@ -28,7 +28,8 @@ type renderer struct {
|
||||||
func NewRenderer(templateGlobPattern string) (r *renderer, err error) {
|
func NewRenderer(templateGlobPattern string) (r *renderer, err error) {
|
||||||
t := template.New("default")
|
t := template.New("default")
|
||||||
t, err = t.Funcs(template.FuncMap{
|
t, err = t.Funcs(template.FuncMap{
|
||||||
"WithEmojis": WithEmojis,
|
"EmojiFilter": EmojiFilter,
|
||||||
|
"StatusContentFilter": StatusContentFilter,
|
||||||
"DisplayInteractionCount": DisplayInteractionCount,
|
"DisplayInteractionCount": DisplayInteractionCount,
|
||||||
"TimeSince": TimeSince,
|
"TimeSince": TimeSince,
|
||||||
"FormatTimeRFC3339": FormatTimeRFC3339,
|
"FormatTimeRFC3339": FormatTimeRFC3339,
|
||||||
|
@ -70,12 +71,24 @@ func (r *renderer) RenderUserPage(ctx context.Context, writer io.Writer, data *U
|
||||||
return r.template.ExecuteTemplate(writer, "user.tmpl", data)
|
return r.template.ExecuteTemplate(writer, "user.tmpl", data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func WithEmojis(content string, emojis []mastodon.Emoji) string {
|
|
||||||
var emojiNameContentPair []string
|
func EmojiFilter(content string, emojis []mastodon.Emoji) string {
|
||||||
|
var replacements []string
|
||||||
for _, e := range emojis {
|
for _, e := range emojis {
|
||||||
emojiNameContentPair = append(emojiNameContentPair, ":"+e.ShortCode+":", "<img class=\"status-emoji\" src=\""+e.URL+"\" alt=\""+e.ShortCode+"\" />")
|
replacements = append(replacements, ":"+e.ShortCode+":", "<img class=\"status-emoji\" src=\""+e.URL+"\" alt=\""+e.ShortCode+"\" />")
|
||||||
}
|
}
|
||||||
return strings.NewReplacer(emojiNameContentPair...).Replace(content)
|
return strings.NewReplacer(replacements...).Replace(content)
|
||||||
|
}
|
||||||
|
|
||||||
|
func StatusContentFilter(content string, emojis []mastodon.Emoji, mentions []mastodon.Mention) string {
|
||||||
|
var replacements []string
|
||||||
|
for _, e := range emojis {
|
||||||
|
replacements = append(replacements, ":"+e.ShortCode+":", "<img class=\"status-emoji\" src=\""+e.URL+"\" alt=\""+e.ShortCode+"\" />")
|
||||||
|
}
|
||||||
|
for _, m := range mentions {
|
||||||
|
replacements = append(replacements, "\""+m.URL+"\"", "\"/user/"+m.ID+"\"")
|
||||||
|
}
|
||||||
|
return strings.NewReplacer(replacements...).Replace(content)
|
||||||
}
|
}
|
||||||
|
|
||||||
func DisplayInteractionCount(c int64) string {
|
func DisplayInteractionCount(c int64) string {
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
</a>
|
</a>
|
||||||
<div>
|
<div>
|
||||||
<div>
|
<div>
|
||||||
<span class="status-dname"> {{WithEmojis .Account.DisplayName .Account.Emojis}} </span>
|
<span class="status-dname"> {{EmojiFilter .Account.DisplayName .Account.Emojis}} </span>
|
||||||
<span class="icon dripicons-user-group"></span>
|
<span class="icon dripicons-user-group"></span>
|
||||||
followed you
|
followed you
|
||||||
</div>
|
</div>
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
</a>
|
</a>
|
||||||
<div>
|
<div>
|
||||||
<div>
|
<div>
|
||||||
<span class="status-dname"> {{WithEmojis .Account.DisplayName .Account.Emojis}} </span>
|
<span class="status-dname"> {{EmojiFilter .Account.DisplayName .Account.Emojis}} </span>
|
||||||
<span class="icon dripicons-retweet retweeted"></span>
|
<span class="icon dripicons-retweet retweeted"></span>
|
||||||
retweeted your post
|
retweeted your post
|
||||||
</div>
|
</div>
|
||||||
|
@ -46,7 +46,7 @@
|
||||||
</a>
|
</a>
|
||||||
<div>
|
<div>
|
||||||
<div>
|
<div>
|
||||||
<span class="status-dname"> {{WithEmojis .Account.DisplayName .Account.Emojis}} </span>
|
<span class="status-dname"> {{EmojiFilter .Account.DisplayName .Account.Emojis}} </span>
|
||||||
<span class="icon dripicons-star liked"></span>
|
<span class="icon dripicons-star liked"></span>
|
||||||
liked your post
|
liked your post
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<a href="/user/{{.Account.ID}}" >
|
<a href="/user/{{.Account.ID}}" >
|
||||||
<img class="status-profile-img" src="{{.Account.AvatarStatic}}" alt="profile-avatar" />
|
<img class="status-profile-img" src="{{.Account.AvatarStatic}}" alt="profile-avatar" />
|
||||||
</a>
|
</a>
|
||||||
<span class="status-dname"> {{WithEmojis .Account.DisplayName .Account.Emojis}} </span>
|
<span class="status-dname"> {{EmojiFilter .Account.DisplayName .Account.Emojis}} </span>
|
||||||
<span class="icon dripicons-retweet retweeted"></span>
|
<span class="icon dripicons-retweet retweeted"></span>
|
||||||
retweeted
|
retweeted
|
||||||
</div>
|
</div>
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
<div class="status">
|
<div class="status">
|
||||||
{{if not .HideAccountInfo}}
|
{{if not .HideAccountInfo}}
|
||||||
<div class="status-name">
|
<div class="status-name">
|
||||||
<span class="status-dname"> {{WithEmojis .Account.DisplayName .Account.Emojis}} </span>
|
<span class="status-dname"> {{EmojiFilter .Account.DisplayName .Account.Emojis}} </span>
|
||||||
<a href="/user/{{.Account.ID}}" >
|
<a href="/user/{{.Account.ID}}" >
|
||||||
<span class="status-uname"> {{.Account.Acct}} </span>
|
<span class="status-uname"> {{.Account.Acct}} </span>
|
||||||
</a>
|
</a>
|
||||||
|
@ -41,7 +41,7 @@
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
<div class="status-content"> {{WithEmojis .Content .Emojis}} </div>
|
<div class="status-content"> {{StatusContentFilter .Content .Emojis .Mentions}} </div>
|
||||||
<div class="status-media-container">
|
<div class="status-media-container">
|
||||||
{{range .MediaAttachments}}
|
{{range .MediaAttachments}}
|
||||||
{{if eq .Type "image"}}
|
{{if eq .Type "image"}}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="user-profile-details-container">
|
<div class="user-profile-details-container">
|
||||||
<div>
|
<div>
|
||||||
<span class="status-dname"> {{WithEmojis .User.DisplayName .User.Emojis}} </span>
|
<span class="status-dname"> {{EmojiFilter .User.DisplayName .User.Emojis}} </span>
|
||||||
<span class="status-uname"> {{.User.Acct}} </span>
|
<span class="status-uname"> {{.User.Acct}} </span>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
|
Loading…
Reference in New Issue