diff --git a/docs/manual/new-vue-ui.rst b/docs/manual/new-vue-ui.rst index f9528ab7..e7b6ed33 100644 --- a/docs/manual/new-vue-ui.rst +++ b/docs/manual/new-vue-ui.rst @@ -60,6 +60,15 @@ When using the custom banner, it is possible to configure a logo by setting ``ui If omitted, the standard pywb logo will be used by default. +If set, the logo should point to a file in the static directory (default is ``static`` but can be changed via the ``static_dir`` config option). + +For example, to use the file ``./static/my-logo.png`` as the logo, set: + +.. code:: yaml + + ui: + logo: my-logo.png + Updating the Vue UI ------------------- diff --git a/docs/manual/template-guide.rst b/docs/manual/template-guide.rst index 957c1d4f..ee2f9efa 100644 --- a/docs/manual/template-guide.rst +++ b/docs/manual/template-guide.rst @@ -61,6 +61,9 @@ can also be overriden: * ``footer.html`` -- Template for adding content as the "footer" of the ```` tag of the ``base`` template +Note: The default pywb ``head.html`` and ``footer.html`` are currently blank. They can be populated to customize the rendering, add analytics, etc... as needed. + + The ``base.html`` template also provides five blocks that can be supplied by templates that extend it. * ``title`` -- Block for supplying the title for the page @@ -157,7 +160,7 @@ Template variables: * ``{{ ui }}`` - an optional ``ui`` dictionary from ``config.yaml``, if any -* ``{{ static_prefix }}`` - the prefix from which static files will be accessed from, e.g. ``http://localhost:8080/static/`` +* ``{{ static_prefix }}`` - the prefix from which static files will be accessed from, e.g. ``http://localhost:8080/static/``. Replay and Banner Templates @@ -186,6 +189,8 @@ Template variables: * ``{{ wb_prefix }}`` - the collection prefix, e.g. ``http://localhost:8080/pywb/`` +* ``{{ host_prefix }}`` - the pywb server origin, e.g. ``http://localhost:8080`` + * ``{{ config }}`` - provides the contents of the ``config.yaml`` as a dictionary. * ``{{ ui }}`` - an optional ``ui`` dictionary from ``config.yaml``, if any. @@ -232,10 +237,10 @@ Template variables: * ``{{ wb_url }}`` - A complete ``WbUrl`` object, which contains the ``url``, ``timestamp`` and ``mod`` properties, representing the replay url. -* ``{{ is_framed }}`` - true/false if currently in framed mode. - * ``{{ wb_prefix }}`` - the collection prefix, e.g. ``http://localhost:8080/pywb/`` +* ``{{ is_proxy }}`` - set to true if page is being loaded via an HTTP/S proxy (checks if WSGI env has ``wsgiprox.proxy_host`` set) + .. _custom-top-frame: @@ -332,7 +337,7 @@ The following template variables are available to all templates. * ``{{ env.pywb_proxy_magic }}`` - if set, indicates pywb is accessed via proxy. See :ref:`https-proxy` -* ``{{ static_prefix }}`` - path to use for loading static files. +* ``{{ static_prefix }}`` - URL path to use for loading static files. UI Configuration diff --git a/docs/manual/ui-guide.rst b/docs/manual/ui-guide.rst index 4d981faa..45c1d8ae 100644 --- a/docs/manual/ui-guide.rst +++ b/docs/manual/ui-guide.rst @@ -66,7 +66,7 @@ It is possible to change these settings via ``config.yaml``: * ``static_prefix`` - sets the URL path used in pywb to serve static content (default ``static``) -* ``static_dir`` - sets the directory name used to read static files (default ``static``) +* ``static_dir`` - sets the directory name used to read static files on disk (default ``static``) While pywb can serve static files, it is recommended to use an existing web server to serve static files, especially if already using it in production. diff --git a/pywb/default_config.yaml b/pywb/default_config.yaml index 5bd54aa1..591d4ec9 100644 --- a/pywb/default_config.yaml +++ b/pywb/default_config.yaml @@ -15,6 +15,11 @@ banner_html: banner.html head_insert_html: head_insert.html frame_insert_html: frame_insert.html +base_html: base.html +header_html: header.html +footer_html: footer.html +head_html: head.html + query_html: query.html search_html: search.html not_found_html: not_found.html @@ -39,6 +44,12 @@ html_templates: - not_found_html - home_html + + - base_html + - header_html + - head_html + - footer_html + - error_html - proxy_cert_download_html - proxy_select_html diff --git a/pywb/manager/manager.py b/pywb/manager/manager.py index 39070b9b..33a8041d 100644 --- a/pywb/manager/manager.py +++ b/pywb/manager/manager.py @@ -237,17 +237,20 @@ directory structure expected by pywb v = defaults[n] print('- {0}: (pywb/{1})'.format(n, v)) - def _confirm_overwrite(self, full_path, msg): + def _confirm_overwrite(self, full_path, msg, ignore=False): if not os.path.isfile(full_path): return True + if ignore: + return False + res = get_input(msg) try: res = strtobool(res) except ValueError: res = False - if not res: + if not res and not ignore: raise IOError('Skipping, {0} already exists'.format(full_path)) def _get_template_path(self, template_name, verb): @@ -268,7 +271,7 @@ directory structure expected by pywb return full_path, filename - def add_template(self, template_name, force=False): + def add_template(self, template_name, force=False, ignore=False): full_path, filename = self._get_template_path(template_name, 'add') msg = ('Template file "{0}" ({1}) already exists. ' + @@ -276,7 +279,11 @@ directory structure expected by pywb msg = msg.format(full_path, template_name) if not force: - self._confirm_overwrite(full_path, msg) + res = self._confirm_overwrite(full_path, msg, ignore) + if ignore and not res: + return + + os.makedirs(os.path.dirname(full_path), exist_ok=True) data = resource_string('pywb', filename) with open(full_path, 'w+b') as fh: @@ -286,6 +293,9 @@ directory structure expected by pywb msg = 'Copied default template "{0}" to "{1}"' print(msg.format(filename, full_path)) + if template_name != "base_html": + self.add_template("base_html", force=False, ignore=True) + def remove_template(self, template_name, force=False): full_path, filename = self._get_template_path(template_name, 'remove') diff --git a/pywb/templates/footer.html b/pywb/templates/footer.html new file mode 100644 index 00000000..30ce0761 --- /dev/null +++ b/pywb/templates/footer.html @@ -0,0 +1,2 @@ +## place content to be added at the very end of the tag here + diff --git a/pywb/templates/head.html b/pywb/templates/head.html new file mode 100644 index 00000000..6625b948 --- /dev/null +++ b/pywb/templates/head.html @@ -0,0 +1 @@ +## place optional content to be injected into the of every page here diff --git a/pywb/templates/header.html b/pywb/templates/header.html index 24228983..f024f577 100644 --- a/pywb/templates/header.html +++ b/pywb/templates/header.html @@ -1,3 +1,4 @@ +## place content to be added at the very beginning of the tag here
{% if not err_msg and locales|length > 1 %}
diff --git a/pywb/templates/index.html b/pywb/templates/index.html index 1e1aa92e..63c7cd34 100644 --- a/pywb/templates/index.html +++ b/pywb/templates/index.html @@ -10,7 +10,7 @@ {% for route in routes %}
  • {{ '/' + route }} - {% if all_metadata and all_metadata[route] %} + {% if all_metadata and all_metadata[route] and all_metadata[route].title %} ({{ all_metadata[route].title }}) {% endif %}
  • diff --git a/pywb/templates/query.html b/pywb/templates/query.html index a410150d..5889b455 100644 --- a/pywb/templates/query.html +++ b/pywb/templates/query.html @@ -66,7 +66,7 @@ renderCal.init(); {% else %} - VueUI.main("{{ static_prefix }}", "{{ url }}", "{{ prefix }}"); + VueUI.main("{{ static_prefix }}", "{{ url }}", "{{ prefix }}", "{{ ui.logo }}"); {% endif %} diff --git a/pywb/version.py b/pywb/version.py index f562ffe7..fdf9fadc 100644 --- a/pywb/version.py +++ b/pywb/version.py @@ -1,4 +1,4 @@ -__version__ = '2.7.0b0' +__version__ = '2.7.0b1' if __name__ == '__main__': print(__version__) diff --git a/pywb/vueui/src/App.vue b/pywb/vueui/src/App.vue index fa0f46af..34ef9009 100644 --- a/pywb/vueui/src/App.vue +++ b/pywb/vueui/src/App.vue @@ -2,7 +2,7 @@