X-Git-Url: https://git.ladys.computer/Gitweb/blobdiff_plain/1f369c85ca0dee892d504527ed0529b3df7f9501b49e2d156c0fde14ac811b2c..f8ca1c0b2e6de3a1518e54ccf9459c3f54098dd90861f3d016561a6fc6dc9a7b:/gitweb.cgi diff --git a/gitweb.cgi b/gitweb.cgi index c8e20d0..eeec2ef 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -10,11 +10,12 @@ use strict; use warnings; use CGI qw(:standard :escapeHTML); +use CGI::Util qw(unescape); use CGI::Carp qw(fatalsToBrowser); use Fcntl ':mode'; my $cgi = new CGI; -my $version = "142"; +my $version = "149"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); my $rss_link = ""; @@ -36,7 +37,7 @@ my $home_text = "indextext.html"; # source of projects list #my $projects_list = $projectroot; -my $projects_list = "index/index.txt"; +my $projects_list = "index/index.aux"; # input validation and dispatch my $action = $cgi->param('a'); @@ -192,7 +193,7 @@ div.title, a.title { a.title:hover { background-color: #d9d8d1; } div.title_text { padding:6px 8px; border: solid #d9d8d1; border-width:0px 0px 1px; } div.log_body { padding:8px 8px 8px 150px; } -span.log_age { position:relative; float:left; width:142px; font-style:italic; } +span.age { position:relative; float:left; width:142px; font-style:italic; } div.log_link { font-size:10px; font-family:sans-serif; font-style:normal; position:relative; float:left; width:142px; @@ -563,7 +564,9 @@ sub git_project_list { open my $fd , $projects_list || return undef; while (my $line = <$fd>) { chomp $line; - my ($path, $owner) = split ':', $line; + my ($path, $owner) = split ' ', $line; + $path = unescape($path); + $owner = unescape($owner); if (!defined $path) { next; } @@ -618,7 +621,7 @@ sub git_project_list { $proj{'owner'} = get_file_owner("$projectroot/$proj{'path'}") || ""; } print "\n" . - "" . $cgi->a({-href => "$my_uri?p=" . $proj{'path'} . ";a=summary"}, escapeHTML($proj{'path'})) . "\n" . + "" . $cgi->a({-href => "$my_uri?p=$proj{'path'};a=summary"}, escapeHTML($proj{'path'})) . "\n" . "$descr\n" . "$proj{'owner'}\n"; my $colored_age; @@ -634,7 +637,8 @@ sub git_project_list { $cgi->a({-href => "$my_uri?p=$proj{'path'};a=summary"}, "summary") . " | " . $cgi->a({-href => "$my_uri?p=$proj{'path'};a=log"}, "log") . " | " . $cgi->a({-href => "$my_uri?p=$proj{'path'};a=tree"}, "tree") . - "\n"; + "\n" . + "\n"; } print "\n" . "
\n" . @@ -690,7 +694,9 @@ sub git_summary { open (my $fd , $projects_list); while (my $line = <$fd>) { chomp $line; - my ($pr, $ow) = split ':', $line; + my ($pr, $ow) = split ' ', $line; + $pr = unescape($pr); + $ow = unescape($ow); if ($pr eq $project) { $owner = $ow; last; @@ -705,7 +711,7 @@ sub git_summary { git_header_html(); print "
\n" . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;hb=$head"}, "latest tree") . + " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree"}, "tree") . "

\n" . "
\n"; print "
project
\n"; @@ -715,7 +721,7 @@ sub git_summary { "owner$owner\n" . "last change$cd{'rfc2822'}\n" . "\n" . - "
\n"; + "
\n"; open my $fd, "-|", "$gitbin/git-rev-list --max-count=11 " . git_read_hash("$project/HEAD") || die_error(undef, "Open failed."); my (@revlist) = map { chomp; $_ } <$fd>; close $fd; @@ -723,19 +729,25 @@ sub git_summary { $cgi->a({-href => "$my_uri?p=$project;a=log", -class => "title"}, "recent commits") . "\n"; my $i = 10; + print "
\n" . + "\n"; foreach my $commit (@revlist) { my %co = git_read_commit($commit); my %ad = date_str($co{'author_epoch'}); - print "
\n" . - $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, - "" . $co{'age_string'} . "" . escapeHTML($co{'title'})) . "\n" . - "
\n"; - if (--$i == 0) { - print "
" . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "...") . "
\n"; + print "\n"; + if (--$i > 0) { + print "\n" . + "\n" . + "\n" . + ""; + } else { + print "\n" . + ""; last; } } - print "
\n"; + print "" . + "\n"; my $taglist = git_read_tags(); if (defined @$taglist) { @@ -743,19 +755,24 @@ sub git_summary { $cgi->a({-href => "$my_uri?p=$project;a=tags", -class => "title"}, "recent tags") . "\n"; my $i = 10; + print "
\n" . + "
$co{'age_string'}$co{'author_name'}" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, escapeHTML($co{'title'})) . "
" . $cgi->a({-href => "$my_uri?p=$project;a=log"}, "...") . "
\n"; foreach my $entry (@$taglist) { my %tag = %$entry; - print "
\n" . - $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}"}, - "$tag{'age'}" . escapeHTML($tag{'name'})) . "\n" . - "
\n"; - if (--$i == 0) { - print "
" . $cgi->a({-href => "$my_uri?p=$project;a=tags"}, "...") . "
\n"; + print "\n"; + if (--$i > 0) { + print "\n" . + "\n" . + ""; + } else { + print "\n" . + ""; last; } } + print "" . + "\n"; } - print "
\n"; git_footer_html(); } @@ -777,11 +794,11 @@ sub git_tags { my %tag = %$entry; print "
\n" . $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}"}, - "$tag{'age'}" . escapeHTML($tag{'name'})) . "\n" . + "$tag{'age'}" . escapeHTML($tag{'name'})) . "\n" . "
\n"; } } - print "
\n"; + print "

\n"; git_footer_html(); } @@ -827,7 +844,7 @@ sub git_blob { print "
\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "commitdiff") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash_base"}, "tree"); + " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash_base"}, "tree"); if (defined $file_name) { print " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash_base;f=$file_name"}, "history"); } @@ -866,6 +883,9 @@ sub git_tree { $hash = git_get_hash_by_path($base, $file_name, "tree"); } } + if (!defined $hash_base) { + $hash_base = git_read_hash("$project/HEAD"); + } open my $fd, "-|", "$gitbin/git-ls-tree $hash" || die_error(undef, "Open git-ls-tree failed."); my (@entries) = map { chomp; $_ } <$fd>; close $fd || die_error(undef, "Reading tree failed."); @@ -937,7 +957,7 @@ sub git_rss { "\n"; print "\n"; print "$project\n". - " " . $my_url . "/$project/log\n". + " $my_url/$project/log\n". "$project log\n". "en\n"; @@ -946,7 +966,7 @@ sub git_rss { my %ad = date_str($co{'author_epoch'}); print "\n" . "\t" . sprintf("%d %s %02d:%02d", $ad{'mday'}, $ad{'month'}, $ad{'hour'}, $ad{'minute'}) . " - " . escapeHTML($co{'title'}) . "\n" . - "\t " . $my_url . "?p=$project;a=commit;h=$commit\n" . + "\t $my_url?p=$project;a=commit;h=$commit\n" . "\t"; my $comment = $co{'comment'}; foreach my $line (@$comment) { @@ -984,7 +1004,7 @@ sub git_log { if (!@revlist) { my %co = git_read_commit($head); - print "
Last change " . $co{'age_string'} . ".

\n"; + print "
Last change $co{'age_string'}.

\n"; } foreach my $commit (@revlist) { @@ -993,7 +1013,7 @@ sub git_log { my %ad = date_str($co{'author_epoch'}); print "
\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit", -class => "title"}, - "" . $co{'age_string'} . "" . escapeHTML($co{'title'})) . "\n" . + "$co{'age_string'}" . escapeHTML($co{'title'})) . "\n" . "
\n"; print "
\n" . "
\n" . @@ -1001,13 +1021,13 @@ sub git_log { " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$commit"}, "commitdiff") . "
\n" . "
\n" . - "" . escapeHTML($co{'author_name'}) . " [" . $ad{'rfc2822'} . "]
\n" . + "" . escapeHTML($co{'author_name'}) . " [$ad{'rfc2822'}]
\n" . "
\n" . "
\n"; my $comment = $co{'comment'}; my $empty = 0; foreach my $line (@$comment) { - if ($line =~ m/^(signed[ \-]off[\-]by[ :]|acked[\-]by[ \:]|cc[ :])/i) { + if ($line =~ m/^(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) { next; } if ($line eq "") { @@ -1038,7 +1058,7 @@ sub git_commit { my @difftree; if (defined $co{'parent'}) { - open my $fd, "-|", "$gitbin/git-diff-tree -r " . $co{'parent'} . " $hash" || die_error(undef, "Open failed."); + open my $fd, "-|", "$gitbin/git-diff-tree -r $co{'parent'} $hash" || die_error(undef, "Open failed."); @difftree = map { chomp; $_ } <$fd>; close $fd || die_error(undef, "Reading diff-tree failed."); } else { @@ -1054,7 +1074,7 @@ sub git_commit { if (defined $co{'parent'}) { print " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff"); } - print " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash"}, "tree") . "\n" . + print " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, "tree") . "\n" . "

\n"; if (defined $co{'parent'}) { print "
\n" . @@ -1062,13 +1082,13 @@ sub git_commit { "
\n"; } else { print "
\n" . - $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" . + $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash", -class => "title"}, escapeHTML($co{'title'})) . "\n" . "
\n"; } print "
\n" . "
$tag{'age'}" . $cgi->a({-href => "$my_uri?p=$project;a=$tag{'type'};h=$tag{'id'}"}, escapeHTML($tag{'name'})) . "
" . $cgi->a({-href => "$my_uri?p=$project;a=tags"}, "...") . "
\n"; print "\n". - "\n"; print "\n"; - print "\n"; + print "\n"; print "\n"; print "\n"; + $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, $co{'tree'}) . "\n"; my $parents = $co{'parents'}; foreach my $par (@$parents) { print "
author" . escapeHTML($co{'author'}) . "
" . $ad{'rfc2822'}; + "
$ad{'rfc2822'}"; if ($ad{'hour_local'} < 6) { printf(" (%02d:%02d %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'}); } else { @@ -1076,10 +1096,10 @@ sub git_commit { } print "
committer" . escapeHTML($co{'committer'}) . "
" . $cd{'rfc2822'} . sprintf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}) . "
$cd{'rfc2822'}" . sprintf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}) . "
commit$hash
tree" . - $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=" . $hash}, $co{'tree'}) . "
parent" . @@ -1101,7 +1121,7 @@ sub git_commit { } else { $empty = 0; } - if ($line =~ m/^(signed[ \-]off[\-]by[ :]|acked[\-]by[ \:]|cc[ :])/i) { + if ($line =~ m/^(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) { $signed = 1; print "" . escapeHTML($line) . "
\n"; } else { @@ -1134,7 +1154,7 @@ sub git_commit { } print "
\n" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, - escapeHTML($file) . " [new " . file_type($mode) . $mode_chng . "]") . "\n" . + escapeHTML($file) . " [new " . file_type($mode) . "$mode_chng]") . "\n" . "
\n"; print "
\n" . $cgi->a({-href => "$my_uri?p=$project;a=blob;h=$id;hb=$hash;f=$file"}, "blob") . "\n" . @@ -1201,7 +1221,7 @@ sub git_blobdiff { $cgi->a({-href => "$my_uri?p=$project;a=log"}, "log") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "commitdiff") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash_base"}, "tree"); + " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash_base"}, "tree"); if (defined $file_name) { print " | " . $cgi->a({-href => "$my_uri?p=$project;a=history;h=$hash_base;f=$file_name"}, "history"); } @@ -1237,7 +1257,7 @@ sub git_commitdiff { if (!%co) { die_error(undef, "Unknown commit object."); } - open my $fd, "-|", "$gitbin/git-diff-tree -r " . $co{'parent'} . " $hash" || die_error(undef, "Open failed."); + open my $fd, "-|", "$gitbin/git-diff-tree -r $co{'parent'} $hash" || die_error(undef, "Open failed."); my (@difftree) = map { chomp; $_ } <$fd>; close $fd || die_error(undef, "Reading diff-tree failed."); @@ -1306,7 +1326,7 @@ sub git_history { print "
\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash"}, "commit") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash"}, "commitdiff") . " | " . - $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$hash"}, "tree") . + $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"}, "tree") . "

\n" . "
\n"; print "
\n" . @@ -1334,16 +1354,16 @@ sub git_history { } print "
\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, - "" . $co{'age_string'} . "" . escapeHTML($co{'title'})) . "\n" . + "$co{'age_string'}" . escapeHTML($co{'title'})) . "\n" . "
\n"; print "
\n" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$commit"}, "commit") . " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=" . $co{'tree'} . ";hb=$commit"}, "tree") . - " | " . $cgi->a({-href => "$my_uri?p=$project;a=blob;hb=$commit;f=" . $file}, "blob"); + " | " . $cgi->a({-href => "$my_uri?p=$project;a=blob;hb=$commit;f=$file"}, "blob"); my $blob = git_get_hash_by_path($hash, $file_name); my $blob_parent = git_get_hash_by_path($commit, $file_name); if (defined $blob && defined $blob_parent && $blob ne $blob_parent) { - print " | " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$blob;hp=$blob_parent;hb=$commit;f=" . $file}, "diff"); + print " | " . $cgi->a({-href => "$my_uri?p=$project;a=blobdiff;h=$blob;hp=$blob_parent;hb=$commit;f=$file"}, "diff"); } print "
\n" . "
\n";