mirror of
https://github.com/DarrenOfficial/dpaste.git
synced 2024-11-23 20:06:35 +11:00
Fixed leading whitespace in API
This commit is contained in:
parent
b1b7aa51a4
commit
7efff4fa19
1 changed files with 3 additions and 9 deletions
|
@ -26,8 +26,6 @@ from .highlight import LEXER_DEFAULT, LEXER_KEYS, LEXER_LIST, LEXER_WORDWRAP, \
|
||||||
PLAIN_CODE, pygmentize
|
PLAIN_CODE, pygmentize
|
||||||
from .models import ONETIME_LIMIT, Snippet
|
from .models import ONETIME_LIMIT, Snippet
|
||||||
|
|
||||||
template_globals = {
|
|
||||||
}
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# Snippet Handling
|
# Snippet Handling
|
||||||
|
@ -49,7 +47,6 @@ class SnippetView(FormView):
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
ctx = super(SnippetView, self).get_context_data(**kwargs)
|
ctx = super(SnippetView, self).get_context_data(**kwargs)
|
||||||
ctx.update(template_globals)
|
|
||||||
ctx.update({
|
ctx.update({
|
||||||
'lexer_list': LEXER_LIST,
|
'lexer_list': LEXER_LIST,
|
||||||
})
|
})
|
||||||
|
@ -100,7 +97,6 @@ class SnippetDetailView(SnippetView, DetailView):
|
||||||
self.object = snippet = self.get_object()
|
self.object = snippet = self.get_object()
|
||||||
|
|
||||||
ctx = super(SnippetDetailView, self).get_context_data(**kwargs)
|
ctx = super(SnippetDetailView, self).get_context_data(**kwargs)
|
||||||
ctx.update(template_globals)
|
|
||||||
ctx.update({
|
ctx.update({
|
||||||
'highlighted': self.highlight_snippet().splitlines(),
|
'highlighted': self.highlight_snippet().splitlines(),
|
||||||
'wordwrap': snippet.lexer in LEXER_WORDWRAP and 'True' or 'False',
|
'wordwrap': snippet.lexer in LEXER_WORDWRAP and 'True' or 'False',
|
||||||
|
@ -160,7 +156,6 @@ class SnippetHistory(TemplateView):
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
ctx = super(SnippetHistory, self).get_context_data(**kwargs)
|
ctx = super(SnippetHistory, self).get_context_data(**kwargs)
|
||||||
ctx.update(template_globals)
|
|
||||||
ctx.update({
|
ctx.update({
|
||||||
'snippets_max': getattr(settings, 'DPASTE_MAX_SNIPPETS_PER_USER', 10),
|
'snippets_max': getattr(settings, 'DPASTE_MAX_SNIPPETS_PER_USER', 10),
|
||||||
'snippet_list': self.snippet_list,
|
'snippet_list': self.snippet_list,
|
||||||
|
@ -223,7 +218,6 @@ class SnippetDiffView(TemplateView):
|
||||||
diff = self.get_diff()
|
diff = self.get_diff()
|
||||||
highlighted = self.highlight_snippet(diff.content)
|
highlighted = self.highlight_snippet(diff.content)
|
||||||
ctx = super(SnippetDiffView, self).get_context_data(**kwargs)
|
ctx = super(SnippetDiffView, self).get_context_data(**kwargs)
|
||||||
ctx.update(template_globals)
|
|
||||||
ctx.update({
|
ctx.update({
|
||||||
'snippet': diff,
|
'snippet': diff,
|
||||||
'highlighted': highlighted.splitlines(),
|
'highlighted': highlighted.splitlines(),
|
||||||
|
@ -246,7 +240,6 @@ class AboutView(TemplateView):
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
ctx = super(AboutView, self).get_context_data(**kwargs)
|
ctx = super(AboutView, self).get_context_data(**kwargs)
|
||||||
ctx.update(template_globals)
|
|
||||||
ctx.update({
|
ctx.update({
|
||||||
'total': Snippet.objects.count(),
|
'total': Snippet.objects.count(),
|
||||||
'stats': Snippet.objects.values('lexer').annotate(
|
'stats': Snippet.objects.values('lexer').annotate(
|
||||||
|
@ -275,6 +268,7 @@ def _format_json(s):
|
||||||
'lexer': s.lexer,
|
'lexer': s.lexer,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
BASE_URL = getattr(settings, 'DPASTE_BASE_URL', 'https://dpaste.de')
|
BASE_URL = getattr(settings, 'DPASTE_BASE_URL', 'https://dpaste.de')
|
||||||
|
|
||||||
FORMAT_MAPPING = {
|
FORMAT_MAPPING = {
|
||||||
|
@ -289,13 +283,13 @@ class APIView(View):
|
||||||
API View
|
API View
|
||||||
"""
|
"""
|
||||||
def post(self, request, *args, **kwargs):
|
def post(self, request, *args, **kwargs):
|
||||||
content = request.POST.get('content', '').strip()
|
content = request.POST.get('content', '')
|
||||||
lexer = request.POST.get('lexer', LEXER_DEFAULT).strip()
|
lexer = request.POST.get('lexer', LEXER_DEFAULT).strip()
|
||||||
filename = request.POST.get('filename', '').strip()
|
filename = request.POST.get('filename', '').strip()
|
||||||
expires = request.POST.get('expires', '').strip()
|
expires = request.POST.get('expires', '').strip()
|
||||||
format = request.POST.get('format', 'default').strip()
|
format = request.POST.get('format', 'default').strip()
|
||||||
|
|
||||||
if not content:
|
if not content.strip():
|
||||||
return HttpResponseBadRequest('No content given')
|
return HttpResponseBadRequest('No content given')
|
||||||
|
|
||||||
# We need at least a lexer or a filename
|
# We need at least a lexer or a filename
|
||||||
|
|
Loading…
Reference in a new issue