Don't do a #-redirect for first message in thread
authorMagnus Hagander <magnus@hagander.net>
Wed, 20 Jun 2018 14:16:32 +0000 (16:16 +0200)
committerMagnus Hagander <magnus@hagander.net>
Wed, 20 Jun 2018 14:16:32 +0000 (16:16 +0200)
On the view-whole-thread page we previously did a redirect back to the
anchor of the very first mail of the thread when loading the first mail
of the thread. This pollutes the URL more than necessary.

We still do the redirect for messages that are not the first, to make it
possible to link to an individual message.

django/archives/mailarchives/templates/message_flat.html
django/archives/mailarchives/views.py

index 2290f04bedf9f17cd2d3794b16074bca010bb1f6..8301982a0d97182a572e0e584eaa9490f7136dea 100644 (file)
@@ -3,6 +3,7 @@
 {%load pgfilters%}
 {%block extrahead%}
 <meta name="robots" content="noindex" />
+{%if not isfirst%}
 <script type="text/javascript">
 function load() {
    if (document.location.href.indexOf('#') < 0) {
@@ -11,6 +12,7 @@ function load() {
 }
 window.onload = load;
 </script>
+{%endif%}
 {%endblock%}
 {%block contents%}
 {%if not msg.hiddenstatus%}
index 0e3a47d62a1413e07606b3b4257b4a6f3eb3b6fd..15adbfcde9c97107aecfad4c17aba75c644ad0a2 100644 (file)
@@ -469,6 +469,8 @@ def message_flat(request, msgid):
        allmsg = list(Message.objects.filter(threadid=msg.threadid).order_by('date'))
        # XXX: need to get the complete list of lists!
 
+       isfirst = (msg == allmsg[0])
+
        newest = calendar.timegm(max(allmsg, key=lambda x: x.date).date.utctimetuple())
        if request.META.has_key('HTTP_IF_MODIFIED_SINCE') and not settings.DEBUG:
                ims = parse_http_date_safe(request.META.get('HTTP_IF_MODIFIED_SINCE'))
@@ -478,6 +480,7 @@ def message_flat(request, msgid):
        r = render_nav(NavContext(request), 'message_flat.html', {
                        'msg': msg,
                        'allmsg': allmsg,
+                       'isfirst': isfirst,
                        })
        r['X-pgthread'] = ":%s:" % msg.threadid
        r['Last-Modified'] = http_date(newest)