Commits

Alexandre Macabies committed a15d3d2

Fixed forum topic template so that it shows nice messages in case of deletion
Added few spaces in the compressed HTML output

Comments (0)

Files changed (5)

common/htmlcompressor.py

             html = httpsProtocolPattern.sub(r"\1\2", html)
 
         if self.removeIntertagSpaces:
-            html = intertagPattern.sub(u"><", html)
+            html = intertagPattern.sub(u"> <", html)
 
         if self.removeMultiSpaces:
             html = multispacePattern.sub(u" ", html)
 import urllib
 import math
 from StringIO import StringIO
+try:
+    from urlparse import urljoin
+except ImportError:
+    from urllib.parse import urljoin
 
 from django.core.urlresolvers import reverse
 from django.http import Http404
 from django.core.cache import cache
-from settings import PAGER_SIBLING_COUNT, PAGE_GETPARAM, SDZ_DATETIME_FORMAT, SDZ_DATE_FORMAT, SDZ_TIME_FORMAT
+from settings import PAGER_SIBLING_COUNT, PAGE_GETPARAM, SDZ_DATETIME_FORMAT, SDZ_DATE_FORMAT, SDZ_TIME_FORMAT, SDZ_BASE_URL
 
 regex_smiley = re.compile(r'<img src="http://(?:www)?\.siteduzero\.com/Templates/images/smilies/[^"]+" alt="([^"]+)"(?: class="smilies")?\s*/>', re.I)
 regex_memberid = re.compile(r'membres\-294\-(?P<id>\d+)', re.I)
     except AttributeError:
         return None
 
+def absolute_url(href):
+    return urljoin(SDZ_BASE_URL, href)
+
 def html_string(html):
+    # TODO: parse known links
     try: # black magic!
         html.make_links_absolute()
     except TypeError: # actually, you should have practise more with Severus Snape
-        html.make_links_absolute('http://www.siteduzero.com/')
+        html.make_links_absolute(SDZ_BASE_URL)
     return etree.tostring(html, encoding=unicode).strip()
 
 def clean_int(x):
         if 'header_message' in elem.get('class', ''):
             author = sdz_member(elem.find('td[1]//a'))
             if clean_text(elem.find('td[2]//span/a').tail).lower().startswith(u'message supprimé'):
+                reason = clean_text(elem.find('td[2]//span/em').text)
                 messages.append({
                     'author': author,
                     'deleted': True,
-                    'deletion_reason': clean_text(elem.find('td[2]//span/em').text),
+                    'deleted_self': reason.lower() == u"cette réponse a été supprimée par l'utilisateur",
+                    'deletion_reason': reason,
                 })
             else:
                 tempmeta = {

templates/mobile/chunks/paginate.html

 {% if pager.should_render_combo %}
     <select class="page-jump" onchange="document.location.href='?{{ PAGE_GETPARAM }}=' + this.options[this.selectedIndex].value;">
     {% for page in pager.range %}
-        <option value="{{ page }}"{% if page == pager.current %} selected{% endif %}>{{ page }}</option>
+        <option value="{{ page }}"{% if page == pager.current %} selected="selected"{% endif %}>{{ page }}</option>
     {% endfor %}
     </select>
 {% endif%}

templates/mobile/forums/topic.html

 {% for message in messages %}
 	<div>
 		{% with message.author as member %}{% include "mobile/chunks/member.html" %}{% endwith %} –
-		Posté le {{ message.posted_on|date:"SHORT_DATETIME_FORMAT" }}
+		{% if message.deleted %}
+            {% if message.deleted_self %}
+                Supprimé par l'auteur
+            {% else %}
+                Supprimé&nbsp;: <em>{{ message.deletion_reason }}</em>
+            {% endif %}
+        {% else %}
+        Posté le {{ message.posted_on|date:"SHORT_DATETIME_FORMAT" }}
+        {% endif %}
         {% if message.helping %}– Cette réponse a aidé &#10003;{% endif %}<br />
 		{{ message.content|safe }}
 		{% if message.date_edition %}