Skip to content

Commit

Permalink
PICARD-2498: Link plugin authors with e-mail using mailto:
Browse files Browse the repository at this point in the history
  • Loading branch information
phw committed Jun 7, 2022
1 parent fdb9752 commit 51bbbf3
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion picard/ui/options/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from html import escape
from operator import attrgetter
import os.path
import re

from PyQt5 import (
QtCore,
Expand Down Expand Up @@ -601,7 +602,7 @@ def refresh_details(self, item):
text.append(plugin.description + "<hr width='90%'/>")
infos = [
(_("Name"), escape(plugin.name)),
(_("Authors"), escape(plugin.author)),
(_("Authors"), self.link_authors(plugin.author)),
(_("License"), plugin.license),
(_("Files"), escape(plugin.files_list)),
]
Expand All @@ -610,6 +611,22 @@ def refresh_details(self, item):
text.append("<b>{0}:</b> {1}".format(label, value))
self.ui.details.setText("<p>{0}</p>".format("<br/>\n".join(text)))

@staticmethod
def link_authors(authors):
formatted_authors = []
re_author = re.compile(r"(?P<author>.*?)\s*<(?P<email>.*?)>")
for author in authors.split(','):
match = re_author.match(author.strip())
if match:
author_str = '<a href="mailto:{email}">{author}</a>'.format(
email=escape(match['email']),
author=escape(match['author']),
)
formatted_authors.append(author_str)
else:
formatted_authors.append(escape(author))
return ', '.join(formatted_authors)

def change_details(self):
item = self.selected_item()
if item:
Expand Down

0 comments on commit 51bbbf3

Please sign in to comment.