From 3ad38938a994c1d5cfedc0b81c6564898844498e Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Wed, 24 Jul 2013 06:00:09 -0700 Subject: [PATCH] Add idle column to project list The current 'Changed' column shows the last time a ref change was received by the site. The new 'Idle' column shows the most recent committer time in refs/heads. --- Girocco/Util.pm | 51 +++++++++++++++++++++++++++++++++++++++++++++++++-- html/girocco.css | 14 +++++++++++--- 2 files changed, 60 insertions(+), 5 deletions(-) diff --git a/Girocco/Util.pm b/Girocco/Util.pm index 15042de..b619acc 100644 --- a/Girocco/Util.pm +++ b/Girocco/Util.pm @@ -212,6 +212,33 @@ sub _rel_age { return $age_str; } +# create relative time string from passed in idle in seconds +sub _rel_idle { + my $idle_str = _rel_age(shift); + $idle_str =~ s/ ago//; + $idle_str = "not at all" if $idle_str eq "right now"; + return $idle_str; +} + +sub _strftime { + use POSIX qw(strftime); + my ($fmt, $secs, $zonesecs) = @_; + my ($S,$M,$H,$d,$m,$y) = gmtime($secs + $zonesecs); + $zonesecs = int($zonesecs / 60); + $fmt =~ s/%z/\$z/g; + my $ans = strftime($fmt, $S, $M, $H, $d, $m, $y, -1, -1, -1); + my $z; + if ($zonesecs < 0) { + $z = "-"; + $zonesecs = -$zonesecs; + } else { + $z = "+"; + } + $z .= sprintf("%02d%02d", int($zonesecs/60), $zonesecs % 60); + $ans =~ s/\$z/$z/g; + return $ans; +} + # 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. The following @@ -219,7 +246,7 @@ sub _rel_age { # 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 -# changed -- if true include a changed column +# changed -- if true include a changed and idle column sub projects_html_list { my $options = {}; if (defined($_[0]) && ref($_[0]) eq 'HASH') { @@ -236,7 +263,13 @@ sub projects_html_list { my $typehead = ''; $typehead = 'Type' if $withtype; my $chghead = ''; - $chghead = 'Changed' if $withchanged; + $chghead = substr(<ChangedChangedThe last time a ref change was received by this site.IdleIdleThe most recent committer time in refs/heads. +EOT my $html = <Project$typehead$chgheadDescription EOT @@ -280,6 +313,20 @@ EOT $changecol = substr(<$rel EOT + my $idletime = $proj->{lastactivity}; + my ($idlesecs, $tz); + $idlesecs = parse_any_date($idletime, \$tz) if $idletime; + if ($idlesecs) { + my $idle2822 = _strftime("%a, %d %b %Y %T %z", $idlesecs, $tz); + $rel = "" . + _rel_idle(time - $idlesecs) . + "$idle2822"; + } else { + $rel = "no commits"; + } + $changecol .= substr(<$rel +EOT } $html .= < span:first-child { position: absolute; left: 0; top: +100%; @@ -111,9 +112,16 @@ div.htmlcgi { min-width: 45ex; z-index: 1; white-space: normal; + font-weight: normal; visibility: hidden; } -.hover:hover span { +.hover .head { + display: block; + font-weight: bold; + margin-bottom: 0.5em; +} + +.hover:hover > span:first-child { visibility: visible; } -- 2.11.4.GIT