##// END OF EJS Templates
#44 Show last replies in the threads list.
neko259 -
r59:583a602b default
parent child Browse files
Show More
@@ -255,6 +255,18 b' class Post(models.Model):'
255
255
256 return replies_count <= settings.MAX_POSTS_PER_THREAD
256 return replies_count <= settings.MAX_POSTS_PER_THREAD
257
257
258 def get_last_replies(self):
259 if settings.LAST_REPLIES_COUNT > 0:
260 reply_count = self.get_reply_count()
261
262 if reply_count > 0:
263 reply_count_to_show = min(settings.LAST_REPLIES_COUNT,
264 reply_count)
265 last_replies = self._get_replies()[reply_count
266 - reply_count_to_show:]
267
268 return last_replies
269
258
270
259 class Admin(models.Model):
271 class Admin(models.Model):
260 """
272 """
@@ -30,7 +30,7 b' html {'
30 color: #fff380;
30 color: #fff380;
31 }
31 }
32
32
33 .post, .dead_post{
33 .post, .dead_post {
34 background: #333;
34 background: #333;
35 margin: 5px;
35 margin: 5px;
36 padding: 10px;
36 padding: 10px;
@@ -185,3 +185,15 b' blockquote {'
185 a:hover {
185 a:hover {
186 text-decoration: underline;
186 text-decoration: underline;
187 }
187 }
188
189 .last-replies {
190 margin-left: 3ex;
191 }
192
193 .thread {
194 margin-bottom: 3ex;
195 }
196
197 .post:target {
198 border: solid 2px white;
199 } No newline at end of file
@@ -128,10 +128,12 b' a {'
128 }
128 }
129
129
130 .post {
130 .post {
131 background: #FFF;
131 clear: left;
132 border-bottom: 1px solid #182F6F;
133 margin: 0 1ex 1em 1ex;
132 margin: 0 1ex 1em 1ex;
134 overflow-x: auto;
133 overflow-x: auto;
134 }
135 .last-replies > .post, body > .post + .post {
136 border-bottom: 1px solid #182F6F;
135 padding-bottom: 1em;
137 padding-bottom: 1em;
136 }
138 }
137
139
@@ -170,22 +172,10 b' a {'
170 clear: left;
172 clear: left;
171 }
173 }
172
174
173 .post {
174 clear: left;
175 }
176
177 .post > .message .get {
175 .post > .message .get {
178 color: #182F6F; font-weight: bold;
176 color: #182F6F; font-weight: bold;
179 }
177 }
180
178
181 .dead_post {
182 background: #FFF;
183 border-bottom: 1px solid #182F6F;
184 margin: 0 1ex 1em 1ex;
185 overflow-x: auto;
186 padding-bottom: 1em;
187 clear: left;
188 }
189 .dead_post > .metadata {
179 .dead_post > .metadata {
190 background: #eee;
180 background: #eee;
191 }
181 }
@@ -206,5 +196,19 b' a {'
206 }
196 }
207
197
208 .comment {
198 .comment {
209 color: darkseagreen;
199 color: #557055;
200 }
201
202 .last-replies {
203 margin-left: 6ex;
204 }
205
206 .thread > .post > .message > .post-info {
207 border-bottom: 2px solid #182F6F;
208 padding-bottom: .5em;
209 }
210
211 .last-replies > .post:last-child {
212 border-bottom: none;
213 padding-bottom: 0;
210 } No newline at end of file
214 }
@@ -183,4 +183,5 b' THEMES = ['
183 ('sw', 'Snow White') ]
183 ('sw', 'Snow White') ]
184 DEFAULT_THEME = 'md'
184 DEFAULT_THEME = 'md'
185
185
186 POPULAR_TAGS = 10 No newline at end of file
186 POPULAR_TAGS = 10
187 LAST_REPLIES_COUNT = 3 No newline at end of file
@@ -9,12 +9,13 b''
9
9
10 {% block content %}
10 {% block content %}
11
11
12 {% if threads %}
12 {% if threads %}
13 {% for thread in threads %}
13 {% for thread in threads %}
14 <div class="thread">
14 {% if thread.can_bump %}
15 {% if thread.can_bump %}
15 <div class="post">
16 <div class="post">
16 {% else %}
17 {% else %}
17 <div class="dead_post">
18 <div class="post dead_post">
18 {% endif %}
19 {% endif %}
19 {% if thread.image %}
20 {% if thread.image %}
20 <div class="image">
21 <div class="image">
@@ -24,34 +25,67 b''
24 </div>
25 </div>
25 {% endif %}
26 {% endif %}
26 <div class="message">
27 <div class="message">
27 <span class="title">{{ thread.title }}</span>
28 <div class="post-info">
28 <a class="post_id" href="{% url 'thread' thread.id %}">
29 <span class="title">{{ thread.title }}</span>
29 (#{{ thread.id }})</a>
30 <a class="post_id" href="{% url 'thread' thread.id %}">
30 [{{ thread.pub_time }}]
31 (#{{ thread.id }})</a>
31 [<a class="link" href="{% url 'thread' thread.id %}#form"
32 [{{ thread.pub_time }}]
32 >{% trans "Reply" %}</a>]
33 [<a class="link" href="{% url 'thread' thread.id %}#form"
34 >{% trans "Reply" %}</a>]
35 </div>
33 {% autoescape off %}
36 {% autoescape off %}
34 {{ thread.text.rendered|truncatechars:300 }}
37 {{ thread.text.rendered|truncatechars:300 }}
35 {% endautoescape %}
38 {% endautoescape %}
36 </div>
39 </div>
37 <div class="metadata">
40 <div class="metadata">
38 {% if thread.tags.all %}
41 {{ thread.get_reply_count }} {% trans 'replies' %},
39 <span class="tags">{% trans 'Tags' %}:
42 {{ thread.get_images_count }} {% trans 'images' %}.
40 {% for tag in thread.tags.all %}
43 {% if thread.tags.all %}
41 <a class="tag" href="
44 <span class="tags">{% trans 'Tags' %}:
42 {% url 'tag' tag_name=tag.name %}">
45 {% for tag in thread.tags.all %}
43 {{ tag.name }}</a>
46 <a class="tag" href="
44 {% endfor %}
47 {% url 'tag' tag_name=tag.name %}">
45 </span>
48 {{ tag.name }}</a>
46 {% endif %},
49 {% endfor %}
47 {{ thread.get_reply_count }} {% trans 'replies' %},
50 </span>
48 {{ thread.get_images_count }} {% trans 'images' %}.
51 {% endif %}
49 {% trans 'Last update: ' %}{{ thread.last_edit_time }}
52 </div>
53 </div>
54 {% if thread.get_last_replies %}
55 <div class="last-replies">
56 {% for post in thread.get_last_replies %}
57 {% if thread.can_bump %}
58 <div class="post">
59 {% else %}
60 <div class="post dead_post">
61 {% endif %}
62 {% if post.image %}
63 <div class="image">
64 <a href="{{ post.image.url }}"><img
65 src="{{ post.image.url_200x150 }}" />
66 </a>
67 </div>
68 {% endif %}
69 <div class="message">
70 <div class="post-info">
71 <span class="title">{{ post.title }}</span>
72 <a class="post_id" href="
73 {% url 'thread' thread.id %}#{{ post.id }}">
74 (#{{ post.id }})</a>
75 [{{ post.pub_time }}]
76 </div>
77 {% autoescape off %}
78 {{ post.text.rendered|truncatechars:300 }}
79 {% endautoescape %}
80 </div>
81 </div>
82 {% endfor %}
50 </div>
83 </div>
51 </div>
84 {% endif %}
85 </div>
52 {% endfor %}
86 {% endfor %}
53 {% else %}
87 {% else %}
54 No threads found.
88 No threads found.
55 <hr />
89 <hr />
56 {% endif %}
90 {% endif %}
57
91
@@ -11,8 +11,11 b''
11
11
12 {% if posts %}
12 {% if posts %}
13 {% for post in posts %}
13 {% for post in posts %}
14 <a id="{{ post.id }}"></a>
14 {% if posts.0.can_bump %}
15 <div class="post">
15 <div class="post" id="{{ post.id }}">
16 {% else %}
17 <div class="post dead_post" id="{{ post.id }}">
18 {% endif %}
16 {% if post.image %}
19 {% if post.image %}
17 <div class="image">
20 <div class="image">
18 <a href="{{ post.image.url }}"><img
21 <a href="{{ post.image.url }}"><img
@@ -21,15 +24,17 b''
21 </div>
24 </div>
22 {% endif %}
25 {% endif %}
23 <div class="message">
26 <div class="message">
24 <span class="title">{{ post.title }}</span>
27 <div class="post-info">
25 <a class="post_id" href="#{{ post.id }}">
28 <span class="title">{{ post.title }}</span>
26 (#{{ post.id }})</a>
29 <a class="post_id" href="#{{ post.id }}">
27 [{{ post.pub_time }}]
30 (#{{ post.id }})</a>
28 {% if post.is_get %}
31 [{{ post.pub_time }}]
29 <span class="get">
32 {% if post.is_get %}
30 {% trans "Get!" %}
33 <span class="get">
31 </span>
34 {% trans "Get!" %}
32 {% endif %}
35 </span>
36 {% endif %}
37 </div>
33 {% autoescape off %}
38 {% autoescape off %}
34 {{ post.text.rendered }}
39 {{ post.text.rendered }}
35 {% endautoescape %}
40 {% endautoescape %}
General Comments 0
You need to be logged in to leave comments. Login now