diff options
author | Jaz Volpert <ericvolp12@gmail.com> | 2024-04-16 14:17:15 -0700 |
---|---|---|
committer | Jaz Volpert <ericvolp12@gmail.com> | 2024-04-16 14:17:15 -0700 |
commit | 09e1f0e9aec4bdce275d20917800d2fc8b62c21a (patch) | |
tree | ee3e2aa2ed4078bc6fdac66fd20ae097d935236c | |
parent | 71c427cea86db31f7bd6c11cd460c0d7a48c0b06 (diff) | |
download | voidsky-09e1f0e9aec4bdce275d20917800d2fc8b62c21a.tar.zst |
Add a handler for /download that directs you to the device-appropriate store
-rw-r--r-- | bskyweb/cmd/bskyweb/server.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/bskyweb/cmd/bskyweb/server.go b/bskyweb/cmd/bskyweb/server.go index 54a3925c6..17d621014 100644 --- a/bskyweb/cmd/bskyweb/server.go +++ b/bskyweb/cmd/bskyweb/server.go @@ -170,6 +170,9 @@ func serve(cctx *cli.Context) error { // home e.GET("/", server.WebHome) + // download + e.GET("/download", server.Download) + // generic routes e.GET("/hashtag/:tag", 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) } +// 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 func (srv *Server) WebGeneric(c echo.Context) error { data := pongo2.Context{} |