|
@@ -38,11 +38,11 @@ class Client:
|
|
auto_index_client: Client
|
|
auto_index_client: Client
|
|
"""The client that is used to render the auto-index page."""
|
|
"""The client that is used to render the auto-index page."""
|
|
|
|
|
|
- head_html = ''
|
|
|
|
- """HTML to be inserted in the <head> of the page template."""
|
|
|
|
|
|
+ shared_head_html = ''
|
|
|
|
+ """HTML to be inserted in the <head> of every page template."""
|
|
|
|
|
|
- body_html = ''
|
|
|
|
- """HTML to be inserted in the <body> of the page template."""
|
|
|
|
|
|
+ shared_body_html = ''
|
|
|
|
+ """HTML to be inserted in the <body> of every page template."""
|
|
|
|
|
|
def __init__(self, page: page, *, shared: bool = False) -> None:
|
|
def __init__(self, page: page, *, shared: bool = False) -> None:
|
|
self.id = str(uuid.uuid4())
|
|
self.id = str(uuid.uuid4())
|
|
@@ -65,6 +65,9 @@ class Client:
|
|
|
|
|
|
self.waiting_javascript_commands: Dict[str, Any] = {}
|
|
self.waiting_javascript_commands: Dict[str, Any] = {}
|
|
|
|
|
|
|
|
+ self._head_html = ''
|
|
|
|
+ self._body_html = ''
|
|
|
|
+
|
|
self.page = page
|
|
self.page = page
|
|
|
|
|
|
self.connect_handlers: List[Union[Callable[..., Any], Awaitable]] = []
|
|
self.connect_handlers: List[Union[Callable[..., Any], Awaitable]] = []
|
|
@@ -87,6 +90,16 @@ class Client:
|
|
"""Return True if the client is connected, False otherwise."""
|
|
"""Return True if the client is connected, False otherwise."""
|
|
return self.environ is not None
|
|
return self.environ is not None
|
|
|
|
|
|
|
|
+ @property
|
|
|
|
+ def head_html(self) -> str:
|
|
|
|
+ """Return the HTML code to be inserted in the <head> of the page template."""
|
|
|
|
+ return self.shared_head_html + self._head_html
|
|
|
|
+
|
|
|
|
+ @property
|
|
|
|
+ def body_html(self) -> str:
|
|
|
|
+ """Return the HTML code to be inserted in the <body> of the page template."""
|
|
|
|
+ return self.shared_body_html + self._body_html
|
|
|
|
+
|
|
def __enter__(self):
|
|
def __enter__(self):
|
|
self.content.__enter__()
|
|
self.content.__enter__()
|
|
return self
|
|
return self
|