2015-07-28 22:44:53 +02:00
|
|
|
|
# Copyright (C) 2011–2015 Alex Schroeder <alex@gnu.org>
|
|
|
|
|
|
# Copyright (C) 2014–2015 Aleks-Daniel Jakimenko <alex.jakimenko@gmail.com>
|
2015-03-28 14:24:26 +01:00
|
|
|
|
#
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify it under
|
|
|
|
|
|
# the terms of the GNU General Public License as published by the Free Software
|
|
|
|
|
|
# Foundation; either version 3 of the License, or (at your option) any later
|
|
|
|
|
|
# version.
|
|
|
|
|
|
#
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
|
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
|
|
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
|
|
|
|
#
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License along with
|
|
|
|
|
|
# this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
#
|
2006-11-11 16:27:11 +00:00
|
|
|
|
# We just try to autodetect everything.
|
|
|
|
|
|
|
2015-03-27 03:01:01 +02:00
|
|
|
|
use strict;
|
2015-08-18 10:48:03 +02:00
|
|
|
|
use v5.10;
|
2015-03-27 03:01:01 +02:00
|
|
|
|
|
2014-08-21 22:23:23 +02:00
|
|
|
|
AddModuleDescription('vcard.pl');
|
2014-08-21 16:41:32 +03:00
|
|
|
|
|
2015-04-10 13:31:28 +03:00
|
|
|
|
our ($q, $bol, @MyRules);
|
2015-03-27 03:01:01 +02:00
|
|
|
|
|
2006-11-11 16:27:11 +00:00
|
|
|
|
push(@MyRules, \&hCardRule);
|
|
|
|
|
|
|
|
|
|
|
|
my $addr = qr(\G(\S+ \S+)
|
|
|
|
|
|
(.*)
|
|
|
|
|
|
((?:[A-Z][A-Z]?-)?\d+) (.*)(?:
|
|
|
|
|
|
(.*))?
|
|
|
|
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
my $email = qr(\G\s*(\S+@\S+)\n?);
|
|
|
|
|
|
|
|
|
|
|
|
my $tel = qr(\G\s*(\S+): (\+?[-0-9 ]+)\n?);
|
|
|
|
|
|
|
|
|
|
|
|
sub hCardRule {
|
2015-02-27 12:10:18 +02:00
|
|
|
|
return unless $bol;
|
2006-11-11 16:27:11 +00:00
|
|
|
|
my ($fn, $street, $zip, $city, $country) = /$addr/cg;
|
|
|
|
|
|
if ($fn) {
|
|
|
|
|
|
my ($mail) = /$email/cg;
|
|
|
|
|
|
my ($phonetype, $phone) = /$tel/cg;
|
|
|
|
|
|
my $html = $q->span({-class=>'fn'}, $fn) . $q->br();
|
|
|
|
|
|
$html .= $q->span({-class=>'street-address'}, $street) . $q->br();
|
|
|
|
|
|
$html .= $q->span({-class=>'postal-code'}, $zip)
|
|
|
|
|
|
. ' ' . $q->span({-class=>'locality'}, $city);
|
|
|
|
|
|
$html .= $q->br()
|
|
|
|
|
|
. $q->span({-class=>'country-name'}, $country) if $country;
|
|
|
|
|
|
my $hCard = $q->p($html);
|
|
|
|
|
|
$html = '';
|
|
|
|
|
|
$html .= $q->span({-class=>'email'},
|
|
|
|
|
|
$q->a({-href=>'mailto:' . $mail}, $mail)) if $mail;
|
|
|
|
|
|
$html .= $q->br() if $mail and $phone;
|
|
|
|
|
|
$html .= $q->span({-class=>'tel'},
|
|
|
|
|
|
$q->span({-class=>'type'}, $phonetype) . ': '
|
|
|
|
|
|
. $q->span({-class=>'value'}, $phone)) if $phone;
|
|
|
|
|
|
$hCard .= $q->p($html) if $html;
|
|
|
|
|
|
$hCard = $q->div({-class=>'vcard',
|
|
|
|
|
|
-style=>'color:red;'}, $hCard);
|
|
|
|
|
|
return CloseHtmlEnvironments() . $hCard . AddHtmlEnvironment('p');
|
|
|
|
|
|
}
|
2015-02-27 12:10:18 +02:00
|
|
|
|
return;
|
2006-11-11 16:27:11 +00:00
|
|
|
|
}
|