diff options
author | FChannel <> | 2022-06-13 22:23:36 -0700 |
---|---|---|
committer | FChannel <> | 2022-06-19 12:53:29 -0700 |
commit | cb9a6cf7fcf379202f2ccfc4776daf4dd1d35b9d (patch) | |
tree | 327795adf7020993b1356961cf5ba869fbb99d02 | |
parent | 5cff4d3740eb8b9f67de9713124e84109d04cff8 (diff) |
admin update board summary form
-rw-r--r-- | main.go | 1 | ||||
-rw-r--r-- | route/routes/admin.go | 31 | ||||
-rw-r--r-- | views/manage.html | 7 | ||||
-rw-r--r-- | views/partials/footer.html | 2 |
4 files changed, 38 insertions, 3 deletions
@@ -66,6 +66,7 @@ func main() { app.Post("/"+config.Key+"/newspost", routes.NewsPost) app.Get("/"+config.Key+"/newsdelete/:ts", routes.NewsDelete) app.Post("/"+config.Key+"/:actor/addjanny", routes.AdminAddJanny) + app.Post("/"+config.Key+"/:actor/editsummary", routes.AdminEditSummary) app.Get("/"+config.Key+"/:actor/deletejanny", routes.AdminDeleteJanny) app.All("/"+config.Key+"/:actor/follow", routes.AdminFollow) app.Get("/"+config.Key+"/:actor", routes.AdminActorIndex) diff --git a/route/routes/admin.go b/route/routes/admin.go index a2b4ad5..c198e21 100644 --- a/route/routes/admin.go +++ b/route/routes/admin.go @@ -355,6 +355,36 @@ func AdminAddJanny(ctx *fiber.Ctx) error { return ctx.Redirect("/"+config.Key+"/"+redirect, http.StatusSeeOther) } +func AdminEditSummary(ctx *fiber.Ctx) error { + id, pass := util.GetPasswordFromSession(ctx) + actor, _ := webfinger.GetActorFromPath(ctx.Path(), "/"+config.Key+"/") + + if actor.Id == "" { + actor, _ = activitypub.GetActorByNameFromDB(config.Domain) + } + + hasAuth, _type := util.HasAuth(pass, actor.Id) + + if !hasAuth || _type != "admin" || (id != actor.Id && id != config.Domain) { + return util.MakeError(errors.New("Error"), "AdminEditSummary") + } + + summary := ctx.FormValue("summary") + + query := `update actor set summary=$1 where id=$2` + if _, err := config.DB.Exec(query, summary, actor.Id); err != nil { + return util.MakeError(err, "AdminEditSummary") + } + + var redirect string + if actor.Name != "main" { + redirect = actor.Name + } + + return ctx.Redirect("/"+config.Key+"/"+redirect, http.StatusSeeOther) + +} + func AdminDeleteJanny(ctx *fiber.Ctx) error { id, pass := util.GetPasswordFromSession(ctx) actor, _ := webfinger.GetActorFromPath(ctx.Path(), "/"+config.Key+"/") @@ -377,7 +407,6 @@ func AdminDeleteJanny(ctx *fiber.Ctx) error { } var redirect string - actor, _ = webfinger.GetActorFromPath(ctx.Path(), "/"+config.Key+"/") if actor.Name != "main" { redirect = actor.Name diff --git a/views/manage.html b/views/manage.html index 7db9d01..315d472 100644 --- a/views/manage.html +++ b/views/manage.html @@ -1,6 +1,11 @@ <div style="text-align: center; margin: 0 auto; width: 400px;"> <h1>Manage /{{ .page.Board.Name }}/</h1> - <!-- <div><a href="/{{ .Key }}/deleteboard?name={{ .Board.Name }}">[Delete Board]</a></div> --> + <form id="summary-form" action="/{{ .page.Key }}/{{ .page.Board.Name }}/editsummary" method="post" enctype="application/x-www-form-urlencoded" style="margin-top: 5px;"> + <input id="summary" name="summary" style="margin-bottom: 5px;" size="35" placeholder="{{ .page.Board.Actor.Summary }}"></input> + <input type="submit" value="Update Summary"><br> + <input type="hidden" name="actor" value="{{ .page.Board.Actor.Id }}"> + </form> + <!-- <div><a href="/{{ .Key }}/deleteboard?name={{ .Board.Name }}">[Delete Board]</a></div> --> <ul style="display: inline-block; padding: 0;"> {{ if .page.IsLocal }} <li style="display: inline-block;">[<a href="#following"> Subscribed </a>]</li> diff --git a/views/partials/footer.html b/views/partials/footer.html index efbde4f..2253039 100644 --- a/views/partials/footer.html +++ b/views/partials/footer.html @@ -1,4 +1,4 @@ -<div align="center" style="width: 500px; margin:0 auto; margin-top: 50px;"> +<div align="center" style="max-width: 500px; margin:0 auto; margin-top: 50px;"> [<a href="/">Home</a>] [<a href="/static/rules.html">Rules</a>] [<a href="/static/faq.html">FAQ</a>] <p>All trademarks and copyrights on this page are owned by their respective parties.</p> </div> |