A social RSS reader built on the AT Protocol. glean.at
glean atproto atmosphere rss feed social app
14
fork

Configure Feed

Select the types of activity you want to include in your feed.

Refactor to use go:embed

+16 -9
+4 -9
internal/server/server.go
··· 8 8 "log/slog" 9 9 "net/http" 10 10 "net/url" 11 - "path/filepath" 12 11 "strconv" 13 12 "strings" 14 13 "time" ··· 27 26 "pkg.rbrt.fr/glean/internal/metrics" 28 27 "pkg.rbrt.fr/glean/internal/sanitize" 29 28 "pkg.rbrt.fr/glean/internal/scraper" 29 + "pkg.rbrt.fr/glean/static" 30 + "pkg.rbrt.fr/glean/internal/tmpl" 30 31 ) 31 32 32 33 func splitString(s, sep string) []string { ··· 182 183 s.router.Get("/xrpc/at.glean.getRecommendations", xrpc.GetRecommendations) 183 184 s.router.Get("/xrpc/at.glean.listFeedLists", xrpc.ListFeedLists) 184 185 185 - s.router.Handle("/static/*", http.StripPrefix("/static/", http.FileServer(http.Dir("static")))) 186 + s.router.Handle("/static/*", http.StripPrefix("/static/", http.FileServer(http.FS(static.Files)))) 186 187 s.router.Handle("/metrics", promhttp.Handler()) 187 188 } 188 189 ··· 325 326 }, 326 327 } 327 328 328 - var allFiles []string 329 - matches, _ := filepath.Glob("internal/tmpl/*.html") 330 - allFiles = append(allFiles, matches...) 331 - partials, _ := filepath.Glob("internal/tmpl/partials/*.html") 332 - allFiles = append(allFiles, partials...) 333 - 334 329 var err error 335 - s.templates, err = template.New("").Funcs(fm).ParseFiles(allFiles...) 330 + s.templates, err = template.New("").Funcs(fm).ParseFS(tmpl.Files, "*.html", "partials/*.html") 336 331 if err != nil { 337 332 s.logger.Error("failed to load templates", "error", err) 338 333 }
+6
internal/tmpl/embed.go
··· 1 + package tmpl 2 + 3 + import "embed" 4 + 5 + //go:embed *.html partials/*.html 6 + var Files embed.FS
+6
static/embed.go
··· 1 + package static 2 + 3 + import "embed" 4 + 5 + //go:embed * 6 + var Files embed.FS