Parent: [b1f258] (diff)

Download this file

lib.html    243 lines (231 with data), 8.9 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
<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}">
<div class="forge_comment_body">
<div class="user_info">
<img src="/images/error.png" alt="icon" width="50" height="50"/>
<br/>
${comment.author().display_name}
</div>
<a py:if="c.user._id and comment.author_id==c.user._id"
href="comments/$comment._id/delete">[X]</a>
<br/>
${Markup(g.markdown.convert(comment.text))}
${comment.posted_ago}
<div class="reply title-pane closed">
<a class="title" href="#">Reply</a>
<div class="content">
<form method="post" action="comments/$comment._id/reply">
<textarea rows="4" cols="60" name="text"></textarea><br/>
<input type="submit" value="Save Comment"/>
</form>
</div>
</div>
</div>
<div class="forge_comment_replies">
<py:for each="cc in comment.replies()">
${display_comment(cc)}
</py:for>
</div>
</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=".">&lt;&lt;</a>
<a href="?offset=${offset - pagesize}">&lt;</a>
<a href="?offset=${offset + pagesize}">&gt;</a>
<a href="?offset=${total - pagesize}">&gt;&gt;</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>
<form method="POST" action="${post.url()}flag">
${submit_button('Flag this post as inappropriate or spam')}
</form>
<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('Spam Post', 'spam')}
${submit_button('Delete Post', 'delete')}
</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="att in post.attachments">
<form py:if="c.user._id and post.author_id==c.user._id"
method="POST" action="${att.url()}"
style="display:inline">
<input type="submit" name="delete" value="Delete"/>
</form>
<a href="${att.url()}">${att.metadata.filename}</a>
($att.length bytes)
<div py:if="att.contentType.startswith('image/') or att.contentType.startswith('text/')"
class="title-pane closed">
<div class="title">View $att.metadata.filename</div>
<img class="content" py:if="att.contentType.startswith('image/')"
style="max-width:100%" src="${att.url()}"/>
<iframe class="content" width="100%" py:if="att.contentType.startswith('text/')"
src="${att.url()}?embed=True"/>
</div>
</div>
</div>
</div>
</div>
</py:def>
</html>