summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xssn.at>2010-05-25 15:47:58 +0200
committerFlorian Pritz <bluewind@xssn.at>2010-05-25 15:47:58 +0200
commit918c45949f8826474885a07617847833c1f0b2dd (patch)
tree7bbcc3e35aa241a748495fb86a81f3c01070bb80
parent76b5704f46d3e59e41ed5883d23dd0d4aa818f4c (diff)
downloadaur-packages-918c45949f8826474885a07617847833c1f0b2dd.tar.gz
aur-packages-918c45949f8826474885a07617847833c1f0b2dd.tar.xz
add fb-client
Signed-off-by: Florian Pritz <bluewind@xssn.at>
-rw-r--r--fb-client/COPYING13
-rw-r--r--fb-client/PKGBUILD23
-rw-r--r--fb-client/fb-0.5.3110
3 files changed, 146 insertions, 0 deletions
diff --git a/fb-client/COPYING b/fb-client/COPYING
new file mode 100644
index 0000000..351d0fb
--- /dev/null
+++ b/fb-client/COPYING
@@ -0,0 +1,13 @@
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+ Version 2, December 2004
+
+ 14 rue de Plaisance, 75014 Paris, France
+ Everyone is permitted to copy and distribute verbatim or modified
+ copies of this license document, and changing it is allowed as long
+ as the name is changed.
+
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. You just DO WHAT THE FUCK YOU WANT TO.
+
diff --git a/fb-client/PKGBUILD b/fb-client/PKGBUILD
new file mode 100644
index 0000000..73180b9
--- /dev/null
+++ b/fb-client/PKGBUILD
@@ -0,0 +1,23 @@
+# Contributor: Florian "Bluewind" Pritz <flo@xssn.at>
+pkgname=fb-client
+pkgver=0.5.3
+pkgrel=1
+pkgdesc="Client for paste.xinu.at"
+arch=('any')
+url="http://paste.xinu.at"
+license=('custom:WTFPLv2')
+depends=('python' 'curl')
+optdepends=('xclip: for automatically copying the URL into the clipboard')
+source=("http://paste.xinu.at/data/client/fb-${pkgver}" "http://paste.xinu.at/data/client/COPYING")
+
+build() {
+ cd "$srcdir"
+ install -Dm755 fb-${pkgver} "$pkgdir/usr/bin/fb"
+ install -Dm644 COPYING "$pkgdir/usr/share/licenses/${pkgname}/LICENSE"
+}
+
+# vim:set ts=2 sw=2 et:
+md5sums=('8e4b27a72c7c417008a9fc760af7eff4'
+ 'dcd8c4d69ca6c3eba9bee2599456e4ac')
+sha1sums=('62a70848de573ab3b6b768509018f68f5cf2f32b'
+ '497e6c7df473efe197c4f1450348dd0e893c706e')
diff --git a/fb-client/fb-0.5.3 b/fb-client/fb-0.5.3
new file mode 100644
index 0000000..98a5256
--- /dev/null
+++ b/fb-client/fb-0.5.3
@@ -0,0 +1,110 @@
+#!/usr/bin/env python
+#----------------------------------------------------
+# Author: Florian "Bluewind" Pritz <flo@xssn.at>
+#
+# Licensed under WTFPL v2
+# (see COPYING for full license text)
+#
+#----------------------------------------------------
+# only works if useragent contains libcurl
+# Dependencies: python, curl
+# Optional: xclip
+#----------------------------------------------------
+
+'''[cat |] %prog [options] [file1 file2 ...]'''
+__version__ = '0.5.3'
+__desc__ = '''
+Upload/nopaste file/stdin to paste.xinu.at and copy URL to clipboard.
+~/.netrc: machine paste.xinu.at password PASSWORD
+'''
+
+from optparse import OptionParser
+from subprocess import Popen, PIPE
+from urllib2 import urlopen
+import os
+import sys
+import netrc
+import re
+
+def do_upload(file, extension=None):
+ curl_args = []
+ if extension:
+ curl_args.append('-F')
+ curl_args.append('extension=%s' % extension)
+
+ url = Popen(merge([['curl', '-#', '-n', '-L', '-F', 'file=@%s' % file,
+ ], curl_args, ['http://paste.xinu.at/file/do_upload']]),
+ stdout=PIPE).communicate()[0].rstrip()
+ print url
+ Popen('echo -n "%s" | nohup >/dev/null xclip 2>&1' % url, shell=True)
+
+def get(id):
+ print urlopen('http://paste.xinu.at/%s' % id).read()
+
+def merge(seq):
+ merged = []
+ for s in seq:
+ for x in s:
+ merged.append(x)
+ return merged
+
+def read_stdin(tmpfile):
+ if os.isatty(sys.stdin.fileno()):
+ print '^C to exit, ^D to send'
+ try:
+ content = sys.stdin.read()
+ except KeyboardInterrupt:
+ sys.exit()
+ if not content:
+ sys.exit()
+ tmpfile = tmpfile.replace('\n', '')
+ f = open(tmpfile, 'w')
+ f.write(content)
+ f.close()
+ return tmpfile
+
+def main():
+ p = OptionParser(version=__version__,
+ usage=__doc__,
+ description=__desc__)
+ p.add_option('-d', '--delete', action='store_true', dest='delete',
+ help='delete IDs', default=False)
+ p.add_option('-e', '--extension', action='store', dest='extension',
+ help='extension for default highlighting (e.g. "diff")', default=None)
+ p.add_option('-g', '--get', action='store_true', dest='get',
+ help='Download File IDs and output to stdout (use with care!)', default=False)
+ options, args = p.parse_args()
+
+ tmpfiles = []
+ tmpdir = Popen(['mktemp', '-d'], stdout=PIPE).communicate()[0]
+ tmpdir = tmpdir.replace('\n', '')
+ if args:
+ for arg in args:
+ if options.delete:
+ Popen(['curl', '-#', '-n', '-L', 'http://paste.xinu.at/file/delete/%s' % arg]).communicate()[0]
+ continue
+
+ if options.get:
+ get(arg)
+ continue
+
+ if re.match('[a-z]+://.+', arg):
+ os.chdir(tmpdir)
+ tmpfiles.append(tmpdir)
+ Popen(['curl', '-#', '-O', arg]).communicate()[0]
+ for file in os.listdir(tmpdir):
+ do_upload(file, extension=options.extension)
+ else:
+ do_upload(arg, extension=options.extension)
+ else:
+ tmpfile = read_stdin(tmpdir+"/stdin")
+ tmpfiles.append(tmpfile)
+ do_upload(tmpfile, extension=options.extension)
+
+ os.chdir('/tmp')
+ for path in tmpfiles:
+ Popen(['rm', '-rf', path])
+ Popen(['rm', '-rf', tmpdir])
+
+if __name__ == '__main__':
+ main()