Merge lp:~widelands-dev/widelands-website/toc_to_latest_posts into lp:widelands-website

Proposed by kaputtnik
Status: Merged
Merged at revision: 548
Proposed branch: lp:~widelands-dev/widelands-website/toc_to_latest_posts
Merge into: lp:widelands-website
Diff against target: 125 lines (+71/-38)
1 file modified
pybb/templates/pybb/all_last_posts.html (+71/-38)
To merge this branch: bzr merge lp:~widelands-dev/widelands-website/toc_to_latest_posts
Reviewer Review Type Date Requested Status
GunChleoc Approve
Review via email: mp+370906@code.launchpad.net

Commit message

Add a toc to latest posts view

Description of the change

The TOC contain all topics (when sorted by topic) or Forum/Topics (when sorted by forum).

I have prepared the alpha site for testing: https://alpha.widelands.org/forum/latest_posts/?days=1000&sort_by=forum

To post a comment you must log in.
548. By kaputtnik

removed wrong pluralization; clarified a comment

549. By kaputtnik

merged trunk

Revision history for this message
GunChleoc (gunchleoc) wrote :

Very nice indeed :)

review: Approve
Revision history for this message
kaputtnik (franku) wrote :

Thanks :-)

merged and deployed

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'pybb/templates/pybb/all_last_posts.html'
2--- pybb/templates/pybb/all_last_posts.html 2019-03-20 21:19:12 +0000
3+++ pybb/templates/pybb/all_last_posts.html 2019-08-02 19:48:22 +0000
4@@ -1,5 +1,12 @@
5 {% extends 'pybb/base.html' %}
6
7+{% load static %}
8+
9+{% block extra_head %}
10+<link rel="stylesheet" type="text/css" media="all" href="{% static 'css/wiki.css' %}" />
11+{{block.super}}
12+{% endblock %}
13+
14 {% block title %}
15 Latest posts - {{ block.super }}
16 {% endblock title %}
17@@ -30,44 +37,70 @@
18 {% endif %}
19 </form>
20
21- <hr>
22-
23-{% if sort_by == 'topic' %}
24- {% for topic, posts in object_list.items %}
25- <h2>Topic: {{ topic }}</h2>
26- <p>
27- At Forum:
28- <a href="{% url 'pybb_forum' topic.forum.id %}">{{ topic.forum }}</a>
29- </p>
30- {% include 'pybb/inlines/latest_posts_table.html'%}
31- {% endfor %}
32-
33-{% else %} {# sort by forum #}
34- {% for forum, topics in object_list.items %}
35- <h2>Forum: {{ forum }}</h2>
36- <table class='forum'>
37- <thead>
38- <tr>
39- <th style="text-align: left; width: 30%;">Topic{{ topic_list|length|pluralize }}</th>
40- <th style="text-align: left;">Post{{ posts|length|pluralize }}</th>
41- </tr>
42- </thead>
43- <tbody>
44- {% for topic, posts in topics.items %}
45- <tr class={% cycle 'odd' 'even' %}>
46- <td class='post'>
47- <a href="{% url 'pybb_topic' topic.id %}">{{ topic }}</a>
48- </td>
49- <td>
50- {% include 'pybb/inlines/latest_posts_table.html'%}
51- </td>
52+ <hr>
53+
54+ <div class="toc">
55+ {% if sort_by == 'topic' %}
56+ <h3>Topic{{ object_list|length|pluralize }}</h3>
57+ <ul>
58+ {% for topic in object_list %}
59+ <li><a href="#{{ topic.pk }}">{{ topic }}</a></li>
60+ {% endfor %}
61+ </ul>
62+ {% else %}
63+ <h3>Forum/Topics</h3>
64+ <ul>
65+ {% for forum, topics in object_list.items %}
66+ {# no access to forum.pk here, slugifying should be safe #}
67+ <li><a href="#{{ forum|slugify }}">{{ forum }}</a>
68+ <ul>
69+ {% for topic in topics %}
70+ <li><a href="#{{ topic.pk }}">{{ topic }}</a></li>
71+ {% endfor %}
72+ </ul>
73+ </li>
74+ {% endfor %}
75+ </ul>
76+ {% endif %}
77+ </div>
78+
79+ <div style="display: table;">
80+ {% if sort_by == 'topic' %}
81+ {% for topic, posts in object_list.items %}
82+ <h2 id="{{ topic.pk }}">Topic: {{ topic }}</h2>
83+ <p>
84+ At Forum:
85+ <a href="{% url 'pybb_forum' topic.forum.id %}">{{ topic.forum }}</a>
86+ </p>
87+ {% include 'pybb/inlines/latest_posts_table.html'%}
88+ {% endfor %}
89+ {% else %} {# sort by forum #}
90+ {% for forum, topics in object_list.items %}
91+ <h2 id="{{ forum|slugify }}">Forum: {{ forum }}</h2>
92+ <table>
93+ <thead>
94+ <tr>
95+ <th style="text-align: left; width: 30%;">Topic{{ topic_list|length|pluralize }}</th>
96+ <th style="text-align: left;">Post{{ posts|length|pluralize }}</th>
97 </tr>
98- {% endfor %}
99- </tbody>
100- </table>
101- {% empty %}
102- <p>Sorry, no posts found...</p>
103- {% endfor %}
104-{% endif %}
105+ </thead>
106+ <tbody>
107+ {% for topic, posts in topics.items %}
108+ <tr class={% cycle 'odd' 'even' %}>
109+ <td class='post'>
110+ <a href="{% url 'pybb_topic' topic.id %}" id="{{ topic.pk }}">{{ topic }}</a>
111+ </td>
112+ <td>
113+ {% include 'pybb/inlines/latest_posts_table.html'%}
114+ </td>
115+ </tr>
116+ {% endfor %}
117+ </tbody>
118+ </table>
119+ {% empty %}
120+ <p>Sorry, no posts found...</p>
121+ {% endfor %}
122+ {% endif %}
123+ </div>
124 </div>
125 {% endblock %}

Subscribers

People subscribed via source and target branches