# HG changeset patch
# User casties
# Date 1369376447 -7200
# Node ID bde0929d34fbe5269a09bc627b1fa27001361746
# Parent a28e67fbdd31f63c350e1864ef330cbd2ab0371f
function for excerpts of project descriptions.
diff -r a28e67fbdd31 -r bde0929d34fb MPIWGProjects.py
--- a/MPIWGProjects.py Tue May 21 18:54:54 2013 +0200
+++ b/MPIWGProjects.py Fri May 24 08:20:47 2013 +0200
@@ -602,13 +602,44 @@
return None
- def getDescription(self, filter=False):
+ def getDescription(self, filter=None, length=0):
"""returns the project description"""
text = getattr(self, 'WEB_project_description', None)
if isinstance(text, list):
# compat with old lists
text = text[0]
+ if filter == 'plaintext':
+ # filter out any tags, keep only text
+ try:
+ xmltext = utf8ify("
%s
"%text)
+ dom = ET.fromstring(xmltext)
+ plaintext = ""
+ for elem in dom.iter():
+ if elem.tag == 'style':
+ # ignore tag
+ continue
+
+ if elem.text:
+ plaintext += elem.text
+ if elem.tail:
+ plaintext += elem.tail
+
+ if length > 0 and len(plaintext) > length:
+ break
+
+ text = plaintext
+ except Exception, e:
+ logging.warn("getDesciption: error parsing description! Returning everything. %s"%e)
+
+ if length > 0 and len(text) > length:
+ # try to not break words
+ if text[length] not in [' ', '.', '?', '!']:
+ # search the last blank
+ length = text.rfind(' ', 0, length)
+
+ return text[:length] + '...'
+
return text
diff -r a28e67fbdd31 -r bde0929d34fb css/mpiwg.css
--- a/css/mpiwg.css Tue May 21 18:54:54 2013 +0200
+++ b/css/mpiwg.css Fri May 24 08:20:47 2013 +0200
@@ -763,6 +763,8 @@
div.mini h2 {
/* e.g. title for mini-books */
font-size: 14px;
+ /* but no line if used inside box */
+ border-bottom: 0;
}
div.mini.website div.description {