Compare commits
2 Commits
8b0c3eb963
...
05d82767ad
Author | SHA1 | Date | |
---|---|---|---|
05d82767ad | |||
882080cc51 |
2
Makefile
2
Makefile
@ -39,7 +39,7 @@ docker-publish:
|
||||
|
||||
.PHONY: run # Run the application
|
||||
run:
|
||||
@go run main.go@npm start
|
||||
@go run main.go
|
||||
|
||||
.PHONY: ci # Perform CI specific tasks to perform on a pull request
|
||||
ci:
|
||||
|
9
main.go
9
main.go
@ -75,19 +75,16 @@ func getTweet(w http.ResponseWriter, r *http.Request) {
|
||||
for _, emoji := range emojis {
|
||||
emojiCount += len([]byte(emoji)) - 1
|
||||
}
|
||||
|
||||
fmt.Println(tweet.FullText)
|
||||
|
||||
tweet.FullText = tweet.FullText[tweet.DisplayTextRange[0] : tweet.DisplayTextRange[1]+emojiCount]
|
||||
|
||||
for _, user := range tweet.Entities.User_mentions {
|
||||
tweet.FullText = strings.ReplaceAll(tweet.FullText, "@"+user.Screen_name, fmt.Sprintf("<a href=\"https://twitter.com/%s/\">@%s</a>", user.Screen_name, user.Screen_name))
|
||||
tweet.FullText = strings.ReplaceAll(tweet.FullText, "@"+user.Screen_name, fmt.Sprintf("<a rel=\"noopener\" target=\"_blank\" href=\"https://twitter.com/%s/\">@%s</a>", user.Screen_name, user.Screen_name))
|
||||
}
|
||||
for _, url := range tweet.Entities.Urls {
|
||||
tweet.FullText = strings.ReplaceAll(tweet.FullText, url.Url, fmt.Sprintf("<a href=\"https://twitter.com/%s/\">%s</a>", url.Expanded_url, url.Display_url))
|
||||
tweet.FullText = strings.ReplaceAll(tweet.FullText, url.Url, fmt.Sprintf("<a rel=\"noopener\" target=\"_blank\" href=\"https://twitter.com/%s/\">%s</a>", url.Expanded_url, url.Display_url))
|
||||
}
|
||||
for _, hashtag := range tweet.Entities.Hashtags {
|
||||
tweet.FullText = strings.ReplaceAll(tweet.FullText, "#"+hashtag.Text, fmt.Sprintf("<a href=\"https://twitter.com/hashtag/%s\">#%s</a>", hashtag.Text, hashtag.Text))
|
||||
tweet.FullText = strings.ReplaceAll(tweet.FullText, "#"+hashtag.Text, fmt.Sprintf("<a rel=\"noopener\" target=\"_blank\" href=\"https://twitter.com/hashtag/%s\">#%s</a>", hashtag.Text, hashtag.Text))
|
||||
}
|
||||
|
||||
templateFuncs := template.FuncMap{
|
||||
|
@ -16,14 +16,14 @@
|
||||
.tweetsvg.reply{font-size:15px;color:rgb(110, 118, 125);}
|
||||
</style>
|
||||
<blockquote class="tweetsvg" xmlns="http://www.w3.org/1999/xhtml">
|
||||
<a class="tweetsvg" href="https://twitter.com/{{ .User.ScreenName }}/"><img class="avatar-tweetsvg" alt="" src="data:image/jpeg;base64,{{ base64 .User.ProfileImageUrlHttps }}" /></a>
|
||||
<a rel="noopener" target="_blank" class="tweetsvg" href="https://twitter.com/{{ .User.ScreenName }}/"><img class="avatar-tweetsvg" alt="" src="data:image/jpeg;base64,{{ base64 .User.ProfileImageUrlHttps }}" /></a>
|
||||
|
||||
<a class="tweetsvg" href="https://twitter.com/{{ .User.ScreenName }}/"><h1 class="tweetsvg">{{ .User.Name }}</h1></a>
|
||||
<a rel="noopener" target="_blank" class="tweetsvg" href="https://twitter.com/{{ .User.ScreenName }}/"><h1 class="tweetsvg">{{ .User.Name }}</h1></a>
|
||||
|
||||
<a class="tweetsvg" href="https://twitter.com/{{ .User.ScreenName }}/"><h2 class="tweetsvg">@{{ .User.ScreenName }}</h2></a>
|
||||
<a rel="noopener" target="_blank" class="tweetsvg" href="https://twitter.com/{{ .User.ScreenName }}/"><h2 class="tweetsvg">@{{ .User.ScreenName }}</h2></a>
|
||||
|
||||
{{ if .InReplyToScreenName }}
|
||||
<p class="tweetsvg reply">Replying to <a href="https://twitter.com/{{ .InReplyToScreenName }}/">@{{ .InReplyToScreenName }}</a></p>
|
||||
<p class="tweetsvg reply">Replying to <a rel="noopener" target="_blank" href="https://twitter.com/{{ .InReplyToScreenName }}/">@{{ .InReplyToScreenName }}</a></p>
|
||||
{{ end }}
|
||||
|
||||
<p class="tweetsvg text">{{ html .FullText }}</p>
|
||||
@ -31,12 +31,12 @@
|
||||
{{ if .ExtendedEntities }}
|
||||
{{ range .ExtendedEntities.Media }}
|
||||
|
||||
<a href="{{ .Media_url_https }}" target="_blank"><img class="media-tweetsvg" width="{{ .Sizes.Small.W }}" src="data:image/jpeg;base64,{{ base64 .Media_url }}" alt="{{ .ExtAltText }}"/></a>
|
||||
<a rel="noopener" target="_blank" href="{{ .Media_url_https }}" target="_blank"><img class="media-tweetsvg" width="{{ .Sizes.Small.W }}" src="data:image/jpeg;base64,{{ base64 .Media_url }}" alt="{{ .ExtAltText }}"/></a>
|
||||
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
<a class="tweetsvg" href="https://twitter.com/{{ .User.ScreenName }}/status/{{ .Id }}">
|
||||
<a rel="noopener" target="_blank" class="tweetsvg" href="https://twitter.com/{{ .User.ScreenName }}/status/{{ .Id }}">
|
||||
<time class="tweetsvg" datetime="{{ isoDate .CreatedAt }}">{{ humanDate .CreatedAt }}</time>
|
||||
</a>
|
||||
</blockquote>
|
||||
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.7 KiB |
Loading…
Reference in New Issue
Block a user