summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pyproject.toml7
-rw-r--r--src/vtt_publish/tui.py72
-rw-r--r--uv.lock2
3 files changed, 63 insertions, 18 deletions
diff --git a/pyproject.toml b/pyproject.toml
index dcde496..eb0ab45 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -11,6 +11,13 @@ dependencies = [
[project.scripts]
publish = 'vtt_publish.tui:main'
+[build-system]
+requires = ["hatchling"]
+build-backend = "hatchling.build"
+
+[tool.hatch.build.targets.wheel]
+packages = ["src/vtt_publish"]
+
[tool.bumpversion]
current_version = "0.3.0"
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
diff --git a/src/vtt_publish/tui.py b/src/vtt_publish/tui.py
index f70e96f..4d6bf4a 100644
--- a/src/vtt_publish/tui.py
+++ b/src/vtt_publish/tui.py
@@ -21,7 +21,37 @@ DEFAULT_CONFIG = {
"Scenes": "scenes",
"Tokens": "tokens",
"Maps": "maps",
- "Handouts": "handouts"
+ "Handouts": "handouts",
+ "Misc": "misc"
+ },
+
+ "ignore_patterns": [
+ "_wip",
+ "_ref",
+ "backup",
+ "old_version",
+ ".git",
+ "__pycache__"
+ ],
+
+ "category_keywords": {
+ "token": "Tokens",
+ "creature": "Tokens",
+ "npc": "Tokens",
+ "character": "Tokens",
+
+ "handout": "Handouts",
+ "letter": "Handouts",
+ "clue": "Handouts",
+ "paper": "Handouts",
+
+ "battlemap": "Maps",
+ "map": "Maps",
+ "grid": "Maps",
+
+ "scene": "Scenes",
+ "bg": "Scenes",
+ "landing": "Scenes"
}
}
@@ -285,12 +315,25 @@ class PublisherApp(App):
self.log_message("System initialized.")
- if not os.path.exists("mock_campaign"):
- create_mock_files()
- try:
- self.query_one(CampaignTree).reload()
- except:
- pass
+ def is_ignored(self, path: Path) -> bool:
+ """Check if path contains any ignored patterns."""
+ path_str = str(path).lower()
+ for pattern in CONFIG.get("ignore_patterns", []):
+ if pattern.lower() in path_str:
+ return True
+ return False
+
+ def guess_category(self, path: Path) -> str:
+ """Guess category based on path keywords."""
+ path_str = str(path).lower()
+
+ # Iterate through keywords in config
+ for keyword, category in CONFIG.get("category_keywords", {}).items():
+ if keyword in path_str:
+ return category
+
+ # Default fallback
+ return "Misc"
# --- ACTIONS & LOGIC ---
def log_message(self, msg: str):
@@ -321,28 +364,24 @@ class PublisherApp(App):
root = Path(root_path)
- # Simple recursive scan mock
for path in root.rglob("*.webp"):
- # Simple heuristic mock
- cat = "Scenes"
- if "creatures" in str(path):
- cat = "Tokens"
- if "handouts" in str(path):
- cat = "Handouts"
+ if self.is_ignored(path):
+ continue
+
+ cat = self.guess_category(path)
full_path_str = str(path.resolve())
current_mtime = path.stat().st_mtime
status = "[NEW]"
- should_check = False
if full_path_str in self.history:
last_record = self.history[full_path_str]
+ cat = last_record.get("category", cat)
last_mtime = last_record.get("mtime", 0)
if current_mtime > last_mtime:
status = "[MOD]"
- should_check = False
else:
status = "[OK]"
@@ -353,7 +392,6 @@ class PublisherApp(App):
initial_icon = table.ICON_UNCHECKED
- # Add row
table.add_row(
initial_icon,
status,
diff --git a/uv.lock b/uv.lock
index a691c8f..2565768 100644
--- a/uv.lock
+++ b/uv.lock
@@ -120,7 +120,7 @@ wheels = [
[[package]]
name = "vtt-publish"
-version = "0.2.0"
+version = "0.3.0"
source = { virtual = "." }
dependencies = [
{ name = "textual" },