chiark / gitweb /
mason/pastebin/: Add `New' links to the `show' and `edit' pages.
[odin-cgi] / mason / pastebin / %show
1 <&| SELF:wrapper,
2         title => Odin::escapify($m, $title) . " (odin.gg Paste Bin)" &>
3 <h1><tt>odin.gg</tt> Paste Bin: <% $title %></h1>
4 <div class="menu">
5   <span class="item"><a href="<% "$Odin::PASTEBIN/$tag?op=raw" |h %>">Raw</a></span>
6 % if (defined $edit) {
7   <span class="item"><a href="<% "$Odin::PASTEBIN/$tag?edit=$edit" |h %>">Edit</a></span>
8 % }
9   <span class="item"><a href="<% "$Odin::PASTEBIN/" |h %>">New</a></span>
10 </div>
11 % if (defined $honc) {
12 <div class="note">
13 <p>Your browser doesn't appear to be accepting my cookies.
14 <p>Don't share the link to this page with other people.  <b>If you do,
15   they'll be able to edit this paste just as you can</b>, using the
16   <b>Edit</b> link at the top of the page.
17 <p>Instead, share this link:
18   <a href="<% "$Odin::PASTEBIN/$tag" |h %>"><%
19     "$Odin::PASTEBIN/$tag" |h %></a>
20 </div>
21 % }
22 <pre class="paste">
23 % if ($lang eq 'txt') {
24 <% $content |h %>\
25 % } else {
26 <%perl>
27         my $kid = open my $fh, "-|" // die "fork: $!";
28         if ($kid == 0) {
29           open my $hl, "|-", "highlight", "-Ohtml", "-f", "-t8", "-S$lang"
30             or die "open highlight: $!";
31           syswrite $hl, $content // die "highlight write: $!";
32           close $hl or die "highlight kid: $!, $?";
33           exit 0;
34         } else {
35           while (sysread $fh, my $buf, 8192) { $m->print($buf); }
36           close $fh and waitpid $kid, 0
37             or die "highlight parent: $!, $?";
38         }
39 </%perl>
40 % }
41 </pre>
42 </&>
43 %#
44 <%args>
45         $content
46         $title
47         $lang
48         $tag
49         $honc
50         $edit
51 </%args>
52 %#
53 <%init>
54         my $db = Odin::open_db;
55 </%init>
56 %#
57 <%once>
58         use utf8;
59 </%once>