Add a handler for /download that directs you to the device-appropriate store

zio/stable
Jaz Volpert 2024-04-16 14:17:15 -07:00
parent 71c427cea8
commit 09e1f0e9ae
1 changed files with 17 additions and 0 deletions

View File

@ -170,6 +170,9 @@ func serve(cctx *cli.Context) error {
// home // home
e.GET("/", server.WebHome) e.GET("/", server.WebHome)
// download
e.GET("/download", server.Download)
// generic routes // generic routes
e.GET("/hashtag/:tag", server.WebGeneric) e.GET("/hashtag/:tag", server.WebGeneric)
e.GET("/search", server.WebGeneric) e.GET("/search", server.WebGeneric)
@ -271,6 +274,20 @@ func (srv *Server) errorHandler(err error, c echo.Context) {
c.Render(code, "error.html", data) c.Render(code, "error.html", data)
} }
// Handler for redirecting to the download page.
func (srv *Server) Download(c echo.Context) error {
ua := c.Request().UserAgent()
if strings.Contains(ua, "Android") {
return c.Redirect(http.StatusFound, "https://play.google.com/store/apps/details?id=xyz.blueskyweb.app")
}
if strings.Contains(ua, "iPhone") || strings.Contains(ua, "iPad") || strings.Contains(ua, "iPod") {
return c.Redirect(http.StatusFound, "https://apps.apple.com/tr/app/bluesky-social/id6444370199")
}
return c.Redirect(http.StatusFound, "/")
}
// handler for endpoint that have no specific server-side handling // handler for endpoint that have no specific server-side handling
func (srv *Server) WebGeneric(c echo.Context) error { func (srv *Server) WebGeneric(c echo.Context) error {
data := pongo2.Context{} data := pongo2.Context{}