From 6726a7989c30568761b899b8ccc1a5d2de603537 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Sat, 13 Jul 2024 19:58:12 +0400 Subject: [PATCH] Ported mindflow admin page to Templ. --- web/mindflow_admin.templ | 73 +++++++++++++++++++++++++++++++- web/templates/mindflow_admin.pug | 66 ----------------------------- 2 files changed, 72 insertions(+), 67 deletions(-) delete mode 100755 web/templates/mindflow_admin.pug diff --git a/web/mindflow_admin.templ b/web/mindflow_admin.templ index 6e640a9..7270e27 100644 --- a/web/mindflow_admin.templ +++ b/web/mindflow_admin.templ @@ -3,7 +3,78 @@ package web import "net/http" import "git.arav.su/Arav/dwelling-home/pkg/mindflow" +import "git.arav.su/Arav/dwelling-home/pkg/util" +import "strconv" +import "time" templ MindflowAdmin(posts []mindflow.Post, categories []mindflow.Category, r *http.Request) { - @base("Mindflow Administration", "", "", "/mindflow/admin", r, nil) + @base("Mindflow Administration", "", "", "/mindflow/admin", r, mindflowAdminHead()) { +
+

Manage categories

+
+ + + + + +
+
+
+

Create a new post

+
+ + + + + +
+
+
+ for _, post := range posts { +
+
+

{ post.Category.Name }: { post.Title }

+
+
+ + + + + + + +
+
+ +
+
+ } + if len(posts) == 0 { +

Nothing? There must be some... Looks like database went down.

+ } +
+ } } + +templ mindflowAdminHead() { + + + +} \ No newline at end of file diff --git a/web/templates/mindflow_admin.pug b/web/templates/mindflow_admin.pug deleted file mode 100755 index e32bebf..0000000 --- a/web/templates/mindflow_admin.pug +++ /dev/null @@ -1,66 +0,0 @@ -extends base.pug - -block meta_description - meta(name='description' content='Here I will post updates on my infrastructure, my very important opinions and thoughts.') - -block append head - link(href='/assets/css/mindflow.css' rel='stylesheet') - link(href='/assets/css/mindflow_admin.css' rel='stylesheet') - script(src='/assets/js/mindflow_admin.js' defer='') - -block nav - a(href='/') Home - a(href='/stuff') Stuff - a(href='/mindflow') Mindflow - a(href='/about') About - a(href='/guestbook') Guestbook - h1 Mindflow Admin - -block content - :go:func MindflowAdmin(title string, posts []mindflow.Post, categories []mindflow.Category, r *http.Request) - section - h2 Manage categories - form(id='manage-categories') - select(name='category' required='') - each category in categories - option(value=category.ID) #{category.Name} - option(value='0') -- New category -- - input(type='text', placeholder='New category name' name='name') - button(type="submit" name="add") Add - button(type="submit" name="edit") Edit - button(type="submit" name="delete") Delete - - section - h2 Create a new post - form(id='add' action='/api/mindflow', method='POST') - select(name='category' required='') - each category in categories - option(value=category.ID) #{category.Name} - input(type='text', placeholder='Title' name='title' required='') - input(type='text', placeholder='URL' name='url') - textarea(placeholder='Body post' name='body' required='') - button(type="submit") Add - section - if (len(posts) > 0) - each post in posts - article(id=post.PostID()) - header - a(href=`#${post.PostID()}`) - h3= post.Category.Name + ": " + post.Title - form.edit - select(name='category' required='') - each category in categories - if (category.ID == post.Category.ID) - option(value=category.ID selected='') #{category.Name} - else - option(value=category.ID) #{category.Name} - input(type='hidden', name='post-id' value=post.ID) - input(type='text', placeholder='Title' name='title' value=post.Title required='') - input(type='text', placeholder='URL' name='url' value=post.URL) - textarea(placeholder='Body post' name='body' required='')!= post.Body - button(name='edit-post') Edit - button(name='delete-post') Delete - footer - time(datetime=util.ToClientTimezone(post.Date, r))= util.ToClientTimezone(post.Date, r).Format(time.RFC1123) - else - p.center Nothing? There must be some... Looks like database went down.