From 1f3ae665ed2e58ca572678ce7caf8b711f226392 Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Tue, 29 Nov 2022 20:59:31 +0100 Subject: Introduce EDIT and MANAGE methods All admin "index" pages are moved under MANAGE, so that we can have (for example) and normal "GET /posts" page later which would replace the current index page, and potentially corresponding pages for the other categories. The EDIT method replaces the old `?edit` pattern, which normalizes how we differentiate page functionality generally. --- src/http/assets.go | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'src/http/assets.go') diff --git a/src/http/assets.go b/src/http/assets.go index 260b786..9c6c67e 100644 --- a/src/http/assets.go +++ b/src/http/assets.go @@ -59,9 +59,9 @@ func resizeImage(out io.Writer, in io.Reader, maxWidth float64) error { } } -func (a *api) renderPostAssetsIndexHandler() http.Handler { +func (a *api) managePostAssetsHandler() http.Handler { - tpl := a.mustParseBasedTpl("assets.html") + tpl := a.mustParseBasedTpl("post-assets-manage.html") return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { @@ -86,17 +86,10 @@ func (a *api) renderPostAssetsIndexHandler() http.Handler { func (a *api) getPostAssetHandler() http.Handler { - renderIndexHandler := a.renderPostAssetsIndexHandler() - return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { id := filepath.Base(r.URL.Path) - if id == "/" { - renderIndexHandler.ServeHTTP(rw, r) - return - } - maxWidth, err := apiutil.StrToInt(r.FormValue("w"), 0) if err != nil { apiutil.BadRequest(rw, r, fmt.Errorf("invalid w parameter: %w", err)) @@ -172,7 +165,7 @@ func (a *api) postPostAssetHandler() http.Handler { return } - a.executeRedirectTpl(rw, r, a.assetsURL(false)) + a.executeRedirectTpl(rw, r, a.manageAssetsURL(false)) }) } @@ -199,6 +192,6 @@ func (a *api) deletePostAssetHandler() http.Handler { return } - a.executeRedirectTpl(rw, r, a.assetsURL(false)) + a.executeRedirectTpl(rw, r, a.manageAssetsURL(false)) }) } -- cgit v1.2.3