extends base.pug

block meta_description
    meta(name='description' content="Guestbook administration.")

block append head
    link(href='/assets/css/guestbook.css' rel='stylesheet')
    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
    a(href='/guestbook') Guestbook
    h1 Guestbook Admin

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
                    form.entry(onsubmit='return false;')
                        header
                            - var created_tz = util.ToClientTimezone(entry.Created, r).Format("Monday _2 January 2006 15:04:05 -07:00")
                            | ##{entry.ID} by #[input(type='text' maxlength='80' placeholder='Name (Anonymous if left blank)' name='name' value=entry.Name)] #[input(type='text' maxlength='255' placeholder='Website (optional)' name='website' value=entry.Website)]
                            if entry.Website != ""
                                | (#[input(type='checkbox' name='hide_website') hide])
                            else
                                | (#[input(type='checkbox' name='hide_website' checked='') hide])
                            p on #[time(datetime=created_tz) #{created_tz}]
                        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("Monday _2 January 2006 15:04:05 -07:00")
                                | 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.
