runtimepy 5.15.6__py3-none-any.whl → 5.15.7__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.2.3
4
- # hash=08c1dda8bd5fefe13af6a8eb49063498
4
+ # hash=7591d3ee09b156575678bdf806e1b5c7
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.15.6"
13
+ VERSION = "5.15.7"
14
14
 
15
15
  # runtimepy-specific content.
16
16
  METRICS_NAME = "metrics"
@@ -82,3 +82,7 @@ body > :first-child {
82
82
  .channel-filter-min-width {
83
83
  min-width: 5.5em;
84
84
  }
85
+
86
+ .media-preview {
87
+ max-width: 70vw;
88
+ }
@@ -5,6 +5,7 @@ A module implementing web server markdown interfaces.
5
5
  # built-in
6
6
  from io import StringIO
7
7
  import mimetypes
8
+ from os import stat_result
8
9
  from pathlib import Path
9
10
  from typing import Iterable, cast
10
11
 
@@ -17,19 +18,46 @@ from vcorelib.paths import stats as _stats
17
18
 
18
19
  LOGO_MARKDOWN = "[![logo](/static/png/chip-circle-bootstrap/128x128.png)](/)"
19
20
  DIR_FILE = "dir.html"
21
+ AUTOPLAY_PREVIEW_SIZE = 100 * (1024 * 1024) # 100 MiB
20
22
 
21
23
 
22
- def file_preview(path: Path, link: Path) -> str:
24
+ def file_preview(path: Path, link: Path, stats: stat_result) -> str:
23
25
  """Get possible preview text for a file."""
24
26
 
25
27
  preview = ""
26
28
 
27
- if path.is_file():
28
- mime, _ = mimetypes.guess_type(path, strict=False)
29
- if mime and mime.startswith("image"):
30
- preview = div(tag="img", src=f"/{link}", alt=str(link)).encode_str(
31
- newlines=False
32
- )
29
+ if not path.is_file():
30
+ return preview
31
+
32
+ mime, _ = mimetypes.guess_type(path, strict=False)
33
+ if mime:
34
+ # Image previews.
35
+ if mime.startswith("image"):
36
+ preview = div(
37
+ tag="img",
38
+ src=f"/{link}",
39
+ alt=str(link),
40
+ class_str="media-preview",
41
+ ).encode_str(newlines=False)
42
+
43
+ # Video previews.
44
+ elif mime.startswith("video"):
45
+ elem = div(tag="video", class_str="media-preview")
46
+ elem.booleans.add("loop")
47
+ elem.booleans.add("controls")
48
+
49
+ if stats.st_size < AUTOPLAY_PREVIEW_SIZE:
50
+ elem.booleans.add("autoplay")
51
+
52
+ div(parent=elem, tag="source", src=f"/{link}", type=mime)
53
+
54
+ preview = elem.encode_str(newlines=False)
55
+
56
+ # Audio previews.
57
+ elif mime.startswith("audio"):
58
+ elem = div(tag="audio", src=f"/{link}")
59
+ elem.booleans.add("controls")
60
+ preview = elem.encode_str(newlines=False)
33
61
 
34
62
  return preview
35
63
 
@@ -65,7 +93,8 @@ def write_markdown_dir(
65
93
  size_str = byte_count_str(stats.st_size) if item.is_file() else ""
66
94
 
67
95
  writer.write(
68
- f"| [{name}](/{curr}) | {size_str} | {file_preview(item, curr)} |"
96
+ f"| [{name}](/{curr}) | {size_str} | "
97
+ f"{file_preview(item, curr, stats)} |"
69
98
  )
70
99
 
71
100
  writer.empty()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: runtimepy
3
- Version: 5.15.6
3
+ Version: 5.15.7
4
4
  Summary: A framework for implementing Python services.
5
5
  Home-page: https://github.com/libre-embedded/runtimepy
6
6
  Author: Libre Embedded
@@ -18,10 +18,10 @@ Requires-Python: >=3.12
18
18
  Description-Content-Type: text/markdown
19
19
  License-File: LICENSE
20
20
  Requires-Dist: aiofiles
21
- Requires-Dist: svgen>=0.8.0
22
21
  Requires-Dist: websockets
23
- Requires-Dist: psutil
22
+ Requires-Dist: svgen>=0.8.0
24
23
  Requires-Dist: vcorelib>=3.6.4
24
+ Requires-Dist: psutil
25
25
  Provides-Extra: test
26
26
  Requires-Dist: pylint; extra == "test"
27
27
  Requires-Dist: flake8; extra == "test"
@@ -51,11 +51,11 @@ Dynamic: requires-python
51
51
  =====================================
52
52
  generator=datazen
53
53
  version=3.2.3
54
- hash=0f8ffdbd46445346cb834d066f58e765
54
+ hash=fd0b9f87927033d8ee2eb5448d8aec76
55
55
  =====================================
56
56
  -->
57
57
 
58
- # runtimepy ([5.15.6](https://pypi.org/project/runtimepy/))
58
+ # runtimepy ([5.15.7](https://pypi.org/project/runtimepy/))
59
59
 
60
60
  [![python](https://img.shields.io/pypi/pyversions/runtimepy.svg)](https://pypi.org/project/runtimepy/)
61
61
  ![Build Status](https://github.com/libre-embedded/runtimepy/workflows/Python%20Package/badge.svg)
@@ -1,4 +1,4 @@
1
- runtimepy/__init__.py,sha256=qAS3P1hKgQCdNqiMTEqhiSnIM9BIwdZqBvOQfrZCBC4,391
1
+ runtimepy/__init__.py,sha256=7thnFUqjyVartp9aKm12dnNSAnzERRQ8j2AimmJPTPk,391
2
2
  runtimepy/__main__.py,sha256=IKioH2xOtsXwrwb9zABDQEJvuAX--Lnh84TeSz0XSs0,332
3
3
  runtimepy/app.py,sha256=Er1ZKKrG9U0FV0gQg_GYF9xDb89HgYnVzS5SjxGa2Tg,970
4
4
  runtimepy/dev_requirements.txt,sha256=VZhW6bJ5YbwaoN4d_XxZFuN5BbDLaG7ngKrGnugVPRw,245
@@ -55,7 +55,7 @@ runtimepy/data/server_dev.yaml,sha256=nQsPh7LuQig3pzHfdg_aD3yOUiCj1sKKfI-WwW3hXm
55
55
  runtimepy/data/tftp_server.yaml,sha256=-bFOWJSagI-fEQQcT8k7eDMJVfSPm2XAxLVG3dqUTa4,204
56
56
  runtimepy/data/css/bootstrap_extra.css,sha256=0NiTnZWnIYf04n9NHVe-nVSOLwePJ6X-3uCgUgAEKPI,3101
57
57
  runtimepy/data/css/font.css,sha256=Pe82E66rNi-cwlQ-_1GHAuhPGu5L4x5KqgV0dbDe51w,977
58
- runtimepy/data/css/main.css,sha256=B3cBrwz6Leox1tYHTzJ7dW7Le0gf5_qZDCNlRsu-0aY,1316
58
+ runtimepy/data/css/main.css,sha256=ohZ98-ffw6U1h2Azj8ToYiXFurQo1rH9r6kFQZkrtQ0,1355
59
59
  runtimepy/data/js/DataConnection.js,sha256=DnX8FMehjJXqmI62UMYXSvl_XdfQMzq3XUDFbLu2GgI,98
60
60
  runtimepy/data/js/JsonConnection.js,sha256=rclZrbmWc_zSs6I_JhOgxnVPFIyPMo5WdjAe8alyZ3o,2729
61
61
  runtimepy/data/js/audio.js,sha256=bLkBqbeHMiGGidfL3iXjmVoF9seK-ZeZ3kwgOrcpgk4,1092
@@ -205,7 +205,7 @@ runtimepy/net/http/version.py,sha256=mp6rgIM7-VUVKLCA0Uw96CmBkL0ET860lDVVEewpZ7w
205
205
  runtimepy/net/server/__init__.py,sha256=ppfMgymYGRz13MvHvwXyy9WAos2wWgaZDf1TW8D1ILU,11813
206
206
  runtimepy/net/server/html.py,sha256=OB2K37kA7MHtcKqp0pZE1q_XgiyvfooigzS0-OQFCCM,1900
207
207
  runtimepy/net/server/json.py,sha256=AaMPw-G-7xX67mf1LvQAipNdwrnmbLDunVlkWf6iOz0,2526
208
- runtimepy/net/server/markdown.py,sha256=KuPKYh7nj5oy70Ff8LRAXwr_Ga4r8_3KksvDfPfFqYM,2690
208
+ runtimepy/net/server/markdown.py,sha256=kKKSGF_HwH8ADnNm5fNnWq4XXh7Td9Iu_QUj_u-qmts,3595
209
209
  runtimepy/net/server/mux.py,sha256=ejET7NpJzzJjkVwR8laSuZYR79DOT3XazmAIm6rENSE,598
210
210
  runtimepy/net/server/app/__init__.py,sha256=0eCcqYvmby_wQTGqAiGbGM5LCxKM2qpjuIT0gLHsoDU,3157
211
211
  runtimepy/net/server/app/base.py,sha256=46aOqZwRss_nh_WfEH1cMJ9GUVoLJjERd7cTRFu6mXE,1878
@@ -311,9 +311,9 @@ runtimepy/tui/channels/__init__.py,sha256=evDaiIn-YS9uGhdo8ZGtP9VK1ek6sr_P1nJ9Ju
311
311
  runtimepy/ui/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
312
312
  runtimepy/ui/button.py,sha256=8MXnhqmVvANwbbTA8gu3b8N4IIvRYicnwxFQD6SZy3U,2045
313
313
  runtimepy/ui/controls.py,sha256=L55Af-4vGq6ZHewdoA7C_mAYq35WXl8NzOdcsmQIo7M,1868
314
- runtimepy-5.15.6.dist-info/licenses/LICENSE,sha256=yKBRwbO-cOPBrlpsZmJkkSa33DfY31aE8t7lZ0DwlUo,1071
315
- runtimepy-5.15.6.dist-info/METADATA,sha256=MoIujpmp5ifEdr-DxKZrNXyHuFSUoeS6iX0iIyqdW2w,9268
316
- runtimepy-5.15.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
317
- runtimepy-5.15.6.dist-info/entry_points.txt,sha256=-btVBkYv7ybcopqZ_pRky-bEzu3vhbaG3W3Z7ERBiFE,51
318
- runtimepy-5.15.6.dist-info/top_level.txt,sha256=0jPmh6yqHyyJJDwEID-LpQly-9kQ3WRMjH7Lix8peLg,10
319
- runtimepy-5.15.6.dist-info/RECORD,,
314
+ runtimepy-5.15.7.dist-info/licenses/LICENSE,sha256=yKBRwbO-cOPBrlpsZmJkkSa33DfY31aE8t7lZ0DwlUo,1071
315
+ runtimepy-5.15.7.dist-info/METADATA,sha256=sZIDlVdKnti18Hr1tMV7HOmFlKoh-PF2XQPC942dRPM,9268
316
+ runtimepy-5.15.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
317
+ runtimepy-5.15.7.dist-info/entry_points.txt,sha256=-btVBkYv7ybcopqZ_pRky-bEzu3vhbaG3W3Z7ERBiFE,51
318
+ runtimepy-5.15.7.dist-info/top_level.txt,sha256=0jPmh6yqHyyJJDwEID-LpQly-9kQ3WRMjH7Lix8peLg,10
319
+ runtimepy-5.15.7.dist-info/RECORD,,