1
0
dwelling-home/web/templates/mindflow_admin.pug

73 lines
3.4 KiB
Plaintext
Executable File

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='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
if (category.ID == 1)
option(value=category.ID selected='') #{category.Name}
else
option(value=category.ID) #{category.Name}
option(value='0') -- New category --
input(type='text', placeholder='New category name' name='new-category')
input(type='text', placeholder='Title' name='title' required='')
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 == 1)
option(value=category.ID selected='') #{category.Name}
else
option(value=category.ID) #{category.Name}
option(value='0') -- New category --
input(type='text', placeholder='New category name' name='new-category')
input(type='hidden', name='post-id' value=post.ID)
input(type='hidden', name='old-category' value=post.Category.ID)
input(type='text', placeholder='Title' name='title' value=post.Title required='')
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.