Beautified the output a little: In the `list' action fields are now displayed accordi...
authorFlorian Forster <octo@verplant.org>
Sun, 11 Jun 2006 21:35:35 +0000 (23:35 +0200)
committerFlorian Forster <octo@verplant.org>
Sun, 11 Jun 2006 21:35:35 +0000 (23:35 +0200)
To do that the logic has been `outsourced' to a function doing the markup..

licom.cgi

index 78270c8..cd02690 100755 (executable)
--- a/licom.cgi
+++ b/licom.cgi
@@ -265,7 +265,7 @@ EOF
                {
                        my $field = $_;
                        my @values = $person->get ($field);
-                       print "\t\t\t\t<td>" . join ('<br />', map { encode_entities ($_) } (@values)) . "</td>\n";
+                       print "\t\t\t\t<td>" . join ('<br />', map { markup_field ($field, $_) } (@values)) . "</td>\n";
                }
 
                print "\t\t\t</tr>\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(<a href="$MySelf?action=browse&group=$val_uri">$val_html</a>);
-                       }
-                       elsif ($field eq 'uri')
-                       {
-                               if ($val =~ m#^([a-z]+)://(.+)$#)
-                               {
-                                       $val_uri = $1 . '://' . uri_escape ($2);
-                               }
-                               else
-                               {
-                                       $val_uri = 'http://' . uri_escape ($val);
-                               }
-                               $val = qq(<a href="$val_uri" class="extern">$val_html</a>);
-                       }
-                       elsif ($field eq 'mail')
-                       {
-                               $val = qq(<a href="mailto:$val_uri" class="mail">$val_html</a>);
-                       }
-                       else
-                       {
-                               $val = $val_html;
-                       }
+                       my $val = markup_field ($field, $values->[$i]);
                        
                        print "\t\t\t<tr>\n" if ($i);
                        print "\t\t\t\t<td>$val</td>\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(<a href="$MySelf?action=browse&group=$value_uri">$value_html</a>));
+       }
+       elsif ($field eq 'uri')
+       {
+               if ($value =~ m#^([a-z]+)://(.+)$#)
+               {
+                       $value_uri = $1 . '://' . uri_escape ($2);
+               }
+               else
+               {
+                       $value_uri = 'http://' . uri_escape ($value);
+               }
+               return (qq(<a href="$value_uri" class="extern">$value_html</a>));
+       }
+       elsif ($field eq 'mail')
+       {
+               return (qq(<a href="mailto:$value_uri" class="mail">$value_html</a>));
+       }
+       return ($value_html);
+}
+
 sub get_contacts
 {
        my $contacts = @_ ? shift : {};