From: Kay Sievers Date: Mon, 17 Oct 2005 01:27:54 +0000 (+0200) Subject: provide filename for "save as" in plaintext views X-Git-Tag: v1.4.0~1^2~48 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=9312944d35b571c4a7fdde266131b1a6f8d03241;p=git.git provide filename for "save as" in plaintext views Signed-off-by: Kay Sievers --- diff --git a/gitweb.cgi b/gitweb.cgi index ecbcd5b3..a11f2974 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -1281,7 +1281,6 @@ sub git_blob { $hash = git_get_hash_by_path($base, $file_name, "blob"); } open my $fd, "-|", "$gitbin/git-cat-file blob $hash" or die_error(undef, "Open failed."); - my $base = $file_name || ""; git_header_html(); if (defined $hash_base && (my %co = git_read_commit($hash_base))) { print "
\n" . @@ -1291,9 +1290,13 @@ sub git_blob { " | " . $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") . "
\n"; - print $cgi->a({-href => "$my_uri?p=$project;a=blob_plain;h=$hash"}, "plain") . "
\n" . - "
\n"; - print "
" . + if (defined $file_name) { + print $cgi->a({-href => "$my_uri?p=$project;a=blob_plain;h=$hash;f=$file_name"}, "plain") . "
\n"; + } else { + print $cgi->a({-href => "$my_uri?p=$project;a=blob_plain;h=$hash"}, "plain") . "
\n"; + } + print "
\n". + "
" . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base", -class => "title"}, escapeHTML($co{'title'})) . "
\n"; } else { @@ -1323,7 +1326,11 @@ sub git_blob { } sub git_blob_plain { - print $cgi->header(-type => "text/plain", -charset => 'utf-8'); + my $save_as = "$hash.txt"; + if (defined $file_name) { + $save_as = $file_name; + } + print $cgi->header(-type => "text/plain", -charset => 'utf-8', '-content-disposition' => "inline; filename=\"$save_as\""); open my $fd, "-|", "$gitbin/git-cat-file blob $hash" or return; undef $/; print <$fd>; @@ -1945,7 +1952,7 @@ sub git_commitdiff_plain { } close $fd; - print $cgi->header(-type => "text/plain", -charset => 'utf-8'); + print $cgi->header(-type => "text/plain", -charset => 'utf-8', '-content-disposition' => "inline; filename=\"git-$hash.patch\""); my %co = git_read_commit($hash); my %ad = date_str($co{'author_epoch'}, $co{'author_tz'}); my $comment = $co{'comment'};