Show recent forum threads on the front page. Sucks, but.
[zzz-spline-forum.git] / splinext / forum / templates / forum / forums.mako
1 <%inherit file="/base.mako" />
2 <%namespace name="forumlib" file="/forum/lib.mako" />
3 <%namespace name="userlib" file="/users/lib.mako" />
4
5 <%def name="title()">Forums</%def>
6
7 <h1>Forums</h1>
8 <table class="forum-list striped-rows">
9 <thead>
10     <tr class="header-row">
11         <th class="name">
12             <img src="${h.static_uri('spline', 'icons/folders-stack.png')}" alt="">
13             Forum
14         </th>
15         <th class="last-post">Last post</th>
16         <th class="stats">Volume</th>
17         <th class="stats">Activity</th>
18     </tr>
19 </thead>
20 <tbody>
21     % for forum in c.forums:
22     <tr>
23         <td class="name">
24             <a href="${url(controller='forum', action='threads', forum_id=forum.id)}">${forum.name}</a>
25             ${forumlib.forum_access_level(forum)}
26             % if forum.description:
27             <div class="forum-description">
28                 ${forum.description}
29             </div>
30             % endif
31         </td>
32
33         <td class="last-post">
34             <% last_post = c.last_post.get(forum.id, None) %> \
35             % if last_post:
36             ## XXX should do direct post link
37             <a href="${url(controller='forum', action='posts', forum_id=forum.id, thread_id=last_post.thread_id)}">${last_post.posted_time}</a>
38             <br> in <a href="${url(controller='forum', action='posts', forum_id=forum.id, thread_id=last_post.thread_id)}">${last_post.thread.subject}</a>
39             <br> by <a href="${url(controller='users', action='profile', id=last_post.author.id, name=last_post.author.name)}">${userlib.color_bar(last_post.author)} ${last_post.author.name}</a>
40             % else:
41             —
42             % endif
43         </td>
44
45         <% relative_volume = c.forum_volume[forum.id] / c.max_volume %>\
46         <td class="stats
47             % if relative_volume < 0.1:
48             verylow
49             % elif relative_volume < 0.33:
50             low
51             % elif relative_volume < 0.5:
52             okay
53             % elif relative_volume < 0.67:
54             high
55             % elif relative_volume < 0.9:
56             veryhigh
57             % else:
58             whoanelly
59             % endif
60         ">
61             ${"{0:3.1f}".format(c.forum_volume[forum.id] * 100)}%
62         </th>
63         <% activity = c.forum_activity[forum.id] %>\
64         <td class="stats
65             % if activity < 0.25:
66             verylow
67             % elif activity < 0.5:
68             low
69             % elif activity < 1.0:
70             okay
71             % elif activity < 2.0:
72             high
73             % elif activity < 4.0:
74             veryhigh
75             % else:
76             whoanelly
77             % endif
78         ">
79             ${"{0:0.3f}".format(activity)}
80         </td>
81     </tr>
82     % endfor
83 </tbody>
84 </table>