updated some formatting, redirect to main page after creating, pre-populate form for easier submissions"
This commit is contained in:
parent
a82f13c317
commit
c92b5cdb68
1 changed files with 20 additions and 20 deletions
40
mysecrets.py
40
mysecrets.py
|
@ -85,7 +85,7 @@ def get_generated_from_url(domain):
|
|||
db.insert('generated', base_url = domain, password = mkpass())
|
||||
gen = db.select('generated', where='base_url LIKE "%'+domain+'%"')
|
||||
|
||||
return gen
|
||||
return gen[0].password
|
||||
|
||||
|
||||
class index:
|
||||
|
@ -115,7 +115,7 @@ class index:
|
|||
|
||||
domain = i.base_url
|
||||
|
||||
body.append('<h1>'+domain+'</h1>\n')
|
||||
body.append('<h1>'+domain+'</h1>')
|
||||
|
||||
selected = get_pair_from_url(i.base_url)
|
||||
generated = get_generated_from_url(i.base_url)
|
||||
|
@ -125,16 +125,25 @@ class index:
|
|||
for pair in selected:
|
||||
body.append('<li class="pair">'+pair.username+' '+pair.password+
|
||||
' <span style="vertical-align:middle;display:inline-block;"><a class="del" \
|
||||
href="/secret/del?id='+str(pair.id)+'">(x)</a></span></li>\n')
|
||||
href="/secret/del?id='+str(pair.id)+'">(x)</a></span></li>')
|
||||
body.append('</ul>')
|
||||
|
||||
body.append('<h2>Suggested:</h2>\n<p>' + generated[0].password + '</p>\n')
|
||||
body.append('<h2>Create:</h2>\n')
|
||||
body.append('<h2>Suggested:</h2>\n<p>' + generated + '</p>')
|
||||
body.append('<h2>Create:</h2>')
|
||||
|
||||
body.append('<form class="form" method="get" action="/secret/create">\n'+ \
|
||||
f.render()+ '\n<input type="submit" name="submit" id="submit"/></form>')
|
||||
|
||||
return render.page('create',''.join(body))
|
||||
body.append('<form class="form" method="get" action="/secret/create"><table>')
|
||||
body.append('<tr><td><label for="base_url">Domain</label></td>')
|
||||
body.append('<td><input id="base_url" type="text" name="base_url" \
|
||||
value="'+domain+'" /></td></tr>')
|
||||
body.append('<tr><td><label for="username">Username</label></td>')
|
||||
body.append('<td><input id="username" type="text" name="username" /></td></tr>')
|
||||
body.append('<tr><td><label for="password">Password</label></td>')
|
||||
body.append('<td><input id="password" type="text" name="password" \
|
||||
value="'+generated+'"/></td></tr>')
|
||||
body.append('<tr><td><input type="submit" name="submit" id="submit" /></td></tr>')
|
||||
body.append('</table></form>')
|
||||
|
||||
return render.page(domain,'\n'.join(body))
|
||||
|
||||
|
||||
if method == 'create':
|
||||
|
@ -147,14 +156,7 @@ class index:
|
|||
n = db.insert('passwords', username=i.username, password=i.password, \
|
||||
base_url=i.base_url)
|
||||
|
||||
selected = get_pair_from_url(i.base_url)
|
||||
|
||||
body = ['<h1>'+i.base_url+'</h1>','']
|
||||
|
||||
for pair in selected:
|
||||
body.append('('+pair.username+', '+pair.password+')')
|
||||
|
||||
return render.page('Created', ''.join(body))
|
||||
raise web.seeother('/secret/new?base_url='+i.base_url)
|
||||
|
||||
if method == 'js-overlay':
|
||||
return '''\
|
||||
|
@ -211,8 +213,6 @@ class index:
|
|||
i.className+='myS';
|
||||
i.style.position='relative';
|
||||
i.style.margin='0em auto';
|
||||
i.style.width='360px';
|
||||
i.style.height='530px';
|
||||
i.style.marginTop='20px';
|
||||
i.style.backgroundColor='rgba(255,255,255,1)';
|
||||
o.appendChild(i);
|
||||
|
@ -221,7 +221,7 @@ class index:
|
|||
f.id='myS-iframe';
|
||||
f.className+='myS';
|
||||
f.width=320;
|
||||
f.height=480;
|
||||
f.height=320;
|
||||
f.style.overflow='auto';
|
||||
f.src='https://amdavidson.net/secret/new?base_url='+document.domain;
|
||||
i.appendChild(f);
|
||||
|
|
Reference in a new issue