From 0e980b1eafe1bfc7f2d6f159ed05171e9771375a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Oddsson?= Date: Thu, 9 Mar 2017 14:27:09 +0000 Subject: [PATCH] Change variable name from `base_url` to `site_url` So it's more in-line with other global context variables ie. `site_name`. See https://github.com/bartTC/dpaste/pull/89#issuecomment-285331008 --- dpaste/context_processors.py | 2 +- dpaste/templates/dpaste/about.html | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dpaste/context_processors.py b/dpaste/context_processors.py index ee72c7f..98939ef 100644 --- a/dpaste/context_processors.py +++ b/dpaste/context_processors.py @@ -2,7 +2,7 @@ from django.conf import settings def dpaste_globals(request): return { - 'base_url': getattr(settings, 'DPASTE_BASE_URL', 'https://dpaste.de'), + 'site_url': getattr(settings, 'DPASTE_BASE_URL', 'https://dpaste.de'), 'site_name': getattr(settings, 'DPASTE_SITE_NAME', 'dpaste.de'), 'jquery_url': getattr(settings, 'DPASTE_JQUERY_URL', 'https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js'), diff --git a/dpaste/templates/dpaste/about.html b/dpaste/templates/dpaste/about.html index 9834b7e..e527a22 100644 --- a/dpaste/templates/dpaste/about.html +++ b/dpaste/templates/dpaste/about.html @@ -37,14 +37,14 @@ on this page. For a quick start here is a code example (Python 2.x):

{# Just put the script in dpaste and copy the source node #} -
  1. #!/usr/bin/env python
  2.  
  3. from urllib import urlencode
  4. from urllib2 import Request, urlopen
  5. from sys import stdin
  6.  
  7. def paste_code():
  8.     request = Request('{{ base_url }}/api/', urlencode({
  9.         'content': stdin.read(),
  10.         'lexer': 'python',
  11.         'format': 'url',
  12.     }))
  13.     print urlopen(request).read()
  14.  
  15. if __name__ == '__main__':
  16.     paste_code()
+
  1. #!/usr/bin/env python
  2.  
  3. from urllib import urlencode
  4. from urllib2 import Request, urlopen
  5. from sys import stdin
  6.  
  7. def paste_code():
  8.     request = Request('{{ site_url }}/api/', urlencode({
  9.         'content': stdin.read(),
  10.         'lexer': 'python',
  11.         'format': 'url',
  12.     }))
  13.     print urlopen(request).read()
  14.  
  15. if __name__ == '__main__':
  16.     paste_code()

Save this script in /usr/local/bin/dpaste and give it the executable bit: chmod +x /usr/local/bin/dpaste.

Usage: cat foo.txt | dpaste

An alternative would be to just use curl: - alias dpaste="curl -F 'content=<-' {{ base_url }}/api/"

+ alias dpaste="curl -F 'content=<-' {{ site_url }}/api/"

Applications using the API:

@@ -84,7 +84,7 @@

Type the 4 letter code of your snippet in the field and submit. - Like this yellow one here: {{ base_url }}/SiZrT + Like this yellow one here: {{ site_url }}/SiZrT