2 my $tag = $m->dhandler_arg;
4 sub set_handoff_cookie ($$%) {
5 my ($tag, $edit, %attr) = @_;
6 Odin::bake_cookie $r, "odin-handoff.$tag=$edit",
7 -path => "$Odin::PASTEBIN_PATH/", %attr;
11 lang => $lang, title => $title,
12 content => Odin::tidy_pastebin_content $content
18 my $db = Odin::open_db;
19 Odin::get_pastebin $db, $tag, my %old;
21 $r->content_type("text/plain; charset=utf8");
22 $m->print($old{content});
24 $m->comp("%show", tag => $tag, %old,
25 edit => $Odin::COOKIE{"odin-handoff.$tag"});
29 Odin::delete_pastebin $tag, $edit;
30 set_handoff_cookie $tag, "nil", -max_age => 5;
31 $m->redirect("$Odin::PASTEBIN/");
33 my $editp = Odin::update_pastebin $tag, $edit, %props;
34 set_handoff_cookie $tag, $edit;
35 if ($editp) { $m->redirect("$Odin::PASTEBIN/$tag"); }
36 else { $m->comp("%edit", tag => $tag, edit => $edit, %props); }
39 } elsif (defined $content) {
40 ($tag, $edit) = Odin::new_pastebin %props;
41 set_handoff_cookie $tag, $edit;
42 $m->redirect("$Odin::PASTEBIN/$tag");
44 Odin::path_info($r) =~ m:/$:
45 or $m->redirect("$Odin::PASTEBIN/", 301);
59 <&| SELF:error, title => "not found", status => 404 &>\
60 tag ‘<% $tag %>’ not found
68 <&| SELF:error, status => 404 &>\
78 use Digest::SHA qw(sha256_hex);