1
0
mirror of https://github.com/webrecorder/pywb.git synced 2025-03-15 00:03:28 +01:00

static prefix: add 'static_prefix' template var which incorporates the wsgi prefix env['SCIPT_NAME']

This commit is contained in:
Ilya Kreymer 2018-05-11 08:48:54 -07:00
parent be3c3c8778
commit 6572705ba8
5 changed files with 14 additions and 7 deletions

View File

@ -287,6 +287,8 @@ class FrontEndApp(object):
if not coll or not self.warcserver.root_dir: if not coll or not self.warcserver.root_dir:
return return
environ['ORIG_SCRIPT_NAME'] = environ.get('SCRIPT_NAME')
if coll != '$root': if coll != '$root':
pop_path_info(environ) pop_path_info(environ)
if record: if record:

View File

@ -348,6 +348,7 @@ class RewriterApp(object):
top_url, top_url,
environ, environ,
framed_replay, framed_replay,
static_prefix=self.get_static_prefix(environ),
config=self.config)) config=self.config))
cookie_rewriter = None cookie_rewriter = None
@ -588,6 +589,9 @@ class RewriterApp(object):
#return request.script_name #return request.script_name
return environ.get('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): def get_full_prefix(self, environ):
return self.get_host_prefix(environ) + self.get_rel_prefix(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) return self.handle_query(environ, wb_url, kwargs, full_prefix)
if self.is_framed_replay(wb_url): 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, return self.frame_insert_view.get_top_frame(wb_url,
full_prefix, full_prefix,
host_prefix, host_prefix,

View File

@ -1,5 +1,5 @@
{% if not env.pywb_proxy_magic or config.proxy.use_banner | default(true) %} {% if not env.pywb_proxy_magic or config.proxy.use_banner | default(true) %}
<!-- default banner, create through js --> <!-- default banner, create through js -->
<script src='{{ host_prefix }}/{{ static_path }}/default_banner.js'> </script> <script src='{{ static_prefix }}/default_banner.js'> </script>
<link rel='stylesheet' href='{{ host_prefix }}/{{ static_path }}/default_banner.css'/> <link rel='stylesheet' href='{{ static_prefix }}/default_banner.css'/>
{% endif %} {% endif %}

View File

@ -12,7 +12,7 @@ html, body
} }
</style> </style>
<script src='{{ host_prefix }}/{{ static_path }}/wb_frame.js'> </script> <script src='{{ static_prefix }}/wb_frame.js'> </script>
{{ banner_html }} {{ banner_html }}

View File

@ -23,11 +23,11 @@
wbinfo.is_live = {{ is_live }}; wbinfo.is_live = {{ is_live }};
wbinfo.coll = "{{ coll }}"; wbinfo.coll = "{{ coll }}";
wbinfo.proxy_magic = "{{ env.pywb_proxy_magic }}"; wbinfo.proxy_magic = "{{ env.pywb_proxy_magic }}";
wbinfo.static_prefix = "{{ host_prefix }}/{{ static_path }}/"; wbinfo.static_prefix = "{{ static_prefix }}/";
</script> </script>
{% if not wb_url.is_banner_only %} {% if not wb_url.is_banner_only %}
<script src='{{ host_prefix }}/{{ static_path }}/wombat.js'> </script> <script src='{{ static_prefix }}/wombat.js'> </script>
<script> <script>
wbinfo.wombat_ts = "{{ wombat_ts }}"; wbinfo.wombat_ts = "{{ wombat_ts }}";
wbinfo.wombat_sec = "{{ wombat_sec }}"; wbinfo.wombat_sec = "{{ wombat_sec }}";
@ -51,7 +51,7 @@
{% endif %} {% endif %}
{% if config.enable_flash_video_rewrite %} {% if config.enable_flash_video_rewrite %}
<script src='{{ host_prefix }}/{{ static_path }}/vidrw.js'> </script> <script src='{{ static_prefix }}/vidrw.js'> </script>
{% endif %} {% endif %}
{{ banner_html }} {{ banner_html }}