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, r *http.Request)

    section
        form(id='add' action='/api/mindflow', method='POST')
            select(name='category' required='')
                option(value='1' selected='') Update
                option(value='2') Diary
                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
                        input(type='hidden', name='post_id' value=post.ID)
                        textarea(placeholder='Body post' name='body' required='')= post.Body
                        button(name='edit') Edit
                        button(name='delete') 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.
