Permalink
Browse files

Better display of card text

  • Loading branch information...
1 parent 131d355 commit 7bedc0f02bebe922215e21c1a7d40ab27914d08d Neil committed Feb 19, 2012
Showing with 22 additions and 3 deletions.
  1. +16 −1 sutekhweb.py
  2. +6 −2 templates/card.html
View
@@ -108,7 +108,22 @@ def print_card(sCardName):
except SQLObjectNotFound:
oCard = None
if oCard:
- return render_template('card.html', card=oCard, parent=sParent)
+ if oCard.text:
+ # We split text into lines, so they can be neatly
+ # formatted by the template
+ aText = oCard.text.split("\n")
+ if '. [' in aText[-1]:
+ # Split discipline level text
+ aSplit = aText.pop().split('. [')
+ # Fix the lines
+ aText.append(aSplit[0] + '.')
+ for sLine in aSplit[1:-1]:
+ aText.append('[' + sLine + '.')
+ aText.append('[' + aSplit[-1])
+ else:
+ aText = []
+ return render_template('card.html', card=oCard, parent=sParent,
+ text=aText)
else:
return render_template('invalid_card.html',
type='Card Name',
View
@@ -54,8 +54,12 @@
</ul>
{% endif %}
{% if card.text %}
-<h2>Text</h2>
-{{ card.text }}
+<div id="text">
+ <h2>Text</h2>
+ {% for line in text %}
+ <p>{{ line }}</p>
+ {% endfor %}
+</div>
{% endif %}
{% endblock %}
{% block navigation %}

0 comments on commit 7bedc0f

Please sign in to comment.