Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- gitweb.cgi 2018-05-30 00:26:43.000000000 +0300
- +++ my_gitweb.cgi 2018-06-16 15:26:41.207212864 +0300
- @@ -24,6 +24,23 @@
- binmode STDOUT, ':utf8';
- +
- +use CGI::Fast (-utf8);
- +use FCGI ();
- +use Encode ();
- +
- +my $enc = Encode::find_encoding('UTF-8');
- +my $org = \&FCGI::Stream::PRINT;
- +no warnings 'redefine';
- +local *FCGI::Stream::PRINT = sub {
- + my @OUTPUT = @_;
- + for (my $i = 1; $i < @_; $i++) {
- + $OUTPUT[$i] = $enc->encode($_[$i], Encode::FB_CROAK|Encode::LEAVE_SRC);
- + }
- + @_ = @OUTPUT;
- + goto $org;
- +};
- +
- if (!defined($CGI::VERSION) || $CGI::VERSION < 4.08) {
- eval 'sub CGI::multi_param { CGI::param(@_) }'
- }
- @@ -5719,7 +5736,7 @@
- }
- print "</td>\n";
- }
- - print "<td>" . $cgi->a({-href => href(project=>$pr->{'path'}, action=>"summary"),
- + print "<td>" . $cgi->a({-href => href(project=>$pr->{'path'}, action=>"tree"),
- -class => "list"},
- esc_html_match_hl($pr->{'path'}, $search_regexp)) .
- "</td>\n" .
- @@ -6527,6 +6544,46 @@
- }
- }
- +sub git_readme_out {
- + my ($roothash) = @_;
- + if (!$prevent_xss) {
- + my $file_name = "README.md";
- + my $readme_md_blob_hash = git_get_hash_by_path($roothash, $file_name, "blob");
- + my $readme_blob_hash;
- + if (!$readme_md_blob_hash) {
- + $file_name = "README";
- + $readme_blob_hash = git_get_hash_by_path($roothash, $file_name, "blob");
- + if (!$readme_blob_hash) {
- + $file_name = "readme.txt";
- + $readme_blob_hash = git_get_hash_by_path($roothash, $file_name, "blob");
- + }
- + }
- + if ($readme_blob_hash || $readme_md_blob_hash) { # if a readme exists
- + print "<div class=\"page_header\">" . $file_name . "</div>\n";
- + print "<div class=\"readme page_body\">";
- + if ($readme_md_blob_hash) {
- + my $cmd_markdownify = $GIT . " " . git_cmd() . " cat-file blob " . $readme_md_blob_hash . " | cmark-gfm --safe |";
- + open FOO, $cmd_markdownify or die_error(500, "Open git-cat-file blob '$readme_md_blob_hash' failed");
- + while (<FOO>) {
- + print sanitize($_);
- + }
- + close(FOO);
- + } else {
- + open my $fd, "-|", git_cmd(), "cat-file", "blob", $readme_blob_hash
- + or die_error(500, "Couldn't cat $file_name, $readme_blob_hash");
- + while (my $line = <$fd>) {
- + chomp $line;
- + $line = untabify($line);
- + printf qq!<div class="pre"> %s</div>\n!, esc_html($line, -nbsp=>1);
- + }
- + close $fd
- + or print "Reading blob failed.\n";
- + }
- + print "</div>";
- + }
- + }
- +}
- +
- sub git_summary {
- my $descr = git_get_project_description($project) || "none";
- my %co = parse_commit("HEAD");
- @@ -6642,6 +6699,8 @@
- 'no_header');
- }
- + git_readme_out($head);
- +
- git_footer_html();
- }
- @@ -7245,6 +7304,11 @@
- }
- print "</table>\n" .
- "</div>";
- +
- + if (!defined $file_name) {
- + git_readme_out($hash_base);
- + }
- +
- git_footer_html();
- }
Add Comment
Please, Sign In to add comment