basic secrets functionality. lots more to do.
This commit is contained in:
parent
4ee5a22e90
commit
c700bf798e
3 changed files with 52 additions and 14 deletions
61
brain.py
61
brain.py
|
@ -91,7 +91,7 @@ def render_file(name,public=False):
|
|||
content += '<p>Back to <a href="/repo/'+sanitize_path(os.path.dirname(name))\
|
||||
+'">'+os.path.dirname(name)+'</a></p>'
|
||||
|
||||
return template('templates/yield', content = content, \
|
||||
return template('templates/repo', content = content, \
|
||||
title=filename)
|
||||
|
||||
else:
|
||||
|
@ -172,7 +172,7 @@ def public(name=''):
|
|||
tree.append('<a href="/new/'+sanitize_path(name)+'">New File</a> ')
|
||||
tree.append('<a href="/mkdir/'+sanitize_path(name)+'">New Dir</a></p>')
|
||||
|
||||
return template('templates/yield', content="\n".join(tree), title="Files in "+sanitize_path(name))
|
||||
return template('templates/repo', content="\n".join(tree), title="Files in "+sanitize_path(name))
|
||||
|
||||
else:
|
||||
return render_file(name)
|
||||
|
@ -227,7 +227,7 @@ def upload(path=''):
|
|||
body.append('</form>')
|
||||
|
||||
|
||||
return template('templates/yield', content='\n'.join(body), \
|
||||
return template('templates/repo', content='\n'.join(body), \
|
||||
title='Add')
|
||||
|
||||
|
||||
|
@ -279,7 +279,7 @@ def do_upload():
|
|||
|
||||
content.append('<p><a href="/upload">Upload another.</a></p>')
|
||||
|
||||
return template('templates/yield', content='\n'.join(content), title='"'+filename+'" uploaded.')
|
||||
return template('templates/repo', content='\n'.join(content), title='"'+filename+'" uploaded.')
|
||||
|
||||
|
||||
|
||||
|
@ -314,7 +314,7 @@ def delete(path = ''):
|
|||
body.append('</table>')
|
||||
body.append('</form>')
|
||||
|
||||
return template('templates/yield', content='\n'.join(body), title='Delete')
|
||||
return template('templates/repo', content='\n'.join(body), title='Delete')
|
||||
|
||||
|
||||
@route('/delete', method='POST')
|
||||
|
@ -347,7 +347,7 @@ def delete():
|
|||
body.append('<p>'+path+' does not exist.</p>')
|
||||
|
||||
|
||||
return template('templates/yield', content='\n'.join(body), title=path+' deleted.')
|
||||
return template('templates/repo', content='\n'.join(body), title=path+' deleted.')
|
||||
|
||||
|
||||
|
||||
|
@ -401,7 +401,7 @@ def edit(path=''):
|
|||
body.append('</table>')
|
||||
body.append('</form>')
|
||||
|
||||
return template('templates/yield', content='\n'.join(body), \
|
||||
return template('templates/repo', content='\n'.join(body), \
|
||||
title='New')
|
||||
|
||||
|
||||
|
@ -435,7 +435,7 @@ def edit():
|
|||
else:
|
||||
body.append('<p>' + path + ' not changed.</p>')
|
||||
|
||||
return template('templates/yield', content='\n'.join(body),\
|
||||
return template('templates/repo', content='\n'.join(body),\
|
||||
title=path+' edited.')
|
||||
|
||||
|
||||
|
@ -475,7 +475,7 @@ def new(path = ''):
|
|||
body.append('</form>')
|
||||
|
||||
|
||||
return template('templates/yield', content='\n'.join(body), \
|
||||
return template('templates/repo', content='\n'.join(body), \
|
||||
title='New')
|
||||
|
||||
@route('/new', method="POST")
|
||||
|
@ -512,7 +512,7 @@ def new():
|
|||
if commit:
|
||||
body.append('<p>Git: '+commit+'</p>')
|
||||
|
||||
return template('templates/yield', content='\n'.join(body), \
|
||||
return template('templates/repo', content='\n'.join(body), \
|
||||
title=filename + ' created')
|
||||
|
||||
|
||||
|
@ -549,7 +549,7 @@ def rename(path = ''):
|
|||
body.append('</form>')
|
||||
|
||||
|
||||
return template('templates/yield', content='\n'.join(body),\
|
||||
return template('templates/repo', content='\n'.join(body),\
|
||||
title='move')
|
||||
|
||||
@route('/move', method="POST")
|
||||
|
@ -584,7 +584,7 @@ def rename():
|
|||
else:
|
||||
body.append('<p>Must have both a current and new name.</p>')
|
||||
|
||||
return template('templates/yield', content='\n'.join(body),\
|
||||
return template('templates/repo', content='\n'.join(body),\
|
||||
title=request.forms.current+' moved to '+request.forms.destination)
|
||||
|
||||
|
||||
|
@ -617,7 +617,7 @@ def mkdir(path=''):
|
|||
body.append('</form>')
|
||||
|
||||
|
||||
return template('templates/yield', content='\n'.join(body),\
|
||||
return template('templates/repo', content='\n'.join(body),\
|
||||
title='Create Directory')
|
||||
|
||||
@route('/mkdir', method="POST")
|
||||
|
@ -637,7 +637,7 @@ def mkdir():
|
|||
body.append('<p>Path exists.</p>')
|
||||
|
||||
|
||||
return template('templates/yield', content='\n'.join(body),\
|
||||
return template('templates/repo', content='\n'.join(body),\
|
||||
title='Create Directory')
|
||||
|
||||
|
||||
|
@ -672,6 +672,39 @@ def short(short = ''):
|
|||
|
||||
|
||||
|
||||
# Let's make a place to store my secrets
|
||||
@route('/secrets/<path>')
|
||||
@route('/secrets/')
|
||||
@route('/secrets')
|
||||
def secrets(path = ''):
|
||||
if path and not path == "list":
|
||||
query = 'SELECT username,password FROM `secrets` WHERE base_url LIKE "%' + path + '";'
|
||||
|
||||
cursor.execute(query)
|
||||
secrets = cursor.fetchall()
|
||||
|
||||
body = []
|
||||
|
||||
for s in secrets:
|
||||
body.append(s[0]+' | '+ s[1]+'<br/>')
|
||||
|
||||
return template('templates/secret', content = '\n'.join(body), title = 'Secrets')
|
||||
|
||||
if path == "list":
|
||||
query = 'SELECT base_url,username,password FROM `secrets`;'
|
||||
|
||||
cursor.execute(query)
|
||||
secrets = cursor.fetchall()
|
||||
|
||||
body = []
|
||||
|
||||
for s in secrets:
|
||||
body.append(s[0]+': '+s[1]+' | '+s[2]+'<br/>')
|
||||
|
||||
return template('templates/secret', content = '\n'.join(body), title = 'Secrets')
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# An API will be needed for bookmarklets and whatnot.
|
||||
|
|
5
templates/secret.tpl
Normal file
5
templates/secret.tpl
Normal file
|
@ -0,0 +1,5 @@
|
|||
{{!content}}
|
||||
|
||||
<p>Back to <a href="/repo">Repo</a></p>
|
||||
|
||||
%rebase templates/layout title=title
|
Loading…
Reference in a new issue