From 2f218ec3747ee47ef5556f6f347545733d270782 Mon Sep 17 00:00:00 2001 From: "Jan \"Yenya\" Kasprzak" Date: Thu, 21 Apr 2022 16:30:53 +0200 Subject: [PATCH] Download link --- paste.pl | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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} %> -- 2.43.5