From 6572705ba88963b94838908696734ce9f1db873e Mon Sep 17 00:00:00 2001 From: Ilya Kreymer Date: Fri, 11 May 2018 08:48:54 -0700 Subject: [PATCH] static prefix: add 'static_prefix' template var which incorporates the wsgi prefix env['SCIPT_NAME'] --- pywb/apps/frontendapp.py | 2 ++ pywb/apps/rewriterapp.py | 7 ++++++- pywb/templates/banner.html | 4 ++-- pywb/templates/frame_insert.html | 2 +- pywb/templates/head_insert.html | 6 +++--- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/pywb/apps/frontendapp.py b/pywb/apps/frontendapp.py index 06ce556d..7017b60b 100644 --- a/pywb/apps/frontendapp.py +++ b/pywb/apps/frontendapp.py @@ -287,6 +287,8 @@ class FrontEndApp(object): if not coll or not self.warcserver.root_dir: return + environ['ORIG_SCRIPT_NAME'] = environ.get('SCRIPT_NAME') + if coll != '$root': pop_path_info(environ) if record: diff --git a/pywb/apps/rewriterapp.py b/pywb/apps/rewriterapp.py index e7e86b03..ee00f81e 100644 --- a/pywb/apps/rewriterapp.py +++ b/pywb/apps/rewriterapp.py @@ -348,6 +348,7 @@ class RewriterApp(object): top_url, environ, framed_replay, + static_prefix=self.get_static_prefix(environ), config=self.config)) cookie_rewriter = None @@ -588,6 +589,9 @@ class RewriterApp(object): #return request.script_name return environ.get('SCRIPT_NAME') + '/' + def get_static_prefix(self, environ): + return self.get_host_prefix(environ) + environ.get('ORIG_SCRIPT_NAME', '') + '/static' + def get_full_prefix(self, environ): return self.get_host_prefix(environ) + self.get_rel_prefix(environ) @@ -641,7 +645,8 @@ class RewriterApp(object): return self.handle_query(environ, wb_url, kwargs, full_prefix) if self.is_framed_replay(wb_url): - extra_params = self.get_top_frame_params(wb_url, kwargs) + extra_params = self.get_top_frame_params(wb_url, kwargs) or {} + extra_params['static_prefix'] = self.get_static_prefix(environ) return self.frame_insert_view.get_top_frame(wb_url, full_prefix, host_prefix, diff --git a/pywb/templates/banner.html b/pywb/templates/banner.html index dffe1057..d240b9da 100644 --- a/pywb/templates/banner.html +++ b/pywb/templates/banner.html @@ -1,5 +1,5 @@ {% if not env.pywb_proxy_magic or config.proxy.use_banner | default(true) %} - - + + {% endif %} diff --git a/pywb/templates/frame_insert.html b/pywb/templates/frame_insert.html index b8fbe1bb..1f7e74e1 100644 --- a/pywb/templates/frame_insert.html +++ b/pywb/templates/frame_insert.html @@ -12,7 +12,7 @@ html, body } - + {{ banner_html }} diff --git a/pywb/templates/head_insert.html b/pywb/templates/head_insert.html index 4ba5ef00..2fd7e0ab 100644 --- a/pywb/templates/head_insert.html +++ b/pywb/templates/head_insert.html @@ -23,11 +23,11 @@ wbinfo.is_live = {{ is_live }}; wbinfo.coll = "{{ coll }}"; wbinfo.proxy_magic = "{{ env.pywb_proxy_magic }}"; - wbinfo.static_prefix = "{{ host_prefix }}/{{ static_path }}/"; + wbinfo.static_prefix = "{{ static_prefix }}/"; {% if not wb_url.is_banner_only %} - + + {% endif %} {{ banner_html }}