Commits

Alexandre Macabies committed b376547

Removing minify middleware that is too severe (thus buggy)
Updating sdz_member for very buggy member links (SdZ code is a shame!)

Comments (0)

Files changed (7)

 - Sous-sites (sciences)
 - Création d'un certain nombre d'options pour alléger ou fournir plus d'options
   à l'utilisateur (stockées en session : cookie), eg. l'affichage des images
+- Modifier le comportement de ``make_absolute_links`` pour parser les liens
+  qui peuvent être visités avec SdZmoar (eg. les profiles ou références à
+  d'autres turoriels).
 
 Licence
 =======

common/middleware.py

 RE_DJANGOSTRIP = re.compile(r'>\s+<')
 
 class MinifyHTMLMiddleware(object):
-    """Provides a simple middleware to compress HTML output on-the-fly."""
+    """
+        Provides a simple middleware to compress HTML output on-the-fly.
+        It does NOT keep important new lines, such as in <pre>, <code> or <textarea>.
+    """
     def process_response(self, request, response):
         if 'text/html' in response['Content-Type'] and settings.COMPRESS_HTML and not settings.DEBUG:
             response.content = RE_DJANGOSTRIP.sub('> <', force_unicode(response.content.strip()))
             nickname = clean_text(span.text)
         else:
             nickname = '(inconnu)'
-    return {
-        'name': nickname,
-        'id': regex_memberid.search(htmllink.get('href')).group('id'),
-    }
+    try:
+        return {
+            'name': nickname,
+            'id': regex_memberid.search(htmllink.get('href')).group('id'),
+        }
+    except AttributeError:
+        return None
 
 def html_string(html):
     try: # black magic!

files/readme

-Django stores static/media/cache files here.
-Do not delete.

settings.py.sample

     'django.middleware.csrf.CsrfViewMiddleware',
 #   'django.contrib.auth.middleware.AuthenticationMiddleware',
     'django.contrib.messages.middleware.MessageMiddleware',
-    'common.middleware.MinifyHTMLMiddleware',
+#   'common.middleware.MinifyHTMLMiddleware', # buggy middleware; see below
 )
 
 ROOT_URLCONF = 'urls'
 # COMPRESS = True
 
 ### Sdzmoar config
-COMPRESS_HTML = True
+# DON'T USE THIS SETTING. THE MIDDLEWARE IS ACTUALLY DISABLED.
+# IT STRIPS TOO MUCH \n THUS CAUSING CODE BLOCKS RENDERED BADLY
+# COMPRESS_HTML = False
 
 # Pages to show before and after the current page in the paginator
 PAGER_SIBLING_COUNT = 3

templates/mobile/tutos/view_mini_tuto.html

 <hr />
+<h2>Sommaire</h2>
 <ul>
 {% for para in paragraphs %}
     <li><a href="#{{ para.anchor }}">{{ para.title }}</a></li>

templates/mobile/tutos/view_tuto.html

     Difficulté&nbsp;: {% if difficulty %}<span class="diff-box diff-{{ difficulty.code }}"></span>{{ difficulty.text }}{% else %}inconnue{% endif %}<br />
     Temps d'étude estimé&nbsp;: {{ time_to_finish|default_if_none:'inconnu' }}
 </p>
-<hr/>
+<hr />
+<h2>Introduction</h2>
 {{ introduction|safe }}
 
 {% if is_big %}
     {% include "mobile/tutos/view_mini_tuto.html" %}
 {% endif %}
 
-<hr/>
+<hr />
+<h2>Conclusion</h2>
 {{ conclusion|safe }}
+
 {% endblock %}