Repository: holoviz/holoviews

Issue:
Ability to change html <title> value when exporting via hv.save()
When I export to an html file, the `<title>` value is always "Panel".

I believe this started happening as of version 1.13. Prior to that, I don't believe a `<title>` was set, so the file name displayed.

It would be wonderful to be able to specify a title for the page when exporting via hv.save().




Discussion:
So this is in fact exposed at the panel level, so if you really need this you can use:

```python
import panel as pn
pn.io.save.save(obj, filename, title='Blah')
```

We just need to expose it from HoloViews.
Ah. Thank you. I did go looking in Panel, but obviously missed it.

From: Philipp Rudiger <notifications@github.com>
Sent: Thursday, June 11, 2020 7:26 AM
To: holoviz/holoviews <holoviews@noreply.github.com>
Cc: Dan Ross <dross@aop.com>; Author <author@noreply.github.com>
Subject: Re: [holoviz/holoviews] Ability to change html <title> value when exporting via hv.save() (#4474)


So this is in fact exposed at the panel level, so if you really need this you can use:

import panel as pn

pn.io.save.save(obj, filename, title='Blah')

We just need to expose it from HoloViews.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<https://protect-us.mimecast.com/s/vqdoClYLN0IojqLzUGWDar?domain=github.com>, or unsubscribe<https://protect-us.mimecast.com/s/y5GOCmZ6gkf59LvRUODSrN?domain=github.com>.


Resolving patch:
diff --git a/holoviews/plotting/renderer.py b/holoviews/plotting/renderer.py
--- a/holoviews/plotting/renderer.py
+++ b/holoviews/plotting/renderer.py
@@ -6,6 +6,7 @@
 from __future__ import unicode_literals, absolute_import
 
 import base64
+import os
 
 from io import BytesIO
 try:
@@ -568,7 +569,7 @@ def plot_options(cls, obj, percent_size):
 
     @bothmethod
     def save(self_or_cls, obj, basename, fmt='auto', key={}, info={},
-             options=None, resources='inline', **kwargs):
+             options=None, resources='inline', title=None, **kwargs):
         """
         Save a HoloViews object to file, either using an explicitly
         supplied format or to the appropriate default.
@@ -576,6 +577,12 @@ def save(self_or_cls, obj, basename, fmt='auto', key={}, info={},
         if info or key:
             raise Exception('Renderer does not support saving metadata to file.')
 
+        if kwargs:
+            param.main.warning("Supplying plot, style or norm options "
+                               "as keyword arguments to the Renderer.save "
+                               "method is deprecated and will error in "
+                               "the next minor release.")
+
         with StoreOptions.options(obj, options, **kwargs):
             plot, fmt = self_or_cls._validate(obj, fmt)
 
@@ -587,9 +594,12 @@ def save(self_or_cls, obj, basename, fmt='auto', key={}, info={},
                 resources = CDN
             elif resources.lower() == 'inline':
                 resources = INLINE
-            if isinstance(basename, basestring) and fmt in MIME_TYPES:
-                basename = '.'.join([basename, fmt])
-            plot.layout.save(basename, embed=True, resources=resources)
+            if isinstance(basename, basestring):
+                if title is None:
+                    title = os.path.basename(basename)
+                if fmt in MIME_TYPES:
+                    basename = '.'.join([basename, fmt])
+            plot.layout.save(basename, embed=True, resources=resources, title=title)
             return
 
         rendered = self_or_cls(plot, fmt)
diff --git a/holoviews/util/__init__.py b/holoviews/util/__init__.py
--- a/holoviews/util/__init__.py
+++ b/holoviews/util/__init__.py
@@ -755,7 +755,7 @@ def register_backend_callback(cls, backend, callback):
         cls._backend_hooks[backend].append(callback)
 
 
-def save(obj, filename, fmt='auto', backend=None, resources='cdn', toolbar=None, **kwargs):
+def save(obj, filename, fmt='auto', backend=None, resources='cdn', toolbar=None, title=None, **kwargs):
     """
     Saves the supplied object to file.
 
@@ -783,6 +783,10 @@ def save(obj, filename, fmt='auto', backend=None, resources='cdn', toolbar=None,
         Bokeh resources used to load bokehJS components. Defaults to
         CDN, to embed resources inline for offline usage use 'inline'
         or bokeh.resources.INLINE.
+    toolbar: bool
+        Whether to include toolbars in the exported plot
+    title: string
+        Custom title for exported HTML file
     **kwargs: dict
         Additional keyword arguments passed to the renderer,
         e.g. fps for animations
@@ -803,7 +807,8 @@ def save(obj, filename, fmt='auto', backend=None, resources='cdn', toolbar=None,
             fmt = formats[-1]
         if formats[-1] in supported:
             filename = '.'.join(formats[:-1])
-    return renderer_obj.save(obj, filename, fmt=fmt, resources=resources)
+    return renderer_obj.save(obj, filename, fmt=fmt, resources=resources,
+                             title=title)
 
 
 def render(obj, backend=None, toolbar=None, **kwargs):


Test patch: