From: Florian Forster Date: Sun, 11 Jun 2006 21:35:35 +0000 (+0200) Subject: Beautified the output a little: In the `list' action fields are now displayed accordi... X-Git-Url: https://git.octo.it/?p=licom.git;a=commitdiff_plain;h=6da463204f0e7002e9f43e1492846833b60457a0 Beautified the output a little: In the `list' action fields are now displayed according to their type, just like in the `detail' action. To do that the logic has been `outsourced' to a function doing the markup.. --- diff --git a/licom.cgi b/licom.cgi index 78270c8..cd02690 100755 --- a/licom.cgi +++ b/licom.cgi @@ -265,7 +265,7 @@ EOF { my $field = $_; my @values = $person->get ($field); - print "\t\t\t\t" . join ('
', map { encode_entities ($_) } (@values)) . "\n"; + print "\t\t\t\t" . join ('
', map { markup_field ($field, $_) } (@values)) . "\n"; } print "\t\t\t\n"; @@ -331,34 +331,7 @@ EOF for (my $i = 0; $i < $num; $i++) { - my $val = $values->[$i]; - my $val_uri = uri_escape ($val); - my $val_html = encode_entities ($val); - - if ($field eq 'group') - { - $val = qq($val_html); - } - elsif ($field eq 'uri') - { - if ($val =~ m#^([a-z]+)://(.+)$#) - { - $val_uri = $1 . '://' . uri_escape ($2); - } - else - { - $val_uri = 'http://' . uri_escape ($val); - } - $val = qq($val_html); - } - elsif ($field eq 'mail') - { - $val = qq($val_html); - } - else - { - $val = $val_html; - } + my $val = markup_field ($field, $values->[$i]); print "\t\t\t\n" if ($i); print "\t\t\t\t$val\n", @@ -1212,6 +1185,7 @@ Content-Type: text/html; charset=UTF-8 table.list { width: 100%; + border: 2px solid #d0d0d0; } table.list td @@ -1222,18 +1196,23 @@ Content-Type: text/html; charset=UTF-8 td { color: black; - background-color: #cccccc; + background-color: #e8e8e8; vertical-align: top; } th { color: black; - background-color: #999999; + background-color: #d0d0d0; padding: 0.3ex; text-align: left; vertical-align: top; } + + ul.groups li + { + margin-top: 0.5ex; + } } \@media print @@ -1424,6 +1403,37 @@ sub verify_fields return (scalar (@errors)); } +sub markup_field +{ + my $field = shift; + my $value = shift; + + my $value_uri = uri_escape ($value); + my $value_html = encode_entities ($value); + + if ($field eq 'group') + { + return (qq($value_html)); + } + elsif ($field eq 'uri') + { + if ($value =~ m#^([a-z]+)://(.+)$#) + { + $value_uri = $1 . '://' . uri_escape ($2); + } + else + { + $value_uri = 'http://' . uri_escape ($value); + } + return (qq($value_html)); + } + elsif ($field eq 'mail') + { + return (qq($value_html)); + } + return ($value_html); +} + sub get_contacts { my $contacts = @_ ? shift : {};