diff --git a/web/main.go b/web/main.go index 83a94c9..7915b9f 100644 --- a/web/main.go +++ b/web/main.go @@ -29,7 +29,13 @@ func AdminOnlyMiddleware(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { c, err := r.Cookie("comfy_admin") if err != nil || !util.IsAdminSessionValid(c.Value) { - http.Redirect(w, r, "/authorize", http.StatusSeeOther) + // Check if it's an HTMX request + if r.Header.Get("HX-Request") == "true" { + w.Header().Set("HX-Redirect", "/authorize") + w.WriteHeader(http.StatusOK) + } else { + http.Redirect(w, r, "/authorize", http.StatusSeeOther) + } return } next.ServeHTTP(w, r) diff --git a/web/static/index.css b/web/static/index.css index f76fa53..a62751a 100644 --- a/web/static/index.css +++ b/web/static/index.css @@ -279,7 +279,6 @@ body { /* ADMIN */ - .admin-login-container { width: max-content; margin: auto; @@ -295,6 +294,38 @@ body { margin-left: auto; } +.admin-dialog { + border: 1px solid #B7C5D9; + background: #EDEFF7; + padding: 6px 8px; + min-width: 160px; + box-shadow: 2px 2px 4px rgba(0, 0, 0, .25); + + font-size: 12px; + color: #000; + + position: fixed; + z-index: 2000; +} + +.admin-dialog h1 { + margin: 0 0 8px 0; + font-size: 14px; + font-weight: bold; + color: #AF0A0F; + text-align: center; +} + +.admin-dialog button { + display: block; + margin: 5px auto; +} + +.admin-dialog-close-btn { + font-weight: bold; + margin-top: 20px !important; +} + /* GENERAL LAYOUT */ .container { diff --git a/web/views/board.templ b/web/views/board.templ index 1174e58..eae054e 100644 --- a/web/views/board.templ +++ b/web/views/board.templ @@ -69,7 +69,8 @@ templ ThreadsCatalog(previews []CatalogThreadPreview, catalogContext CatalogCont for _, preview := range previews { {{ replyCount := strconv.FormatInt(int64(preview.ReplyCount), 10) }} {{ ipCount := strconv.FormatInt(int64(preview.IpCount), 10) }} -
+ {{ elThreadId := fmt.Sprintf("thread-%d", preview.ThreadId) }} +
- R: { replyCount } / I: { ipCount } + + R: { replyCount } / I: { ipCount } + if catalogContext.IsAdmin { + + M + + } +

{ preview.Subject }

@templ.Raw(util.EnrichPost(preview.Body))

- if catalogContext.IsAdmin { + +

{ elThreadId }

- } + hx-confirm="Are you sure you wish to delete this thread?" + >Delete + +
}