From 2bf7a52c6195a52e12cb2b9821a9a026846e7b1c Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Sun, 7 Aug 2005 20:26:03 +0200 Subject: [PATCH] v164 --- gitweb.cgi | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 80e0d119..8dc7a735 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -15,7 +15,7 @@ use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "163"; +my $version = "164"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -335,8 +335,11 @@ sub git_read_commit { $co{'author'} = $1; $co{'author_epoch'} = $2; $co{'author_tz'} = $3; - $co{'author_name'} = $co{'author'}; - $co{'author_name'} =~ s/ <.*//; + if ($co{'author'} =~ m/^([^<]+) ; $co{'comment'} = \@comment; - $comment[0] =~ m/^(.{0,50}[^ \/\-_:\.]{0,10})/; - $co{'title'} = $1; - if ($comment[0] ne $co{'title'}) { - $co{'title'} .= " ..."; - } + $co{'title'} = chop_str($comment[0], 50); close $fd || return; my $age = time - $co{'committer_epoch'}; @@ -467,6 +466,18 @@ sub mode_str { } } +sub chop_str { + my $str = shift; + my $len = shift; + + $str =~ m/^(.{0,$len}[^ \/\-_:\.@]{0,10})/; + my $chopped = $1; + if ($chopped ne $str) { + $chopped .= " ..."; + } + return $chopped; +} + sub file_type { my $mode = oct shift; @@ -614,6 +625,7 @@ sub git_project_list { next; } my $descr = git_read_description($proj{'path'}) || ""; + $descr = chop_str($descr, 30); # get directory owner if not already specified if (!defined $proj{'owner'}) { $proj{'owner'} = get_file_owner("$projectroot/$proj{'path'}") || ""; @@ -626,7 +638,7 @@ sub git_project_list { $alternate ^= 1; print "" . $cgi->a({-href => "$my_uri?p=$proj{'path'};a=summary", -class => "list"}, escapeHTML($proj{'path'})) . "\n" . "$descr\n" . - "$proj{'owner'}\n"; + "" . chop_str($proj{'owner'}, 20) . "\n"; my $colored_age; if ($co{'age'} < 60*60*2) { $colored_age = "$co{'age_string'}"; @@ -742,7 +754,7 @@ sub git_summary { $alternate ^= 1; if (--$i > 0) { print "$co{'age_string'}\n" . - "$co{'author_name'}\n" . + "" . escapeHTML(chop_str($co{'author_name'}, 10)) . "\n" . "" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, "" . escapeHTML($co{'title'}) . "") . "\n" . "" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . @@ -1499,7 +1511,7 @@ sub git_history { } $alternate ^= 1; print "$co{'age_string'}\n" . - "$co{'author_name'}\n" . + "" . escapeHTML(chop_str($co{'author_name'}, 10)) . "\n" . "" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "list"}, "" . escapeHTML($co{'title'}) . "") . "\n" . "" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . -- 2.11.0