From c834b5b515f3abbd417c2d6beb39329b786a67ff Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Sat, 18 Mar 2017 11:03:02 +0100 Subject: Added option to remember syntax choice. As a side effect the default syntax name in settings.py now uses the syntax value instead of the displayed text. --- pastepy.py | 10 +++++++--- templates/paste.tmpl | 10 ++++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/pastepy.py b/pastepy.py index 8d38866..9697fac 100644 --- a/pastepy.py +++ b/pastepy.py @@ -80,9 +80,10 @@ class Paste(object): 'title': settings.pastebin_name, 'header': settings.pastebin_name, 'lexers': self.lexers, - 'default': settings.default, 'nick': c['nick'].value if 'nick' in c else 'Anonymous', - 'remembered': 'nick' in c, + 'syntax': c['syntax'].value if 'syntax' in c else settings.default, + 'remember_me': 'nick' in c, + 'remember_syntax': 'syntax' in c, }))] def preview(self, mp): @@ -125,7 +126,10 @@ class Paste(object): c['nick'] = nick dt = (datetime.datetime.utcnow() + datetime.timedelta(days = 30)) if 'remember_me' in mp else datetime.datetime.utcfromtimestamp(0) c['nick']['expires'] = dt.strftime('%a, %d-%b-%y %H:%M:%S GMT') - headers.append(('Set-Cookie', c['nick'].OutputString())) + c['syntax'] = syntax + dt = (datetime.datetime.utcnow() + datetime.timedelta(days = 30)) if 'remember_syntax' in mp else datetime.datetime.utcfromtimestamp(0) + c['syntax']['expires'] = dt.strftime('%a, %d-%b-%y %H:%M:%S GMT') + headers.append(('Set-Cookie', c.output())) self.start_response('302 Found', headers) return [] diff --git a/templates/paste.tmpl b/templates/paste.tmpl index e0fea2e..f9c9504 100644 --- a/templates/paste.tmpl +++ b/templates/paste.tmpl @@ -10,13 +10,19 @@ #for cat, ls in $lexers #for k, v in $ls - + #end for #end for + + + +
  • + + +
  • -
  • -- cgit v1.2.3