summaryrefslogtreecommitdiff
path: root/index.cgi
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2016-05-28 11:42:09 +0200
committerYorhel <git@yorhel.nl>2016-05-28 11:42:09 +0200
commit9df7ea36431064c9a6db04b4a5a1444b9511e1be (patch)
tree02bc6554f2a4501956e8f1e95dfe5a1a1a1acb80 /index.cgi
parentd8822b4f11cf8329f556baa2c39449674342afb6 (diff)
Add "copy" button to pastes
Diffstat (limited to 'index.cgi')
-rwxr-xr-xindex.cgi23
1 files changed, 16 insertions, 7 deletions
diff --git a/index.cgi b/index.cgi
index bea8ef2..ca7bc09 100755
--- a/index.cgi
+++ b/index.cgi
@@ -24,6 +24,7 @@ my $codematch = qr/([a-z0-9]{5}|[a-zA-Z0-9\.-]{32})/;
TUWF::register(
qr// => \&home,
qr/mypastes/ => \&mypastes,
+ qr/copy\/$codematch/ => \&home,
qr/$codematch\.txt/ => \&raw,
qr/$codematch/ => \&paste,
);
@@ -98,12 +99,12 @@ sub upload {
sub home {
- my $self = shift;
+ my($self, $copy) = @_;
# upload form
if($self->reqMethod() ne 'POST') {
$self->htmlHeader('mypastes');
- $self->htmlUploadForm;
+ $self->htmlUploadForm($copy);
$self->htmlFooter;
return;
}
@@ -275,6 +276,8 @@ sub htmlHeader {
a href => '#', onclick => "return unpaste('/$$_')", 'unpaste';
txt ' ';
a href => "/$$_.txt", 'raw';
+ txt ' ';
+ a href => "/copy/$$_", 'copy';
} else {
/newpaste/ && a href => '/', 'new paste';
/mypastes/ && a href => '#', onclick => 'return mypastes()', 'my pastes';
@@ -297,7 +300,13 @@ sub htmlFooter {
sub htmlUploadForm {
- my $self = shift;
+ my($self, $copy) = @_;
+
+ my $r = $copy
+ ? $self->getpaste($copy, 'raw, wrap, parse_urls, syntax')
+ : { raw => '', wrap => 0, parse_urls => 1, syntax => 'nosyntax' };
+ return if !ref $r;
+
use utf8;
Tr;
td class => 'ff', '';
@@ -306,7 +315,7 @@ sub htmlUploadForm {
fieldset;
legend '▾ Contents';
- textarea name => 'f', id => 'f', '';
+ textarea name => 'f', id => 'f', $r->{raw};
br;
input type => 'submit', value => 'Submit', id => 'submit';
txt '-or- ';
@@ -317,17 +326,17 @@ sub htmlUploadForm {
fieldset;
legend '▾ Options';
a href => '#', id => 'formatsave', 'save as default';
- input type => 'checkbox', class => 'check', id => 'w', name => 'w', value => 1;
+ input type => 'checkbox', class => 'check', id => 'w', name => 'w', value => 1, $r->{wrap} ? (checked => 'checked') : ();
label for => 'w', ' allow line wrapping';
br;
- input type => 'checkbox', class => 'check', id => 'c', name => 'c', value => 1, checked => 'checked';
+ input type => 'checkbox', class => 'check', id => 'c', name => 'c', value => 1, $r->{parse_urls} ? (checked => 'checked') : ();
label for => 'c', ' make URLs clickable';
br;
input type => 'checkbox', class => 'check', id => 'l', name => 'l', value => 1;
label for => 'l', ' secure but ugly URL';
br;
i 'Syntax highlighting: ';
- input type => 'text', name => 's', id => 's', size => 10, value => 'nosyntax';
+ input type => 'text', name => 's', id => 's', size => 10, value => $r->{syntax};
i;
txt ' Popular: ';
b class => 'syntax';