updated gitignore and build.py works to update vault

This commit is contained in:
venus
2026-03-04 23:10:09 -06:00
parent f22fb410ab
commit 35f0edbc83
4 changed files with 14 additions and 13 deletions

1
.gitignore vendored
View File

@@ -1 +1,2 @@
app/__pychache__ app/__pychache__
public-vault

View File

@@ -13,13 +13,6 @@ CONTENT_DIR = Path("/content")
VAULT_DIR = "/vault" VAULT_DIR = "/vault"
build.obsidian_vault(VAULT_DIR) 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("/") @app.route("/")
def index(): def index():
@@ -31,4 +24,4 @@ def index():
@app.route ("/<filename>") # renders a filename if not otherwise specified @app.route ("/<filename>") # renders a filename if not otherwise specified
def render_post(filename): def render_post(filename):
return build.render_file(filename, CONTENT_DIR) return build.html_file(filename, CONTENT_DIR)

View File

@@ -5,7 +5,7 @@ from pathlib import Path
import os 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" filePath = contentPath / f"{filename}.md"
# 3. Protect against missing files # 3. Protect against missing files
if not filePath.is_file(): if not filePath.is_file():
@@ -18,20 +18,27 @@ def render_file(filename: str, contentPath: Path): #renders markwown from filena
return htmlContent return htmlContent
def obsidian_vault(dest = "/vault"): # makes sure there is a vault in dest def obsidian_vault(dest = "/vault"): # makes sure there is a vault in dest
if os.path.exists(dest): # TO DO account for vault existing and not being a valid repo
return "vault exists"
from git import Repo from git import Repo
url = os.getenv("OBSIDIAN_VAULT_URL") url = os.getenv("OBSIDIAN_VAULT_URL")
token = os.getenv("OBSIDIAN_VAULT_TOKEN") token = os.getenv("OBSIDIAN_VAULT_TOKEN")
if token: if token:
print ("token found") print ("token found")
url = f"https://{token}@{url}" 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}") print (f"building vault from {url} in {dest}")
Repo.clone_from(url, dest) Repo.clone_from(url, dest)
print("finished vault!") print("finished vault!")
return 1
def public_notes(src: str): # return a list of notes tagged with public from an obsidian directory def public_notes(src: str): # return a list of notes tagged with public from an obsidian directory
# build vault from source # build vault from source

View File

@@ -10,4 +10,4 @@ services:
- '80:80' - '80:80'
volumes: volumes:
- ./content:/content - ./content:/content
- /home/venus/Documents/Personal-Wiki:/vault - ./public-vault:/vault