# Print plain message and exit
function message {
while [ "$1" == '-h' ]; do
- shift; echo $1; shift
+ shift; echo "$1"; shift
done
header text/plain
echo "$*"
"File '$1' not found"
fi
- if [[ "$HTTP_ACCEPT" == *'html'* &&
- "$QUERY_STRING" != 'raw'* ]]; then
- # Create a temp file with the provided modeline
- output="$(mktemp)"
- tmp="$(mktemp)"
- sed "\$avim: $(get_modeline)" "$input" > "$tmp"
-
- # - I have some plugins in ~/.vim
- # - Run ex in screen to trick it into thinking that it
- # has a real terminal, note that we also have to set
- # term=xterm-256color in vimrc
- HOME=/home/andy \
- screen -D -m ex -nXZ -i NONE -u vimrc \
- '+sil! set fde= fdt= fex= inde= inex= key= pa= pexpr=' \
- '+sil! set iconstring= ruf= stl= tal=' \
- "+sil! set titlestring=$1\ -\ vpaste.net" \
- '+sil! set noml' \
- '+sil! $d|'$trim \
- '+sil! %s/\r//g' \
- '+sil! TOhtml' \
- "+sav! $output" \
- '+qall!' \
- "$tmp"
-
- header text/html
- cat "$output"
- rm "$tmp" "$output"
- else
+ # Check for raw paste
+ if [[ "$QUERY_STRING" == 'raw'* ||
+ "$REQUEST_URI" != *'?'* &&
+ "$HTTP_ACCEPT" != *'html'* ]]; then
header text/plain
sed "$trim" "$input"
+ exit
fi
+
+ # Create a temp file with the provided modeline
+ output="$(mktemp)"
+ tmp="$(mktemp)"
+ sed "\$avim: $(get_modeline)" "$input" > "$tmp"
+
+ # - I have some plugins in ~/.vim
+ # - Run ex in screen to trick it into thinking that it
+ # has a real terminal, note that we also have to set
+ # term=xterm-256color in vimrc
+ HOME=/home/andy \
+ screen -D -m ex -nXZ -i NONE -u vimrc \
+ '+sil! set fde= fdt= fex= inde= inex= key= pa= pexpr=' \
+ '+sil! set iconstring= ruf= stl= tal=' \
+ "+sil! set titlestring=$1\ -\ vpaste.net" \
+ '+sil! set noml' \
+ '+sil! $d|'$trim \
+ '+sil! %s/\r//g' \
+ '+sil! TOhtml' \
+ "+sav! $output" \
+ '+qall!' \
+ "$tmp"
+
+ header text/html
+ cat "$output"
+ rm "$tmp" "$output"
}
EOF
# Redirect user
- uri="$SCRIPT_URI$(basename "$output")"
+ uri="$url$(basename "$output")"
message -h 'Status: 302 Found' \
-h "Location: $uri" \
"$uri"
</style>
</head>
<body>
- <form id="form" method="post" action="?" enctype="multipart/form-data">
+ <form id="form" method="post" enctype="multipart/form-data">
<div style="margin:0 0 1.5em 0;">
<input style="display:none" type="text" name="ignoreme" value="">
<textarea name="text" cols="80" rows="25" style="width:100%; height:20em;"></textarea>
<pre> vpaste file [option=value,..]</pre>
<pre> <command> | vpaste [option=value,..]</pre>
<br />
- <pre> <command> | curl -F 'text=<-' $SCRIPT_URI[?option=value,..]</pre>
+ <pre> <command> | curl -F 'text=<-' $url[?option=value,..]</pre>
<br />
<pre> :map vp :exec "w !vpaste ft=".&ft<CR></pre>
<pre> :vmap vp <ESC>:exec "'<,'>w !vpaste ft=".&ft<CR></pre>
}
# Main
+PATH=/bin:/usr/bin
+url="http://$HTTP_HOST${REQUEST_URI/\?*}"
pathinfo="${REQUEST_URI/*\/}"
pathinfo="${pathinfo/\?*}"