bugfix with quotes, added bootstrap themes
This commit is contained in:
parent
a79c9ad007
commit
d30c9d71a6
|
@ -224,7 +224,8 @@ def create_app(subdomain=None):
|
||||||
edit_cname = to_canonical(request.form['name'])
|
edit_cname = to_canonical(request.form['name'])
|
||||||
if edit_cname != cname:
|
if edit_cname != cname:
|
||||||
w.rename_page(cname, edit_cname)
|
w.rename_page(cname, edit_cname)
|
||||||
w.write_page(edit_cname, request.form['content'], message=request.form['message'])
|
w.write_page(edit_cname, request.form['content'], message=request.form['message'],
|
||||||
|
username=CurrentUser.get('username'))
|
||||||
return redirect("/" + edit_cname)
|
return redirect("/" + edit_cname)
|
||||||
else:
|
else:
|
||||||
if data:
|
if data:
|
||||||
|
|
|
@ -31,6 +31,7 @@ def to_dict(cur, first=False):
|
||||||
else:
|
else:
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def cache_it(fn):
|
def cache_it(fn):
|
||||||
def wrap(*args, **kw):
|
def wrap(*args, **kw):
|
||||||
key = "%s:%s" % (args[0].table, args[1])
|
key = "%s:%s" % (args[0].table, args[1])
|
||||||
|
@ -47,6 +48,7 @@ def cache_it(fn):
|
||||||
return data
|
return data
|
||||||
else:
|
else:
|
||||||
data = fn(*args)
|
data = fn(*args)
|
||||||
|
print data
|
||||||
ret = data
|
ret = data
|
||||||
if data is None:
|
if data is None:
|
||||||
data = ''
|
data = ''
|
||||||
|
@ -59,6 +61,7 @@ def cache_it(fn):
|
||||||
return ret
|
return ret
|
||||||
return wrap
|
return wrap
|
||||||
|
|
||||||
|
|
||||||
class BaseModel(RethinkModel):
|
class BaseModel(RethinkModel):
|
||||||
|
|
||||||
_conn = db
|
_conn = db
|
||||||
|
@ -74,7 +77,7 @@ class BaseModel(RethinkModel):
|
||||||
|
|
||||||
@cache_it
|
@cache_it
|
||||||
def get_by_id(self, id):
|
def get_by_id(self, id):
|
||||||
return to_dict(rdb.table(self.table).get(id).run(self._conn))
|
return rdb.table(self.table).get(id).run(self._conn)
|
||||||
|
|
||||||
def get_all(self, arg, index):
|
def get_all(self, arg, index):
|
||||||
return rdb.table(self.table).get_all(arg, index=index).run(self._conn)
|
return rdb.table(self.table).get_all(arg, index=index).run(self._conn)
|
||||||
|
@ -96,6 +99,12 @@ class CurrentUser():
|
||||||
|
|
||||||
def __init__(self, id):
|
def __init__(self, id):
|
||||||
self.id = id
|
self.id = id
|
||||||
|
if id:
|
||||||
|
user = User()
|
||||||
|
session['user'] = user.get_by_id(id)
|
||||||
|
#import sys
|
||||||
|
#sys.exit()
|
||||||
|
#session['user'] = to_dict(user.get_one(id, 'id'), True)
|
||||||
|
|
||||||
def get_id(self):
|
def get_id(self):
|
||||||
return self.id
|
return self.id
|
||||||
|
@ -142,7 +151,7 @@ class User(BaseModel):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if bcrypt.checkpw(password, data['password']):
|
if bcrypt.checkpw(password, data['password']):
|
||||||
cls.login(data['id'], data)
|
cls.login(data['id'])
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
@ -164,12 +173,11 @@ class User(BaseModel):
|
||||||
password=bcrypt.hashpw(password, bcrypt.gensalt(10)),
|
password=bcrypt.hashpw(password, bcrypt.gensalt(10)),
|
||||||
avatar=gravatar_url(email))
|
avatar=gravatar_url(email))
|
||||||
|
|
||||||
User.login(u.id, to_dict(user.get_one(u.id, 'id')))
|
User.login(u.id)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def login(cls, id, data=None):
|
def login(cls, id, data=None):
|
||||||
login_user(CurrentUser(id), True)
|
login_user(CurrentUser(id), True)
|
||||||
session['user'] = data
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def logout(cls):
|
def logout(cls):
|
||||||
|
|
9
realms/static/css/bootstrap/amelia.css
Normal file
9
realms/static/css/bootstrap/amelia.css
Normal file
File diff suppressed because one or more lines are too long
9
realms/static/css/bootstrap/cerulean.css
Normal file
9
realms/static/css/bootstrap/cerulean.css
Normal file
File diff suppressed because one or more lines are too long
9
realms/static/css/bootstrap/cosmo.css
Normal file
9
realms/static/css/bootstrap/cosmo.css
Normal file
File diff suppressed because one or more lines are too long
9
realms/static/css/bootstrap/cyborg.css
Normal file
9
realms/static/css/bootstrap/cyborg.css
Normal file
File diff suppressed because one or more lines are too long
9
realms/static/css/bootstrap/default.css
Normal file
9
realms/static/css/bootstrap/default.css
Normal file
File diff suppressed because one or more lines are too long
9
realms/static/css/bootstrap/flatly.css
Normal file
9
realms/static/css/bootstrap/flatly.css
Normal file
File diff suppressed because one or more lines are too long
9
realms/static/css/bootstrap/journal.css
Normal file
9
realms/static/css/bootstrap/journal.css
Normal file
File diff suppressed because one or more lines are too long
9
realms/static/css/bootstrap/readable.css
Normal file
9
realms/static/css/bootstrap/readable.css
Normal file
File diff suppressed because one or more lines are too long
9
realms/static/css/bootstrap/simplex.css
Normal file
9
realms/static/css/bootstrap/simplex.css
Normal file
File diff suppressed because one or more lines are too long
9
realms/static/css/bootstrap/slate.css
Normal file
9
realms/static/css/bootstrap/slate.css
Normal file
File diff suppressed because one or more lines are too long
9
realms/static/css/bootstrap/spacelab.css
Normal file
9
realms/static/css/bootstrap/spacelab.css
Normal file
File diff suppressed because one or more lines are too long
9
realms/static/css/bootstrap/united.css
Normal file
9
realms/static/css/bootstrap/united.css
Normal file
File diff suppressed because one or more lines are too long
|
@ -11,6 +11,11 @@ body {
|
||||||
padding-bottom: 10px;
|
padding-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.navbar-nav>li>a:hover {
|
||||||
|
padding-top: 10px;
|
||||||
|
padding-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
#main-body {
|
#main-body {
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="wiki" class="control-label">Site Name</label>
|
<label for="wiki" class="control-label">Site Name</label>
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input id="wiki" name="name" type="text" class="form-control" value="{{ request.args.get('site') }}" />
|
<input id="wiki" name="name" type="text" class="form-control" value="{{ request.args.get('site', '') }}" />
|
||||||
<span class="input-group-addon">.realms.io</span>
|
<span class="input-group-addon">.realms.io</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -16,6 +16,4 @@
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
<title>Realms</title>
|
<title>Realms</title>
|
||||||
|
|
||||||
<link href="/static/css/cerulean.bootstrap.min.css" rel="stylesheet">
|
<link href="/static/css/bootstrap/spacelab.css" rel="stylesheet">
|
||||||
<link href="/static/css/font-awesome.min.css" rel="stylesheet">
|
<link href="/static/css/font-awesome.min.css" rel="stylesheet">
|
||||||
<link href="/static/css/style.css" rel="stylesheet">
|
<link href="/static/css/style.css" rel="stylesheet">
|
||||||
|
|
||||||
|
@ -51,6 +51,7 @@
|
||||||
<li><a href="/_new/">Create New Wiki</a></li>
|
<li><a href="/_new/">Create New Wiki</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
{% if session.get('user') %}
|
{% if session.get('user') %}
|
||||||
<li class="dropdown user-avatar">
|
<li class="dropdown user-avatar">
|
||||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
from lxml.html.clean import clean_html
|
from lxml.html.clean import clean_html
|
||||||
import ghdiff
|
import ghdiff
|
||||||
|
|
||||||
|
@ -70,6 +71,9 @@ class Wiki():
|
||||||
# adding the div wrapper apparently fixes anomalies with the lxml parser with certain markdown
|
# adding the div wrapper apparently fixes anomalies with the lxml parser with certain markdown
|
||||||
content = clean_html('<div>' + content + '</div>')
|
content = clean_html('<div>' + content + '</div>')
|
||||||
content = content[5:-6]
|
content = content[5:-6]
|
||||||
|
content = re.sub(r"(\n>)", "\n>", content)
|
||||||
|
content = re.sub(r"(^>)", ">", content)
|
||||||
|
|
||||||
filename = self.cname_to_filename(to_canonical(name))
|
filename = self.cname_to_filename(to_canonical(name))
|
||||||
f = open(self.path + "/" + filename, 'w')
|
f = open(self.path + "/" + filename, 'w')
|
||||||
f.write(content)
|
f.write(content)
|
||||||
|
@ -83,8 +87,9 @@ class Wiki():
|
||||||
|
|
||||||
if not username:
|
if not username:
|
||||||
username = self.default_committer_name
|
username = self.default_committer_name
|
||||||
email = "%s@domain.com" % username
|
|
||||||
|
|
||||||
|
if not email:
|
||||||
|
email = "%s@realms.io" % username
|
||||||
|
|
||||||
return self.repo.commit(name=username,
|
return self.repo.commit(name=username,
|
||||||
email=email,
|
email=email,
|
||||||
|
|
Loading…
Reference in a new issue