memoryfield-tool 0.0.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.
- memoryfield_tool/__init__.py +6 -0
- memoryfield_tool/__main__.py +3 -0
- memoryfield_tool/assets.py +16 -0
- memoryfield_tool/catalog.py +53 -0
- memoryfield_tool/cli.py +1131 -0
- memoryfield_tool/config.py +150 -0
- memoryfield_tool/db.py +20 -0
- memoryfield_tool/embed.py +19 -0
- memoryfield_tool/export.py +23 -0
- memoryfield_tool/fields.py +78 -0
- memoryfield_tool/frontmatter.py +138 -0
- memoryfield_tool/index.py +184 -0
- memoryfield_tool/pages.py +201 -0
- memoryfield_tool/reindex.py +39 -0
- memoryfield_tool/search.py +145 -0
- memoryfield_tool/static/pico.min.css +4 -0
- memoryfield_tool/templates/base.html +46 -0
- memoryfield_tool/transport.py +294 -0
- memoryfield_tool/uuid_compat.py +8 -0
- memoryfield_tool/validate.py +149 -0
- memoryfield_tool/web.py +208 -0
- memoryfield_tool-0.0.1.dist-info/METADATA +245 -0
- memoryfield_tool-0.0.1.dist-info/RECORD +26 -0
- memoryfield_tool-0.0.1.dist-info/WHEEL +4 -0
- memoryfield_tool-0.0.1.dist-info/entry_points.txt +2 -0
- memoryfield_tool-0.0.1.dist-info/licenses/COPYING +661 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
PICO_CDN_URL = "https://cdn.jsdelivr.net/npm/@picocss/pico@2.0.6/css/pico.min.css"
|
|
4
|
+
_PICO_LOCAL = Path(__file__).parent / "static" / "pico.min.css"
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def has_bundled_pico() -> bool:
|
|
8
|
+
"""True when the build hook produced the bundled pico.min.css (absent in dev)."""
|
|
9
|
+
return _PICO_LOCAL.is_file()
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def pico_css_href() -> str:
|
|
13
|
+
"""The stylesheet URL: bundled asset when present, else the pinned CDN fallback."""
|
|
14
|
+
if has_bundled_pico():
|
|
15
|
+
return "/static/pico.min.css"
|
|
16
|
+
return PICO_CDN_URL
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
from . import frontmatter, pages
|
|
2
|
+
from .transport import Transport
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def catalog_field(t: Transport, *, field_name: str | None = None) -> list[dict[str, object]]:
|
|
6
|
+
"""Return per-page dicts for a field, in filename order (unsorted)."""
|
|
7
|
+
rows: list[dict[str, object]] = []
|
|
8
|
+
for key in pages.collect_pages(t):
|
|
9
|
+
text = t.read_object(key).decode("utf-8")
|
|
10
|
+
fm, _has = frontmatter.parse_frontmatter(text)
|
|
11
|
+
fm_dict = fm if fm is not None else {}
|
|
12
|
+
row: dict[str, object] = {
|
|
13
|
+
"filename": key,
|
|
14
|
+
"title": str(fm_dict.get("title", "")),
|
|
15
|
+
"summary": str(fm_dict.get("summary", "")),
|
|
16
|
+
"created": fm_dict.get("created", ""),
|
|
17
|
+
"updated": fm_dict.get("updated", ""),
|
|
18
|
+
}
|
|
19
|
+
if field_name is not None:
|
|
20
|
+
row["field"] = field_name
|
|
21
|
+
rows.append(row)
|
|
22
|
+
return rows
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def catalog_sort(rows: list[dict[str, object]], sort: str) -> list[dict[str, object]]:
|
|
26
|
+
"""Return rows sorted per the awiki catalog sort rules."""
|
|
27
|
+
rows = list(rows)
|
|
28
|
+
if sort == "path":
|
|
29
|
+
rows.sort(key=lambda r: str(r["filename"]))
|
|
30
|
+
elif sort == "title":
|
|
31
|
+
rows.sort(key=lambda r: str(r["title"]).lower())
|
|
32
|
+
elif sort == "created":
|
|
33
|
+
rows.sort(key=lambda r: str(r["created"]), reverse=True)
|
|
34
|
+
elif sort == "updated":
|
|
35
|
+
rows.sort(key=lambda r: str(r["updated"]), reverse=True)
|
|
36
|
+
return rows
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def catalog_markdown(rows: list[dict[str, object]], *, show_field: bool = False) -> str:
|
|
40
|
+
"""Render rows as a markdown table, optionally with a leading Field column."""
|
|
41
|
+
if show_field:
|
|
42
|
+
out = ["| Field | Page | Summary |", "|-------|------|---------|"]
|
|
43
|
+
else:
|
|
44
|
+
out = ["| Page | Summary |", "|------|---------|"]
|
|
45
|
+
for r in rows:
|
|
46
|
+
summary = str(r["summary"] or "—")
|
|
47
|
+
if len(summary) > 160:
|
|
48
|
+
summary = summary[:157] + "..."
|
|
49
|
+
if show_field:
|
|
50
|
+
out.append(f"| {r['field']} | {r['filename']} | {summary} |")
|
|
51
|
+
else:
|
|
52
|
+
out.append(f"| {r['filename']} | {summary} |")
|
|
53
|
+
return "\n".join(out)
|