Skip to content

Commit

Permalink
feat: add emojify filter and allow emojis in comments
Browse files Browse the repository at this point in the history
Signed-off-by: Manfred Touron <94029+moul@users.noreply.github.com>
  • Loading branch information
moul committed Nov 9, 2020
1 parent f1a6184 commit ec7143d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/sgtm/page_post.tmpl.html
Expand Up @@ -25,7 +25,7 @@
<div class="col-md-8">
<h1>{{.Post.Post.Title}}</h1>
<p>by <a href="{{.Post.Post.Author.CanonicalURL}}"><img height="30" src="{{.Post.Post.Author.Avatar}}" />@{{.Post.Post.Author.Slug}}</a></p>

{{if .Post.Post.IsSoundCloud}}
<iframe id="soundcloud-player" width=100% height=166 scrolling=no frameborder=no allow=autoplay
src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/{{.Post.Post.SoundCloudID}}{{with .Post.Post.SoundCloudSecretToken}}%3Fsecret_token%3D{{.}}{{end}}&color=%23ff5500&auto_play=false&hide_related=true&show_comments=false&show_user=true&show_reposts=false&show_teaser=false"></iframe>
Expand Down Expand Up @@ -63,7 +63,7 @@ <h1>{{.Post.Post.Title}}</h1>
<a href="{{.Author.CanonicalURL}}"><h5 class="mt-0 d-inline-block">{{.Author.DisplayName}}</h5></a>
<a href="{{$root.Post.Post.CanonicalURL}}#comment-{{$comment.ID}}"><small class="text-muted">{{.CreatedAt | fromUnixNano | prettyAgo}}</small></a>
<div class="media">
{{$comment.Body}}
{{$comment.Body | emojify}}
</div>
</div>
</div>
Expand Down
4 changes: 4 additions & 0 deletions pkg/sgtm/templates.go
Expand Up @@ -13,6 +13,7 @@ import (
packr "github.com/gobuffalo/packr/v2"
striptags "github.com/grokify/html-strip-tags-go"
"github.com/hako/durafmt"
emoji "github.com/kyokomi/emoji/v2"
"github.com/microcosm-cc/bluemonday"
blackfriday "github.com/russross/blackfriday/v2"
"go.uber.org/zap"
Expand Down Expand Up @@ -105,6 +106,9 @@ func loadTemplates(box *packr.Box, filenames ...string) *template.Template {
shorten = strings.TrimPrefix(shorten, "www.")
return shorten
}
funcmap["emojify"] = func(input string) string {
return emoji.Sprint(input)
}
funcmap["newline"] = func() string {
return "\n"
}
Expand Down

0 comments on commit ec7143d

Please sign in to comment.