mirror of
https://gitea.phreedom.club/localhost_frssoft/bloat.git
synced 2024-11-27 01:13:00 +00: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) {
|
||||
t := template.New("default")
|
||||
t, err = t.Funcs(template.FuncMap{
|
||||
"WithEmojis": WithEmojis,
|
||||
"EmojiFilter": EmojiFilter,
|
||||
"StatusContentFilter": StatusContentFilter,
|
||||
"DisplayInteractionCount": DisplayInteractionCount,
|
||||
"TimeSince": TimeSince,
|
||||
"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)
|
||||
}
|
||||
|
||||
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 {
|
||||
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 {
|
||||
|
@ -11,7 +11,7 @@
|
||||
</a>
|
||||
<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>
|
||||
followed you
|
||||
</div>
|
||||
@ -31,7 +31,7 @@
|
||||
</a>
|
||||
<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>
|
||||
retweeted your post
|
||||
</div>
|
||||
@ -46,7 +46,7 @@
|
||||
</a>
|
||||
<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>
|
||||
liked your post
|
||||
</div>
|
||||
|
@ -4,7 +4,7 @@
|
||||
<a href="/user/{{.Account.ID}}" >
|
||||
<img class="status-profile-img" src="{{.Account.AvatarStatic}}" alt="profile-avatar" />
|
||||
</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>
|
||||
retweeted
|
||||
</div>
|
||||
@ -22,7 +22,7 @@
|
||||
<div class="status">
|
||||
{{if not .HideAccountInfo}}
|
||||
<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}}" >
|
||||
<span class="status-uname"> {{.Account.Acct}} </span>
|
||||
</a>
|
||||
@ -41,7 +41,7 @@
|
||||
{{end}}
|
||||
{{end}}
|
||||
</div>
|
||||
<div class="status-content"> {{WithEmojis .Content .Emojis}} </div>
|
||||
<div class="status-content"> {{StatusContentFilter .Content .Emojis .Mentions}} </div>
|
||||
<div class="status-media-container">
|
||||
{{range .MediaAttachments}}
|
||||
{{if eq .Type "image"}}
|
||||
|
@ -9,7 +9,7 @@
|
||||
</div>
|
||||
<div class="user-profile-details-container">
|
||||
<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>
|
||||
</div>
|
||||
<div>
|
||||
|
Loading…
Reference in New Issue
Block a user