chiark / gitweb /
mason/pastebin/%show: Don't flush FS buffers in `filter' child.
[odin-cgi] / mason / pastebin / %show
index cfa0f263b1bf952787f5355855e3c5fa7faed762..3a8edb355bcbf2227c231e77ee6be519a53f0463 100644 (file)
@@ -1,3 +1,27 @@
+%# -*-html-*-
+%#
+%# Pastebin display webservice for Odin
+%#
+%# (c) 2015 Mark Wooding
+%#
+%#----- Licensing notice ----------------------------------------------------
+%#
+%# This file is part of the `odin.gg' service, `odin-cgi'.
+%#
+%# `odin-cgi' is free software; you can redistribute it and/or modify
+%# it under the terms of the GNU Affero General Public License as
+%# published by the Free Software Foundation; either version 3 of the
+%# License, or (at your option) any later version.
+%#
+%# `odin-cgi' is distributed in the hope that it will be useful,
+%# but WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+%# GNU Affero General Public License for more details.
+%#
+%# You should have received a copy of the GNU Affero General Public
+%# License along with `odin-cgi'; if not, see
+%# <http://www.gnu.org/licenses/>.
+%#
 <&| SELF:wrapper,
        title => Odin::escapify($m, $title) . " (odin.gg Paste Bin)" &>
 <h1><tt>odin.gg</tt> Paste Bin: <% $title %></h1>
@@ -28,6 +52,9 @@
 % filter "highlight", $m, $content,
 %   "highlight", "-Ohtml", "-f", "-t8", "-S$1";
 </pre>
+% } elsif ($lang eq "md") {
+% filter "markdown", $m, $content,
+%   "markdown", "-fnohtml,autolink,safelink,footnote";
 % } else {
 <div class="note">
 <p>I don't know how to display content with language
@@ -55,6 +82,7 @@
 %#
 <%once>
        use utf8;
+       use POSIX qw(_exit);
 
        sub filter ($$$@) {
          my ($what, $m, $content, @cmd) = @_;
@@ -63,7 +91,7 @@
            open my $hl, "|-", @cmd or die "open $what: $!";
            syswrite $hl, $content // die "$what write: $!";
            close $hl or die "$what kid: $!, $?";
-           exit 0;
+           _exit 0;
          } else {
            while (sysread $fh, my $buf, 8192) { $m->print($buf); }
            close $fh and waitpid $kid, 0