<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:py="http://genshi.edgewall.org/"
xmlns:xi="http://www.w3.org/2001/XInclude">
<?python
from pyforge.lib.security import has_artifact_access
?>
<py:def function="threads_table(threads)">
<input py:for="i,thread in enumerate(threads)"
type="hidden" name="thread-${i}.id" value="$thread._id"/>
<table id="threads">
<thead>
<tr>
<th>Topics</th>
<th>Replies</th>
<th>Views</th>
<th>Last Post</th>
<th>Subscribed</th>
</tr>
</thead>
<tbody>
<py:for each="i, thread in enumerate(threads)">
${thread_row(i, thread)}
</py:for>
</tbody>
</table>
</py:def>
<py:def function="forums_table(parent_id)">
<input py:for="i,forum in enumerate(c.app.subforums_of(parent_id))"
type="hidden" name="forum-${i}.shortname" value="$forum.shortname"/>
<table id="forums">
<thead>
<tr>
<th/>
<th>Forum</th><th>Topics</th><th>Posts</th><th>Last Post</th><th>Subscribed</th>
</tr>
</thead>
<tbody>
<py:for each="i, forum in enumerate(c.app.subforums_of(parent_id))">
${forum_row(i, forum)}
</py:for>
</tbody>
</table>
</py:def>
<py:def function="forum_row(i, forum)">
<tr>
<td>[icon]</td>
<td>
<a href="${forum.url()}">$forum.name</a>($forum.shortname)<br/>
${Markup(g.markdown.convert(forum.description))}
<py:if test="forum.subforums">
<b>Subforums:</b>
<span py:for="i, sf in enumerate(forum.subforums)">
<py:if test="i != 0">, </py:if>
<a href="${sf.url()}">$sf.name</a>
</span>
</py:if>
</td>
<td>${forum.num_topics}</td>
<td>${forum.num_posts}</td>
<td>${post_summary(forum.last_post)}</td>
<td>${checkbox('forum-%s.subscribed' % i, None, forum.subscription())}
</td>
</tr>
</py:def>
<py:def function="forum_admin_row(i, forum)">
<tr>
<td>[icon]</td>
<td>
<div class="editable viewing">
<div class="viewer"><a href="${forum.url()}">$forum.name</a>($forum.shortname)</div>
<div class="editor">
${text_field('forum-%s.name' % i, 'Forum Name', forum.name)}
</div>
</div>
<div class="editable viewing">
<div class="viewer">${Markup(g.markdown.convert(forum.description))}</div>
<div class="editor">
${text_area('forum-%s.description' % i, 'Description', forum.description)}
</div>
</div>
<py:if test="forum.subforums">
<b>Subforums:</b>
<span py:for="i, sf in enumerate(forum.subforums)">
<py:if test="i != 0">, </py:if>
<a href="${sf.url()}">$sf.name</a>
</span>
</py:if>
</td>
<td>${forum.num_topics}</td>
<td>${forum.num_posts}</td>
<td>${post_summary(forum.last_post)}</td>
<td>
${submit_button('Delete', 'forum-%s.delete' % i)}
</td>
</tr>
</py:def>
<py:def function="display_comment(comment)">
<div id="comment-${comment._id}"
style="padding-left: 10px; border-left: 1px solid grey">
Posted by <em>${comment.author().display_name}</em> at ${comment.timestamp}
<a py:if="c.user._id and comment.author_id==c.user._id"
href="comments/$comment._id/delete">[X]</a>
<br/>
<p py:content="comment.text"/>
<div class="reply">
<h3>Reply</h3>
<form class="hidden" method="post" action="comments/$comment._id/reply">
<textarea rows="4" cols="60" name="text"></textarea><br/>
<input type="submit"/>
</form>
</div>
<py:for each="cc in comment.replies()">
${display_comment(cc)}
</py:for>
</div>
</py:def>
<py:def function="thread_row(i, thread)">
<tr>
<td><a href="${thread.url()}">$thread.subject</a></td>
<td>$thread.num_replies</td>
<td>$thread.num_views</td>
<td>${post_summary(thread.last_post)}</td>
<td>${checkbox('thread-%s.subscribed' % i, None, thread.subscription())}</td>
</tr>
</py:def>
<py:def function="post_summary(post)">
<span py:if="post">
by <a href="${post.author().url()}">${post.author().display_name}</a>
${h.ago(post.timestamp)}
</span>
</py:def>
<py:def function="page_nav(offset,total,pagesize)"
py:with="cur_page=offset / pagesize; num_pages=total/pagesize">
<p>Page ${1 + cur_page} of ${1 + num_pages}</p>
<a href="."><<</a>
<a href="?offset=${offset - pagesize}"><</a>
<a href="?offset=${offset + pagesize}">></a>
<a href="?offset=${total - pagesize}">>></a>
</py:def>
<py:def function="display_post(post)">
<div id="post-${post.slug}" class="title-pane">
<div class="title">
<strong>$post.subject</strong>
by <a href="${post.author().url()}">${post.author().display_name}</a>
${h.ago(post.timestamp)}
</div>
<div class="content">
<a href="${post.url()}">Permalink</a>
<div py:if="has_artifact_access('moderate', post)()"
class="title-pane closed">
<span class="title">Moderate</span>
<div class="content">
<form method="POST" action="${post.url()}moderate">
<fieldset py:if="has_artifact_access('moderate', post.thread)()">
<legend>Promote post to its own thread</legend>
${text_field('subject', 'Thread title', post.subject)}
${submit_button('Promote to thread')}
</fieldset>
${submit_button('Delete Post')}
</form>
</div>
</div>
<br/>
${Markup(g.markdown.convert(post.text))}
<div py:if="has_artifact_access('moderate', post)()"
class="title-pane closed">
<span class="title">Edit Post</span>
<div class="content">
<form method="POST" action="${post.url()}">
${text_field('subject', 'Subject', post.subject)}
${text_area('text', 'Content', post.text)}
${submit_button('Update post')}
</form>
</div>
</div>
<div style="padding-left: 10px; border-left: 1px solid grey">
<div py:if="has_artifact_access('post', post.thread)()" class="reply title-pane closed">
<div class="title">Reply to ${post.author().display_name}</div>
<div class="content">
<form method="post" action="${post.url() + 'reply'}">
${text_field('subject', 'Subject', post.reply_subject())}
${text_area('text', 'Content', post.reply_text())}
${submit_button('Send Reply')}
</form>
</div>
</div>
<div py:if="has_artifact_access('moderate', post)()" class="reply title-pane closed">
<div class="title">New Attachment</div>
<div class="content">
<form method="post" action="${post.url() + 'attach'}" enctype="multipart/form-data">
${file_field('file_info', 'File to upload')}
${submit_button('Attach file')}
</form>
</div>
</div>
<div py:for="md in post.attachments"
py:with="url=post.attachment_url(md);filename=post.attachment_filename(md);ct=md.contentType">
<form py:if="c.user._id and post.author_id==c.user._id"
method="POST" action="$url"
style="display:inline">
<input type="submit" name="delete" value="Delete"/>
</form>
<a href="$url">$filename</a>
($md.length bytes)
<div py:if="ct.startswith('image/') or ct.startswith('text/')"
class="title-pane closed">
<div class="title">View $filename</div>
<img class="content" py:if="ct.startswith('image/')" style="max-width:100%" src="$url"/>
<iframe class="content" width="100%" py:if="ct.startswith('text/')"
src="$url?embed=True"/>
</div>
</div>
</div>
</div>
</div>
</py:def>
</html>