Treat posts as markdown. #262
[zzz-spline-forum.git] / splinext / forum / templates / forum / lib.mako
1 <%namespace name="lib" file="/lib.mako" />
2 <%namespace name="userlib" file="/users/lib.mako" />
3
4 <%def name="forum_access_level(forum)">
5 % if forum.access_level != 'normal':
6 <div class="forum-access-level">
7     % if forum.access_level == 'soapbox':
8     <img src="${h.static_uri('spline', 'icons/soap.png')}" alt=""> <strong>Soapbox</strong>: Regular users can't start new threads.
9     % elif forum.access_level == 'archive':
10     <img src="${h.static_uri('spline', 'icons/wooden-box.png')}" alt=""> <strong>Archive</strong>: No more posting!
11     % endif
12 </div>
13 % endif
14 </%def>
15
16 ## Prints a little hierarchy of context when viewing a thread
17 <%def name="hierarchy(forum, thread=None)">
18 <ul class="forum-hierarchy">
19 <li>
20     % if thread:
21     <a href="${url(controller='forum', action='threads', forum_id=forum.id)}">
22     % else:
23     <strong>
24     % endif
25         <img src="${h.static_uri('spline', 'icons/folders-stack.png')}" alt=""> ${forum.name}
26     % if thread:
27     </a>
28     % else:
29     </strong>
30     % endif
31     % if forum.description:
32     &mdash; ${forum.description}
33     % endif
34     ${forum_access_level(forum)}
35 </li>
36 % if thread:
37 <li>
38     <strong><img src="${h.static_uri('spline', 'icons/folder-open-document-text.png')}" alt=""> ${thread.subject}</strong>
39 </li>
40 % endif
41 </ul>
42 </%def>
43
44 <%def name="posts(posts)">
45 <div class="forum-post-container">
46     % for post in posts:
47     <div class="forum-post">
48         <div class="author">
49             <div class="avatar">
50                 ${userlib.avatar(post.author)}
51             </div>
52             <div class="name">
53                 <a href="${url(controller='users', action='profile', id=post.author.id, name=post.author.name)}">
54                     ${post.author.name}
55                     ${userlib.color_bar(post.author)}
56                 </a>
57             </div>
58         </div>
59         <div class="meta">
60             <time>${post.posted_time}</time>
61         </div>
62         <div class="content">${post.content | n}</div>
63     </div>
64     % endfor
65 </div>
66 </%def>
67
68 <%def name="write_thread_form(forum)">
69 % if forum.can_create_thread(c.user):
70 <h1>Create new thread</h1>
71 ${h.form(url(controller='forum', action='write_thread', forum_id=forum.id))}
72 <dl class="standard-form">
73     ${lib.field('subject', form=c.write_thread_form)}
74     ${lib.field('content', form=c.write_thread_form, rows=12, cols=80)}
75
76     <dd><button type="submit">Post!</button></dd>
77 </dl>
78 ${h.end_form()}
79 % endif  ## can create post
80 </%def>
81
82 <%def name="write_post_form(thread)">
83 % if thread.can_create_post(c.user):
84 <h1>Reply</h1>
85 ${h.form(url(controller='forum', action='write', forum_id=thread.forum.id, thread_id=thread.id))}
86 <dl class="standard-form">
87     ${lib.field('content', form=c.write_post_form, rows=12, cols=80)}
88
89     <dd><button type="submit">Post!</button></dd>
90 </dl>
91 ${h.end_form()}
92 % endif  ## can create post
93 </%def>