# Remove url codings from stdin
function get_modeline {
echo "$QUERY_STRING" |
- sed -e 's/%\([0-9A-F][0-9A-F]\)/\\\\\x\1/g; s/[,&?]/ /g' |
+ sed -e 's/%\([0-9A-F][0-9A-F]\)/\\\\\x\1/g' \
+ -e 's/[^a-zA-Z0-9.:=_\-]/ /g' |
xargs echo -e
}
function get_param {
function format {
# Create a temp file with the provided modeline
tmp="$(mktemp)"
- sed "\$avim: $(get_modeline)" "$1" > "$tmp"
+ sed -e "1ivim: $(get_modeline)" \
+ -e "\$avim: $(get_modeline)" "$1" > "$tmp"
# Determine cache name
md5="$(cat index.cgi vimrc "$tmp" /usr/bin/ex | md5sum -b)"
'+sil! set iconstring= ruf= stl= tal=' \
"+sil! set titlestring=$1\ -\ vpaste.net" \
'+sil! set noml' \
- '+sil! $d|'$2 \
+ '+sil! 1d|$d|'$2 \
'+sil! %s/\r//g' \
'+sil! TOhtml' \
"+sav! $out" \
spam=$(echo -n "$body" | cut_file "ignoreme")
text=$(echo -n "$body" | cut_file "(text|x)")
bans=$(echo -n "$REMOTE_ADDR" | grep -f blacklist)
- [ ! -z "$spam" ] && respond "Spam check.."
- [ ! -z "$bans" ] && respond "You have been banned"
+
+ [ ! -z "$spam" ] && respond -h "Status: 403 Forbidden" "Spam check.."
+ [ ! -z "$bans" ] && respond -h "Status: 403 Forbidden" "You have been banned"
[ -z "$text" ] && respond "No text pasted"
# Format and save message
uploads=$(ls -t db 2>/dev/null | head -n 5)
filetype=$(get_param '^(ft|filet(y(pe?)?)?)$')
vpaste='<a href="vpaste?ft=sh">vpaste</a>'
- repo='https://lug.rose-hulman.edu/svn/misc/trunk/htdocs/vpaste/'
+ pileus='http://pileus.org/tools/vpaste'
+ gitweb='http://pileus.org/git/?p=vpaste'
+ mailman='http://pileus.org/mailman/listinfo/dev'
+ repo='git://pileus.org/vpaste'
respond -c text/html
cat <<-EOF
<meta name="description" content="vpaste: Vim based pastebin" />
<meta name="keywords" content="vpaste,paste,pastebin,vim" />
<meta name="google-site-verification" content="OvHF73zD7osJ1VSq9rJxnMFlja36944ud6CiP_iXQnI" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<style type="text/css">
* { margin: 0;
padding: 0; }
- body { margin: 4em 8em 4em 8em;
- font-family: sans-serif; }
+ body { font-family: sans-serif; }
input { padding: 2px 6px 3px 6px; }
+ a { text-decoration: none; }
/* Items */
- textarea { width: 100%;
- margin-bottom: 0.5em; }
- .buttons { float: left; }
- .links { float: right; }
- .links * { text-decoration: none;
- margin-left: 0.5em; }
+ textarea { width: 100%; }
.box { display: none;
- clear: both;
- margin-top: 2.7em;
border-top: solid 1px #888; }
/* box contents */
h1 { margin-top: 1.0em;
ul,dd,dl,p { margin: 0 0 0 2em; }
dt { font-weight: bold;
padding: 0.5em 0 0 0; }
- span { font-family: monospace; }
+ .upload { font-family: monospace; }
.cmds dd { font-family: monospace; }
</style>
+ <style type="text/css" media="screen and (min-device-width:800px)">
+ body { margin: 4em 8em; }
+ textarea { margin-bottom: 0.5em; }
+ .buttons { float: left; }
+ .links { float: right; }
+ .links * { margin-left: 0.5em; }
+ .box { clear: both;
+ margin-top: 2.7em; }
+ </style>
+ <style type="text/css" media="screen and (max-device-width:800px)">
+ textarea, input, select, .links
+ { display: block;
+ width: 100%;
+ margin-bottom: 0.75em; }
+ body { margin: 1em; }
+ textarea { height: 17em; }
+ select { height: 2em; }
+ input { height: 3em; }
+ .links { text-align: center; }
+ .links a { margin: 0em 0.25em; }
+ #vpaste { font-size: large; }
+ .sep { display: block;
+ height: 0.5em;
+ visibility:hidden; }
+ </style>
<script type="text/javascript">
//<![CDATA[
function show(id) {
<input type="submit" value="Paste" />
</div>
<div class="links">
- <a href="">vpaste</a> <span>-</span>
+ <a href="" id="vpaste">vpaste</a> <span class="sep">-</span>
<a href="#usage" onclick="show('usage' )">Usage</a>
<a href="#devel" onclick="show('devel' )">Development</a>
<a href="#uploads" onclick="show('uploads')">Uploads</a>
<a href="blacklist?raw">blacklist</a></dd>
<dt>Patches</dt>
<dd><a href="2html.patch?ft=diff">2html.patch</a></dd>
- <dt>Subversion</dt>
- <dd><a href="$repo">$repo</a></dd>
+ <dt>Development</dt>
+ <dd><a href="$pileus">homepage</a>
+ <a href="$gitweb">gitweb</a><br />
+ <code>git clone $repo</code></dd>
</dl>
<h1>Bugs</h1>
<ul>
<li>Using strange filetypes (ft=2html) may result in strange output.</li>
- <li><a href="mailto:andy753421@gmail.com?subject=vpaste bug">Other?</a></li>
+ <li>Other issues can be sent to the pileus.org
+ <a href="$mailman">mailing list</a>.</li>
</ul>
</div>
<h1>Recent Uploads</h1>
<ul>$(for upload in ${uploads[@]}; do
echo -n "<li>"
- echo -n "<span>$upload</span> "
+ echo -n "<span class=\"upload\">$upload</span> "
echo -n "<a href='$upload?raw'>text</a> "
echo -n "<a href='$upload'>rainbow</a>"
echo "</li>"