summaryrefslogtreecommitdiff
path: root/index.cgi
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2010-10-05 17:20:10 +0200
committerYorhel <git@yorhel.nl>2010-10-05 17:20:10 +0200
commit46800ef12d8d81424e7a767eef02251fc5c5284d (patch)
tree3540bcca86226b6c246ce01135b57a8d9edba8cb /index.cgi
parentb124ecc13dd416a0e3b4fe3a7652c3ee1893dd50 (diff)
Abstracted layout links
and disabled the mypastes feature while we were at it.
Diffstat (limited to 'index.cgi')
-rwxr-xr-xindex.cgi71
1 files changed, 35 insertions, 36 deletions
diff --git a/index.cgi b/index.cgi
index 096307c..4c1d171 100755
--- a/index.cgi
+++ b/index.cgi
@@ -126,23 +126,14 @@ sub view {
$r->{html} =~ s/\n/<br \/>/g;
}
$r->{html} =~ s/(http|https):\/\/([^< ]+[0-9a-zA-Z=\/-])/<a href="$1:\/\/$2" rel="nofollow">$1:\/\/$2<\/a>/g if $r->{parse_urls};
- html(sprintf q|
- <div id="toplinks">
- %s
- <a href="/%s.txt">raw</a>
- <a href="/">new paste</a>
- </div>
- <table>
- <tr><td colspan="2" class="header">
- <h1>Blicky.net nopaste</h1>
- </td></tr>
- <tr><td class="numbers"><pre>%s</pre></td><td class="code"><pre%s>%s</pre></td></tr>
- </table>|,
+ html(
$r->{ip} && $r->{ip} eq $ENV{REMOTE_ADDR} ? qq{<a href="/$code/unpaste">unpaste</a>} : '',
- $code,
- $r->{wrap} ? '' : join("\n", map qq|<a name="r$_" href="#r$_">$_</a>|, 1..$cnt),
- $r->{wrap} ? ' class="allowwrap"' : '',
- $r->{html},
+ qq{<a href="/$code.txt">raw</a>},
+ 'newpaste',
+ sprintf q|<tr><td class="numbers"><pre>%s</pre></td><td class="top code"><pre%s>%s</pre></td></tr>|,
+ $r->{wrap} ? '' : join("\n", map qq|<a name="r$_" href="#r$_">$_</a>|, 1..$cnt),
+ $r->{wrap} ? ' class="allowwrap"' : '',
+ $r->{html},
);
exit;
}
@@ -172,23 +163,22 @@ sub form {
my @syn = map qq|<a href="#" onclick="return setsyn(this)">$_</a>|, @syntax;
use utf8;
html(sprintf <<'__', join(' ', @l), join(' ', @syn));
-<form enctype="multipart/form-data" accept-charset="utf-8" method="post" action="/">
- <table>
- <tr><td colspan="2" class="header"><h1>Blicky.net nopaste</h1></tr>
- <tr><td class="ff">&nbsp;</td><td style="border-top: 1px solid #999">
- <fieldset>
- <legend>▾ Contents</legend>
- <textarea name="f" id="f"></textarea><br />
- <input type="submit" value="Submit" id="submit" />
- -or- <input type="file" name="u" id="u" /> <i>(UTF-8, max. ~1MiB)</i>
- </fieldset>
- <fieldset>
- <legend>▾ Formatting</legend>
- <input type="checkbox" id="w" name="w" value="1" /> <label for="w">allow line wrapping</label><br />
- <input type="checkbox" id="c" name="c" value="1" checked="checked" /> <label for="c">make URLs clickable</label><br />
- <i>Syntax highlighting:</i> <input type="text" name="s" id="s" size="10" value="nosyntax" /> <i>Popular: <b class="syntax">%s</b> | <a href="#" onclick="return showall()">Show all &raquo;</a></i>
- <div id="syntax" style="display: none">%s</div>
- </fieldset>
+ <tr><td class="ff">&nbsp;</td><td class="top">
+ <form enctype="multipart/form-data" accept-charset="utf-8" method="post" action="/">
+ <fieldset>
+ <legend>▾ Contents</legend>
+ <textarea name="f" id="f"></textarea><br />
+ <input type="submit" value="Submit" id="submit" />
+ -or- <input type="file" name="u" id="u" /> <i>(UTF-8, max. ~1MiB)</i>
+ </fieldset>
+ <fieldset>
+ <legend>▾ Formatting</legend>
+ <input type="checkbox" id="w" name="w" value="1" /> <label for="w">allow line wrapping</label><br />
+ <input type="checkbox" id="c" name="c" value="1" checked="checked" /> <label for="c">make URLs clickable</label><br />
+ <i>Syntax highlighting:</i> <input type="text" name="s" id="s" size="10" value="nosyntax" /> <i>Popular: <b class="syntax">%s</b> | <a href="#" onclick="return showall()">Show all &raquo;</a></i>
+ <div id="syntax" style="display: none">%s</div>
+ </fieldset>
+ </form>
</td></tr>
<tr><td class="ff">&nbsp;</td><td><ul>
<li>Pastes don't expire.</li>
@@ -196,14 +186,13 @@ sub form {
<li>Want to paste stuff from the commandline? We have a <a href="/bpaste.pl">script</a> for that.</li>
<li>Code highlighting is provided by vim.</li>
</ul></td></tr>
- </table>
-</form>
__
exit;
}
sub mypastes {
+ plain("Feature disabled");
my $q = $db->prepare("SELECT code, to_char(date, 'YYYY-MM-DD HH24:MI:SS') AS date, syntax, substring(raw from 1 for 50) AS preview FROM pastes WHERE ip = ? ORDER BY date DESC");
$q->execute($ENV{REMOTE_ADDR});
html(sprintf <<' __', $ENV{REMOTE_ADDR},
@@ -227,7 +216,9 @@ sub mypastes {
sub html {
header('text/html');
- printf <<'__', scalar shift;
+ my %links = (newpaste=>'<a href="/">new paste</a>');
+ my $links = !$#_ ? '' : join ' ', map $links{$_} || $_, @_[0..$#_-1];
+ printf <<'__', $links, $_[$#_];
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
@@ -246,7 +237,15 @@ sub html {
</head>
<body>
<div id="leftdiv"></div>
+ <div id="toplinks">
%s
+ </div>
+ <table>
+ <tr><td colspan="2" class="header">
+ <h1>Blicky.net nopaste</h1>
+ </td></tr>
+ %s
+ </table>
</body>
</html>
__