diff --git a/lib/PostText/Controller/Remark.pm b/lib/PostText/Controller/Remark.pm index 4b7f8c2..5061339 100644 --- a/lib/PostText/Controller/Remark.pm +++ b/lib/PostText/Controller/Remark.pm @@ -11,6 +11,13 @@ sub by_id($self) { $self->stash(status => 404, error => 'Remark not found 🤷') unless keys %{$remark}; + # Set filename for right-click & save-as behavior + if ($self->stash('format') eq 'txt') { + $self->res->headers->content_disposition( + "inline; filename=remark_${remark_id}.txt" + ) + } + $self->render; } diff --git a/lib/PostText/Controller/Thread.pm b/lib/PostText/Controller/Thread.pm index c910d95..5011098 100644 --- a/lib/PostText/Controller/Thread.pm +++ b/lib/PostText/Controller/Thread.pm @@ -75,6 +75,13 @@ sub by_id($self) { $self->stash(status => 404, error => 'Page not found 🕵️') unless scalar @{$remarks} || $this_page == $last_page; + # Set filename for right-click & save-as behavior + if ($self->stash('format') eq 'txt') { + $self->res->headers->content_disposition( + "inline; filename=thread_${thread_id}.txt" + ) + } + $self->render; }