mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-24 06:59:52 +01:00
templateview update:
- make 'pywb.template_params', and 'pywb.template_dir' keys configurable in JinjaEnv - don't pass 'iframe_url' to frame template, just pass 'is_proxy'
This commit is contained in:
parent
1bfba09c94
commit
16ede7abbb
@ -32,12 +32,17 @@ class JinjaEnv(object):
|
|||||||
assets_path=None,
|
assets_path=None,
|
||||||
globals=None,
|
globals=None,
|
||||||
overlay=None,
|
overlay=None,
|
||||||
extensions=None):
|
extensions=None,
|
||||||
|
env_template_params_key='pywb.template_params',
|
||||||
|
env_template_dir_key='pywb.templates_dir'):
|
||||||
|
|
||||||
self._init_filters()
|
self._init_filters()
|
||||||
|
|
||||||
loader = ChoiceLoader(self._make_loaders(paths, packages))
|
loader = ChoiceLoader(self._make_loaders(paths, packages))
|
||||||
|
|
||||||
|
self.env_template_params_key = env_template_params_key
|
||||||
|
self.env_template_dir_key = env_template_dir_key
|
||||||
|
|
||||||
extensions = extensions or []
|
extensions = extensions or []
|
||||||
|
|
||||||
if assets_path:
|
if assets_path:
|
||||||
@ -116,7 +121,7 @@ class BaseInsertView(object):
|
|||||||
|
|
||||||
def render_to_string(self, env, **kwargs):
|
def render_to_string(self, env, **kwargs):
|
||||||
template = None
|
template = None
|
||||||
template_path = env.get('pywb.templates_dir')
|
template_path = env.get(self.jenv.env_template_dir_key)
|
||||||
|
|
||||||
if template_path:
|
if template_path:
|
||||||
# jinja paths are not os paths, always use '/' as separator
|
# jinja paths are not os paths, always use '/' as separator
|
||||||
@ -131,7 +136,7 @@ class BaseInsertView(object):
|
|||||||
if not template:
|
if not template:
|
||||||
template = self.jenv.jinja_env.get_template(self.insert_file)
|
template = self.jenv.jinja_env.get_template(self.insert_file)
|
||||||
|
|
||||||
params = env.get('pywb.template_params')
|
params = env.get(self.jenv.env_template_params_key)
|
||||||
if params:
|
if params:
|
||||||
kwargs.update(params)
|
kwargs.update(params)
|
||||||
kwargs['env'] = env
|
kwargs['env'] = env
|
||||||
@ -190,12 +195,7 @@ class TopFrameView(BaseInsertView):
|
|||||||
else:
|
else:
|
||||||
timestamp = timestamp_now()
|
timestamp = timestamp_now()
|
||||||
|
|
||||||
if 'wsgiprox.proxy_host' in env:
|
is_proxy = 'wsgiprox.proxy_host' in env
|
||||||
if not wb_url.url.startswith(env['wsgi.url_scheme'] + ':'):
|
|
||||||
wb_url.url = env['wsgi.url_scheme'] + ':' + wb_url.url.split(':', 1)[-1]
|
|
||||||
iframe_url = wb_url.url
|
|
||||||
else:
|
|
||||||
iframe_url = wb_prefix + embed_url
|
|
||||||
|
|
||||||
params = {'host_prefix': host_prefix,
|
params = {'host_prefix': host_prefix,
|
||||||
'wb_prefix': wb_prefix,
|
'wb_prefix': wb_prefix,
|
||||||
@ -206,7 +206,7 @@ class TopFrameView(BaseInsertView):
|
|||||||
'replay_mod': replay_mod},
|
'replay_mod': replay_mod},
|
||||||
|
|
||||||
'embed_url': embed_url,
|
'embed_url': embed_url,
|
||||||
'iframe_url': iframe_url,
|
'is_proxy': is_proxy,
|
||||||
'timestamp': timestamp,
|
'timestamp': timestamp,
|
||||||
'url': wb_url.get_url()
|
'url': wb_url.get_url()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user