[svn] fixed lodgeit script, documented it online
This commit is contained in:
parent
ef8f43d294
commit
1d9af4cdc8
@ -2,7 +2,66 @@
|
||||
{% block help_body %}
|
||||
<h3>Scripts and Editor Integration</h3>
|
||||
<p>
|
||||
Documentation coming soon, check out <a href="/about/">the about page</a>
|
||||
for the moment, links to the scripts and plugins are there.
|
||||
For some popular editors lodgeit integration scripts/plugins exist.
|
||||
Additionally there is also a small script that allows pasting from the
|
||||
command line.
|
||||
</p>
|
||||
<h3>Command Line Script</h3>
|
||||
<p>
|
||||
The usage is pretty simple, to paste a file use the following command
|
||||
</p>
|
||||
<pre class="sample">lodgeit.py /path/to/file</pre>
|
||||
<p>
|
||||
This will use various guessing methods to get the correct language of
|
||||
the file. If all guessing fails it falls back to a normal text paste.
|
||||
You can also provide the language yourself.
|
||||
</p>
|
||||
<pre class="sample">lodgeit.py -l LANGUAGE /path/to/file</pre>
|
||||
<p>
|
||||
For a list of supported languages use the following command:
|
||||
</p>
|
||||
<pre class="sample">lodgeit.py --languages</pre>
|
||||
<p>If no file is given it will read from the standard input stream.</p>
|
||||
<p>
|
||||
<strong>Download:</strong>
|
||||
<a href="http://trac.pocoo.org/repos/lodgeit/scripts/lodgeit.py">lodgeit.py</a>
|
||||
</p>
|
||||
<h3>Vim Support</h3>
|
||||
<p>
|
||||
If Vim is your editor you can paste and download pastes directly from
|
||||
within Vim.
|
||||
</p>
|
||||
<p>
|
||||
All you have to do to paste the current range or whole buffer to lodgeit
|
||||
is executing <tt>:Lodgeit</tt>. If you want you can map this command to
|
||||
a mapping like ctrl+p by adding this to your vimrc:
|
||||
</p>
|
||||
<pre class="sample">map ^P :Lodgeit<CR></pre>
|
||||
<p>(^P is entered using ctrl + v, ctrl + in vim)</p>
|
||||
<p>
|
||||
If you want to reply to a paste from within Vim you can call
|
||||
<tt>:Lodgeit PASTE_URL</tt> or <tt>:Lodgeit #PASTE_ID</tt> and load the
|
||||
paste into a new tab. After modifing it you can push the new version to
|
||||
the server using <tt>:Lodgeit</tt>.
|
||||
</p>
|
||||
<p>
|
||||
<strong>Download:</strong>
|
||||
<a href="http://www.vim.org/scripts/script.php?script_id=1965">lodgeit.vim</a>
|
||||
</p>
|
||||
<h3>Emacs Support</h3>
|
||||
<p>
|
||||
You need a working installation of <a href="http://pymacs.progiciels-bpi.ca/manual/Installation.html#Installation">Pymacs</a>. This is the more difficult part
|
||||
of installation procedure, refer to the <a href="http://pymacs.progiciels-bpi.ca/manual/Installation.html#Installation">Pymacs documentation</a> for help. If
|
||||
Pymacs is working, you just need to put <tt>paste.py</tt> into a directory, where
|
||||
Pymacs can find it (see pymacs-load-path Variable), and add the line
|
||||
(pymacs-load "paste") to your ~.emacs. If you want a Pastebin menu in
|
||||
your menu bar, you also need to add the line (paste-menu).
|
||||
</p>
|
||||
<p>
|
||||
Detailed usage instructions are located <a href="http://lunaryorn.de/projects/paste/">on the project page</a>.
|
||||
</p>
|
||||
<p>
|
||||
<strong>Download:</strong>
|
||||
<a href="http://lunaryorn.de/projects/paste/">paste.py</a>
|
||||
</p>
|
||||
{% endblock %}
|
||||
|
@ -13,9 +13,7 @@
|
||||
Under UNIX create a file called ``~/.lodgerc``, under Windows
|
||||
create a file ``%APPDATA%/_lodgerc`` to override defaults::
|
||||
|
||||
author=Your Name
|
||||
language=default_language
|
||||
private=true/false
|
||||
clipboard=true/false
|
||||
open_browser=true/false
|
||||
encoding=fallback_charset
|
||||
@ -44,9 +42,7 @@ def fail(msg, code):
|
||||
def load_default_settings():
|
||||
"""Load the defaults from the lodgeitrc file."""
|
||||
settings = {
|
||||
'author': None,
|
||||
'language': None,
|
||||
'private': False,
|
||||
'clipboard': True,
|
||||
'open_browser': False,
|
||||
'encoding': 'iso-8859-15'
|
||||
@ -66,7 +62,7 @@ def load_default_settings():
|
||||
if len(p) == 2:
|
||||
key = p[0].strip().lower()
|
||||
if key in settings:
|
||||
if key in ('private', 'clipboard', 'open_browser'):
|
||||
if key in ('clipboard', 'open_browser'):
|
||||
settings[key] = p[1].strip().lower() in \
|
||||
('true', '1', 'on', 'yes')
|
||||
else:
|
||||
@ -108,7 +104,8 @@ def get_xmlrpc_service():
|
||||
_xmlrpc_service
|
||||
except NameError:
|
||||
try:
|
||||
_xmlrpc_service = xmlrpclib.ServerProxy(SERVICE_URL+'xmlrpc/')
|
||||
_xmlrpc_service = xmlrpclib.ServerProxy(SERVICE_URL + 'xmlrpc/',
|
||||
allow_none=True)
|
||||
except:
|
||||
fail('Could not connect to Pastebin', -1)
|
||||
return _xmlrpc_service
|
||||
@ -143,12 +140,6 @@ def open_webbrowser(url):
|
||||
webbrowser.open(url)
|
||||
|
||||
|
||||
def get_unix_username():
|
||||
"""Return the current unix username"""
|
||||
import getpass
|
||||
return getpass.getuser()
|
||||
|
||||
|
||||
def language_exists(language):
|
||||
"""Check if a language alias exists."""
|
||||
xmlrpc = get_xmlrpc_service()
|
||||
@ -187,7 +178,6 @@ def download_paste(uid):
|
||||
|
||||
def create_paste(code, language, filename, mimetype):
|
||||
xmlrpc = get_xmlrpc_service()
|
||||
print language, filename, mimetype
|
||||
rv = xmlrpc.pastes.newPaste(language, code, None, filename, mimetype)
|
||||
if not rv:
|
||||
fail('Could not commit paste. Something went wrong', 4)
|
||||
@ -203,14 +193,8 @@ if __name__ == '__main__':
|
||||
|
||||
parser.add_option('-v', '--version', action='store_true',
|
||||
help='Print script version')
|
||||
#parser.add_option('-t', '--title',
|
||||
# help='Title of the paste (default is FILE if given)')
|
||||
#parser.add_option('-a', '--author', default=settings['author'],
|
||||
# help='Name of the author (default is UNIX username)')
|
||||
parser.add_option('-l', '--language', default=settings['language'],
|
||||
help='Used syntax highlighter for the file')
|
||||
#parser.add_option('-p', '--private', default=settings['private'],
|
||||
# action='store_true', help='Paste as private')
|
||||
parser.add_option('-e', '--encoding', default=settings['encoding'],
|
||||
help='Specify the encoding of a file (default is '
|
||||
'utf-8 or guessing if available)')
|
||||
@ -222,7 +206,6 @@ if __name__ == '__main__':
|
||||
action='store_true',
|
||||
default=settings['open_browser'],
|
||||
help='Open the paste in a web browser')
|
||||
#parser.add_option('--tags', help='List of comma separated tags')
|
||||
parser.add_option('--languages', action='store_true', default=False,
|
||||
help='Retrieve a list of supported languages')
|
||||
parser.add_option('--download', metavar='UID',
|
||||
@ -248,11 +231,6 @@ if __name__ == '__main__':
|
||||
download_paste(opts.download)
|
||||
sys.exit()
|
||||
|
||||
#if opts.tags:
|
||||
# opts.tags = [t.strip() for t in opts.tags.split(',')]
|
||||
#else:
|
||||
# opts.tags = []
|
||||
|
||||
# check language if given
|
||||
if opts.language and not language_exists(opts.language):
|
||||
fail('Language %s is not supported', 3)
|
||||
@ -271,13 +249,6 @@ if __name__ == '__main__':
|
||||
fail('Aborted, paste file was empty', 4)
|
||||
|
||||
# fill with default settings
|
||||
#if not opts.author:
|
||||
# opts.author = get_unix_username()
|
||||
#if not opts.title:
|
||||
# if args:
|
||||
# opts.title = args[0]
|
||||
# else:
|
||||
# opts.title = ''
|
||||
mimetype = ''
|
||||
filename = args and args[0] or ''
|
||||
if not opts.language:
|
||||
|
Loading…
x
Reference in New Issue
Block a user