Implement Knowledge City platform, organizer and DAV integration

Capture accumulated application, UI, CLI, regression tests and design documentation changes, including task project mapping and default CalDAV list naming.

Keep deployment data, backups, local credentials and build artifacts out of Git. Move the Compose enrollment token to an ignored local environment file.
This commit is contained in:
Anya Tokugawa committed 2026-09-27 14:44:43 +09:00
1 parent 288e6e94ac
commit c1175d389f
699 files changed
+110197 -4117

No files matched your search

+1636
View File
File diff suppressed because it is too large. Load diff
+47
View File
@@ -0,0 +1,47 @@
import importlib.util
from pathlib import Path
import unittest
SCRIPT = Path(__file__).with_name("pageswiki-cli")
SPEC = importlib.util.spec_from_file_location("pageswiki_cli", SCRIPT)
if SPEC is None or SPEC.loader is None:
from importlib.machinery import SourceFileLoader
SPEC = importlib.util.spec_from_loader(
"pageswiki_cli",
SourceFileLoader("pageswiki_cli", str(SCRIPT)),
)
assert SPEC is not None and SPEC.loader is not None
pageswiki_cli = importlib.util.module_from_spec(SPEC)
SPEC.loader.exec_module(pageswiki_cli)
class ContentTypeDetectionTest(unittest.TestCase):
def test_extensionless_shell(self) -> None:
content_type = pageswiki_cli.detect_content_type(
b"#!/usr/bin/env bash\necho hello\n",
)
self.assertEqual(content_type, "application/x-sh; charset=utf-8")
def test_extensionless_utf8_text(self) -> None:
content_type = pageswiki_cli.detect_content_type(
"拡張子なしの文書\n".encode(),
)
self.assertEqual(content_type, "text/plain; charset=utf-8")
def test_magic_number_wins_over_text_analysis(self) -> None:
content_type = pageswiki_cli.detect_content_type(
b"%PDF-1.7\nsample",
)
self.assertEqual(content_type, "application/pdf")
def test_shift_jis_text(self) -> None:
content_type = pageswiki_cli.detect_content_type(
"日本語の文書\n".encode("shift_jis"),
)
self.assertEqual(content_type, "text/plain; charset=shift_jis")
if __name__ == "__main__":
unittest.main()
+43
View File
@@ -0,0 +1,43 @@
import runpy
import sqlite3
import tempfile
import unittest
from pathlib import Path
CLI = runpy.run_path(str(Path(__file__).with_name("pageswiki-cli")))["PagesWikiCLI"]
class AssetMetadataTest(unittest.TestCase):
def test_head_metadata_and_history_follow_cli_uploads(self):
with tempfile.TemporaryDirectory() as directory:
cli = CLI.__new__(CLI)
cli.documents = Path(directory) / "documents"
cli.domain_uuid = "test-domain"
cli.db = sqlite3.connect(":memory:")
self.addCleanup(cli.db.close)
cli.db.row_factory = sqlite3.Row
cli.db.executescript("""
CREATE TABLE objects(uuid TEXT PRIMARY KEY,kind TEXT,created_at INTEGER);
CREATE TABLE assets(domain_uuid TEXT,address TEXT,object_uuid TEXT,
head_document_hash TEXT,content_type TEXT,filename TEXT,size_bytes INTEGER,
created_at_ms INTEGER,updated_at_ms INTEGER,PRIMARY KEY(domain_uuid,address));
""")
address = "asset:image:logo"
payload = b"\x89PNG\r\n\x1a\nfixture"
self.assertEqual(cli.put_asset(address, payload, "logo.png"), "updated")
self.assertEqual(cli.put_asset(address, payload, "logo.png"), "skipped")
self.assertEqual(cli.put_asset(address, payload, "renamed.png"), "updated")
row = cli.db.execute("SELECT * FROM assets").fetchone()
self.assertEqual(row["content_type"], "image/png")
self.assertEqual(row["filename"], "renamed.png")
self.assertEqual(row["size_bytes"], len(payload))
self.assertEqual(cli.document_path(row["head_document_hash"]).read_bytes(), payload)
history = cli.db.execute("SELECT * FROM asset_head_history ORDER BY id").fetchall()
self.assertEqual(len(history), 2)
self.assertEqual(history[-1]["document_hash"], row["head_document_hash"])
self.assertEqual(history[-1]["filename"], "renamed.png")
if __name__ == "__main__":
unittest.main()