runtimepy 5.9.0__py3-none-any.whl → 5.9.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
runtimepy/__init__.py CHANGED
@@ -1,7 +1,7 @@
1
1
  # =====================================
2
2
  # generator=datazen
3
3
  # version=3.1.4
4
- # hash=809a612b14ec99a3d62dfdd4add8900e
4
+ # hash=47ca3ea38190cecfff6abaeec5ce0939
5
5
  # =====================================
6
6
 
7
7
  """
@@ -10,7 +10,7 @@ Useful defaults and other package metadata.
10
10
 
11
11
  DESCRIPTION = "A framework for implementing Python services."
12
12
  PKG_NAME = "runtimepy"
13
- VERSION = "5.9.0"
13
+ VERSION = "5.9.1"
14
14
 
15
15
  # runtimepy-specific content.
16
16
  METRICS_NAME = "metrics"
@@ -10,15 +10,19 @@ function lightDarkClick(event) {
10
10
  window.location.hash = lightMode ? "#light-mode" : "";
11
11
  }
12
12
 
13
- let lightDarkButton = document.getElementById("theme-button");
14
- if (lightDarkButton) {
15
- lightDarkButton.addEventListener("click", lightDarkClick);
16
- }
13
+ window.onload = () => {
14
+ let lightDarkButton = document.getElementById("theme-button");
15
+ if (lightDarkButton) {
16
+ lightDarkButton.addEventListener("click", lightDarkClick);
17
+ }
17
18
 
18
- if (window.location.hash) {
19
- let parts = window.location.hash.slice(1).split(",");
19
+ if (window.location.hash) {
20
+ let parts = window.location.hash.slice(1).split(",");
20
21
 
21
- if (parts.includes("light-mode")) {
22
- lightDarkButton.click();
22
+ if (parts.includes("light-mode")) {
23
+ lightDarkButton.click();
24
+ }
23
25
  }
24
- }
26
+
27
+ bootstrap_init();
28
+ };
@@ -4,7 +4,8 @@ A module implementing HTML-related interfaces.
4
4
 
5
5
  # built-in
6
6
  from io import StringIO
7
- from typing import Optional
7
+ from typing import Any, Optional
8
+ from urllib.parse import parse_qs
8
9
 
9
10
  # third-party
10
11
  from svgen.element import Element
@@ -12,6 +13,7 @@ from svgen.element.html import Html, div
12
13
  from vcorelib import DEFAULT_ENCODING
13
14
  from vcorelib.io import IndentedFileWriter
14
15
  from vcorelib.paths import find_file
16
+ from vcorelib.python import StrToBool
15
17
 
16
18
  # internal
17
19
  from runtimepy import PKG_NAME
@@ -26,18 +28,25 @@ from runtimepy.net.html.bootstrap.elements import (
26
28
  )
27
29
 
28
30
 
29
- def create_app_shell(parent: Element, **kwargs) -> tuple[Element, Element]:
31
+ def create_app_shell(
32
+ parent: Element,
33
+ bootstrap_theme: str = "dark",
34
+ use_button_column: bool = True,
35
+ **kwargs,
36
+ ) -> tuple[Element, Element]:
30
37
  """Create a bootstrap-based application shell."""
31
38
 
32
39
  container = div(parent=parent, **kwargs)
33
40
  container.add_class("d-flex", "align-items-start", "bg-body")
34
41
 
35
42
  # Dark theme.
36
- container["data-bs-theme"] = "dark"
43
+ container["data-bs-theme"] = bootstrap_theme
37
44
 
38
45
  # Buttons.
39
- button_column = div(parent=container)
40
- button_column.add_class("d-flex", "flex-column", "h-100", "bg-dark-subtle")
46
+ button_column = div(parent=container if use_button_column else None)
47
+ button_column.add_class(
48
+ "d-flex", "flex-column", "h-100", f"bg-{bootstrap_theme}-subtle"
49
+ )
41
50
 
42
51
  # Dark/light theme switch button.
43
52
  bootstrap_button(
@@ -50,14 +59,18 @@ def create_app_shell(parent: Element, **kwargs) -> tuple[Element, Element]:
50
59
  return container, button_column
51
60
 
52
61
 
53
- def markdown_page(parent: Element, markdown: str, **kwargs) -> None:
62
+ def markdown_page(
63
+ parent: Element, markdown: str, **kwargs
64
+ ) -> tuple[Element, Element]:
54
65
  """Compose a landing page."""
55
66
 
56
- container = centered_markdown(
57
- create_app_shell(parent, **kwargs)[0], markdown, "h-100", "text-body"
58
- )
67
+ parent, button_column = create_app_shell(parent, **kwargs)
68
+
69
+ container = centered_markdown(parent, markdown, "h-100", "text-body")
59
70
  container.add_class("overflow-y-auto")
60
71
 
72
+ return container, button_column
73
+
61
74
 
62
75
  def common_css(document: Html) -> None:
63
76
  """Add common CSS to an HTML document."""
@@ -69,14 +82,38 @@ def common_css(document: Html) -> None:
69
82
  )
70
83
 
71
84
 
72
- def full_markdown_page(document: Html, markdown: str) -> None:
85
+ def full_markdown_page(
86
+ document: Html, markdown: str, uri_query: Optional[str] = None
87
+ ) -> None:
73
88
  """Render a full markdown HTML app."""
74
89
 
75
90
  common_css(document)
76
- markdown_page(document.body, markdown, id=PKG_NAME)
91
+
92
+ markdown_kwargs: dict[str, Any] = {"id": PKG_NAME}
93
+
94
+ if uri_query:
95
+ parsed = parse_qs(uri_query)
96
+
97
+ # Handle pages optimized for document creation.
98
+ if "print" in parsed and any(
99
+ StrToBool.check(x) for x in parsed["print"]
100
+ ):
101
+ markdown_kwargs["bootstrap_theme"] = "light"
102
+ markdown_kwargs["use_button_column"] = False
103
+
104
+ _, button_column = markdown_page(
105
+ document.body, markdown, **markdown_kwargs
106
+ )
107
+
108
+ bootstrap_button(
109
+ icon_str("printer"),
110
+ tooltip="Printer-friendly view.",
111
+ id="print-button",
112
+ parent=div(tag="a", href="?print=true", parent=button_column),
113
+ )
77
114
 
78
115
  # JavaScript.
79
- append_kind(document.body, "markdown_page")
116
+ append_kind(document.body, "util", "markdown_page")
80
117
  add_bootstrap_js(document.body)
81
118
 
82
119
 
@@ -136,7 +136,11 @@ class RuntimepyServerConnection(HttpConnection):
136
136
  return result
137
137
 
138
138
  def render_markdown(
139
- self, content: str, response: ResponseHeader, **kwargs
139
+ self,
140
+ content: str,
141
+ response: ResponseHeader,
142
+ query: Optional[str],
143
+ **kwargs,
140
144
  ) -> bytes:
141
145
  """Return rendered markdown content."""
142
146
 
@@ -146,6 +150,7 @@ class RuntimepyServerConnection(HttpConnection):
146
150
  full_markdown_page(
147
151
  document,
148
152
  writer.stream.getvalue(), # type: ignore
153
+ uri_query=query,
149
154
  )
150
155
 
151
156
  response["Content-Type"] = f"text/html; charset={DEFAULT_ENCODING}"
@@ -153,12 +158,16 @@ class RuntimepyServerConnection(HttpConnection):
153
158
  return document.encode_str().encode()
154
159
 
155
160
  async def render_markdown_file(
156
- self, path: Path, response: ResponseHeader, **kwargs
161
+ self,
162
+ path: Path,
163
+ response: ResponseHeader,
164
+ query: Optional[str],
165
+ **kwargs,
157
166
  ) -> bytes:
158
167
  """Render a markdown file as HTML and return the result."""
159
168
 
160
169
  return self.render_markdown(
161
- (await read_binary(path)).decode(), response, **kwargs
170
+ (await read_binary(path)).decode(), response, query, **kwargs
162
171
  )
163
172
 
164
173
  async def try_file(
@@ -177,7 +186,7 @@ class RuntimepyServerConnection(HttpConnection):
177
186
  md_candidate = candidate.with_suffix(".md")
178
187
  if md_candidate.is_file():
179
188
  return await self.render_markdown_file(
180
- md_candidate, response
189
+ md_candidate, response, path[1]
181
190
  )
182
191
 
183
192
  if candidate.is_file():
@@ -1,5 +1,5 @@
1
1
  aiofiles
2
- vcorelib>=3.4.8
2
+ vcorelib>=3.5.1
3
3
  svgen>=0.7.4
4
4
  websockets
5
5
  psutil
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: runtimepy
3
- Version: 5.9.0
3
+ Version: 5.9.1
4
4
  Summary: A framework for implementing Python services.
5
5
  Home-page: https://github.com/vkottler/runtimepy
6
6
  Author: Vaughn Kottler
@@ -17,11 +17,11 @@ Classifier: License :: OSI Approved :: MIT License
17
17
  Requires-Python: >=3.12
18
18
  Description-Content-Type: text/markdown
19
19
  License-File: LICENSE
20
- Requires-Dist: websockets
21
20
  Requires-Dist: svgen>=0.7.4
21
+ Requires-Dist: websockets
22
22
  Requires-Dist: psutil
23
23
  Requires-Dist: aiofiles
24
- Requires-Dist: vcorelib>=3.4.8
24
+ Requires-Dist: vcorelib>=3.5.1
25
25
  Provides-Extra: test
26
26
  Requires-Dist: pylint; extra == "test"
27
27
  Requires-Dist: flake8; extra == "test"
@@ -49,11 +49,11 @@ Dynamic: requires-python
49
49
  =====================================
50
50
  generator=datazen
51
51
  version=3.1.4
52
- hash=3ef34104e5e034e1dbd47bb8020808b6
52
+ hash=f3a77d6dfc0bda171a9716c3731531c5
53
53
  =====================================
54
54
  -->
55
55
 
56
- # runtimepy ([5.9.0](https://pypi.org/project/runtimepy/))
56
+ # runtimepy ([5.9.1](https://pypi.org/project/runtimepy/))
57
57
 
58
58
  [![python](https://img.shields.io/pypi/pyversions/runtimepy.svg)](https://pypi.org/project/runtimepy/)
59
59
  ![Build Status](https://github.com/vkottler/runtimepy/workflows/Python%20Package/badge.svg)
@@ -1,11 +1,11 @@
1
- runtimepy/__init__.py,sha256=Hpdu2mXPW86wvJDXbnHtABLikRBQtxf-jEtzqNYLzZQ,390
1
+ runtimepy/__init__.py,sha256=WYh3eb-XrVkK9YtfaTCSVSalmUbmw6WkcNIFMdC2A7Y,390
2
2
  runtimepy/__main__.py,sha256=OPAed6hggoQdw-6QAR62mqLC-rCkdDhOq0wyeS2vDRI,332
3
3
  runtimepy/app.py,sha256=sTvatbsGZ2Hdel36Si_WUbNMtg9CzsJyExr5xjIcxDE,970
4
4
  runtimepy/dev_requirements.txt,sha256=j0dh11ztJAzfaUL0iFheGjaZj9ppDzmTkclTT8YKO8c,230
5
5
  runtimepy/entry.py,sha256=3672ccoslf2h8Wg5M_SuW6SoEx0oslRoi0ngZsgjNz8,1954
6
6
  runtimepy/mapping.py,sha256=VQK1vzmQVvYYKI85_II37-hIEbvgL3PzNy-WI6TTo80,5091
7
7
  runtimepy/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
- runtimepy/requirements.txt,sha256=06GUbnvKnIxnUcTivKEv2Ik34C9RU8Sm5Ko9uvI1f9s,124
8
+ runtimepy/requirements.txt,sha256=PdID4t7w3qsEoNwrMR-SJoH5OQ9oIUcpesKJC4AiU64,124
9
9
  runtimepy/schemas.py,sha256=zTgxPm9DHZ0R_bmmOjNQMTXdtM_Hb1bE-Fog40jDCgg,839
10
10
  runtimepy/util.py,sha256=GuyIHVFGMS02OR6-O3LnlV3DqG5hj4-IUud0QM6WicA,1684
11
11
  runtimepy/channel/__init__.py,sha256=pf0RJ5g37_FVV8xoUNgzFGuIfbZEYSBA_cQlJSDTPDo,4774
@@ -60,7 +60,7 @@ runtimepy/data/js/audio.js,sha256=bLkBqbeHMiGGidfL3iXjmVoF9seK-ZeZ3kwgOrcpgk4,10
60
60
  runtimepy/data/js/events.js,sha256=rgz3Q_8J6sfU_7Sa7fG1mZD0pQ4S3vwN2mqcvQfePkM,554
61
61
  runtimepy/data/js/init.js,sha256=IeFqfab7CM2-Z4fIbyGaUD4M2orUT8uLwcVlleQqXzg,1522
62
62
  runtimepy/data/js/main.js,sha256=nYIQ6O76EWqlzwX7oEwPXqC-LCUFCZYDADK9QbYRDKk,404
63
- runtimepy/data/js/markdown_page.js,sha256=pygLkO6P1AJnOy5PjIUH_px1OEiROrSNLGLUFuERMJc,610
63
+ runtimepy/data/js/markdown_page.js,sha256=7PNELE79WB3YU_rGq_0v-uDB7kyYtn5U8zpBeBiVHqg,678
64
64
  runtimepy/data/js/util.js,sha256=Xc8pHUiFDBDvIqTamWrCYUOpF7iR9VNvPDCSCQAfLDA,1424
65
65
  runtimepy/data/js/worker.js,sha256=V9deGAynjvUr1D-WGi3wUW8rxoaNLvBvayMoLFZk3w0,2444
66
66
  runtimepy/data/js/classes/App.js,sha256=nnY42Q3tlNzf8JZtuGKyxJZLLNMfResdww8svOQMC3U,3402
@@ -166,7 +166,7 @@ runtimepy/net/arbiter/struct/__init__.py,sha256=Vr38dp2X0PZOrAbjKsZ9xZdQ1j3z92s4
166
166
  runtimepy/net/arbiter/tcp/__init__.py,sha256=djNm8il_9aLNpGsYResJlFmyIqx9XNLqVay-mYnn8vc,1530
167
167
  runtimepy/net/arbiter/tcp/json.py,sha256=W9a_OwBPmIoB2XZf4iuAIWQhMg2qA9xejBhGBdNCPnI,742
168
168
  runtimepy/net/factories/__init__.py,sha256=rPdBVpgzzQYF61w6efQrEre71yMPHd6kanBpMdOX-3c,4672
169
- runtimepy/net/html/__init__.py,sha256=BQeGpZWfGSmMg1R0N9GaOZfyFn4UQGHKoFOhd-1G75Q,3983
169
+ runtimepy/net/html/__init__.py,sha256=2wdkMAomTlKJURi7eIhFUcXYXPAC-WWAuCfKy5QFTac,4964
170
170
  runtimepy/net/html/arbiter.py,sha256=SkZZm-CmyCxbAcWZbvCLH-RwFUJPvrvR5yWysVVuvCM,951
171
171
  runtimepy/net/html/bootstrap/__init__.py,sha256=ONhwx68piWjsrf88FMpda84TWSPqgi-RZCBuWCci_ak,1444
172
172
  runtimepy/net/html/bootstrap/elements.py,sha256=NBdjg0_1LTxoyJrNQNw-2v8AWaiW2S1poJcDo4P6GWE,5355
@@ -178,7 +178,7 @@ runtimepy/net/http/request_target.py,sha256=EE1aI5VSARw1h93jyZvP56ir5O5fjd6orYK-
178
178
  runtimepy/net/http/response.py,sha256=Sup8W_A0ADNzR5olKrQsVNhsQXUwPOD-eJLlLOgYlAY,2316
179
179
  runtimepy/net/http/state.py,sha256=qCMN8aWfCRfU9XP-cIhSOo2RqfljTjbQRCflfcy2bfY,1626
180
180
  runtimepy/net/http/version.py,sha256=mp6rgIM7-VUVKLCA0Uw96CmBkL0ET860lDVVEewpZ7w,1098
181
- runtimepy/net/server/__init__.py,sha256=sYvvt7p3yTFCR2YXf4Qx3bKo_AafW0OjQ_30KKbg2DM,9488
181
+ runtimepy/net/server/__init__.py,sha256=Kg1NenLXSDWYa7NFvQLu2hHU4p6sYXwspv2NSZ7VfSo,9647
182
182
  runtimepy/net/server/html.py,sha256=ufg0PQF_iUE7PT0n3Pn3jTcun7mspZUI6_ooblcNnvI,1217
183
183
  runtimepy/net/server/json.py,sha256=a7vM5yfq2er4DexzFqEMnxoMGDeuywKkVH4-uNJBAik,2522
184
184
  runtimepy/net/server/app/__init__.py,sha256=beU67t7zoKGlO7aldjQMUwYLm9mSlc78eMQazri-otw,3012
@@ -284,9 +284,9 @@ runtimepy/tui/task.py,sha256=nUZo9fuOC-k1Wpqdzkv9v1tQirCI28fZVgcC13Ijvus,1093
284
284
  runtimepy/tui/channels/__init__.py,sha256=evDaiIn-YS9uGhdo8ZGtP9VK1ek6sr_P1nJ9JuSET0o,4536
285
285
  runtimepy/ui/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
286
286
  runtimepy/ui/controls.py,sha256=yvT7h3thbYaitsakcIAJ90EwKzJ4b-jnc6p3UuVf_XE,1241
287
- runtimepy-5.9.0.dist-info/LICENSE,sha256=yKBRwbO-cOPBrlpsZmJkkSa33DfY31aE8t7lZ0DwlUo,1071
288
- runtimepy-5.9.0.dist-info/METADATA,sha256=d7lEAUBqGKdhpRo6BKLfB06RErKoWPhk8RD-kMoZiKE,9371
289
- runtimepy-5.9.0.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
290
- runtimepy-5.9.0.dist-info/entry_points.txt,sha256=-btVBkYv7ybcopqZ_pRky-bEzu3vhbaG3W3Z7ERBiFE,51
291
- runtimepy-5.9.0.dist-info/top_level.txt,sha256=0jPmh6yqHyyJJDwEID-LpQly-9kQ3WRMjH7Lix8peLg,10
292
- runtimepy-5.9.0.dist-info/RECORD,,
287
+ runtimepy-5.9.1.dist-info/LICENSE,sha256=yKBRwbO-cOPBrlpsZmJkkSa33DfY31aE8t7lZ0DwlUo,1071
288
+ runtimepy-5.9.1.dist-info/METADATA,sha256=1_fDtWfB-WZA3Jn79TabypVK4cR3UArOAj3Z6puQ124,9371
289
+ runtimepy-5.9.1.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
290
+ runtimepy-5.9.1.dist-info/entry_points.txt,sha256=-btVBkYv7ybcopqZ_pRky-bEzu3vhbaG3W3Z7ERBiFE,51
291
+ runtimepy-5.9.1.dist-info/top_level.txt,sha256=0jPmh6yqHyyJJDwEID-LpQly-9kQ3WRMjH7Lix8peLg,10
292
+ runtimepy-5.9.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.2)
2
+ Generator: setuptools (76.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5