summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2017-03-18 11:03:02 +0100
committerJon Bergli Heier <snakebite@jvnv.net>2017-03-18 11:04:21 +0100
commitc834b5b515f3abbd417c2d6beb39329b786a67ff (patch)
tree3931b118018ad67c2be28fec5c64fdaec6be9717
parentaffcd2b148e974c02a5f60e14cccd16257a53c0d (diff)
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.
-rw-r--r--pastepy.py10
-rw-r--r--templates/paste.tmpl10
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
<optgroup label="$cat">
#for k, v in $ls
- <option value="$v"#if $k == $default# selected="selected"#end if#>$k</option>
+ <option value="$v"#if $v == $syntax# selected="selected"#end if#>$k</option>
#end for
</optgroup>
#end for
</select>
+ <input type="checkbox" name="remember_syntax" id="remember_syntax" #if $remember_syntax#checked #end if#>
+ <label for="remember_syntax">Remember syntax</label>
+ </li>
+ <li>
+ <input type="text" name="nick" id="nick" value="$nick">
+ <input type="checkbox" name="remember_me" id="remember_me" #if $remember_me#checked #end if#>
+ <label for="remember_me">Remember me</label>
</li>
- <li><input type="text" name="nick" id="nick" value="$nick"> <label for="remember_me"><input type="checkbox" name="remember_me" id="remember_me" #if $remembered#checked="true" #end if#/> Remember me</label></li>
<li><input type="text" name="title" id="title" value="Untitled"></li>
<li><textarea rows="15" cols="80" name="text" id="text"></textarea></li>
<li>