diff --git a/server.py b/server.py
index 3d484e63..dd54066b 100644
--- a/server.py
+++ b/server.py
@@ -3,7 +3,7 @@
reload(sys)
sys.setdefaultencoding('utf-8')
-from flask import Flask, request, render_template, jsonify, Response, send_file
+from flask import Flask, request, render_template, url_for, jsonify, Response, send_file
import os
import os.path
import subprocess
@@ -27,9 +27,54 @@
PANDOC_EXTENSIONS = ['pdf', 'docx', 'epub', 'html']
DOCVERTER_URL = 'http://c.docverter.com/convert'
PDFLATEX_EXISTS = distutils.spawn.find_executable("pdflatex") != None
-STATIC_URL_PATH = '/markx/static' # flask default
-app = Flask(__name__, static_url_path=STATIC_URL_PATH)
+app = Flask(__name__)
+
+class ReverseProxied(object):
+ '''Wrap the application in this middleware and configure the
+ front-end server to add these headers, to let you quietly bind
+ this to a URL other than / and to an HTTP scheme that is
+ different than what is used locally.
+
+ In nginx:
+ location /myprefix {
+ proxy_pass http://192.168.0.1:5000;
+ proxy_set_header Host $host;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header X-Scheme $scheme;
+ proxy_set_header X-Script-Name /myprefix;
+ }
+
+ In Apache2:
+
+ ProxyPass http://192.168.0.1:5000
+ ProxyPassReverse http://192.168.0.1:5000
+ RequestHeader set X-Script-Name /markx
+
+
+ :param app: the WSGI application
+ '''
+ def __init__(self, app):
+ self.app = app
+
+ def __call__(self, environ, start_response):
+ script_name = environ.get('HTTP_X_SCRIPT_NAME', '')
+ if script_name:
+ environ['SCRIPT_NAME'] = script_name
+ path_info = environ['PATH_INFO']
+ if path_info.startswith(script_name):
+ environ['PATH_INFO'] = path_info[len(script_name):]
+
+ scheme = environ.get('HTTP_X_SCHEME', '')
+ if scheme:
+ environ['wsgi.url_scheme'] = scheme
+ return self.app(environ, start_response)
+
+app.wsgi_app = ReverseProxied(app.wsgi_app)
+def get_url_for(filename, **values):
+ return url_for('static', filename=filename, **values)
+app.jinja_env.globals['static'] = get_url_for
+
app.config.from_object(__name__)
print " * Overriding deafult configuration with config.py file"
app.config.from_pyfile('config.py', silent=True)
diff --git a/static/css/editor.css b/static/css/editor.css
index 3df60fe0..a7432527 100644
--- a/static/css/editor.css
+++ b/static/css/editor.css
@@ -70,7 +70,7 @@ body
}
.wmd-button > span {
- background-image: url("/static/img/wmd-buttons.png");
+ background-image: url('../img/wmd-buttons.png');
background-repeat: no-repeat;
background-position: 0px 0px;
width: 20px;
diff --git a/static/css/fonts.css b/static/css/fonts.css
index fdd7bcf5..88c5c9ca 100644
--- a/static/css/fonts.css
+++ b/static/css/fonts.css
@@ -1,10 +1,10 @@
@font-face {
font-family: 'icomoon';
- src:url('/static/fonts/icomoon.eot');
- src:url('/static/fonts/icomoon.eot?#iefix') format('embedded-opentype'),
- url('/static/fonts/icomoon.woff') format('woff'),
- url('/static/fonts/icomoon.ttf') format('truetype'),
- url('/static/fonts/icomoon.svg#icomoon') format('svg');
+ src:url('../fonts/icomoon.eot');
+ src:url('../fonts/icomoon.eot?#iefix') format('embedded-opentype'),
+ url('../fonts/icomoon.woff') format('woff'),
+ url('../fonts/icomoon.ttf') format('truetype'),
+ url('../fonts/icomoon.svg#icomoon') format('svg');
font-weight: normal;
font-style: normal;
}
diff --git a/templates/base.html b/templates/base.html
index 988f0c60..e8a03bc1 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -7,20 +7,20 @@
-
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
{% block head %}
{% endblock head %}
diff --git a/templates/index.html b/templates/index.html
index 92d1442d..ec4e3ee5 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -5,7 +5,7 @@
-
+