diff --git a/gitweb.pl b/gitweb.pl index 85a5f530cc..dd487c3d88 100755 --- a/gitweb.pl +++ b/gitweb.pl @@ -2,7 +2,7 @@ # gitweb.pl - simple web interface to track changes in git repositories # -# Version 020 +# Version 021 # # (C) 2005, Kay Sievers # (C) 2005, Christian Gierke @@ -34,13 +34,13 @@ if ($url_parm =~ m#/(.+)/commit/([0-9a-fA-F]+)$#) { $project = $1; $action = "commit"; $hash = $2; -} elsif ($url_parm =~ m#/(.+)/treediff/([0-9a-fA-F]+)$#) { +} elsif ($url_parm =~ m#/(.+)/commitdiff/([0-9a-fA-F]+)$#) { $project = $1; - $action = "treediff"; + $action = "commitdiff"; $hash = $2; -} elsif ($url_parm =~ m#/(.+)/diff/([0-9a-fA-F]+)/([0-9a-fA-F]+)$#) { +} elsif ($url_parm =~ m#/(.+)/blobdiff/([0-9a-fA-F]+)/([0-9a-fA-F]+)$#) { $project = $1; - $action = "diff"; + $action = "blobdiff"; $hash = $2; $hash_parent = $3; } elsif ($url_parm =~ m#/(.+)/blob/([0-9a-fA-F]+)$#) { @@ -59,6 +59,10 @@ if ($url_parm =~ m#/(.+)/commit/([0-9a-fA-F]+)$#) { $project = $1; $action = "log"; $view_back = 1; +} elsif ($url_parm =~ m#/(.+)/rss$#) { + $project = $1; + $action = "rss"; + $view_back = 1; } elsif ($url_parm =~ m#/git-logo.png$#) { print $cgi->header(-type => 'image/png'); print "\211\120\116\107\015\012\032\012\000\000\000\015\111\110\104\122". @@ -93,6 +97,7 @@ print < git - $project $action + @@ -213,20 +218,21 @@ if ($project eq "") { my (@path) = grep(!/^\./, readdir($fd)); closedir($fd); git_header(); - print "

\n"; + print "
\n"; + print "

\n"; foreach my $line (@path) { if (-e "$projectroot/$defaultprojects/$line/.git/HEAD") { print $cgi->a({-href => "$myself/$defaultprojects/$line/log"}, $line) . "
\n"; } } - print "
"; + print "

"; git_footer(); exit; } if ($action eq "blob") { git_header(); - print "

\n"; + print "

\n"; print "
\n";
 	open my $fd, "-|", "$gitbin/cat-file", "blob", $hash;
 	my $nr;
@@ -236,7 +242,7 @@ if ($action eq "blob") {
 	}
 	close $fd;
 	print "
\n"; - print "
"; + print "
"; git_footer(); } elsif ($action eq "tree") { if ($hash eq "") { @@ -250,7 +256,7 @@ if ($action eq "blob") { my (@entries) = map { chomp; $_ } <$fd>; close $fd; git_header(); - print "

\n"; + print "

\n"; print "
\n";
 	foreach my $line (@entries) {
 		#'100644	blob	0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa	panic.c'
@@ -265,9 +271,9 @@ if ($action eq "blob") {
 		}
 	}
 	print "
\n"; - print "
"; + print "
"; git_footer(); -} elsif ($action eq "log") { +} elsif ($action eq "log" || $action eq "rss") { open my $fd, "$projectroot/$project/.git/HEAD"; my $head = <$fd>; chomp $head; @@ -275,20 +281,33 @@ if ($action eq "blob") { open $fd, "-|", "$gitbin/rev-tree", $head; my (@revtree) = reverse sort map { chomp; $_ } <$fd>; close $fd; - git_header(); - print "
\n"; - print "view "; - print $cgi->a({-href => "$myself/$project/log"}, "last day") . " | "; - print $cgi->a({-href => "$myself/$project/log/7"}, "week") . " | "; - print $cgi->a({-href => "$myself/$project/log/31"}, "month") . " | "; - print $cgi->a({-href => "$myself/$project/log/365"}, "year") . " | "; - print $cgi->a({-href => "$myself/$project/log/0"}, "all") . "
\n"; - print "

\n"; - print "
\n"; - print "\n"; + + if ($action eq "log") { + git_header(); + print "
\n"; + print "view "; + print $cgi->a({-href => "$myself/$project/log"}, "last day") . " | "; + print $cgi->a({-href => "$myself/$project/log/7"}, "week") . " | "; + print $cgi->a({-href => "$myself/$project/log/31"}, "month") . " | "; + print $cgi->a({-href => "$myself/$project/log/365"}, "year") . " | "; + print $cgi->a({-href => "$myself/$project/log/0"}, "all") . "
\n"; + print "

\n"; + print "
\n"; + print "
\n"; + } elsif ($action eq "rss") { + print $cgi->header(-type => 'text/xml; charset: utf-8'); + print "\n". + "\n"; + print "\n"; + print "$project\n". + " " . $cgi->url() . "/$project/log\n". + "$project log\n". + "en\n"; + } + for (my $i = 0; $i <= $#revtree; $i++) { my $rev = $revtree[$i]; - #foreach my $rev (@revtree) { + #foreach my $rev (@revtree) { # '1114106118 755e3010ee10dadf42a8a80770e1b115fb038d9b:1 2af17b4854036a1c2ec6c101d93c8dd1ed80d24e:1' last if !($rev =~ m/^([0-9]+) ([0-9a-fA-F]+).* ([0-9a-fA-F]+)/); my $time = $1; @@ -319,6 +338,7 @@ if ($action eq "blob") { } } $shortlog = <$fd>; + chomp($shortlog); $shortlog = escapeHTML($shortlog); $comment = $shortlog . "
"; while (my $line = <$fd>) { @@ -352,43 +372,55 @@ if ($action eq "blob") { $age_string = int $age/60; $age_string .= " minutes ago"; } - if ($view_back > 0 && $age > $view_back*60*60*24) { - if ($i == 0) { + if ($action eq "log") { + if ($view_back > 0 && $age > $view_back*60*60*24) { + if ($i == 0) { + print "
\n"; + print "\n"; + print "\n"; + } + last; + } print "\n"; - print "\n"; + print "\n"; + print ""; print "\n"; + print "\n"; + print "\n"; + print ""; + print "\n"; + print "\n"; + print "\n"; + print ""; + print "\n"; + } elsif ($action eq "rss") { + if ($i < 12) { + print "\n\t$age_string: $shortlog\n"; + print "\t " . $cgi->url() . "/$project/commit/$commit\n"; + print "\n"; } - last; - } - print "\n"; - print "\n"; - print ""; - print "\n"; - print "\n"; - print "\n"; - print ""; - print "\n"; - print "\n"; - print "\n"; - print ""; - print "\n"; } - print "
Last change $age_string.
Last change $age_string. " . $age_string . "" . $cgi->a({-href => "$myself/$project/commit/$commit"}, $shortlog) . "
"; + print $cgi->a({-href => "$myself/$project/commitdiff/$commit"}, "view diff") . "
\n"; + print $cgi->a({-href => "$myself/$project/commit/$commit"}, "view commit") . "
\n"; + print $cgi->a({-href => "$myself/$project/tree/$tree"}, "view tree") . "
\n"; + print "
\n"; + print "author    " . escapeHTML($author) . " [" . gmtime($author_time) . " " . $author_timezone . "]
\n"; + print "committer " . escapeHTML($committer) . " [" . gmtime($committer_time) . " " . $committer_timezone . "]
\n"; + print "commit    $commit
\n"; + print "tree      $tree
\n"; + foreach my $par (@parents) { + print "parent    $par
\n"; + } + print "
\n"; + print "$comment

\n"; + print "
" . $age_string . "" . $cgi->a({-href => "$myself/$project/commit/$commit"}, $shortlog) . "
"; - print $cgi->a({-href => "$myself/$project/treediff/$commit"}, "view diff") . "
\n"; - print $cgi->a({-href => "$myself/$project/commit/$commit"}, "view commit") . "
\n"; - print $cgi->a({-href => "$myself/$project/tree/$tree"}, "view tree") . "
\n"; - print "
\n"; - print "author    " . escapeHTML($author) . " [" . gmtime($author_time) . " " . $author_timezone . "]
\n"; - print "committer " . escapeHTML($committer) . " [" . gmtime($committer_time) . " " . $committer_timezone . "]
\n"; - print "commit    $commit
\n"; - print "tree      $tree
\n"; - foreach my $par (@parents) { - print "parent    $par
\n"; } - print "
\n"; - print "$comment

\n"; - print "
\n"; - git_footer(); + if ($action eq "log") { + print "\n"; + git_footer(); + } elsif ($action eq "rss") { + print ""; + } } elsif ($action eq "commit") { my $parent = ""; open my $fd, "-|", "$gitbin/cat-file", "commit", $hash; @@ -408,8 +440,8 @@ if ($action eq "blob") { close $fd; git_header(); - print "
\n"; - print "view " . $cgi->a({-href => "$myself/$project/treediff/$hash"}, "diff") . "


\n"; + print "
\n"; + print "view " . $cgi->a({-href => "$myself/$project/commitdiff/$hash"}, "diff") . "


\n"; print "
$shortlog
\n"; print "
\n";
 	foreach my $line (@difftree) {
@@ -430,22 +462,22 @@ if ($action eq "blob") {
 				$id =~ m/([0-9a-fA-F]+)->([0-9a-fA-F]+)/;
 				my $old = $1;
 				my $new = $2;
-				print "changed\t" . $cgi->a({-href => "$myself/$project/diff/$old/$new"}, $file) . "\n";
+				print "changed\t" . $cgi->a({-href => "$myself/$project/blobdiff/$old/$new"}, $file) . "\n";
 			}
 		}
 	}
 	print "
\n"; - print "
"; + print "
"; git_footer(); -} elsif ($action eq "diff") { +} elsif ($action eq "blobdiff") { git_header(); - print "

\n"; + print "

\n"; print "
\n";
 	git_diff($hash, $hash_parent, $hash, $hash_parent);
 	print "
\n"; - print "
"; + print "
"; git_footer(); -} elsif ($action eq "treediff") { +} elsif ($action eq "commitdiff") { my $parent = ""; open my $fd, "-|", "$gitbin/cat-file", "commit", $hash; while (my $line = <$fd>) { @@ -464,8 +496,8 @@ if ($action eq "blob") { close $fd; git_header(); - print "
\n"; - print "view " . $cgi->a({-href => "$myself/$project/commit/$hash"}, "commit") . "


\n"; + print "
\n"; + print "view " . $cgi->a({-href => "$myself/$project/commit/$hash"}, "commit") . "


\n"; print "
$shortlog
\n"; print "
\n";
 	foreach my $line (@difftree) {
@@ -488,12 +520,6 @@ if ($action eq "blob") {
 		}
 	}
 	print "
\n"; - print "
"; - git_footer(); -} else { - git_header(); - print "

\n"; - print "unknown action\n"; - print "
"; + print "
"; git_footer(); }