From: Jan "Yenya" Kasprzak Date: Thu, 21 Apr 2022 14:30:53 +0000 (+0200) Subject: Download link X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?p=paste.git;a=commitdiff_plain;h=HEAD Download link --- diff --git a/paste.pl b/paste.pl index 285c349..3eb1388 100755 --- a/paste.pl +++ b/paste.pl @@ -56,6 +56,13 @@ get '/.' return $c->reply->not_found if !defined $stat; + if (defined $c->param('download')) { + $c->res->headers->content_disposition( + "attachment; filename=$fullname" + ); + $c->reply->file($file); + return; + } $c->stash(mtime => POSIX::strftime('%Y-%m-%d %H:%M:%S', localtime($stat->mtime))); my $content = $file->slurp; @@ -100,7 +107,9 @@ __DATA__

<%= $filename%>.<%= $ext %> — <%= config->{appname} %>
-Created: <%= $mtime %>

+Created: <%= $mtime %> +<%= link_to "Download" => url_for->query(download => 1), class => 'downl' %> +
<%= $file_content %>
@@ -179,6 +188,10 @@ __DATA__ a { color: #90c0ff; } + a.downl { + display: inline-block; + float: right; + } <%= config->{appname} %>