summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-05-05 10:18:05 +0200
committerDanilo M. <danix@danix.xyz>2026-05-05 10:18:05 +0200
commit0b192692a3108ca9def1f462aa5bb2489fa87690 (patch)
tree26eeb78e02e836a73969a7e7b7be44951742cc9f
parentc554c8cd4a2b603f4a97f50adf78bc82c5e74d9d (diff)
downloadpublisher-0b192692a3108ca9def1f462aa5bb2489fa87690.tar.gz
publisher-0b192692a3108ca9def1f462aa5bb2489fa87690.zip
fix: use lowercase article types and restore selection in FrontmatterEditor
ARTICLE_TYPES lowercased to match Hugo theme expectations. FrontmatterEditor now matches the existing frontmatter value case-insensitively so the correct type is selected rather than defaulting to the first item. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
-rw-r--r--TODO.md2
-rw-r--r--core/models.py2
-rw-r--r--tests/test_models.py4
-rw-r--r--ui/frontmatter_editor.py5
4 files changed, 7 insertions, 6 deletions
diff --git a/TODO.md b/TODO.md
index c888c8b..e38edf7 100644
--- a/TODO.md
+++ b/TODO.md
@@ -19,7 +19,7 @@
## frontmatter
### taxonomies
-- [ ] when modifying the frontmatter, the square brackets around the tags or categories lists are not maintained.
+- [✅] when modifying the frontmatter, the square brackets around the tags or categories lists are not maintained.
### article types
- [ ] the program should respect the article type already set in the frontmatter and don't default to "Life" if the article is set to something else.
- [ ] the theme expects the article type to be lowercase. The program currently writes them as uppercase
diff --git a/core/models.py b/core/models.py
index 9a7cff5..e7f0c36 100644
--- a/core/models.py
+++ b/core/models.py
@@ -2,7 +2,7 @@ from __future__ import annotations
from dataclasses import dataclass
from pathlib import Path
-ARTICLE_TYPES = ["Life", "Photo", "Link", "Quote", "Tech"]
+ARTICLE_TYPES = ["life", "photo", "link", "quote", "tech"]
@dataclass
diff --git a/tests/test_models.py b/tests/test_models.py
index 3d83653..29564dc 100644
--- a/tests/test_models.py
+++ b/tests/test_models.py
@@ -4,8 +4,8 @@ from core.models import Article, ARTICLE_TYPES
def test_article_types_contains_five():
assert len(ARTICLE_TYPES) == 5
- assert "Tech" in ARTICLE_TYPES
- assert "Life" in ARTICLE_TYPES
+ assert "tech" in ARTICLE_TYPES
+ assert "life" in ARTICLE_TYPES
def test_article_fields():
diff --git a/ui/frontmatter_editor.py b/ui/frontmatter_editor.py
index 160536e..add9a41 100644
--- a/ui/frontmatter_editor.py
+++ b/ui/frontmatter_editor.py
@@ -75,8 +75,9 @@ class FrontmatterEditor(QDialog):
if key == "type":
widget = QComboBox()
widget.addItems(ARTICLE_TYPES)
- if str(val) in ARTICLE_TYPES:
- widget.setCurrentText(str(val))
+ val_lower = str(val).lower()
+ if val_lower in ARTICLE_TYPES:
+ widget.setCurrentText(val_lower)
self._fields[key] = widget
elif key == "tags":
widget = QLineEdit(", ".join(str(v) for v in val) if isinstance(val, list) else str(val))