From 320773f7ebf3c0070e69797aa2b69e14110d23fa Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Wed, 10 Jul 2013 20:17:47 -0700 Subject: [PATCH] Enhance project list display Include a type column that shows either "mirror" or "n users" that has a hover display of either the mirror from url or the list of users. --- Girocco/Util.pm | 35 +++++++++++++++++++++++++++++------ cgi/projlist.cgi | 2 +- html/girocco.css | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 7 deletions(-) diff --git a/Girocco/Util.pm b/Girocco/Util.pm index 8066561..1e2bb48 100644 --- a/Girocco/Util.pm +++ b/Girocco/Util.pm @@ -163,22 +163,27 @@ sub _escapeHTML { # Take a list of project names and produce a nicely formated table that # includes owner links and descriptions. If the list is empty returns ''. -# The first argument may be a hash ref that contains options. Currently -# the target option is recognized and it sets the target of the owner link -# and setting emptyok to true returns an empty table rather than ''. +# The first argument may be a hash ref that contains options. The following +# options are available: +# target -- sets the target value of the owner link +# emptyok -- if true returns an empty table rather than '' +# typecol -- if true include type column with hover info sub projects_html_list { my $options = {}; if (defined($_[0]) && ref($_[0]) eq 'HASH') { $options = shift; } - return '' unless @_; + return '' unless @_ || (defined($options->{emptyok}) && $options->{emptyok}); require Girocco::Project; my $count = 0; my $target = ''; $target = " target=\""._escapeHTML($options->{target})."\"" if defined($options->{target}); + my $withtype = defined($options->{typecol}) && $options->{typecol}; + my $typehead = ''; + $typehead = 'Type' if $withtype; my $html = <ProjectDescription +$typehead EOT my $trclass = ' class="odd"'; foreach (sort({lc($a) cmp lc($b)} @_)) { @@ -187,9 +192,27 @@ EOT my $projname = $proj->{name}.".git"; my $projdesc = $proj->{desc}||''; utf8::decode($projdesc) if utf8::valid($projdesc); + my $typecol = ''; + if ($withtype) { + if ($proj->{mirror}) { + $typecol = substr(<mirror@{[_escapeHTML($proj->{url})]} +EOT + } else { + my $users = @{$proj->{users}}; + $users .= ' user'; + $users .= 's' unless @{$proj->{users}} == 1; + my $userlist = join(', ', sort({lc($a) cmp lc($b)} @{$proj->{users}})); + $typecol = $userlist ? substr(<$users$userlist +EOT + +EOT + } + } $html .= < +>@{[_escapeHTML($projname)]}$typecol EOT $trclass = $trclass ? '' : ' class="odd"'; ++$count; diff --git a/cgi/projlist.cgi b/cgi/projlist.cgi index 3bb8070..873f04a 100755 --- a/cgi/projlist.cgi +++ b/cgi/projlist.cgi @@ -68,7 +68,7 @@ close F; @projects or die "not found owner's projects, that's really weird!"; $displayname =~ s,@,,; -my $projectlist = projects_html_list({emptyok=>1}, @projects); +my $projectlist = projects_html_list({emptyok=>1, typecol=>1}, @projects); print <The owner '$displayname' has the following projects registered at this site:

$projectlist diff --git a/html/girocco.css b/html/girocco.css index a84c482..6ebd8cd 100644 --- a/html/girocco.css +++ b/html/girocco.css @@ -72,3 +72,45 @@ div.htmlcgi { .projectlist th { text-align: left; } + +.projectlist th.desc { + min-width: 40ex; +} + +.projectlist th, .projectlist td:first-child, .projectlist td.type { + white-space: nowrap; +} + +.nowrap { + white-space: nowrap !important; + min-width: 0 !important; +} + +.hover { + position: relative; + border-bottom: thin dotted; +} + +.hover:hover { + border-bottom: hidden; + background-color: #ffffe4; +} + +.hover span { + position: absolute; + left: 0; + top: +100%; + margin-top: 1ex; + margin-left: 1.25ex; + border: thin solid; + padding: 1ex; + background-color: white; + min-width: 45ex; + z-index: 1; + white-space: normal; + visibility: hidden; +} + +.hover:hover span { + visibility: visible; +} -- 2.11.4.GIT
ProjectDescription
$users@{[_escapeHTML($projname)]}@{[_escapeHTML($projdesc)]}
@{[_escapeHTML($projdesc)]}