feat: composer improvements
This commit is contained in:
@@ -264,12 +264,19 @@ async def get_remote_page(hash_hex: str, path: str = Query("index.mu")):
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def _read_local_page(path: str) -> dict:
|
||||
from converter import execute_dynamic_script
|
||||
|
||||
pages_dir = os.environ.get("PAGES_DIR", str(Path.home() / ".nomadnetwork/storage/pages"))
|
||||
filepath = Path(pages_dir) / path
|
||||
try:
|
||||
return {"content": filepath.read_text()}
|
||||
except FileNotFoundError:
|
||||
if not filepath.exists():
|
||||
return {"content": None, "error": "Page not found"}
|
||||
try:
|
||||
if os.access(filepath, os.X_OK):
|
||||
script = filepath.read_text(encoding="utf-8")
|
||||
return {"content": execute_dynamic_script(script)}
|
||||
return {"content": filepath.read_text()}
|
||||
except Exception as exc:
|
||||
return {"content": None, "error": str(exc)}
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user