From f59e46c7dfa11e4514f8e1e76f534f82d717fef0 Mon Sep 17 00:00:00 2001 From: Matthew Scragg Date: Sun, 30 Aug 2015 19:17:51 -0500 Subject: [PATCH] Disable sendfile when running dev from vagrant. Upgrade gunicorn. Add BS3 classes to rendered markdown tables. Fixes #72 --- realms/config/__init__.py | 6 +++++- realms/lib/util.py | 4 ++++ realms/static/js/mdr.js | 16 +++++++++++++++- setup.py | 2 +- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/realms/config/__init__.py b/realms/config/__init__.py index fe333b4..0c740a9 100644 --- a/realms/config/__init__.py +++ b/realms/config/__init__.py @@ -1,7 +1,7 @@ import os import json from urlparse import urlparse - +from realms.lib.util import in_vagrant def update(data): conf = read() @@ -152,6 +152,10 @@ SQLALCHEMY_DATABASE_URI = DB_URI _url = urlparse(BASE_URL) RELATIVE_PATH = _url.path +if in_vagrant(): + # sendfile doesn't work well with Virtualbox shared folders + USE_X_SENDFILE = False + if ENV != "DEV": DEBUG = False ASSETS_DEBUG = False diff --git a/realms/lib/util.py b/realms/lib/util.py index bfc49aa..e121ada 100644 --- a/realms/lib/util.py +++ b/realms/lib/util.py @@ -126,6 +126,10 @@ def in_virtualenv(): return hasattr(sys, 'real_prefix') +def in_vagrant(): + return os.path.isdir("/vagrant") + + def is_su(): return os.geteuid() == 0 diff --git a/realms/static/js/mdr.js b/realms/static/js/mdr.js index a532560..445b425 100644 --- a/realms/static/js/mdr.js +++ b/realms/static/js/mdr.js @@ -54,7 +54,10 @@ var MDR = { meta: null, md: null, sanitize: true, // Override - parse: function(md){ return marked(md); }, + renderer: new marked.Renderer(), + parse: function(md){ + return marked(md, { renderer: this.renderer }); + }, convert: function(md, sanitize) { if (this.sanitize !== null) { sanitize = this.sanitize; @@ -103,4 +106,15 @@ var MDR = { hook: function() { } +}; + +MDR.renderer.table = function(header, body) { + return '\n' + + '\n' + + header + + '\n' + + '\n' + + body + + '\n' + + '
\n'; }; \ No newline at end of file diff --git a/setup.py b/setup.py index 1809f0f..1812098 100644 --- a/setup.py +++ b/setup.py @@ -37,7 +37,7 @@ setup(name='realms-wiki', 'gevent==1.0.2', 'ghdiff==0.4', 'gittle==0.4.0', - 'gunicorn==19.1.1', + 'gunicorn==19.3', 'itsdangerous==0.24', 'markdown2==2.3.0', 'simplejson==3.6.3'