1.1 --- a/MoinShare.py Tue Nov 12 23:07:50 2013 +0100
1.2 +++ b/MoinShare.py Wed Nov 13 15:44:34 2013 +0100
1.3 @@ -13,7 +13,7 @@
1.4 from MoinSupport import *
1.5 from ItemSupport import ItemStore
1.6 from MoinMessage import GPG, is_encrypted, is_signed, MoinMessageError
1.7 -from MoinMessageSupport import get_homedir
1.8 +from MoinMessageSupport import get_homedir, get_username_for_fingerprint
1.9 from MoinMoin.support.htmlmarkup import HTMLParseError, HTMLSanitizer, Markup
1.10 from MoinMoin import wikiutil
1.11 from email.parser import Parser
1.12 @@ -92,6 +92,7 @@
1.13 self.content = None
1.14 self.content_type = None
1.15 self.updated = None
1.16 + self.author = None
1.17
1.18 # Page-related attributes.
1.19
1.20 @@ -127,6 +128,7 @@
1.21 update.title = self.title
1.22 update.link = self.link
1.23 update.updated = self.updated
1.24 + update.author = self.author
1.25 update.fragment = self.fragment
1.26 update.preferred = self.preferred
1.27 update.message_number = self.message_number
1.28 @@ -235,17 +237,23 @@
1.29
1.30 update.fragment = update.updated = getDateTimeFromRFC2822(message.get("date"))
1.31 update.title = message.get("subject", "Update #%d" % message_number)
1.32 + update.author = message.get("moin-user")
1.33
1.34 update.message_number = message_number
1.35
1.36 - update.content, update.content_type, update.parts = getUpdateContentFromPart(message, request)
1.37 + update.content, update.content_type, update.parts, actual_author = \
1.38 + getUpdateContentFromPart(message, request)
1.39 +
1.40 + if actual_author:
1.41 + update.author = actual_author
1.42 +
1.43 return update
1.44
1.45 def getUpdateContentFromPart(part, request):
1.46
1.47 """
1.48 - Return decoded content, the content type and any subparts in a tuple for a
1.49 - given 'part'.
1.50 + Return decoded content, the content type, any subparts, and any author
1.51 + identity in a tuple for a given 'part'.
1.52 """
1.53
1.54 # Determine whether the part has several representations.
1.55 @@ -254,7 +262,7 @@
1.56
1.57 if not part.is_multipart():
1.58 content, content_type = getPartContent(part)
1.59 - return content, content_type, None
1.60 + return content, content_type, None, None
1.61
1.62 # For a collection of related parts, use the first as the update content
1.63 # and assume that the formatter will reference the other parts.
1.64 @@ -262,21 +270,22 @@
1.65 elif part.get_content_subtype() == "related":
1.66 main_part = part.get_payload()[0]
1.67 content, content_type = getPartContent(main_part)
1.68 - return content, content_type, [main_part]
1.69 + return content, content_type, [main_part], None
1.70
1.71 # Encrypted content cannot be meaningfully separated.
1.72
1.73 elif part.get_content_subtype() == "encrypted":
1.74 try:
1.75 - part = getDecryptedParts(part, request)
1.76 - return getUpdateContentFromPart(part, request)
1.77 + part, author = getDecryptedParts(part, request)
1.78 + content, content_type, parts, _author = getUpdateContentFromPart(part, request)
1.79 + return content, content_type, parts, author
1.80 except MoinMessageError:
1.81 - return None, part.get_content_type(), part.get_payload()
1.82 + return None, part.get_content_type(), part.get_payload(), None
1.83
1.84 # Otherwise, just obtain the parts for separate display.
1.85
1.86 else:
1.87 - return None, part.get_content_type(), part.get_payload()
1.88 + return None, part.get_content_type(), part.get_payload(), None
1.89
1.90 def getDecryptedParts(part, request):
1.91
1.92 @@ -292,15 +301,14 @@
1.93 part = Parser().parse(StringIO(text))
1.94
1.95 # Extract any signature details.
1.96 - # NOTE: Incorporate the signature into the output.
1.97
1.98 if is_signed(part):
1.99 result = gpg.verifyMessage(part)
1.100 if result:
1.101 fingerprint, identity, content = result
1.102 - return content
1.103 + return content, get_username_for_fingerprint(request, fingerprint)
1.104
1.105 - return part
1.106 + return part, None
1.107
1.108 def getPartContent(part):
1.109
3.1 --- a/macros/SharedContent.py Tue Nov 12 23:07:50 2013 +0100
3.2 +++ b/macros/SharedContent.py Wed Nov 13 15:44:34 2013 +0100
3.3 @@ -331,6 +331,11 @@
3.4 if show_content:
3.5 append(fmt.div(on=1, css_class="moinshare-update"))
3.6
3.7 + if update.author:
3.8 + append(fmt.div(on=1, css_class="moinshare-author"))
3.9 + append(fmt.text(update.author))
3.10 + append(fmt.div(on=0))
3.11 +
3.12 append(formatUpdate(update, request, fmt))
3.13
3.14 append(fmt.div(on=1, css_class="moinshare-date"))