begin dashboard using mako templates
This commit is contained in:
parent
39899dda81
commit
2bfbad39ca
@ -51,7 +51,8 @@ url = lambda path, endpoint, methods: Rule(path, endpoint=endpoint, methods=meth
|
||||
|
||||
url_map = Map([
|
||||
# moderation panel
|
||||
url('/', 'admin.index', ['GET', 'POST']),
|
||||
url('/', 'admin.login', ['GET', 'POST']),
|
||||
url('/admin/', 'admin.index', ['GET', 'POST']),
|
||||
|
||||
# comment API, note that the client side quotes the URL, but this is
|
||||
# actually unnecessary. PEP 333 aka WSGI always unquotes PATH_INFO.
|
||||
@ -65,6 +66,7 @@ url_map = Map([
|
||||
class Isso:
|
||||
|
||||
PRODUCTION = True
|
||||
SECRET = 'secret'
|
||||
SECRET_KEY = ',\x1e\xbaY\xbb\xdf\xe7@\x85\xe3\xd9\xb4A9\xe4G\xa6O'
|
||||
MODERATION = False
|
||||
SQLITE = None
|
||||
@ -134,7 +136,7 @@ def main():
|
||||
|
||||
if len(args) > 0 and args[0] == 'import':
|
||||
if len(args) < 2:
|
||||
print 'usage: isso import FILE'
|
||||
print 'Usage: isso import FILE'
|
||||
sys.exit(2)
|
||||
|
||||
with io.open(args[1], encoding='utf-8') as fp:
|
||||
|
@ -3,8 +3,32 @@
|
||||
# Copyright 2012, Martin Zimmermann <info@posativ.org>. All rights reserved.
|
||||
# License: BSD Style, 2 clauses. see isso/__init__.py
|
||||
|
||||
from werkzeug.utils import redirect
|
||||
from werkzeug.wrappers import Response
|
||||
|
||||
from mako.lookup import TemplateLookup
|
||||
from itsdangerous import SignatureExpired, BadSignature
|
||||
|
||||
mako = TemplateLookup(directories=['isso/templates'], input_encoding='utf-8')
|
||||
render = lambda template, **context: mako.get_template(template).render_unicode(**context)
|
||||
|
||||
|
||||
def login(app, environ, request):
|
||||
|
||||
if request.method == 'POST':
|
||||
if request.form.get('secret') == app.SECRET:
|
||||
rdr = redirect('/admin/', 301)
|
||||
rdr.set_cookie('session-admin', app.signer.dumps('*'), max_age=app.MAX_AGE)
|
||||
return rdr
|
||||
|
||||
return Response(render('login.mako'), content_type='text/html')
|
||||
|
||||
|
||||
def index(app, environ, request):
|
||||
return Response('', 200)
|
||||
|
||||
try:
|
||||
app.unsign(request.cookies.get('session-admin', ''))
|
||||
except (SignatureExpired, BadSignature):
|
||||
return redirect('/')
|
||||
|
||||
return Response(render('admin.mako'), content_type='text/html')
|
||||
|
@ -33,7 +33,6 @@ def insert(db, thread, comments):
|
||||
author=item['author'], email=item['email'], parent=parent)
|
||||
|
||||
rv = db.add(path, comment)
|
||||
print rv.id, rv.text[:25], rv.author
|
||||
remap[item['dsq:id']] = rv.id
|
||||
|
||||
|
||||
@ -62,5 +61,3 @@ def disqus(db, xml):
|
||||
id = thread.attrib.get(dsq + 'id')
|
||||
if id in res:
|
||||
insert(db, thread, res[id])
|
||||
# for comment in res[_id]:
|
||||
# print ' ', comment['author'], comment['text'][:25]
|
||||
|
17
isso/templates/admin.mako
Normal file
17
isso/templates/admin.mako
Normal file
@ -0,0 +1,17 @@
|
||||
<%inherit file="base.mako"/>
|
||||
|
||||
<%block name="title">
|
||||
Isso – Dashboard
|
||||
</%block>
|
||||
|
||||
<h1>Dashboard</h1>
|
||||
|
||||
<div>
|
||||
<h2>Pending</h2>
|
||||
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h2>Recent</h2>
|
||||
|
||||
</div>
|
23
isso/templates/base.mako
Normal file
23
isso/templates/base.mako
Normal file
@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<head>
|
||||
<title><%block name="title" /></title>
|
||||
<meta charset="utf-8" />
|
||||
<style>
|
||||
body {
|
||||
|
||||
font-size: 1em;
|
||||
line-height: 1.4;
|
||||
margin: 0 auto;
|
||||
width: 960px;
|
||||
}
|
||||
|
||||
body > h1 {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
<%block name="style" />
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
${self.body()}
|
||||
</body>
|
38
isso/templates/login.mako
Normal file
38
isso/templates/login.mako
Normal file
@ -0,0 +1,38 @@
|
||||
<%inherit file="base.mako"/>
|
||||
|
||||
<%block name="title">
|
||||
Isso – Login
|
||||
</%block>
|
||||
|
||||
<%block name="style">
|
||||
|
||||
#login {
|
||||
margin: 280px 270px 0 270px;
|
||||
padding: 30px;
|
||||
background-color: #DDD;
|
||||
border-radius: 8px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.button {
|
||||
border: 1px solid #006;
|
||||
margin-left: 2px;
|
||||
padding: 2px 4px 2px 4px;
|
||||
}
|
||||
|
||||
#login input {
|
||||
margin-top: 8px;
|
||||
text-align: center;
|
||||
}
|
||||
#login input:-moz-placeholder, #login input::-webkit-input-placeholder {} {
|
||||
color: #CCC;
|
||||
}
|
||||
</%block>
|
||||
|
||||
<!-- login form -->
|
||||
<div id="login">
|
||||
<form action="/" method="post">
|
||||
<input name="secret" placeholder="secret" type="password" />
|
||||
<input type="submit" name="submit" value="Login" class="button" />
|
||||
</form>
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user