diff options
Diffstat (limited to 'src/vtt_publish/tui.py')
| -rw-r--r-- | src/vtt_publish/tui.py | 72 |
1 files changed, 55 insertions, 17 deletions
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, |
