guestbook_admin template and assets.
This commit is contained in:
parent
790c866456
commit
8cb5cbc342
56
web/assets/css/guestbook_admin.css
Executable file
56
web/assets/css/guestbook_admin.css
Executable file
@ -0,0 +1,56 @@
|
||||
::placeholder { color: var(--primary-color); }
|
||||
|
||||
small { font-size: .8rem; }
|
||||
|
||||
form {
|
||||
display: grid;
|
||||
gap: .5rem;
|
||||
grid-template-areas:
|
||||
"m m"
|
||||
"e d";
|
||||
grid-template-columns: 1fr 1fr;
|
||||
width: 100%; }
|
||||
|
||||
textarea {
|
||||
background-color: var(--background-color);
|
||||
border: none;
|
||||
border-bottom: 1px solid var(--primary-color);
|
||||
color: var(--text-color);
|
||||
font: inherit;
|
||||
grid-area: m;
|
||||
height: 5.5rem;
|
||||
max-width: 100%;
|
||||
min-width: 100%; }
|
||||
|
||||
textarea:focus {
|
||||
outline-color: var(--primary-color);
|
||||
outline-style: solid;
|
||||
outline-width: 1px; }
|
||||
|
||||
button {
|
||||
background-color: var(--primary-color);
|
||||
border: none;
|
||||
color: #f5f5f5;
|
||||
font: inherit;
|
||||
grid-area: b;
|
||||
height: 2rem; }
|
||||
|
||||
button:hover {
|
||||
background-color: var(--secondary-color);
|
||||
cursor: pointer; }
|
||||
|
||||
button[name="edit-entry"],
|
||||
button[name="edit-reply"],
|
||||
button[name="reply"] { grid-area: e; }
|
||||
|
||||
button[name="delete-entry"],
|
||||
button[name="delete-reply"] { grid-area: d;}
|
||||
|
||||
article:not(:last-child) { margin-bottom: 1rem; }
|
||||
|
||||
article header {
|
||||
display: inline;
|
||||
font-size: .85rem; }
|
||||
|
||||
article > *,
|
||||
article div.reply > * { margin-left: .5rem; }
|
49
web/assets/js/guestbook_admin.js
Normal file
49
web/assets/js/guestbook_admin.js
Normal file
@ -0,0 +1,49 @@
|
||||
function get_entry_id(button) {
|
||||
return button.form.children[0].value
|
||||
}
|
||||
|
||||
// EDIT ENTRY
|
||||
|
||||
function edit_entry(e) {
|
||||
}
|
||||
|
||||
for (const edit_entry_button of document.getElementsByName("edit-entry"))
|
||||
edit_entry_button.addEventListener("click", edit_entry);
|
||||
|
||||
// DELETE ENTRY
|
||||
|
||||
function delete_entry(e) {
|
||||
fetch("/guestbook/admin/entry/"+get_entry_id(e.target), {method:"DELETE"})
|
||||
.catch(e => console.log(e))
|
||||
.then(() => window.location = "/guestbook/admin");
|
||||
}
|
||||
|
||||
for (const delete_entry_button of document.getElementsByName("delete-entry"))
|
||||
delete_entry_button.addEventListener("click", delete_entry);
|
||||
|
||||
// EDIT REPLY
|
||||
|
||||
function edit_reply(e) {
|
||||
}
|
||||
|
||||
for (const edit_reply_button of document.getElementsByName("edit-reply"))
|
||||
edit_reply_button.addEventListener("click", edit_reply);
|
||||
|
||||
// DELETE REPLY
|
||||
|
||||
function delete_reply(e) {
|
||||
fetch("/guestbook/admin/reply/"+get_entry_id(e.target), {method:"DELETE"})
|
||||
.catch(e => console.log(e))
|
||||
.then(() => window.location = "/guestbook/admin");
|
||||
}
|
||||
|
||||
for (const delete_reply_button of document.getElementsByName("delete-reply"))
|
||||
delete_reply_button.addEventListener("click", delete_reply);
|
||||
|
||||
// NEW REPLY
|
||||
|
||||
function send_reply(e) {
|
||||
}
|
||||
|
||||
for (const reply_button of document.getElementsByName("reply"))
|
||||
reply_button.addEventListener("click", send_reply);
|
47
web/templates/guestbook_admin.pug
Executable file
47
web/templates/guestbook_admin.pug
Executable file
@ -0,0 +1,47 @@
|
||||
extends base.pug
|
||||
|
||||
block meta_description
|
||||
meta(name='description' content="Guestbook administration.")
|
||||
|
||||
block append head
|
||||
link(href='/assets/css/guestbook_admin.css' rel='stylesheet')
|
||||
script(src='/assets/js/guestbook_admin.js' defer='')
|
||||
|
||||
block nav
|
||||
a(href='/') Home
|
||||
a(href='/stuff') Stuff
|
||||
a(href='/mindflow') Mindflow
|
||||
a(href='/about') About
|
||||
h1 Guestbook
|
||||
|
||||
block content
|
||||
:go:func GuestbookAdmin(title, owner string, entries []*guestbook.Entry, r *http.Request)
|
||||
section#posts
|
||||
if (len(entries) > 0)
|
||||
each entry in entries
|
||||
article
|
||||
header
|
||||
- var created_tz = util.ToClientTimezone(entry.Created, r).Format("2006-01-02T15:04:05")
|
||||
| Entry ##{entry.ID} by #[span.highlighted #{entry.Name}] #[em #{entry.Website}] on #[time(datetime=created_tz) #{created_tz}]
|
||||
form.entry(onsubmit='return false;')
|
||||
input(type='hidden' value=entry.ID name='entry_id')
|
||||
textarea(maxlength='4096' placeholder='Your message' name="message" required='')= entry.Message
|
||||
button(name="edit-entry") Edit
|
||||
button(name="delete-entry") Delete
|
||||
if (entry.Reply != nil)
|
||||
.reply
|
||||
header
|
||||
- var reply_created_tz = util.ToClientTimezone(entry.Reply.Created, r).Format("2006-01-02 15:04:05")
|
||||
| Reply by #[span.highlighted #{owner}] on #[time(datetime=reply_created_tz) #{reply_created_tz}]
|
||||
form.reply(onsubmit='return false;')
|
||||
input(type='hidden' value=entry.ID name='entry_id')
|
||||
textarea(maxlength='4096' placeholder='Your message' name="message" required='')= entry.Reply.Message
|
||||
button(name="edit-reply") Edit
|
||||
button(name="delete-reply") Delete
|
||||
else
|
||||
form.reply(onsubmit='return false;')
|
||||
input(type='hidden' value=entry.ID name='entry_id')
|
||||
textarea(maxlength='4096' placeholder='Write a reply' name="message" required='')
|
||||
button(name="reply") Reply
|
||||
else
|
||||
p.center No posts.
|
@ -13,6 +13,7 @@ import (
|
||||
//
|
||||
//go:generate $GOPATH/bin/jade -basedir ./templates -pkg=web -stdbuf -stdlib -writer index.pug stuff.pug mindflow.pug
|
||||
//go:generate $GOPATH/bin/jade -basedir ./templates -pkg=web -stdbuf -stdlib -writer about.pug guestbook.pug rss.pug
|
||||
//go:generate $GOPATH/bin/jade -basedir ./templates -pkg=web -stdbuf -stdlib -writer guestbook_admin.pug
|
||||
|
||||
//go:generate $GOPATH/bin/jade -basedir ./templates -pkg=web -stdbuf -stdlib -writer article.pug
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user