@matheusbsbs / matheus-bagliano / commits / 9312944d35
Fork 0

provide filename for "save as" in plaintext views

Signed-off-by: Kay Sievers <kay.sievers@suse.de>

Kay Sievers committed Oct 17, 2005 at 03:27 UTC 9312944d35b571c4a7fdde266131b1a6f8d03241
1 file changed +13 -6
gitweb.cgi
+13 -6
@@ -1281,7 +1281,6 @@ sub git_blob {
1281 $hash = git_get_hash_by_path($base, $file_name, "blob");
1282 }
1283 open my $fd, "-|", "$gitbin/git-cat-file blob $hash" or die_error(undef, "Open failed.");
1284 - my $base = $file_name || "";
1284 git_header_html();
1285 if (defined $hash_base && (my %co = git_read_commit($hash_base))) {
1286 print "<div class=\"page_nav\">\n" .
@@ -1291,9 +1290,13 @@ sub git_blob {
1290 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base"}, "commit") .
1291 " | " . $cgi->a({-href => "$my_uri?p=$project;a=commitdiff;h=$hash_base"}, "commitdiff") .
1292 " | " . $cgi->a({-href => "$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash_base"}, "tree") . "<br/>\n";
1294 - print $cgi->a({-href => "$my_uri?p=$project;a=blob_plain;h=$hash"}, "plain") . "<br/>\n" .
1295 - "</div>\n";
1296 - print "<div>" .
1293 + if (defined $file_name) {
1294 + print $cgi->a({-href => "$my_uri?p=$project;a=blob_plain;h=$hash;f=$file_name"}, "plain") . "<br/>\n";
1295 + } else {
1296 + print $cgi->a({-href => "$my_uri?p=$project;a=blob_plain;h=$hash"}, "plain") . "<br/>\n";
1297 + }
1298 + print "</div>\n".
1299 + "<div>" .
1300 $cgi->a({-href => "$my_uri?p=$project;a=commit;h=$hash_base", -class => "title"}, escapeHTML($co{'title'})) .
1301 "</div>\n";
1302 } else {
@@ -1323,7 +1326,11 @@ sub git_blob {
1326 }
1327
1328 sub git_blob_plain {
1326 - print $cgi->header(-type => "text/plain", -charset => 'utf-8');
1329 + my $save_as = "$hash.txt";
1330 + if (defined $file_name) {
1331 + $save_as = $file_name;
1332 + }
1333 + print $cgi->header(-type => "text/plain", -charset => 'utf-8', '-content-disposition' => "inline; filename=\"$save_as\"");
1334 open my $fd, "-|", "$gitbin/git-cat-file blob $hash" or return;
1335 undef $/;
1336 print <$fd>;
@@ -1945,7 +1952,7 @@ sub git_commitdiff_plain {
1952 }
1953 close $fd;
1954
1948 - print $cgi->header(-type => "text/plain", -charset => 'utf-8');
1955 + print $cgi->header(-type => "text/plain", -charset => 'utf-8', '-content-disposition' => "inline; filename=\"git-$hash.patch\"");
1956 my %co = git_read_commit($hash);
1957 my %ad = date_str($co{'author_epoch'}, $co{'author_tz'});
1958 my $comment = $co{'comment'};