# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-# Remove url codings form stdin
+# Remove url codings from stdin
function get_modeline {
modeline=$(
echo "$QUERY_STRING" |
# - I have some plugins in ~/.vim
# - Run ex in screen to trick it into thinking that it
- # has a real terminal, not that we also have to set
+ # 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 \
'+set iconstring= ruf= stl= tal= titlestring=' \
'+set noml' \
'+2d|'$trim \
- '+%s/\r//g' \
+ '+%s/\r//g' \
'+TOhtml' \
"+sav! $output" \
'+qall!' \
# Upload handler
function do_upload {
+ text=$(cut_file "$1")
+ if [ -z "$text" ]; then
+ header text/plain
+ echo "No text pasted"
+ exit
+ fi
output="$(mktemp db/XXXXX)"
uri="$url$(basename "$output")${QUERY_STRING:+"?"}"
- (get_modeline; cut_file "$1") > "$output"
+ (get_modeline; echo "$text") > "$output"
echo "Status: 302 Found"
echo "Location: $uri"
header text/plain
sed -n '/^\(syntax\|manual\|synload\|2html\|colortest\|hitest\).vim$/d; s/.vim$//p' |
sort | uniq
)
-uploads=$(ls -t db | head -n 5 | sed "s!^!$url!")
+uploads=$(ls -t db | head -n 5)
header text/html
cat - <<EOF
blockquote,dd,dl,p,pre,ul { margin:0 0 0 2em; }
dt { font-weight:bold; padding:0.5em 0 0 0; }
blockquote { width:50em; font-size:small; }
+ span { font-family:monospace; }
</style>
</head>
<body>
</ul>
<h4>LATEST UPLOADS</h4>
- <ul>$(for uri in ${uploads[@]}; do
- echo "<li><a href='$uri'>$uri</a></li>"
+ <ul>$(for upload in ${uploads[@]}; do
+ echo -n "<li>"
+ echo -n "<span>$upload</span> "
+ echo -n "<a href='$upload'>text</a> "
+ echo -n "<a href='$upload?'>rainbow</a>"
+ echo "</li>"
done)</ul>
</body>
</html>