Redirecting to the full messageid pollutes the URL pretty badly. md5 is
not the best of hashes, but the likelihood of getting an md5 collission
on the messageid *within a single thread* is extremely low -- and of
course if it happens the only effect is on the initial scroll of the
window.
{%extends "page.html"%}
+{%load pgfilters%}
{%block title%}{%if not msg.hiddenstatus%}{{msg.subject}}{%endif%}{%endblock%}
{%load pgfilters%}
{%block extrahead%}
<script type="text/javascript">
function load() {
if (document.location.href.indexOf('#') < 0) {
- document.location.href = document.location.href + '#' + '{{msg.messageid}}';
+ document.location.href = document.location.href + '#' + '{{msg.messageid|md5}}';
}
}
window.onload = load;
{%endif%}
{%for m in allmsg %}
<a name="{{m.messageid}}"></a>
+<a name="{{m.messageid|md5}}"></a>
{% include '_message.html' with msg=m show_all=True %}
{% if not forloop.last %}
<hr style="margin-bottom: 0.5rem;" />
from email.utils import parseaddr
import re
+import hashlib
register = template.Library()
if name:
return name
return email.split('@')[0]
+
+@register.filter(name='md5')
+@stringfilter
+def md5(value):
+ return hashlib.md5(value).hexdigest()