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