summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--hyperkitty/fixtures/rating_testdata.json6
-rw-r--r--hyperkitty/static/css/style.css2
-rw-r--r--hyperkitty/templates/messages/message.html2
-rw-r--r--hyperkitty/templates/register.html2
-rw-r--r--hyperkitty/templates/thread.html4
-rw-r--r--hyperkitty/templatetags/hk_generic.py36
-rw-r--r--hyperkitty/tests/test_templatetags.py25
7 files changed, 33 insertions, 44 deletions
diff --git a/hyperkitty/fixtures/rating_testdata.json b/hyperkitty/fixtures/rating_testdata.json
index 7f41f18..d59ce2e 100644
--- a/hyperkitty/fixtures/rating_testdata.json
+++ b/hyperkitty/fixtures/rating_testdata.json
@@ -43,6 +43,12 @@
}
}, {
"pk": 1,
+ "model": "auth.user",
+ "fields": {
+ "username": "testuser"
+ }
+}, {
+ "pk": 1,
"model": "hyperkitty.tag",
"fields": {
"tag": "aamir",
diff --git a/hyperkitty/static/css/style.css b/hyperkitty/static/css/style.css
index b124833..57b8fcf 100644
--- a/hyperkitty/static/css/style.css
+++ b/hyperkitty/static/css/style.css
@@ -711,5 +711,7 @@ ul.attachments-list li {
.email_body .quoted-text {
display: none;
+ border-left: 2px solid rgb(55, 113, 200);
+ padding-left: 0.2em;
}
diff --git a/hyperkitty/templates/messages/message.html b/hyperkitty/templates/messages/message.html
index 37bc795..00919d6 100644
--- a/hyperkitty/templates/messages/message.html
+++ b/hyperkitty/templates/messages/message.html
@@ -30,7 +30,7 @@
</div>
<div class="{% if unfolded %}first_{% endif %}email_body"
- >{{ email.content|wordwrap:90|urlizetrunc:76|escapeemail|snip_quoted }}</div>
+ >{{ email.content|snip_quoted|wordwrap:90|urlizetrunc:76|escapeemail }}</div>
{% if unfolded and email.attachments|count %}
<p class="attachments">Attachments:</p>
diff --git a/hyperkitty/templates/register.html b/hyperkitty/templates/register.html
index 2e033b5..bcd955a 100644
--- a/hyperkitty/templates/register.html
+++ b/hyperkitty/templates/register.html
@@ -6,7 +6,7 @@
<form action="" method="post" class="login mm_clear">
{% csrf_token %}
{{ form.as_p }}
- <input type=hidden name=next value={{ next }}>
+ <input type="hidden" name="next" value="{{ next }}">
<div class="field">
<button class="btn btn-primary" type="submit">
{% trans "Register" %}
diff --git a/hyperkitty/templates/thread.html b/hyperkitty/templates/thread.html
index 3ac059d..295da84 100644
--- a/hyperkitty/templates/thread.html
+++ b/hyperkitty/templates/thread.html
@@ -44,8 +44,8 @@
<script src="{{ STATIC_URL }}js/libs/jquery.expander.js"></script>
<script type="text/javascript">
$(document).ready(function() {
- $('div.email_body a.quoted-switch').click(function() {
- $(this).next(".quoted-text").toggle();
+ $('div.email_body .quoted-switch a').click(function() {
+ $(this).parent().next(".quoted-text").slideToggle('fast');
return false;
});
});
diff --git a/hyperkitty/templatetags/hk_generic.py b/hyperkitty/templatetags/hk_generic.py
index fd6897f..b219eba 100644
--- a/hyperkitty/templatetags/hk_generic.py
+++ b/hyperkitty/templatetags/hk_generic.py
@@ -139,7 +139,7 @@ def viewer_date(email):
return localtime(email_date)
-SNIPPED_RE = re.compile("^\s*&gt;.*$", re.M)
+SNIPPED_RE = re.compile("^(\s*&gt;).*$", re.M)
@register.filter(needs_autoescape=True)
def snip_quoted(content, quotemsg="[...]", autoescape=None):
"""Snip quoted text in messages"""
@@ -147,25 +147,27 @@ def snip_quoted(content, quotemsg="[...]", autoescape=None):
content = conditional_escape(content)
quoted = []
current_quote = []
- quoting = False
+ current_quote_orig = []
lastline = None
for line in content.split("\n"):
- if SNIPPED_RE.match(line):
- quoting = True
- if lastline == "":
- current_quote.append(lastline)
+ match = SNIPPED_RE.match(line)
+ if match is not None:
+ #if lastline == "":
+ # current_quote_orig.append(lastline)
+ current_quote_orig.append(line)
+ content_start = len(match.group(1))
+ current_quote.append(line[content_start:])
else:
- quoting = False
- if current_quote:
- quoted.append(current_quote[:])
+ if current_quote_orig:
+ current_quote_orig.append("")
+ quoted.append( (current_quote_orig[:], current_quote[:]) )
current_quote = []
- if quoting:
- current_quote.append(line)
+ current_quote_orig = []
lastline = line
- for quote in quoted:
- replaced = ('<a href="#" class="quoted-switch">%s</a>' % quotemsg
- +'<span class="quoted-text">\n'
- +"\n".join([q for q in quote if q != ""])
- +'</span>')
- content = content.replace("\n".join(quote), replaced)
+ for quote_orig, quote in quoted:
+ replaced = (' <div class="quoted-switch"><a href="#">%s</a></div>' % quotemsg
+ +'<div class="quoted-text">'
+ +"\n".join(quote)
+ +' </div>')
+ content = content.replace("\n".join(quote_orig), replaced)
return mark_safe(content)
diff --git a/hyperkitty/tests/test_templatetags.py b/hyperkitty/tests/test_templatetags.py
index 1275b25..eab0187 100644
--- a/hyperkitty/tests/test_templatetags.py
+++ b/hyperkitty/tests/test_templatetags.py
@@ -36,29 +36,8 @@ This is the response.
"""
expected = """
On Fri, 09.11.12 11:27, Someone wrote:
-<a href="#" class="quoted-switch">%s</a><span class="quoted-text">
-&gt; This is the first quoted line
-&gt; This is the second quoted line</span>
-This is the response.
-""" % self.quotemsg
- result = snip_quoted(contents, self.quotemsg)
- self.assertEqual(result, expected)
-
- def test_quote_2(self):
- """The quote starts with a newline"""
- contents = """
-On Fri, 09.11.12 11:27, Someone wrote:
-
-&gt; This is the first quoted line
-&gt; This is the second quoted line
-This is the response.
-"""
- expected = """
-On Fri, 09.11.12 11:27, Someone wrote:
-<a href="#" class="quoted-switch">%s</a><span class="quoted-text">
-&gt; This is the first quoted line
-&gt; This is the second quoted line</span>
-This is the response.
+ <div class="quoted-switch"><a href="#">%s</a></div><div class="quoted-text"> This is the first quoted line
+ This is the second quoted line </div>This is the response.
""" % self.quotemsg
result = snip_quoted(contents, self.quotemsg)
self.assertEqual(result, expected)