chiark / gitweb /
bin/populate-lang-table, mason/pastebin/%show: Segregate `highlight' languages.
[odin-cgi] / mason / pastebin / %show
index 972ef87d1b21e7f1fa4f94b90b4d568c6512bc4d..9e6afabf37ed72f5207eca7ffe127f0efbbee4b5 100644 (file)
@@ -2,19 +2,34 @@
        title => Odin::escapify($m, $title) . " (odin.gg Paste Bin)" &>
 <h1><tt>odin.gg</tt> Paste Bin: <% $title %></h1>
 <div class="menu">
-  <span class="item"><a href="<% "$Odin::PASTEBIN/$tag?op=raw" %>">Raw</a></span>
+  <span class="item"><a href="<% "$Odin::PASTEBIN/$tag?op=raw" |h %>">Raw</a></span>
 % if (defined $edit) {
-  <span class="item"><a href="<% "$Odin::PASTEBIN/$tag?edit=$edit" %>">Edit</a></span>
+  <span class="item"><a href="<% "$Odin::PASTEBIN/$tag?edit=$edit" |h %>">Edit</a></span>
 % }
+  <span class="item"><a href="<% "$Odin::PASTEBIN/" |h %>">New</a></span>
 </div>
-<pre class="paste">
+% if (defined $honc) {
+<div class="note">
+<p>Your browser doesn't appear to be accepting my cookies.
+<p>Don't share the link to this page with other people.  <b>If you do,
+  they'll be able to edit this paste just as you can</b>, using the
+  <b>Edit</b> link at the top of the page.
+<p>Instead, share this link:
+  <a href="<% "$Odin::PASTEBIN/$tag" |h %>"><%
+    "$Odin::PASTEBIN/$tag" |h %></a>
+</div>
+% }
 % if ($lang eq 'txt') {
+<pre class="paste">
 <% $content |h %>\
-% } else {
+</pre>
+% } elsif ($lang =~ /^hl:(.*)$/) {
+<pre class="paste">
 <%perl>
+       my $hl_lang = $1;
        my $kid = open my $fh, "-|" // die "fork: $!";
        if ($kid == 0) {
-         open my $hl, "|-", "highlight", "-Ohtml", "-f", "-t8", "-S$lang"
+         open my $hl, "|-", "highlight", "-Ohtml", "-f", "-t8", "-S$hl_lang"
            or die "open highlight: $!";
          syswrite $hl, $content // die "highlight write: $!";
          close $hl or die "highlight kid: $!, $?";
            or die "highlight parent: $!, $?";
        }
 </%perl>
-% }
 </pre>
+% } else {
+<div class="note">
+<p>I don't know how to display content with language
+  &lsquo;<% $lang |h %>&rsquo;.  This is a bug in the Pastebin program.
+  Here's the raw text, in case that's useful.
+</div>
+<pre class="paste">
+<% $content |h %>\
+</pre>
+% }
 </&>
 %#
 <%args>
@@ -34,7 +58,8 @@
        $title
        $lang
        $tag
-       $edit => undef
+       $honc
+       $edit
 </%args>
 %#
 <%init>