From c6379803a14976e1914e9085e6eb838334f396bb Mon Sep 17 00:00:00 2001 From: Aioros Date: Tue, 26 Mar 2019 15:34:44 -0700 Subject: [PATCH 1/2] Normalize case for configuration paths Inconsistent case from different calls to os.path.dirname on Windows would cause problems in creating relative paths in views, like imagepaths in /workspaces. --- excalibur/configuration.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/excalibur/configuration.py b/excalibur/configuration.py index 3434ded..f8d37c7 100644 --- a/excalibur/configuration.py +++ b/excalibur/configuration.py @@ -132,8 +132,8 @@ def parameterized_config(template): # for Flask ALLOWED_EXTENSIONS = ['pdf', 'json'] SECRET_KEY = conf.get('webserver', 'SECRET_KEY') -PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__)) -PDFS_FOLDER = os.path.join(PROJECT_ROOT, 'www/static/uploads') +PROJECT_ROOT = os.path.normcase(os.path.dirname(os.path.abspath(__file__))) +PDFS_FOLDER = os.path.normcase(os.path.join(PROJECT_ROOT, 'www/static/uploads')) USING_SQLITE = True if conf.get('core', 'SQL_ALCHEMY_CONN').startswith('sqlite') else False get = conf.get From 18871f1ef6fda1997ad359c2dd8241993b8caa18 Mon Sep 17 00:00:00 2001 From: Aioros Date: Tue, 26 Mar 2019 18:15:28 -0700 Subject: [PATCH 2/2] Normalize forward slashes for image paths Backward slashes on Windows created encoding problems on the js side, causing problems in the jquery.selectareas plugin: the selected area would have no background property, appearing white and opaque. --- excalibur/www/views.py | 1 + 1 file changed, 1 insertion(+) diff --git a/excalibur/www/views.py b/excalibur/www/views.py index 8c0dab9..f11cc20 100644 --- a/excalibur/www/views.py +++ b/excalibur/www/views.py @@ -85,6 +85,7 @@ def workspaces(file_id): for page in imagepaths: imagepaths[page] = imagepaths[page].replace( os.path.join(conf.PROJECT_ROOT, 'www'), '') + imagepaths[page] = imagepaths[page].replace(os.sep, '/') filedims = file.filedims imagedims = file.imagedims detected_areas = file.detected_areas