responsive app menu

This commit is contained in:
metacryst
2025-10-29 16:03:47 -05:00
parent 6d46875546
commit 0e36cd30cc
8 changed files with 104 additions and 76 deletions

View File

@@ -34,16 +34,6 @@ func main() {
}
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
// Keeps server from crashing if a request fails
// defer func() {
// if r := recover(); r != nil {
// log.Error().
// Interface("panic_reason", r).
// Bytes("stack_trace", debug.Stack()).
// Msg("panic in http goroutine")
// }
// }()
if(loggedIn(w, r)) {
log.Info().Msg("logged")
if isWebSocketRequest(r) {
@@ -106,7 +96,8 @@ func handleSite(w http.ResponseWriter, r *http.Request) {
handlers.HandleLogout(w, r)
return
}
if strings.HasPrefix(r.URL.Path, "/_") {
if strings.Contains(r.URL.Path, "/_") {
log.Debug().Msg("this is what it is")
handleAsset(w, r)
return
}
@@ -117,8 +108,10 @@ func handleSite(w http.ResponseWriter, r *http.Request) {
func serveSiteFiles(w http.ResponseWriter, r *http.Request) {
path := r.URL.Path
if path == "/" {
if(strings.Contains(path, "75820185")) {
_, after, _ := strings.Cut(path, "75820185")
path = after
} else {
// Required for sign in / sign out redirect to work properly
w.Header().Set("Cache-Control", "no-store, no-cache, must-revalidate, proxy-revalidate")
w.Header().Set("Pragma", "no-cache")
@@ -126,8 +119,6 @@ func serveSiteFiles(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Surrogate-Control", "no-store")
path = "/index.html"
} else if !strings.Contains(path, ".") {
path = filepath.Join("/pages", path) + ".html"
}
filePath := filepath.Join("../ui/site", path)
@@ -136,8 +127,8 @@ func serveSiteFiles(w http.ResponseWriter, r *http.Request) {
}
func handleAsset(w http.ResponseWriter, r *http.Request) {
path := r.URL.Path
filePath := filepath.Join("../ui", path)
_, after, _ := strings.Cut(r.URL.Path, "/_")
filePath := filepath.Join("../ui", "/_" + after)
log.Debug().Msgf("serving asset: %s", filePath)
http.ServeFile(w, r, filePath)
}