3 # Copyright (C) 2009 Andy Spencer
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # Remove url codings form stdin
17 sed -e 's/%\([0-9A-F][0-9A-F]\)/\\\\\x\1/g; s/[,&]/ /g' | xargs echo -e
20 # Extract an uploaded file from standard input
21 # $1 is the boundary delimiter for the file
27 /^\\r$/ && st==1 {st=2};
29 # Remove trailing ^M's that come with CGI
32 # Print out a generic header
34 echo "Content-Type: text/html; charset=UTF-8"
38 # Print out a generic header
40 echo "Content-Type: text/plain; charset=UTF-8"
44 # Format a file for viewing
48 elif [ -f "db/$1" ]; then
53 echo "File '$1' not found"
57 modeline="$(echo $QUERY_STRING | urldecode)"
59 if [ -z "$modeline" ]; then
63 # I have some plugins in ~/.vim
65 # Run vimhi.sh in screen to trick it into thinking
66 # that it has a real terminal, not that we also have to
67 # set term=xterm-256color in vimrc
70 screen -D -m ./vimhi.sh "$input" "$output" "$modeline"
79 output="$(mktemp db/XXXXX)"
80 uri="$SCRIPT_URI$(basename "$output")"
81 cut_file "$1" > "$output"
89 ls /usr/share/vim/vim{72,files}/syntax/ /home/andy/.vim/after/syntax/ |
90 sed -n 's/.vim$//p' | sort | uniq
92 uploads=$(ls -t db | head -n 5 | sed "s!^!$SCRIPT_URI!")
99 * { margin:0; padding:0; }
101 h4 { margin:1em 0 0 0; }
102 p,ul,dl,dd,pre,blockquote { margin:0 0 0 2em; }
103 dt { font-weight:bold; padding:0.5em 0 0 0; }
104 blockquote { height:2pc; width:30em; font-size:smaller; overflow:hidden; }
105 blockquote:hover { height:auto; width:auto; }
110 <p>vpaste: Vim enabled pastebin</p>
113 <pre><command> | curl -F 'x=<-' $SCRIPT_URI</pre>
116 <p>Add <b>?option[=value] ..</b> to make your text a rainbow.</p>
120 <dt>ft, filetype={filetype}</dt>
121 <dd>A filetype to use for highlighting, see FILETYPES</dd>
122 <dt>bg, background={light|dark}</dt>
123 <dd>Background color to use for the page</dd>
124 <dt>et, expandtab</dt>
125 <dd>Expand tabs to spaces</dd>
126 <dt>ts, tabstop=[N]</dt>
127 <dd>Number of spaces to use for tabs when <b>et</b> is set</dd>
129 <dd>See :help modeline for more information</dd>
133 <blockquote><u>[+]</u> $filetypes</blockquote>
137 <li><a href="vpaste?ft=sh">vpaste</a>
138 <li><a href="index.cgi?ft=sh">index.cgi</a>
139 <li><a href="vimhi.sh?ft=sh">vimhi.sh</a>
140 <li><a href="vimrc?ft=vim">vimrc</a>
141 <li><a href="htaccess?ft=apache">htaccess</a>
142 <li><a href="2html-et.patch?ft=diff">2html-et.patch</a>
145 <h4>LATEST UPLOADS</h4>
146 <ul>$(for uri in ${uploads[@]}; do
147 echo "<li><a href='$uri'>$uri</a>"
155 pathinfo="${SCRIPT_URL/*vpaste\/}"
156 boundary="${CONTENT_TYPE/*boundary\=/}"
158 if [ "$pathinfo" ]; then
160 elif [ "$CONTENT_TYPE" ]; then
161 do_upload "$boundary"