Add feedtype icons next to the nick of each twt (#1036)

Depends on yarnsocial/go-types#9

Co-authored-by: James Mills <prologic@shortcircuit.net.au>
Reviewed-on: #1036
pull/1037/head
James Mills 1 month ago
parent 02e77650b7
commit a26a8561ef
  1. 2
      .vscode/settings.json
  2. 8
      go.mod
  3. 11
      go.sum
  4. 1
      internal/templates.go
  5. 8
      internal/theme/static/css/02-tabler-icons.css
  6. BIN
      internal/theme/static/css/tabler-icons.woff
  7. 6
      internal/theme/templates/partials.html
  8. 19
      internal/utils.go

@ -1,4 +1,4 @@
{
"html.format.wrapLineLength": 0,
""html.format.enable": false
"html.format.enable": false
}

@ -34,7 +34,7 @@ require (
github.com/gavv/httpexpect/v2 v2.3.1
github.com/go-mail/mail v2.3.1+incompatible
github.com/go-playground/validator/v10 v10.9.0 // indirect
github.com/goccy/go-yaml v1.9.5
github.com/goccy/go-yaml v1.9.6
github.com/gofrs/flock v0.8.1 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/gomarkdown/markdown v0.0.0-20221013030248-663e2500819c
@ -49,7 +49,7 @@ require (
github.com/jinzhu/now v1.1.5 // indirect
github.com/julienschmidt/httprouter v1.3.0
github.com/justinas/nosurf v1.1.1
github.com/klauspost/compress v1.15.11 // indirect
github.com/klauspost/compress v1.15.12 // indirect
github.com/lithammer/shortuuid/v3 v3.0.7
github.com/makeworld-the-better-one/go-gemini v0.13.0
github.com/marksalpeter/sugar v0.0.0-20160713164314-a69afe358ea8 // indirect
@ -98,9 +98,9 @@ require (
github.com/writeas/slug v1.2.0
go.yarn.social/client v0.0.0-20221026065557-81f92f9fecbc
go.yarn.social/lextwt v0.0.0-20221025191146-36407f57fe7a
go.yarn.social/types v0.0.0-20221026065125-bb0847d28781
go.yarn.social/types v0.0.0-20221027060940-9ca280309582
golang.org/x/crypto v0.1.0
golang.org/x/exp v0.0.0-20221026004748-78e5e7837ae6 // indirect
golang.org/x/exp v0.0.0-20221026153819-32f3d567a233 // indirect
golang.org/x/image v0.1.0 // indirect
golang.org/x/net v0.1.0
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4

@ -300,6 +300,8 @@ github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LB
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/goccy/go-yaml v1.9.5 h1:Eh/+3uk9kLxG4koCX6lRMAPS1OaMSAi+FJcya0INdB0=
github.com/goccy/go-yaml v1.9.5/go.mod h1:U/jl18uSupI5rdI2jmuCswEA2htH9eXfferR3KfscvA=
github.com/goccy/go-yaml v1.9.6 h1:KhAu1zf9JXnm3vbG49aDE0E5uEBUsM4uwD31/58ZWyI=
github.com/goccy/go-yaml v1.9.6/go.mod h1:JubOolP3gh0HpiBc4BLRD4YmjEjHAmIIB2aaXKkTfoE=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/gofrs/flock v0.8.0/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU=
github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw=
@ -525,6 +527,8 @@ github.com/klauspost/compress v1.13.4/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8
github.com/klauspost/compress v1.15.2/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU=
github.com/klauspost/compress v1.15.11 h1:Lcadnb3RKGin4FYM/orgq0qde+nc15E5Cbqg4B9Sx9c=
github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM=
github.com/klauspost/compress v1.15.12 h1:YClS/PImqYbn+UILDnqxQCZ3RehC9N318SU3kElDUEM=
github.com/klauspost/compress v1.15.12/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
@ -897,6 +901,8 @@ go.yarn.social/lextwt v0.0.0-20221025191146-36407f57fe7a/go.mod h1:XcveSVLWxkBBW
go.yarn.social/types v0.0.0-20221025190911-9524f5b4a743/go.mod h1:XN+G4HprNn/Gp7OF2zveqsCRSWFCHtOaIRh2GlcK+U4=
go.yarn.social/types v0.0.0-20221026065125-bb0847d28781 h1:zEWYkVegXj1rcMMzX+m9E7ePHxJs7LT9049KOVG1/SQ=
go.yarn.social/types v0.0.0-20221026065125-bb0847d28781/go.mod h1:XN+G4HprNn/Gp7OF2zveqsCRSWFCHtOaIRh2GlcK+U4=
go.yarn.social/types v0.0.0-20221027060940-9ca280309582 h1:afYj65Uv/Y3XYdwXyt/eWqErIkQFTu3yHJAsEfOi/pg=
go.yarn.social/types v0.0.0-20221027060940-9ca280309582/go.mod h1:XN+G4HprNn/Gp7OF2zveqsCRSWFCHtOaIRh2GlcK+U4=
goji.io v2.0.2+incompatible/go.mod h1:sbqFwrtqZACxLBTQcdgVjFh54yGVCvwq8+w49MVMMIk=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
@ -936,6 +942,8 @@ golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMk
golang.org/x/exp v0.0.0-20200228211341-fcea875c7e85/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw=
golang.org/x/exp v0.0.0-20221026004748-78e5e7837ae6 h1:mC6uOkPi9SUk8A59jZvw7//rlyc+MlELtQUCyOUSKZQ=
golang.org/x/exp v0.0.0-20221026004748-78e5e7837ae6/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE=
golang.org/x/exp v0.0.0-20221026153819-32f3d567a233 h1:9bNbSKT4RPLEzne0Xh1v3NaNecsa1DKjkOuTbY6V9rI=
golang.org/x/exp v0.0.0-20221026153819-32f3d567a233/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
@ -967,6 +975,7 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.6.0/go.mod h1:4mET923SAdbXp2ki8ey+zGs1SLqsuM2Y0uvdZR/fUNI=
golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@ -1151,6 +1160,7 @@ golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220406163625-3f8b81556e12/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220502124256-b6088ccd6cba/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
@ -1244,6 +1254,7 @@ golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

@ -94,6 +94,7 @@ func NewTemplateManager(conf *Config, translator *Translator, cache *Cache, arch
funcMap["urlForRootConv"] = URLForRootConvFactory(conf, cache, archive)
funcMap["getConvLength"] = GetConvLength(conf, cache, archive)
funcMap["getForkLength"] = GetForkLength(conf, cache, archive)
funcMap["getFeedTypeClass"] = GetFeedTypeClass(conf, cache)
funcMap["isAdminUser"] = IsAdminUserFactory(conf)
funcMap["isSpecialFeed"] = IsSpecialFeed
funcMap["isFeatureEnabled"] = func(name string) bool {

@ -241,3 +241,11 @@
.ti-volume-3:before {
content: "\eb50";
}
.ti-robot:before {
content: "\f00b";
}
.ti-user:before {
content: "\eb4d";
}

@ -151,10 +151,12 @@
<div class="author">
<div class="p-name">
{{ if isLocalURL $.Twt.Twter.URI }}
<a href="{{ $.Twt.Twter.URI | trimSuffix "/twtxt.txt" }}">{{ $.Twt.Twter.Nick }}</a>
<a href="{{ $.Twt.Twter.URI | trimSuffix "/twtxt.txt" }}">{{ $.Twt.Twter.Nick }}
{{ else }}
<a href="/external?uri={{ $.Twt.Twter.URI }}&nick={{ $.Twt.Twter.Nick }}">{{ $.Twt.Twter.Nick }}</a>
<a href="/external?uri={{ $.Twt.Twter.URI }}&nick={{ $.Twt.Twter.Nick }}">{{ $.Twt.Twter.Nick }}
{{ end }}
<i class="ti ti-{{ getFeedTypeClass $.Twt.Twter }}"></i>
</a>
</div>
<div class="p-org">
<a target="_blank" href="{{ $.Twt.Twter.URI | baseFromURL }}">{{ $.Twt.Twter.URI | hostnameFromURL }}</a>

@ -1626,6 +1626,25 @@ func GetForkLength(conf *Config, cache *Cache, archive Archiver) func(twt types.
}
}
func GetFeedTypeClass(conf *Config, cache *Cache) func(twter types.Twter) string {
return func(twter types.Twter) string {
metadata := twter.Metadata
if len(metadata) == 0 {
if cachedTwter := cache.GetTwter(twter.URI); cachedTwter != nil {
metadata = cachedTwter.Metadata
}
}
switch types.GetFeedType(twter.URI, metadata) {
case types.FeedTypeBot:
return "robot"
case types.FeedTypeRSS:
return "rss"
default:
return "user"
}
}
}
func ExtractHashFromSubject(subject string) string {
var hash string

Loading…
Cancel
Save