diff --git a/brain.py b/brain.py index 2926693..1dc2213 100644 --- a/brain.py +++ b/brain.py @@ -91,7 +91,7 @@ def render_file(name,public=False): content += '

Back to '+os.path.dirname(name)+'

' - return template('templates/yield', content = content, \ + return template('templates/repo', content = content, \ title=filename) else: @@ -172,7 +172,7 @@ def public(name=''): tree.append('New File ') tree.append('New Dir

') - 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('') - 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('

Upload another.

') - 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('') body.append('') - 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('

'+path+' does not exist.

') - 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('') body.append('') - 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('

' + path + ' not changed.

') - 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('') - 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('

Git: '+commit+'

') - 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('') - 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('

Must have both a current and new name.

') - 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('') - 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('

Path exists.

') - 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/') +@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]+'
') + + 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]+'
') + + return template('templates/secret', content = '\n'.join(body), title = 'Secrets') + + + # An API will be needed for bookmarklets and whatnot. diff --git a/templates/yield.tpl b/templates/repo.tpl similarity index 100% rename from templates/yield.tpl rename to templates/repo.tpl diff --git a/templates/secret.tpl b/templates/secret.tpl new file mode 100644 index 0000000..30981aa --- /dev/null +++ b/templates/secret.tpl @@ -0,0 +1,5 @@ +{{!content}} + +

Back to Repo

+ +%rebase templates/layout title=title