summaryrefslogtreecommitdiff
path: root/src/http/assets.go
diff options
context:
space:
mode:
authorBrian Picciano <mediocregopher@gmail.com>2022-11-29 20:59:31 +0100
committerBrian Picciano <mediocregopher@gmail.com>2022-11-29 20:59:31 +0100
commit1f3ae665ed2e58ca572678ce7caf8b711f226392 (patch)
treee023602e07e2a80d24ef9d9527ddca0e1640e929 /src/http/assets.go
parent31f8f37c5ad3ad4ac7b3cc93d0257dd80c877c7c (diff)
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.
Diffstat (limited to 'src/http/assets.go')
-rw-r--r--src/http/assets.go15
1 files changed, 4 insertions, 11 deletions
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))
})
}