Updated contact "mailto:" URL
authorThierry Florac <tflorac@ulthar.net>
Tue, 22 Jan 2019 14:55:36 +0100
changeset 390 f2c646b0ddbf
parent 389 ff9d82c2d216
child 391 896a5919adb8
Updated contact "mailto:" URL
src/pyams_default_theme/component/paragraph/contact.py
src/pyams_default_theme/component/paragraph/templates/contact-default.pt
--- a/src/pyams_default_theme/component/paragraph/contact.py	Tue Jan 22 14:27:31 2019 +0100
+++ b/src/pyams_default_theme/component/paragraph/contact.py	Tue Jan 22 14:55:36 2019 +0100
@@ -9,6 +9,8 @@
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE.
 #
+from pyramid.encode import url_quote
+
 
 __docformat__ = 'restructuredtext'
 
@@ -95,3 +97,14 @@
         if not label:
             label = self.request.localizer.translate(_("contact-button-label", default="Contact"))
         return label
+
+    @property
+    def contact_url(self):
+        if self.name:
+            return 'mailto:{}'.format(url_quote('{} <{}>'.format(self.name, self.contact_email)))
+        else:
+            return 'mailto:{}'.format(self.contact_email)
+
+    @property
+    def contact_subject(self):
+        return url_quote(self.title)
--- a/src/pyams_default_theme/component/paragraph/templates/contact-default.pt	Tue Jan 22 14:27:31 2019 +0100
+++ b/src/pyams_default_theme/component/paragraph/templates/contact-default.pt	Tue Jan 22 14:55:36 2019 +0100
@@ -25,7 +25,7 @@
 		<tal:if condition="view.contact_email">
 			<span i18n:translate="">Contact email:</span>
 			<a tal:define="button_label view.button_label"
-			   href="mailto:${view.contact_email}?subject=${view.title}">
+			   href="${view.contact_url}?subject=${view.contact_subject}">
 				${button_label}
 			</a><br />
 		</tal:if>