From bf217ec0818ca35b1960c6a25bf498b6a3e5ab1c Mon Sep 17 00:00:00 2001 From: haikdc Date: Sun, 5 Apr 2026 16:58:14 -0700 Subject: [PATCH] [Haik]: ckpt, abstracted the templates functionality and swap contents to be legit files --- backend/apps/app_builder/app_builder.py | 2 +- .../content}/app_builder_skill.md | 0 .../content/template_index.html} | 25 +------------------ .../templates/content/template_meta.json | 4 +++ .../apps/app_builder/templates/templates.py | 20 +++++++++++++++ 5 files changed, 26 insertions(+), 25 deletions(-) rename backend/apps/app_builder/{ => templates/content}/app_builder_skill.md (100%) rename backend/apps/app_builder/{templates.py => templates/content/template_index.html} (69%) create mode 100644 backend/apps/app_builder/templates/content/template_meta.json create mode 100644 backend/apps/app_builder/templates/templates.py diff --git a/backend/apps/app_builder/app_builder.py b/backend/apps/app_builder/app_builder.py index 8989fc52..0dc1a454 100644 --- a/backend/apps/app_builder/app_builder.py +++ b/backend/apps/app_builder/app_builder.py @@ -17,7 +17,7 @@ from backend.apps.app_builder.App import ( ) from backend.config.paths import DB_ROOT from backend.apps.app_builder.executor import execute_backend_code -from backend.apps.app_builder.templates import APP_BUILDER_SKILL, APP_BUILDER_TEMPLATE_FILES +from backend.apps.app_builder.templates.templates import APP_BUILDER_SKILL, APP_BUILDER_TEMPLATE_FILES from backend.apps.app_builder.helpers import walk_directory APP_BUILDER_DIR = os.path.join(DB_ROOT, "app_builder") diff --git a/backend/apps/app_builder/app_builder_skill.md b/backend/apps/app_builder/templates/content/app_builder_skill.md similarity index 100% rename from backend/apps/app_builder/app_builder_skill.md rename to backend/apps/app_builder/templates/content/app_builder_skill.md diff --git a/backend/apps/app_builder/templates.py b/backend/apps/app_builder/templates/content/template_index.html similarity index 69% rename from backend/apps/app_builder/templates.py rename to backend/apps/app_builder/templates/content/template_index.html index 2eb288b9..c08b3b76 100644 --- a/backend/apps/app_builder/templates.py +++ b/backend/apps/app_builder/templates/content/template_index.html @@ -1,13 +1,3 @@ -"""Default template files seeded into new App Builder workspaces.""" - -import os - -_SKILL_PATH = os.path.join(os.path.dirname(__file__), "app_builder_skill.md") - -with open(_SKILL_PATH) as _f: - APP_BUILDER_SKILL = _f.read() - -APP_BUILDER_TEMPLATE_INDEX = """\ @@ -47,17 +37,4 @@ APP_BUILDER_TEMPLATE_INDEX = """\ - -""" - -APP_BUILDER_TEMPLATE_META = """\ -{ - "name": "", - "description": "" -} -""" - -APP_BUILDER_TEMPLATE_FILES = { - "index.html": APP_BUILDER_TEMPLATE_INDEX, - "meta.json": APP_BUILDER_TEMPLATE_META, -} + \ No newline at end of file diff --git a/backend/apps/app_builder/templates/content/template_meta.json b/backend/apps/app_builder/templates/content/template_meta.json new file mode 100644 index 00000000..b9fd3854 --- /dev/null +++ b/backend/apps/app_builder/templates/content/template_meta.json @@ -0,0 +1,4 @@ +{ + "name": "", + "description": "" +} \ No newline at end of file diff --git a/backend/apps/app_builder/templates/templates.py b/backend/apps/app_builder/templates/templates.py new file mode 100644 index 00000000..9b9c367f --- /dev/null +++ b/backend/apps/app_builder/templates/templates.py @@ -0,0 +1,20 @@ +"""Default template files seeded into new App Builder workspaces.""" + +import os +from typing import Dict +from typeguard import typechecked + +P_SELF_DIR = os.path.dirname(__file__) +P_CONTENT_DIR = os.path.join(P_SELF_DIR, "content") + +@typechecked +def p_read(filename: str) -> str: + with open(os.path.join(P_CONTENT_DIR, filename)) as f: + return f.read() + +APP_BUILDER_SKILL: str = p_read("app_builder_skill.md") + +APP_BUILDER_TEMPLATE_FILES: Dict[str, str] = { + "index.html": p_read("template_index.html"), + "meta.json": p_read("template_meta.json"), +} \ No newline at end of file