extends vibenews.web.layout

block title
	- title = ("reply-to" in req.query || "reply-to" in req.form ? "Reply" : "Post new topic");

	script(type="text/javascript", src="#{req.rootDir}scripts/jquery.js")
	script(type="text/javascript", src="#{req.rootDir}scripts/vibenews-reply.js")

block vibenews.navigation
	- import vibenews.webstrings;
	ul
		li
			a(href="../")= forumIndexNavCaption
		li
			a(href="#{info.group.name}/")= info.group.caption
		- if( auto prp = "thread" in req.query )
			li
				a(href="#{info.group.name}/thread/#{*prp}/")= info.threadSubject
			li
				a(href="./post?group=#{info.group.name}&thread=#{*prp}&reply-to=#{req.query[`reply-to`]}") Reply
		- else
			li
				a(href="./post?group=#{info.group.name}") Post new topic

block vibenews.body
	- if( info.error.length )
		p.error= info.error

	form(action='post', method="POST")
		input(type="hidden", name="group", value="#{info.group.name}")
		- if( auto prt = "reply-to" in req.query )
			input(type="hidden", name="reply-to", value=*prt)
		- else if( auto prt = "reply-to" in req.form )
			input(type="hidden", name="reply-to", value=*prt)
		input#fc(type="hidden", name="check", value="3fb")
		table
			col.caption.helptext
			tr
				td.helptext.top-align(rowspan=3)
					p(style="color: gray;") Use 
						a(href="http://daringfireball.net/projects/markdown/basics", target="_blank") Markdown
						| with GitHub style extensions to format your message.
					div.post-content.markdown-cheatsheet
						h1 # heading
						h2 ## sub heading
						h3 ### sub sub heading
						p
							em *emphasized text*
						p
							strong **strong text**
						p
							code.prettyprint.lang-d `print("inline code");`
						p
							a(href="http://example.org") &lt;http://example.org&gt;
						p
							a(href="http://example.org") [link label](http://example.org)
						blockquote &gt; quoted<br>&gt; text
						pre.code.prettyprint.lang-d.
							```
							void code_block()
							{
								print("Hello!");
							}
							```

				td
					- if (!info.loggedIn)
						div
							label(for="name") Name:
							input#name(type="text", name="name", value="#{info.name}")
						div
							label(for="email") Email:
							input#email(type="email", name="email", value="#{info.email}")
					div
						label(for="subject") Subject:
						input#subject(type="text", name="subject", value="#{info.subject}")
			tr

				td.top-align
					#message-area
						textarea#message(name="message", rows="18", onkeyup="onTextChange()", onchange="onTextChange()")= info.message
						#message-preview.post-content
						:javascript updatePreview()
			tr
				td
					button(type="submit") Post

	script var fc=document.getElementById("fc");fc.setAttribute("value","a"+fc.getAttribute("value")+"#{info.postEpoch}");
