##// END OF EJS Templates
Refactored post view, added a hint of how to add new tags to favorites
neko259 -
r1093:0edfd683 default
parent child Browse files
Show More
@@ -33,7 +33,7 b" ATTRIBUTE_ROWS = 'rows'"
33 LAST_POST_TIME = 'last_post_time'
33 LAST_POST_TIME = 'last_post_time'
34 LAST_LOGIN_TIME = 'last_login_time'
34 LAST_LOGIN_TIME = 'last_login_time'
35 TEXT_PLACEHOLDER = _('Type message here. Use formatting panel for more advanced usage.')
35 TEXT_PLACEHOLDER = _('Type message here. Use formatting panel for more advanced usage.')
36 TAGS_PLACEHOLDER = _('tag1 several_words_tag')
36 TAGS_PLACEHOLDER = _('music images i_dont_like_tags')
37
37
38 LABEL_TITLE = _('Title')
38 LABEL_TITLE = _('Title')
39 LABEL_TEXT = _('Text')
39 LABEL_TEXT = _('Text')
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -7,7 +7,7 b' msgid ""'
7 msgstr ""
7 msgstr ""
8 "Project-Id-Version: PACKAGE VERSION\n"
8 "Project-Id-Version: PACKAGE VERSION\n"
9 "Report-Msgid-Bugs-To: \n"
9 "Report-Msgid-Bugs-To: \n"
10 "POT-Creation-Date: 2015-04-07 15:26+0300\n"
10 "POT-Creation-Date: 2015-04-14 13:07+0300\n"
11 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
11 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
12 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
12 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13 "Language-Team: LANGUAGE <LL@li.org>\n"
13 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -44,8 +44,8 b' msgstr ""'
44 "Π’Π²ΠΎΠ΄ΠΈΡ‚Π΅ сообщСниС сюда. Π˜ΡΠΏΠΎΠ»ΡŒΠ·ΡƒΠΉΡ‚Π΅ панСль для Π±ΠΎΠ»Π΅Π΅ слоТного форматирования."
44 "Π’Π²ΠΎΠ΄ΠΈΡ‚Π΅ сообщСниС сюда. Π˜ΡΠΏΠΎΠ»ΡŒΠ·ΡƒΠΉΡ‚Π΅ панСль для Π±ΠΎΠ»Π΅Π΅ слоТного форматирования."
45
45
46 #: forms.py:36
46 #: forms.py:36
47 msgid "tag1 several_words_tag"
47 msgid "music images i_dont_like_tags"
48 msgstr "ΠΌΠ΅Ρ‚ΠΊΠ°1 ΠΌΠ΅Ρ‚ΠΊΠ°_ΠΈΠ·_Π½Π΅ΡΠΊΠΎΠ»ΡŒΠΊΠΈΡ…_слов"
48 msgstr "ΠΌΡƒΠ·Ρ‹ΠΊΠ° ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΠΈ Ρ‚Π΅Π³ΠΈ_Π½Π΅_Π½ΡƒΠΆΠ½Ρ‹"
49
49
50 #: forms.py:38
50 #: forms.py:38
51 msgid "Title"
51 msgid "Title"
@@ -59,7 +59,7 b' msgstr "\xd0\xa2\xd0\xb5\xd0\xba\xd1\x81\xd1\x82"'
59 msgid "Tag"
59 msgid "Tag"
60 msgstr "ΠœΠ΅Ρ‚ΠΊΠ°"
60 msgstr "ΠœΠ΅Ρ‚ΠΊΠ°"
61
61
62 #: forms.py:41 templates/boards/base.html:36 templates/search/search.html:7
62 #: forms.py:41 templates/boards/base.html:40 templates/search/search.html:7
63 msgid "Search"
63 msgid "Search"
64 msgstr "Поиск"
64 msgstr "Поиск"
65
65
@@ -76,7 +76,6 b' msgid "e-mail"'
76 msgstr ""
76 msgstr ""
77
77
78 #: forms.py:152
78 #: forms.py:152
79 #| msgid "All threads"
80 msgid "Additional threads"
79 msgid "Additional threads"
81 msgstr "Π”ΠΎΠΏΠΎΠ»Π½ΠΈΡ‚Π΅Π»ΡŒΠ½Ρ‹Π΅ Ρ‚Π΅ΠΌΡ‹"
80 msgstr "Π”ΠΎΠΏΠΎΠ»Π½ΠΈΡ‚Π΅Π»ΡŒΠ½Ρ‹Π΅ Ρ‚Π΅ΠΌΡ‹"
82
81
@@ -94,50 +93,50 b' msgstr "\xd0\xa2\xd0\xb5\xd0\xba\xd1\x81\xd1\x82 \xd0\xb4\xd0\xbe\xd0\xbb\xd0\xb6\xd0\xb5\xd0\xbd \xd0\xb1\xd1\x8b\xd1\x82\xd1\x8c \xd0\xba\xd0\xbe\xd1\x80\xd0\xbe\xd1\x87\xd0\xb5 %s \xd1\x81\xd0\xb8\xd0\xbc\xd0\xb2\xd0\xbe\xd0\xbb\xd0\xbe\xd0\xb2"'
94 msgid "Invalid URL"
93 msgid "Invalid URL"
95 msgstr "НСвСрный URL"
94 msgstr "НСвСрный URL"
96
95
97 #: forms.py:214
96 #: forms.py:215
98 msgid "Invalid additional thread list"
97 msgid "Invalid additional thread list"
99 msgstr "НСвСрный список Π΄ΠΎΠΏΠΎΠ»Π½ΠΈΡ‚Π΅Π»ΡŒΠ½Ρ‹Ρ… Ρ‚Π΅ΠΌ"
98 msgstr "НСвСрный список Π΄ΠΎΠΏΠΎΠ»Π½ΠΈΡ‚Π΅Π»ΡŒΠ½Ρ‹Ρ… Ρ‚Π΅ΠΌ"
100
99
101 #: forms.py:249
100 #: forms.py:250
102 msgid "Either text or image must be entered."
101 msgid "Either text or image must be entered."
103 msgstr "ВСкст ΠΈΠ»ΠΈ ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΠ° Π΄ΠΎΠ»ΠΆΠ½Ρ‹ Π±Ρ‹Ρ‚ΡŒ Π²Π²Π΅Π΄Π΅Π½Ρ‹."
102 msgstr "ВСкст ΠΈΠ»ΠΈ ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΠ° Π΄ΠΎΠ»ΠΆΠ½Ρ‹ Π±Ρ‹Ρ‚ΡŒ Π²Π²Π΅Π΄Π΅Π½Ρ‹."
104
103
105 #: forms.py:265
104 #: forms.py:266
106 #, python-format
105 #, python-format
107 msgid "Wait %s seconds after last posting"
106 msgid "Wait %s seconds after last posting"
108 msgstr "ΠŸΠΎΠ΄ΠΎΠΆΠ΄ΠΈΡ‚Π΅ %s сСкунд послС послСднСго постинга"
107 msgstr "ΠŸΠΎΠ΄ΠΎΠΆΠ΄ΠΈΡ‚Π΅ %s сСкунд послС послСднСго постинга"
109
108
110 #: forms.py:277
109 #: forms.py:278
111 #, python-format
110 #, python-format
112 msgid "Image must be less than %s bytes"
111 msgid "Image must be less than %s bytes"
113 msgstr "Π˜Π·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠ΅ Π΄ΠΎΠ»ΠΆΠ½ΠΎ Π±Ρ‹Ρ‚ΡŒ ΠΌΠ΅Π½Π΅Π΅ %s Π±Π°ΠΉΡ‚"
112 msgstr "Π˜Π·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠ΅ Π΄ΠΎΠ»ΠΆΠ½ΠΎ Π±Ρ‹Ρ‚ΡŒ ΠΌΠ΅Π½Π΅Π΅ %s Π±Π°ΠΉΡ‚"
114
113
115 #: forms.py:324 templates/boards/posting_general.html:148
114 #: forms.py:325 templates/boards/posting_general.html:148
116 #: templates/boards/rss/post.html:10 templates/boards/tags.html:7
115 #: templates/boards/rss/post.html:10 templates/boards/tags.html:7
117 msgid "Tags"
116 msgid "Tags"
118 msgstr "ΠœΠ΅Ρ‚ΠΊΠΈ"
117 msgstr "ΠœΠ΅Ρ‚ΠΊΠΈ"
119
118
120 #: forms.py:331
119 #: forms.py:332
121 msgid "Inappropriate characters in tags."
120 msgid "Inappropriate characters in tags."
122 msgstr "НСдопустимыС символы Π² ΠΌΠ΅Ρ‚ΠΊΠ°Ρ…."
121 msgstr "НСдопустимыС символы Π² ΠΌΠ΅Ρ‚ΠΊΠ°Ρ…."
123
122
124 #: forms.py:342
123 #: forms.py:343
125 msgid "Need at least 1 required tag."
124 msgid "Need at least 1 required tag."
126 msgstr "НуТна хотя Π±Ρ‹ 1 ΠΎΠ±ΡΠ·Π°Ρ‚Π΅Π»ΡŒΠ½Π°Ρ ΠΌΠ΅Ρ‚ΠΊΠ°."
125 msgstr "НуТна хотя Π±Ρ‹ 1 ΠΎΠ±ΡΠ·Π°Ρ‚Π΅Π»ΡŒΠ½Π°Ρ ΠΌΠ΅Ρ‚ΠΊΠ°."
127
126
128 #: forms.py:354
127 #: forms.py:355
129 msgid "Theme"
128 msgid "Theme"
130 msgstr "Π’Π΅ΠΌΠ°"
129 msgstr "Π’Π΅ΠΌΠ°"
131
130
132 #: forms.py:355
131 #: forms.py:356
133 msgid "User name"
132 msgid "User name"
134 msgstr "Имя ΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»Ρ"
133 msgstr "Имя ΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»Ρ"
135
134
136 #: forms.py:356
135 #: forms.py:357
137 msgid "Time zone"
136 msgid "Time zone"
138 msgstr "Часовой пояс"
137 msgstr "Часовой пояс"
139
138
140 #: forms.py:362
139 #: forms.py:363
141 msgid "Inappropriate characters."
140 msgid "Inappropriate characters."
142 msgstr "НСдопустимыС символы."
141 msgstr "НСдопустимыС символы."
143
142
@@ -173,29 +172,33 b' msgstr "\xd0\x9b\xd0\xb5\xd0\xbd\xd1\x82\xd0\xb0"'
173 msgid "All threads"
172 msgid "All threads"
174 msgstr "ВсС Ρ‚Π΅ΠΌΡ‹"
173 msgstr "ВсС Ρ‚Π΅ΠΌΡ‹"
175
174
176 #: templates/boards/base.html:34
175 #: templates/boards/base.html:36
176 msgid "Add tags"
177 msgstr "Π”ΠΎΠ±Π°Π²ΠΈΡ‚ΡŒ ΠΌΠ΅Ρ‚ΠΊΠΈ"
178
179 #: templates/boards/base.html:38
177 msgid "Tag management"
180 msgid "Tag management"
178 msgstr "Π£ΠΏΡ€Π°Π²Π»Π΅Π½ΠΈΠ΅ ΠΌΠ΅Ρ‚ΠΊΠ°ΠΌΠΈ"
181 msgstr "Π£ΠΏΡ€Π°Π²Π»Π΅Π½ΠΈΠ΅ ΠΌΠ΅Ρ‚ΠΊΠ°ΠΌΠΈ"
179
182
180 #: templates/boards/base.html:39 templates/boards/base.html.py:40
183 #: templates/boards/base.html:43 templates/boards/base.html.py:44
181 #: templates/boards/notifications.html:8
184 #: templates/boards/notifications.html:8
182 msgid "Notifications"
185 msgid "Notifications"
183 msgstr "УвСдомлСния"
186 msgstr "УвСдомлСния"
184
187
185 #: templates/boards/base.html:47 templates/boards/settings.html:9
188 #: templates/boards/base.html:51 templates/boards/settings.html:9
186 msgid "Settings"
189 msgid "Settings"
187 msgstr "Настройки"
190 msgstr "Настройки"
188
191
189 #: templates/boards/base.html:60
192 #: templates/boards/base.html:64
190 msgid "Admin"
193 msgid "Admin"
191 msgstr "АдминистрированиС"
194 msgstr "АдминистрированиС"
192
195
193 #: templates/boards/base.html:62
196 #: templates/boards/base.html:66
194 #, python-format
197 #, python-format
195 msgid "Speed: %(ppd)s posts per day"
198 msgid "Speed: %(ppd)s posts per day"
196 msgstr "Π‘ΠΊΠΎΡ€ΠΎΡΡ‚ΡŒ: %(ppd)s сообщСний Π² дСнь"
199 msgstr "Π‘ΠΊΠΎΡ€ΠΎΡΡ‚ΡŒ: %(ppd)s сообщСний Π² дСнь"
197
200
198 #: templates/boards/base.html:64
201 #: templates/boards/base.html:68
199 msgid "Up"
202 msgid "Up"
200 msgstr "Π’Π²Π΅Ρ€Ρ…"
203 msgstr "Π’Π²Π΅Ρ€Ρ…"
201
204
@@ -229,11 +232,11 b' msgstr "\xd0\x98\xd0\xb7\xd0\xbc\xd0\xb5\xd0\xbd\xd0\xb8\xd1\x82\xd1\x8c \xd1\x82\xd0\xb5\xd0\xbc\xd1\x83"'
229 msgid "Replies"
232 msgid "Replies"
230 msgstr "ΠžΡ‚Π²Π΅Ρ‚Ρ‹"
233 msgstr "ΠžΡ‚Π²Π΅Ρ‚Ρ‹"
231
234
232 #: templates/boards/post.html:86 templates/boards/thread.html:30
235 #: templates/boards/post.html:86 templates/boards/thread.html:31
233 msgid "messages"
236 msgid "messages"
234 msgstr "сообщСний"
237 msgstr "сообщСний"
235
238
236 #: templates/boards/post.html:87 templates/boards/thread.html:31
239 #: templates/boards/post.html:87 templates/boards/thread.html:32
237 msgid "images"
240 msgid "images"
238 msgstr "ΠΈΠ·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠΉ"
241 msgstr "ΠΈΠ·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠΉ"
239
242
@@ -356,7 +359,7 b' msgstr "\xd0\x9c\xd0\xb5\xd1\x82\xd0\xba\xd0\xb8 \xd0\xbd\xd0\xb5 \xd0\xbd\xd0\xb0\xd0\xb9\xd0\xb4\xd0\xb5\xd0\xbd\xd1\x8b."'
356 msgid "All tags"
359 msgid "All tags"
357 msgstr "ВсС ΠΌΠ΅Ρ‚ΠΊΠΈ"
360 msgstr "ВсС ΠΌΠ΅Ρ‚ΠΊΠΈ"
358
361
359 #: templates/boards/thread.html:32
362 #: templates/boards/thread.html:33
360 msgid "Last update: "
363 msgid "Last update: "
361 msgstr "ПослСднСС обновлСниС: "
364 msgstr "ПослСднСС обновлСниС: "
362
365
@@ -392,5 +395,7 b' msgstr "\xd0\x9e\xd0\xb1\xd0\xbd\xd0\xbe\xd0\xb2\xd0\xb8\xd1\x82\xd1\x8c"'
392
395
393 #: templates/search/search.html:17
396 #: templates/search/search.html:17
394 msgid "Ok"
397 msgid "Ok"
395 msgstr ""
398 msgstr "Ок"
396
399
400 #~ msgid "tag1 several_words_tag"
401 #~ msgstr "ΠΌΠ΅Ρ‚ΠΊΠ°1 ΠΌΠ΅Ρ‚ΠΊΠ°_ΠΈΠ·_Π½Π΅ΡΠΊΠΎΠ»ΡŒΠΊΠΈΡ…_слов"
@@ -28,9 +28,13 b''
28
28
29 <div class="navigation_panel header">
29 <div class="navigation_panel header">
30 <a class="link" href="{% url 'index' %}">{% trans "All threads" %}</a>
30 <a class="link" href="{% url 'index' %}">{% trans "All threads" %}</a>
31 {% autoescape off %}
31 {% if tags_str %}
32 {{ tags_str }},
32 {% autoescape off %}
33 {% endautoescape %}
33 {{ tags_str }},
34 {% endautoescape %}
35 {% else %}
36 {% trans 'Add tags' %} β†’
37 {% endif %}
34 <a href="{% url 'tags' 'required'%}" title="{% trans 'Tag management' %}"
38 <a href="{% url 'tags' 'required'%}" title="{% trans 'Tag management' %}"
35 >[...]</a>,
39 >[...]</a>,
36 <a href="{% url 'search' %}" title="{% trans 'Search' %}">[S]</a>.
40 <a href="{% url 'search' %}" title="{% trans 'Search' %}">[S]</a>.
@@ -4,92 +4,85 b''
4
4
5 {% get_current_language as LANGUAGE_CODE %}
5 {% get_current_language as LANGUAGE_CODE %}
6
6
7 {% if thread.archived %}
7 <div class="{{ css_class }}" id="{{ post.id }}">
8 <div class="post archive_post" id="{{ post.id }}">
8 <div class="post-info">
9 {% elif bumpable %}
9 <a class="post_id" href="{{ post.get_url }}">({{ post.get_absolute_id }})</a>
10 <div class="post" id="{{ post.id }}">
10 <span class="title">{{ post.title }}</span>
11 {% else %}
11 <span class="pub_time"><time datetime="{{ post.pub_time|date:'c' }}">{{ post.pub_time|date:'r' }}</time></span>
12 <div class="post dead_post" id="{{ post.id }}">
12 {% comment %}
13 {% endif %}
13 Thread death time needs to be shown only if the thread is alredy archived
14
14 and this is an opening post (thread death time) or a post for popup
15 <div class="post-info">
15 (we don't see OP here so we show the death time in the post itself).
16 <a class="post_id" href="{{ post.get_url }}">({{ post.get_absolute_id }})</a>
16 {% endcomment %}
17 <span class="title">{{ post.title }}</span>
17 {% if thread.archived %}
18 <span class="pub_time"><time datetime="{{ post.pub_time|date:'c' }}">{{ post.pub_time|date:'r' }}</time></span>
18 {% if is_opening %}
19 {% comment %}
19 β€” <time datetime="{{ thread.bump_time|date:'c' }}">{{ thread.bump_time|date:'r' }}</time>
20 Thread death time needs to be shown only if the thread is alredy archived
20 {% endif %}
21 and this is an opening post (thread death time) or a post for popup
22 (we don't see OP here so we show the death time in the post itself).
23 {% endcomment %}
24 {% if thread.archived %}
25 {% if is_opening %}
26 β€” <time datetime="{{ thread.bump_time|date:'c' }}">{{ thread.bump_time|date:'r' }}</time>
27 {% endif %}
21 {% endif %}
28 {% endif %}
22 {% if is_opening and need_open_link %}
29 {% if is_opening and need_open_link %}
23 {% if thread.archived %}
30 {% if thread.archived %}
24 <a class="link" href="{% url 'thread' post.id %}">{% trans "Open" %}</a>
31 <a class="link" href="{% url 'thread' post.id %}">{% trans "Open" %}</a>
25 {% else %}
32 {% else %}
26 <a class="link" href="{% url 'thread' post.id %}#form">{% trans "Reply" %}</a>
33 <a class="link" href="{% url 'thread' post.id %}#form">{% trans "Reply" %}</a>
27 {% endif %}
34 {% endif %}
28 {% endif %}
35 {% endif %}
29 {% if reply_link and not thread.archived %}
36 {% if reply_link and not thread.archived %}
30 <a href="#form" onclick="addQuickReply('{{ post.id }}'); return false;">{% trans 'Reply' %}</a>
37 <a href="#form" onclick="addQuickReply('{{ post.id }}'); return false;">{% trans 'Reply' %}</a>
31 {% endif %}
38 {% endif %}
39
32
40 {% if moderator %}
33 {% if moderator %}
41 <span class="moderator_info">
34 <span class="moderator_info">
42 <a href="{% url 'admin:boards_post_change' post.id %}">{% trans 'Edit' %}</a>
35 <a href="{% url 'admin:boards_post_change' post.id %}">{% trans 'Edit' %}</a>
43 {% if is_opening %}
36 {% if is_opening %}
44 | <a href="{% url 'admin:boards_thread_change' thread.id %}">{% trans 'Edit thread' %}</a>
37 | <a href="{% url 'admin:boards_thread_change' thread.id %}">{% trans 'Edit thread' %}</a>
45 {% endif %}
38 {% endif %}
46 </span>
39 </span>
40 {% endif %}
41 </div>
42 {% comment %}
43 Post images. Currently only 1 image can be posted and shown, but post model
44 supports multiple.
45 {% endcomment %}
46 {% if post.images.exists %}
47 {% with post.images.all.0 as image %}
48 {% autoescape off %}
49 {{ image.get_view }}
50 {% endautoescape %}
51 {% endwith %}
47 {% endif %}
52 {% endif %}
48 </div>
53 {% comment %}
49 {% comment %}
54 Post message (text)
50 Post images. Currently only 1 image can be posted and shown, but post model
55 {% endcomment %}
51 supports multiple.
56 <div class="message">
52 {% endcomment %}
53 {% if post.images.exists %}
54 {% with post.images.all.0 as image %}
55 {% autoescape off %}
57 {% autoescape off %}
56 {{ image.get_view }}
58 {% if truncated %}
59 {{ post.get_text|truncatewords_html:50 }}
60 {% else %}
61 {{ post.get_text }}
62 {% endif %}
57 {% endautoescape %}
63 {% endautoescape %}
58 {% endwith %}
64 {% if post.is_referenced %}
59 {% endif %}
65 <div class="refmap">
60 {% comment %}
66 {% autoescape off %}
61 Post message (text)
67 {% trans "Replies" %}: {{ post.refmap }}
62 {% endcomment %}
68 {% endautoescape %}
63 <div class="message">
69 </div>
64 {% autoescape off %}
65 {% if truncated %}
66 {{ post.get_text|truncatewords_html:50 }}
67 {% else %}
68 {{ post.get_text }}
69 {% endif %}
70 {% endif %}
70 {% endautoescape %}
71 </div>
71 {% if post.is_referenced %}
72 {% comment %}
72 <div class="refmap">
73 Thread metadata: counters, tags etc
73 {% autoescape off %}
74 {% endcomment %}
74 {% trans "Replies" %}: {{ post.refmap }}
75 {% if is_opening %}
75 {% endautoescape %}
76 <div class="metadata">
77 {% if is_opening and need_open_link %}
78 {{ thread.get_reply_count }} {% trans 'messages' %},
79 {{ thread.get_images_count }} {% trans 'images' %}.
80 {% endif %}
81 <span class="tags">
82 {% autoescape off %}
83 {{ thread.get_tag_url_list }}
84 {% endautoescape %}
85 </span>
76 </div>
86 </div>
77 {% endif %}
87 {% endif %}
78 </div>
88 </div>
79 {% comment %}
80 Thread metadata: counters, tags etc
81 {% endcomment %}
82 {% if is_opening %}
83 <div class="metadata">
84 {% if is_opening and need_open_link %}
85 {{ thread.get_reply_count }} {% trans 'messages' %},
86 {{ thread.get_images_count }} {% trans 'images' %}.
87 {% endif %}
88 <span class="tags">
89 {% autoescape off %}
90 {{ thread.get_tag_url_list }}
91 {% endautoescape %}
92 </span>
93 </div>
94 {% endif %}
95 </div>
@@ -43,7 +43,6 b' def image_actions(*args, **kwargs):'
43 action['link'] % image_link, action['name'])for action in actions])
43 action['link'] % image_link, action['name'])for action in actions])
44
44
45
45
46 # TODO Use get_view of a post instead of this
47 @register.inclusion_tag('boards/post.html', name='post_view')
46 @register.inclusion_tag('boards/post.html', name='post_view')
48 def post_view(post, moderator=False, need_open_link=False, truncated=False,
47 def post_view(post, moderator=False, need_open_link=False, truncated=False,
49 reply_link=False, **kwargs):
48 reply_link=False, **kwargs):
@@ -53,87 +52,27 b' def post_view(post, moderator=False, nee'
53
52
54 thread = post.get_thread()
53 thread = post.get_thread()
55 is_opening = post.is_opening()
54 is_opening = post.is_opening()
56 can_bump = thread.can_bump()
57
55
58 if is_opening:
56 if is_opening:
59 opening_post_id = post.id
57 opening_post_id = post.id
60 else:
58 else:
61 opening_post_id = thread.get_opening_post_id()
59 opening_post_id = thread.get_opening_post_id()
62
60
61 css_class = 'post'
62 if thread.archived:
63 css_class += ' archive_post'
64 elif not thread.can_bump():
65 css_class += ' dead_post'
66
63 return {
67 return {
64 'post': post,
68 'post': post,
65 'moderator': moderator,
69 'moderator': moderator,
66 'is_opening': is_opening,
70 'is_opening': is_opening,
67 'thread': thread,
71 'thread': thread,
68 'bumpable': can_bump,
72 'css_class': css_class,
69 'need_open_link': need_open_link,
73 'need_open_link': need_open_link,
70 'truncated': truncated,
74 'truncated': truncated,
71 'opening_post_id': opening_post_id,
75 'opening_post_id': opening_post_id,
72 'reply_link': reply_link,
76 'reply_link': reply_link,
73 }
77 }
74
78
75
76 # TODO Fix or remove this method
77 @register.filter(is_safe=True)
78 def truncate_lines(text, length):
79 if length <= 0:
80 return ''
81
82 html4_singlets = (
83 'br', 'col', 'link', 'base', 'img',
84 'param', 'area', 'hr', 'input'
85 )
86
87 # Count non-HTML chars/words and keep note of open tags
88 pos = 0
89 end_text_pos = 0
90 current_len = 0
91 open_tags = []
92
93 while current_len <= length:
94 m = REGEX_LINES.search(text, pos)
95 if not m:
96 # Checked through whole string
97 break
98 pos = m.end(0)
99 if m.group(1):
100 # It's an actual non-HTML word or char
101 current_len += 1
102 if current_len == length:
103 end_text_pos = m.start(0)
104 continue
105 # Check for tag
106 tag = REGEX_TAG.match(m.group(0))
107 if not tag or current_len >= length:
108 # Don't worry about non tags or tags after our truncate point
109 continue
110 closing_tag, tagname, self_closing = tag.groups()
111 # Element names are always case-insensitive
112 tagname = tagname.lower()
113 if self_closing or tagname in html4_singlets:
114 pass
115 elif closing_tag:
116 # Check for match in open tags list
117 try:
118 i = open_tags.index(tagname)
119 except ValueError:
120 pass
121 else:
122 # SGML: An end tag closes, back to the matching start tag,
123 # all unclosed intervening start tags with omitted end tags
124 open_tags = open_tags[i + 1:]
125 else:
126 # Add it to the start of the open tags list
127 open_tags.insert(0, tagname)
128
129 if current_len <= length:
130 return text
131 out = text[:end_text_pos]
132
133 if not out.endswith(ELLIPSIZER):
134 out += ELLIPSIZER
135 # Close any tags still open
136 for tag in open_tags:
137 out += '</%s>' % tag
138 # Return string
139 return out
General Comments 0
You need to be logged in to leave comments. Login now