From 465195f20327c3a3d9ef5824580a11c383f262d9 Mon Sep 17 00:00:00 2001 From: Ilya Kreymer Date: Tue, 24 Jul 2018 18:25:30 -0700 Subject: [PATCH] static path prefix fix to support non-root pywb deployment: - store original wsgi SCRIPT_NAME (before collection path is pushed) - add 'static_prefix' jinja env global which defaults to original prefix + /static/ - update existing templates to use '{{ static_prefix }}' instead of '{{ host_prefix }}/{{ static_path }'' - set 'pywb.host_prefix' via rewriterapp, set 'static_prefix' to absolute url if available (to support proxy mode) --- pywb/apps/frontendapp.py | 3 +++ pywb/apps/rewriterapp.py | 2 ++ pywb/templates/head_insert.html | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pywb/apps/frontendapp.py b/pywb/apps/frontendapp.py index e03c632f..2de16fa6 100644 --- a/pywb/apps/frontendapp.py +++ b/pywb/apps/frontendapp.py @@ -494,6 +494,9 @@ class FrontEndApp(object): # store original script_name (original prefix) before modifications are made environ['pywb.app_prefix'] = environ.get('SCRIPT_NAME', '') + # store original script_name (original prefix) before modifications are made + environ['ORIG_SCRIPT_NAME'] = environ.get('SCRIPT_NAME') + lang = args.pop('lang', '') if lang: pop_path_info(environ) diff --git a/pywb/apps/rewriterapp.py b/pywb/apps/rewriterapp.py index 1186db75..335a77bf 100644 --- a/pywb/apps/rewriterapp.py +++ b/pywb/apps/rewriterapp.py @@ -267,6 +267,8 @@ class RewriterApp(object): 'pywb.static_prefix', '/static/') is_proxy = ('wsgiprox.proxy_host' in environ) + environ['pywb.host_prefix'] = host_prefix + if self.use_js_obj_proxy: content_rw = self.js_proxy_rw else: diff --git a/pywb/templates/head_insert.html b/pywb/templates/head_insert.html index b1fe7f59..e1506d83 100644 --- a/pywb/templates/head_insert.html +++ b/pywb/templates/head_insert.html @@ -3,7 +3,7 @@ {% set urlsplit = cdx.url | urlsplit %} wbinfo = {}; wbinfo.top_url = "{{ top_url }}"; -{% if is_framed %} +{% if is_framed == 'true' %} // Fast Top-Frame Redirect if (window == window.top && wbinfo.top_url) { var loc = window.location.href.replace(window.location.hash, "");