From 35f0edbc83281c8058e70d5e9af1f14ee07e57b1 Mon Sep 17 00:00:00 2001 From: venus Date: Wed, 4 Mar 2026 23:10:09 -0600 Subject: [PATCH] updated gitignore and build.py works to update vault --- .gitignore | 1 + app/__init__.py | 9 +-------- app/build.py | 15 +++++++++++---- compose.yml | 2 +- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 7de00e0..7d3326f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ app/__pychache__ +public-vault diff --git a/app/__init__.py b/app/__init__.py index 72fcb53..bb5293a 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -13,13 +13,6 @@ CONTENT_DIR = Path("/content") VAULT_DIR = "/vault" build.obsidian_vault(VAULT_DIR) -# Find obsidian vault path or clone it -# if not os.path.exists(VAULT_DIR): -# # print(os.getenv("OBSIDIAN_VAULT_URL")) -# build.clone_gittea_repo(os.getenv("OBSIDIAN_VAULT_URL"), VAULT_DIR, os.getenv("OBSIDIAN_VALUT_TOKEN")) -# else: -# print("vault already exists") - @app.route("/") def index(): @@ -31,4 +24,4 @@ def index(): @app.route ("/") # renders a filename if not otherwise specified def render_post(filename): - return build.render_file(filename, CONTENT_DIR) + return build.html_file(filename, CONTENT_DIR) diff --git a/app/build.py b/app/build.py index 5f48b42..905483d 100644 --- a/app/build.py +++ b/app/build.py @@ -5,7 +5,7 @@ from pathlib import Path import os -def render_file(filename: str, contentPath: Path): #renders markwown from filename +def html_file(filename: str, contentPath: Path): #renders markwown from filename filePath = contentPath / f"{filename}.md" # 3. Protect against missing files if not filePath.is_file(): @@ -18,20 +18,27 @@ def render_file(filename: str, contentPath: Path): #renders markwown from filena return htmlContent def obsidian_vault(dest = "/vault"): # makes sure there is a vault in dest - if os.path.exists(dest): - return "vault exists" - + # TO DO account for vault existing and not being a valid repo from git import Repo url = os.getenv("OBSIDIAN_VAULT_URL") token = os.getenv("OBSIDIAN_VAULT_TOKEN") + if token: print ("token found") url = f"https://{token}@{url}" + if os.path.exists(os.path.join(dest, '.git')): + print (f"pulling vault from {url} in {dest}") + repo = Repo(dest) + origin = repo.remotes.origin + origin.pull() + return 1 + print (f"building vault from {url} in {dest}") Repo.clone_from(url, dest) print("finished vault!") + return 1 def public_notes(src: str): # return a list of notes tagged with public from an obsidian directory # build vault from source diff --git a/compose.yml b/compose.yml index a718c2a..e4935e2 100755 --- a/compose.yml +++ b/compose.yml @@ -10,4 +10,4 @@ services: - '80:80' volumes: - ./content:/content - - /home/venus/Documents/Personal-Wiki:/vault + - ./public-vault:/vault