diff --git a/pkg/web/templates/tweet.html b/pkg/web/templates/tweet.html index d019a1b..96165d5 100644 --- a/pkg/web/templates/tweet.html +++ b/pkg/web/templates/tweet.html @@ -5,8 +5,8 @@ <meta name="theme-color" content="#26a7de"> <link rel="canonical" href="{{ .URL }}"> - <meta property="twitter:site" content="{{ .Username }}"> - <meta property="twitter:creator" content="{{ .Username }}"> + <meta property="twitter:site" content="@{{ .Username }}"> + <meta property="twitter:creator" content="@{{ .Username }}"> <meta property="twitter:title" content="{{ .Title }}"> {{- range $idx, $e := .Images }} <meta property="twitter:image" content="{{ $e }}"> diff --git a/pkg/web/templates/video.html b/pkg/web/templates/video.html index c4dc13b..2c02e15 100644 --- a/pkg/web/templates/video.html +++ b/pkg/web/templates/video.html @@ -6,8 +6,8 @@ <link rel="canonical" href="{{ .URL }}"> {{- if .Videos }} - <meta property="twitter:site" content="{{ .Username }}"> - <meta property="twitter:creator" content="{{ .Username }}"> + <meta property="twitter:site" content="@{{ .Username }}"> + <meta property="twitter:creator" content="@{{ .Username }}"> {{- range $idx, $e := .Videos }} <meta property="twitter:player:stream" content="{{ $e }}"> <meta property="og:video" content="{{ $e }}"> diff --git a/pkg/web/web.go b/pkg/web/web.go index 161bcc0..11b99f1 100644 --- a/pkg/web/web.go +++ b/pkg/web/web.go @@ -23,7 +23,7 @@ const ( //go:embed templates/*.html var templateFiles embed.FS -type Reponse struct { +type Response struct { StatusCode int ContentType string Content string @@ -34,7 +34,7 @@ type WebServer struct { scraper *ts.Scraper templates *template.Template avatarCache *cache.Cache[string, string] - responseCache *cache.Cache[string, Reponse] + responseCache *cache.Cache[string, Response] Server *http.Server } @@ -64,7 +64,7 @@ func New(config *config.Config, scraper *ts.Scraper) (*WebServer, error) { scraper, tmpl, cache.New[string, string](), - cache.New[string, Reponse](), + cache.New[string, Response](), &http.Server{ Handler: sm, Addr: fmt.Sprintf(":%d", config.WebPort), @@ -130,7 +130,7 @@ func (ws WebServer) handleTemplate(w http.ResponseWriter, r *http.Request, id st } if !slices.Contains(ws.config.Channels, tweet.Username) { - res := Reponse{http.StatusBadRequest, "text/plain", "Bad Request"} + res := Response{http.StatusBadRequest, "text/plain", "Bad Request"} ws.responseCache.Set(template+"-"+id, res, TweetCacheTime) response(w, res) return @@ -182,7 +182,7 @@ func (ws WebServer) handleTemplate(w http.ResponseWriter, r *http.Request, id st return } - res := Reponse{http.StatusOK, "text/html", tpl.String()} + res := Response{http.StatusOK, "text/html", tpl.String()} ws.responseCache.Set(template+"-"+id, res, TweetCacheTime) response(w, res) } @@ -197,14 +197,14 @@ func validUserAgent(ua string, uas []string) bool { } func badRequest(w http.ResponseWriter) { - response(w, Reponse{http.StatusBadRequest, "text/plain", "Bad Request"}) + response(w, Response{http.StatusBadRequest, "text/plain", "Bad Request"}) } func serverError(w http.ResponseWriter) { - response(w, Reponse{http.StatusInternalServerError, "text/plain", "Internal Server Error"}) + response(w, Response{http.StatusInternalServerError, "text/plain", "Internal Server Error"}) } -func response(w http.ResponseWriter, res Reponse) { +func response(w http.ResponseWriter, res Response) { w.WriteHeader(res.StatusCode) w.Header().Set("Content-Type", res.ContentType) fmt.Fprint(w, res.Content)