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;
12 return $Odin::COOKIE{"odin-cookie-probe"} ? "" : "?honc=$edit";
15 Odin::bake_cookie $r, "odin-cookie-probe=t";
18 lang => $lang, title => $title,
19 content => Odin::tidy_pastebin_content $content
25 my $db = Odin::open_db;
26 Odin::get_pastebin $db, $tag, my %old;
28 $r->content_type("text/plain; charset=utf8");
29 $m->print($old{content});
31 $edit = $Odin::COOKIE{"odin-handoff.$tag"};
32 $m->comp("%show", tag => $tag,
33 honc => $honc, edit => $edit // $honc, %old);
37 Odin::delete_pastebin $tag, $edit;
38 set_handoff_cookie $tag, "nil", -max_age => 5;
39 $m->redirect("$Odin::PASTEBIN/");
41 set_handoff_cookie $tag, $edit;
42 my $editp = Odin::update_pastebin $tag, $edit, %props;
44 $m->redirect("$Odin::PASTEBIN/$tag" . hasuff $edit);
46 $m->comp("%edit", tag => $tag, edit => $edit, %props);
50 } elsif (defined $content) {
51 ($tag, $edit) = Odin::new_pastebin %props;
52 set_handoff_cookie $tag, $edit;
53 $m->redirect("$Odin::PASTEBIN/$tag" . hasuff $edit);
55 Odin::path_info($r) =~ m:/$:
56 or $m->redirect("$Odin::PASTEBIN/", 301);
71 <&| SELF:error, title => "not found", status => 404 &>\
72 tag ‘<% $tag %>’ not found
80 <&| SELF:error, status => 403 &>\
90 use Digest::SHA qw(sha256_hex);