Probably functional. Testing
This commit is contained in:
@@ -9,24 +9,6 @@ from typing import Optional
|
||||
class TemplateManager:
|
||||
def __init__(self, templates_dir: Path):
|
||||
self.templates_dir = templates_dir
|
||||
|
||||
if not templates_dir.exists():
|
||||
templates_dir.mkdir(parents=True)
|
||||
self._create_default_template()
|
||||
|
||||
def _create_default_template(self):
|
||||
"""Create default template"""
|
||||
default_template = {
|
||||
"title": "heur|orig",
|
||||
"created": "heur|orig",
|
||||
"changed": "heur|orig",
|
||||
"authors": "heur|orig",
|
||||
"version": "heur|orig",
|
||||
"tags": "orig|ai default"
|
||||
}
|
||||
|
||||
with open(self.templates_dir / 'default.json', 'w', encoding='utf-8') as f:
|
||||
json.dump(default_template, f, indent=2)
|
||||
|
||||
def load_template(self, name: str) -> dict:
|
||||
"""Load template by name"""
|
||||
@@ -35,8 +17,6 @@ class TemplateManager:
|
||||
if not template_path.exists():
|
||||
# Fallback to default
|
||||
template_path = self.templates_dir / 'default.json'
|
||||
if not template_path.exists():
|
||||
self._create_default_template()
|
||||
|
||||
with open(template_path, 'r', encoding='utf-8') as f:
|
||||
return json.load(f)
|
||||
|
||||
Reference in New Issue
Block a user