parent
992cfb96d2
commit
672856e9af
|
@ -14,6 +14,8 @@
|
||||||
"js-yaml": "~3.2.1",
|
"js-yaml": "~3.2.1",
|
||||||
"store-js": "~1.3.16",
|
"store-js": "~1.3.16",
|
||||||
"bootswatch-dist": "3.2.0-flatly",
|
"bootswatch-dist": "3.2.0-flatly",
|
||||||
"bootbox": "4.3.0"
|
"bootbox": "4.3.0",
|
||||||
|
"datatables": "1.10.3",
|
||||||
|
"datatables-plugins": "latest"
|
||||||
}
|
}
|
||||||
}
|
}
|
15
manage.py
15
manage.py
|
@ -81,11 +81,15 @@ def setup_redis(**kw):
|
||||||
install_redis()
|
install_redis()
|
||||||
|
|
||||||
|
|
||||||
|
def get_prefix():
|
||||||
|
import sys
|
||||||
|
return sys.prefix
|
||||||
|
|
||||||
|
|
||||||
def get_pip():
|
def get_pip():
|
||||||
""" Get virtualenv path for pip
|
""" Get virtualenv path for pip
|
||||||
"""
|
"""
|
||||||
import sys
|
return get_prefix() + '/bin/pip'
|
||||||
return sys.prefix + '/bin/pip'
|
|
||||||
|
|
||||||
|
|
||||||
@cli.command()
|
@cli.command()
|
||||||
|
@ -173,6 +177,13 @@ def drop_db():
|
||||||
db.drop_all()
|
db.drop_all()
|
||||||
|
|
||||||
|
|
||||||
|
@cli.command()
|
||||||
|
def test():
|
||||||
|
""" Run tests
|
||||||
|
"""
|
||||||
|
call([get_prefix() + "/bin/nosetests", config.APP_PATH])
|
||||||
|
|
||||||
|
|
||||||
@cli.command()
|
@cli.command()
|
||||||
def version():
|
def version():
|
||||||
""" Output version
|
""" Output version
|
||||||
|
|
|
@ -206,6 +206,8 @@ assets.register('main.js',
|
||||||
'js/html-sanitizer-minified.js', # don't minify?
|
'js/html-sanitizer-minified.js', # don't minify?
|
||||||
'vendor/highlightjs/highlight.pack.js',
|
'vendor/highlightjs/highlight.pack.js',
|
||||||
'vendor/parsleyjs/dist/parsley.js',
|
'vendor/parsleyjs/dist/parsley.js',
|
||||||
|
'vendor/datatables/media/js/jquery.dataTables.js',
|
||||||
|
'vendor/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.js',
|
||||||
'js/hbs-helpers.js',
|
'js/hbs-helpers.js',
|
||||||
'js/mdr.js')
|
'js/mdr.js')
|
||||||
|
|
||||||
|
@ -213,6 +215,7 @@ assets.register('main.css',
|
||||||
'vendor/bootswatch-dist/css/bootstrap.css',
|
'vendor/bootswatch-dist/css/bootstrap.css',
|
||||||
'vendor/components-font-awesome/css/font-awesome.css',
|
'vendor/components-font-awesome/css/font-awesome.css',
|
||||||
'vendor/highlightjs/styles/github.css',
|
'vendor/highlightjs/styles/github.css',
|
||||||
|
'vendor/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.css',
|
||||||
'css/style.css')
|
'css/style.css')
|
||||||
|
|
||||||
app.discover()
|
app.discover()
|
||||||
|
|
|
@ -13,6 +13,16 @@ from realms import cache
|
||||||
from realms.lib.hook import HookMixin
|
from realms.lib.hook import HookMixin
|
||||||
|
|
||||||
|
|
||||||
|
def cname_to_filename(cname):
|
||||||
|
return cname.lower() + ".md"
|
||||||
|
|
||||||
|
|
||||||
|
def filename_to_cname(filename):
|
||||||
|
""" It's assumed filename is already cname format
|
||||||
|
"""
|
||||||
|
return os.path.splitext(filename)[0]
|
||||||
|
|
||||||
|
|
||||||
class Wiki(HookMixin):
|
class Wiki(HookMixin):
|
||||||
path = None
|
path = None
|
||||||
base_path = '/'
|
base_path = '/'
|
||||||
|
@ -87,7 +97,7 @@ class Wiki(HookMixin):
|
||||||
|
|
||||||
content = re.sub(r"```(.*?)```", unescape_repl, content, flags=re.DOTALL)
|
content = re.sub(r"```(.*?)```", unescape_repl, content, flags=re.DOTALL)
|
||||||
|
|
||||||
filename = self.cname_to_filename(cname)
|
filename = cname_to_filename(cname)
|
||||||
with open(self.path + "/" + filename, 'w') as f:
|
with open(self.path + "/" + filename, 'w') as f:
|
||||||
f.write(content)
|
f.write(content)
|
||||||
|
|
||||||
|
@ -113,7 +123,7 @@ class Wiki(HookMixin):
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def rename_page(self, old_name, new_name, user=None):
|
def rename_page(self, old_name, new_name, user=None):
|
||||||
old_filename, new_filename = map(self.cname_to_filename, [old_name, new_name])
|
old_filename, new_filename = map(cname_to_filename, [old_name, new_name])
|
||||||
if old_filename not in self.gittle.index:
|
if old_filename not in self.gittle.index:
|
||||||
# old doesn't exist
|
# old doesn't exist
|
||||||
return None
|
return None
|
||||||
|
@ -140,7 +150,7 @@ class Wiki(HookMixin):
|
||||||
return cached
|
return cached
|
||||||
|
|
||||||
# commit = gittle.utils.git.commit_info(self.repo[sha])
|
# commit = gittle.utils.git.commit_info(self.repo[sha])
|
||||||
filename = self.cname_to_filename(name).encode('latin-1')
|
filename = cname_to_filename(name).encode('latin-1')
|
||||||
sha = sha.encode('latin-1')
|
sha = sha.encode('latin-1')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -177,8 +187,21 @@ class Wiki(HookMixin):
|
||||||
new = self.get_page(name, sha=new_sha)
|
new = self.get_page(name, sha=new_sha)
|
||||||
return ghdiff.diff(old['data'], new['data'])
|
return ghdiff.diff(old['data'], new['data'])
|
||||||
|
|
||||||
|
def get_index(self):
|
||||||
|
rv = []
|
||||||
|
index = self.repo.open_index()
|
||||||
|
for name in index:
|
||||||
|
rv.append(dict(name=filename_to_cname(name),
|
||||||
|
filename=name,
|
||||||
|
ctime=index[name].ctime[0],
|
||||||
|
mtime=index[name].mtime[0],
|
||||||
|
sha=index[name].sha,
|
||||||
|
size=index[name].size))
|
||||||
|
|
||||||
|
return rv
|
||||||
|
|
||||||
def get_history(self, name, limit=100):
|
def get_history(self, name, limit=100):
|
||||||
file_path = self.cname_to_filename(name)
|
file_path = cname_to_filename(name)
|
||||||
versions = []
|
versions = []
|
||||||
walker = self.repo.get_walker(paths=[file_path], max_entries=limit)
|
walker = self.repo.get_walker(paths=[file_path], max_entries=limit)
|
||||||
for entry in walker:
|
for entry in walker:
|
||||||
|
@ -198,6 +221,3 @@ class Wiki(HookMixin):
|
||||||
|
|
||||||
return versions
|
return versions
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def cname_to_filename(cname):
|
|
||||||
return cname.lower() + ".md"
|
|
|
@ -121,6 +121,11 @@ def create(name):
|
||||||
info={})
|
info={})
|
||||||
|
|
||||||
|
|
||||||
|
@blueprint.route("/_index")
|
||||||
|
def index():
|
||||||
|
return render_template('wiki/index.html', index=g.current_wiki.get_index())
|
||||||
|
|
||||||
|
|
||||||
@blueprint.route("/", defaults={'name': 'home'})
|
@blueprint.route("/", defaults={'name': 'home'})
|
||||||
@blueprint.route("/<name>")
|
@blueprint.route("/<name>")
|
||||||
def page(name):
|
def page(name):
|
||||||
|
|
|
@ -40,6 +40,9 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="navbar-collapse collapse navbar-inverse-collapse">
|
<div class="navbar-collapse collapse navbar-inverse-collapse">
|
||||||
<ul class="nav navbar-nav">
|
<ul class="nav navbar-nav">
|
||||||
|
{% if config.get('ROOT_ENDPOINT') != 'wiki.index' %}
|
||||||
|
<li><a href="{{ url_for('wiki.index') }}"><i class="fa fa-list"></i> Index</a></li>
|
||||||
|
{% endif %}
|
||||||
<li><a href="{{ url_for('wiki.create') }}"><i class="fa fa-plus"></i> New</a></li>
|
<li><a href="{{ url_for('wiki.create') }}"><i class="fa fa-plus"></i> New</a></li>
|
||||||
{% if name %}
|
{% if name %}
|
||||||
<li><a href="{{ url_for('wiki.edit', name=name) }}"><i class="fa fa-pencil"></i> Edit</a></li>
|
<li><a href="{{ url_for('wiki.edit', name=name) }}"><i class="fa fa-pencil"></i> Edit</a></li>
|
||||||
|
|
Loading…
Reference in a new issue