From 6cbe0998b04e6e512a04e8f90ea992dc1dda397e Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Wed, 2 Sep 2015 22:35:52 -0700 Subject: [PATCH] Util.pm: support size column in projects_html_list output Signed-off-by: Kyle J. McKay --- Girocco/Util.pm | 23 +++++++++++++++++++++-- html/girocco.css | 6 ++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/Girocco/Util.pm b/Girocco/Util.pm index a723c0c..ea717c3 100644 --- a/Girocco/Util.pm +++ b/Girocco/Util.pm @@ -552,6 +552,7 @@ sub _strftime { # options are available: # target -- sets the target value of the owner link # emptyok -- if true returns an empty table rather than '' +# sizecol -- if true include a human-readable size column # typecol -- if true include type column with hover info # changed -- if true include a changed and idle column sub projects_html_list { @@ -565,8 +566,11 @@ sub projects_html_list { my $target = ''; $target = " target=\""._escapeHTML($options->{target})."\"" if defined($options->{target}); + my $withsize = defined($options->{sizecol}) && $options->{sizecol}; my $withtype = defined($options->{typecol}) && $options->{typecol}; my $withchanged = defined($options->{changed}) && $options->{changed}; + my $sizehead = ''; + $sizehead = 'Size' if $withsize; my $typehead = ''; $typehead = 'Type' if $withtype; my $chghead = ''; @@ -578,7 +582,7 @@ sub projects_html_list { > EOT my $html = <Project$typehead$chgheadDescription +$sizehead$typehead$chghead EOT my $trclass = ' class="odd"'; foreach (sort({lc($a) cmp lc($b)} @_)) { @@ -587,6 +591,21 @@ EOT my $projname = $proj->{name}.".git"; my $projdesc = $proj->{desc}||''; utf8::decode($projdesc) if utf8::valid($projdesc); + my $sizecol = ''; + if ($withsize) { + my $psize = $proj->{reposizek}; + $psize = undef unless defined($psize) && $psize =~ /^\d+$/; + $psize = 0 if !defined($psize) && $proj->is_empty; + if (!defined($psize)) { + $psize = 'unknown'; + } elsif (!$psize) { + $psize = 'empty'; + } else { + $psize = human_size($psize * 1024); + $psize =~ s/ /\ /g; + } + $sizecol = ''; + } my $typecol = ''; if ($withtype) { if ($proj->{mirror}) { @@ -637,7 +656,7 @@ EOT } $html .= <$typecol$changecol +>@{[_escapeHTML($projname)]}$sizecol$typecol$changecol EOT $trclass = $trclass ? '' : ' class="odd"'; ++$count; diff --git a/html/girocco.css b/html/girocco.css index 3631ae2..3522944 100644 --- a/html/girocco.css +++ b/html/girocco.css @@ -99,6 +99,7 @@ div.htmlcgi h4 { .projectlist th, .projectlist td:first-child, +.projectlist td.sizecol, .projectlist td.type, .projectlist td.change, .projectlist td.idle, @@ -107,6 +108,11 @@ div.htmlcgi h4 { white-space: nowrap; } +.projectlist th.sizecol, +.projectlist td.sizecol { + text-align: right; +} + .nowrap { white-space: nowrap !important; min-width: 0 !important; -- 2.11.4.GIT
ProjectDescription
'.$psize.'@{[_escapeHTML($projname)]}@{[_escapeHTML($projdesc)]}
@{[_escapeHTML($projdesc)]}