Deliver stored exercise HTML on the catalog API.
Deploy Development / deploy (push) Successful in 52s
Test Suite / pytest-backend (push) Successful in 52s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 16s
Test Suite / k6 /health Baseline (push) Successful in 35s
Test Suite / playwright-tests (push) Failing after 7m43s
Deploy Development / deploy (push) Successful in 52s
Test Suite / pytest-backend (push) Successful in 52s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 16s
Test Suite / k6 /health Baseline (push) Successful in 35s
Test Suite / playwright-tests (push) Failing after 7m43s
The receiving application needs paragraphs, line breaks, lists and emphasis as stored in Shinkan. The catalog now returns that HTML and marks the text format, while titles and short variant descriptions stay plain text. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
68ae82a5e5
commit
5ff0cd43ee
3 files changed
+54
-10
No files matched your search
@@ -15,6 +15,8 @@ from datetime import datetime, timezone
|
||||
from html import unescape
|
||||
from typing import Any, Iterable, Optional
|
||||
|
||||
from exercise_rich_text import normalize_inline_exercise_media_markup
|
||||
|
||||
PART_ROLES = (
|
||||
"goal",
|
||||
"prerequisites",
|
||||
@@ -235,8 +237,20 @@ def catalog_available(offered: bool, in_scope: bool) -> bool:
|
||||
return bool(offered) and bool(in_scope)
|
||||
|
||||
|
||||
def catalog_html(value: Optional[str]) -> str:
|
||||
"""Gespeichertes Übungs-HTML. Absätze, Umbrüche, Listen und Hervorhebungen bleiben erhalten."""
|
||||
if value is None:
|
||||
return ""
|
||||
normalized = normalize_inline_exercise_media_markup(str(value))
|
||||
return normalized or ""
|
||||
|
||||
|
||||
def catalog_document(exercise: dict, variants: list[dict], media: list[dict]) -> dict:
|
||||
"""Aktueller Übungsstand. Die Reihenfolge der Varianten und Medien gehört zum Inhalt."""
|
||||
"""Aktueller Übungsstand. Die Reihenfolge der Varianten und Medien gehört zum Inhalt.
|
||||
|
||||
text_format html gilt für summary, goal, execution, preparation, trainer_notes
|
||||
und variants.execution_changes. Titel, Variantenbeschreibung und Material bleiben Text.
|
||||
"""
|
||||
ordered_variants = sorted(
|
||||
variants,
|
||||
key=lambda item: (item.get("sequence_order") is None, item.get("sequence_order") or 0, int(item.get("id") or 0)),
|
||||
@@ -247,12 +261,13 @@ def catalog_document(exercise: dict, variants: list[dict], media: list[dict]) ->
|
||||
)
|
||||
return {
|
||||
"source_id": str(exercise.get("public_id")),
|
||||
"text_format": "html",
|
||||
"title": exercise.get("title") or "",
|
||||
"summary": plaintext(exercise.get("summary")),
|
||||
"goal": plaintext(exercise.get("goal")),
|
||||
"execution": plaintext(exercise.get("execution")),
|
||||
"preparation": plaintext(exercise.get("preparation")),
|
||||
"trainer_notes": plaintext(exercise.get("trainer_notes")),
|
||||
"summary": catalog_html(exercise.get("summary")),
|
||||
"goal": catalog_html(exercise.get("goal")),
|
||||
"execution": catalog_html(exercise.get("execution")),
|
||||
"preparation": catalog_html(exercise.get("preparation")),
|
||||
"trainer_notes": catalog_html(exercise.get("trainer_notes")),
|
||||
"equipment": _equipment_text(exercise) or "",
|
||||
"duration_min": exercise.get("duration_min"),
|
||||
"duration_max": exercise.get("duration_max"),
|
||||
@@ -260,8 +275,8 @@ def catalog_document(exercise: dict, variants: list[dict], media: list[dict]) ->
|
||||
{
|
||||
"id": str(item.get("public_id")),
|
||||
"name": item.get("variant_name") or "",
|
||||
"description": plaintext(item.get("description")),
|
||||
"execution_changes": plaintext(item.get("execution_changes")),
|
||||
"description": (item.get("description") or "").strip(),
|
||||
"execution_changes": catalog_html(item.get("execution_changes")),
|
||||
"sequence_order": item.get("sequence_order"),
|
||||
}
|
||||
for item in ordered_variants
|
||||
|
||||
@@ -345,6 +345,28 @@ def test_catalog_reports_variant_and_media_order_changes() -> None:
|
||||
]
|
||||
|
||||
|
||||
def test_catalog_keeps_stored_html() -> None:
|
||||
exercise = _catalog_exercise()
|
||||
exercise["execution"] = "<p>Stand aufrecht.</p><p>Drehe die <strong>Hüfte</strong>.</p><br><ul><li>eins</li><li>zwei</li></ul>"
|
||||
exercise["goal"] = "<script>alert(1)</script><p>Sehen</p>"
|
||||
variant = [{
|
||||
"id": 1,
|
||||
"public_id": "var-1",
|
||||
"variant_name": "Karte",
|
||||
"description": "Kurzer Text",
|
||||
"execution_changes": "<p>Langsamer.</p><p>Mit Partner.</p>",
|
||||
"sequence_order": 1,
|
||||
}]
|
||||
document = catalog_document(exercise, variant, [])
|
||||
assert document["text_format"] == "html"
|
||||
assert document["execution"] == "<p>Stand aufrecht.</p><p>Drehe die <strong>Hüfte</strong>.</p><br><ul><li>eins</li><li>zwei</li></ul>"
|
||||
assert document["goal"] == "<p>Sehen</p>"
|
||||
assert "<script>" not in document["goal"]
|
||||
assert document["variants"][0]["description"] == "Kurzer Text"
|
||||
assert document["variants"][0]["execution_changes"] == "<p>Langsamer.</p><p>Mit Partner.</p>"
|
||||
assert catalog_hash(catalog_document(exercise, variant, [])) == catalog_hash(document)
|
||||
|
||||
|
||||
def test_catalog_hides_unselected_and_out_of_scope_exercises() -> None:
|
||||
assert catalog_available(True, True) is True
|
||||
assert catalog_available(False, True) is False
|
||||
|
||||
+9
-2
@@ -1,6 +1,6 @@
|
||||
# Shinkan Jinkendo Version Information
|
||||
|
||||
APP_VERSION = "0.8.259"
|
||||
APP_VERSION = "0.8.260"
|
||||
BUILD_DATE = "2026-11-23"
|
||||
DB_SCHEMA_VERSION = "20261123101"
|
||||
|
||||
@@ -39,7 +39,7 @@ MODULE_VERSIONS = {
|
||||
"skill_profiles": "1.0.0", # Phase 3: gewichtetes Fähigkeiten-Profil + skill-discovery/suggestions
|
||||
"methods": "0.1.0",
|
||||
"exercises": "2.39.0", # API-Bereitstellung je Übung, einzeln und als Auswahl
|
||||
"distribution": "1.5.1", # Produktivabruf standardmäßig an; Cursor-Signatur aus dem vorhandenen DB-Geheimnis
|
||||
"distribution": "1.6.0", # Katalogabruf liefert das gespeicherte Übungs-HTML
|
||||
"planning_exercise_suggest": "0.23.8", # Progressionsgraph: Katalog-Kontext (Fokus/Stil/TT/ZG) im Match-Profil
|
||||
"training_units": "0.4.0", # POST .../publish-to-framework: Ablauf aus geplanter Einheit → Rahmen-Slot-Blueprint
|
||||
"training_programs": "0.1.0",
|
||||
@@ -55,6 +55,13 @@ MODULE_VERSIONS = {
|
||||
}
|
||||
|
||||
CHANGELOG = [
|
||||
{
|
||||
"version": "0.8.260",
|
||||
"date": "2026-11-23",
|
||||
"changes": [
|
||||
"Der Katalogabruf gibt Kurztext, Anleitung und Variantenabweichungen als gespeichertes HTML aus. Absätze, Zeilenumbrüche, Listen und Hervorhebungen bleiben erhalten.",
|
||||
],
|
||||
},
|
||||
{
|
||||
"version": "0.8.259",
|
||||
"date": "2026-11-23",
|
||||
|
||||
Reference in new issue
Block a user