Skip to content

Commit bf05dc1

Browse files
committed
BibFormat: vCard support for people collection
* Adds vCard support for detailed profile pages for the people collection and contains full name, affiliation, email, phone, mobile, and fax number. Uses microformats hCard 1.0. Signed-off-by: Jochen Klein <j.klein@cern.ch>
1 parent 2c05ccf commit bf05dc1

2 files changed

Lines changed: 40 additions & 10 deletions

File tree

modules/bibformat/etc/format_templates/People_HTML_detailed.bft

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,10 @@ table tr td {
7777
}
7878
</style>
7979

80+
<div class="vcard">
8081
<div class="row">
81-
<BFE_FIELD tag="100__a" prefix='<h1>' suffix='</h1>' />
82-
<BFE_FIELD tag="371__0" />
82+
<BFE_FIELD tag="100__a" prefix="<h1 class='fn'>" suffix="</h1>" />
83+
<BFE_FIELD tag="371__0" prefix="<span class='org'>" suffix="</span>" />
8384
</div>
8485

8586
<h2>Personal Information</h2>
@@ -112,6 +113,7 @@ table tr td {
112113
<BFE_AUTHORITY_CONTACT
113114
prefix="<table><tbody>"
114115
suffix="</tbody></table>"
116+
vcard_support="yes"
115117
default="<i>No contact information.</i>" />
116118
</div>
117119
<div class="column">
@@ -121,6 +123,7 @@ table tr td {
121123
default="<i>No profiles.</i>"/>
122124
</div>
123125
</div>
126+
</div>
124127

125128
<h2>Publications</h2>
126129
<BFE_AUTHORITY_PUBLICATIONS

modules/bibformat/lib/elements/bfe_authority_contact.py

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,44 +21,69 @@
2121
from invenio.messages import gettext_set_language
2222

2323

24-
def format_email(email, email_href="yes", icon="no"):
24+
def format_email(email, email_href="yes", icon="no", vcard_support="no"):
2525
"""Return formatted email address."""
26+
vcard_enabled = True if vcard_support.lower() == "yes" else False
27+
2628
if email_href.lower() == "yes":
27-
email = "<a href='mailto:{0}'>{0}</a>".format(email)
29+
email = "<a {0}href='mailto:{1}'>{1}</a>".format(
30+
"class='email' " if vcard_enabled else "", email)
31+
else:
32+
if vcard_enabled:
33+
email = "<span class='email'>{0}</span>".format(email)
2834
if icon.lower() == "yes":
2935
icon_class = "fa fa-envelope"
3036
email = "<i class='{0}' style='font-size: 0.9em;'></i> {1}".format(
3137
icon_class, email)
3238
return email
3339

3440

35-
def format_phone_number(phone_number, icon="no"):
41+
def format_phone_number(phone_number, icon="no", vcard_support="no"):
3642
"""Return formatted phone number."""
43+
if vcard_support.lower() == "yes":
44+
phone_number = (
45+
"<span class='tel'>"
46+
"<span class='type' style='display: none;'>work</span>"
47+
"<span class='value'>{0}</span>"
48+
"</span>".format(phone_number))
3749
if icon.lower() == "yes":
3850
icon_class = "fa fa-phone"
3951
phone_number = "<i class='{0}'></i> {1}".format(
4052
icon_class, phone_number)
4153
return phone_number
4254

4355

44-
def format_mobile_number(mobile_number, icon="no"):
56+
def format_mobile_number(mobile_number, icon="no", vcard_support="no"):
4557
"""Return formatted mobile phone number."""
58+
if vcard_support.lower() == "yes":
59+
mobile_number = (
60+
"<span class='tel'>"
61+
"<span class='type' style='display: none;'>cell</span>"
62+
"<span class='value'>{0}</span>"
63+
"</span>".format(mobile_number))
4664
if icon.lower() == "yes":
4765
icon_class = "fa fa-mobile"
4866
mobile_number = "<i class='{0}'></i> {1}".format(
4967
icon_class, mobile_number)
5068
return mobile_number
5169

5270

53-
def format_fax_number(fax_number, icon="no"):
71+
def format_fax_number(fax_number, icon="no", vcard_support="no"):
5472
"""Return formatted fax number."""
73+
if vcard_support.lower() == "yes":
74+
fax_number = (
75+
"<span class='tel'>"
76+
"<span class='type' style='display: none;'>fax</span>"
77+
"<span class='value'>{0}</span>"
78+
"</span>".format(fax_number))
5579
if icon.lower() == "yes":
5680
icon_class = "fa fa-fax"
5781
fax_number = "<i class='{0}'></i> {1}".format(icon_class, fax_number)
5882
return fax_number
5983

6084

61-
def format_element(bfo, contact_type="all", email_href="yes", icon="no"):
85+
def format_element(bfo, contact_type="all", vcard_support="no",
86+
email_href="yes", icon="no"):
6287
"""Return contact information for the record.
6388
6489
:param string contact_type: return all contact information if 'all',
@@ -79,10 +104,12 @@ def format_element(bfo, contact_type="all", email_href="yes", icon="no"):
79104
tbl_row = "<tr><th>{0}</th><td>{1}</td></tr>"
80105
if email:
81106
result += tbl_row.format(
82-
_("Email address"), format_email(email[0].lower(), email_href))
107+
_("Email address"), format_email(
108+
email[0].lower(), email_href, vcard_support=vcard_support))
83109
if phone_number:
84110
result += tbl_row.format(
85-
_("Phone number"), format_phone_number(phone_number[0]))
111+
_("Phone number"), format_phone_number(
112+
phone_number[0], vcard_support=vcard_support))
86113
if mobile_number:
87114
result += tbl_row.format(
88115
_("Mobile number"), format_mobile_number(mobile_number[0]))

0 commit comments

Comments
 (0)