From 06fba690993d440b88a960db1212bd414d78e5a1 Mon Sep 17 00:00:00 2001 From: Redume Date: Sun, 9 Oct 2022 17:54:24 +0300 Subject: [PATCH] added an error page if you access the site via phone --- web/pages/about.go | 23 ++++++++++++++++++++++- web/pages/index.go | 11 +++++++++-- web/pages/settings.go | 23 ++++++++++++++++++++++- web/static/style/settings.css | 4 ++-- 4 files changed, 55 insertions(+), 6 deletions(-) diff --git a/web/pages/about.go b/web/pages/about.go index 67391c0..bba81e7 100644 --- a/web/pages/about.go +++ b/web/pages/about.go @@ -1,7 +1,28 @@ package page -import "net/http" +import ( + "github.com/Redume/EveryNasa/functions" + "net/http" + "strings" +) func AboutHandler(w http.ResponseWriter, r *http.Request) { + con := functions.Connected() + if con == false { + http.ServeFile(w, r, "web/src/errors/504.html") + return + } + + userAgent := r.UserAgent() + if strings.Contains(userAgent, "Mobile") { + http.ServeFile(w, r, "web/src/errors/mobile.html") + return + } + + if r.URL.Path != "/about" { + http.ServeFile(w, r, "web/src/errors/404.html") + return + } + http.ServeFile(w, r, "web/src/about.html") } diff --git a/web/pages/index.go b/web/pages/index.go index de2e3b6..79af089 100644 --- a/web/pages/index.go +++ b/web/pages/index.go @@ -1,9 +1,9 @@ package page import ( - "net/http" - "github.com/Redume/EveryNasa/functions" + "net/http" + "strings" ) func GalleryHandler(w http.ResponseWriter, r *http.Request) { @@ -13,6 +13,13 @@ func GalleryHandler(w http.ResponseWriter, r *http.Request) { return } + userAgent := r.UserAgent() + + if strings.Contains(userAgent, "Mobile") { + http.ServeFile(w, r, "web/src/errors/mobile.html") + return + } + if r.URL.Path != "/" { http.ServeFile(w, r, "web/src/errors/404.html") return diff --git a/web/pages/settings.go b/web/pages/settings.go index 987368c..3114022 100644 --- a/web/pages/settings.go +++ b/web/pages/settings.go @@ -1,7 +1,28 @@ package page -import "net/http" +import ( + "github.com/Redume/EveryNasa/functions" + "net/http" + "strings" +) func SettingsHandler(w http.ResponseWriter, r *http.Request) { + con := functions.Connected() + if con == false { + http.ServeFile(w, r, "web/src/errors/504.html") + return + } + + userAgent := r.UserAgent() + if strings.Contains(userAgent, "Mobile") { + http.ServeFile(w, r, "web/src/errors/mobile.html") + return + } + + if r.URL.Path != "/settings" { + http.ServeFile(w, r, "web/src/errors/404.html") + return + } + http.ServeFile(w, r, "web/src/settings.html") } diff --git a/web/static/style/settings.css b/web/static/style/settings.css index 4c26062..088c1c2 100644 --- a/web/static/style/settings.css +++ b/web/static/style/settings.css @@ -48,5 +48,5 @@ } #createLabelButton { - margin-left: -12em; -} + margin-left: -12em; +} \ No newline at end of file