Просмотр исходного кода

Crop the topic title when title exceeds a specified topic length

sh4nks 11 лет назад
Родитель
Сommit
a51886f586
2 измененных файлов с 8 добавлено и 1 удалено
  1. 7 0
      flaskbb/app.py
  2. 1 1
      flaskbb/templates/forum/category_layout.html

+ 7 - 0
flaskbb/app.py

@@ -190,6 +190,13 @@ def configure_template_filters(app):
         return False
 
 
+    @app.template_filter()
+    def crop_topic_title(title):
+        if len(title) > 15:
+            return title[:15] + "..."
+        return title
+
+
 def configure_before_handlers(app):
     """
     Configures the before request handlers

+ 1 - 1
flaskbb/templates/forum/category_layout.html

@@ -37,7 +37,7 @@
             <td valign="top" align="right" style="white-space: nowrap">
                 {% if forum.last_post_id %}
                 <a href="{{ url_for('forum.view_post', post_id=forum.last_post_id) }}" title="{{ forum.last_post.topic.title }}">
-                    <strong>{{ forum.last_post.topic.title }}</strong>
+                    <strong>{{ forum.last_post.topic.title|crop_topic_title() }}</strong>
                 </a>
                 <br />
                 {{ forum.last_post.date_created|time_since }}<br />