vault clones from env vars in compose
This commit is contained in:
47
app/build.py
47
app/build.py
@@ -2,6 +2,7 @@ from obsidian_parser import Vault
|
||||
import shutil
|
||||
import markdown
|
||||
from pathlib import Path
|
||||
import os
|
||||
|
||||
|
||||
def render_file(filename: str, contentPath: Path): #renders markwown from filename
|
||||
@@ -16,24 +17,36 @@ def render_file(filename: str, contentPath: Path): #renders markwown from filena
|
||||
htmlContent = markdown.markdown(textContent)
|
||||
return htmlContent
|
||||
|
||||
print("build imported")
|
||||
# def clone_gittea_repo(url: str, token: str = "", dest: str): # clone a gittea repo using optional security token into dest dirand return a path to the directory
|
||||
# return dest
|
||||
def obsidian_vault(dest = "/vault"): # makes sure there is a vault in dest
|
||||
if os.path.exists(dest):
|
||||
return "vault exists"
|
||||
|
||||
# def public_notes(src: str): # return a list of notes tagged with public from an obsidian directory
|
||||
# # build vault from source
|
||||
# vault = Vault(src)
|
||||
# if vault:
|
||||
# print ("found vault")
|
||||
# else:
|
||||
# print("could not find vault")
|
||||
# return []
|
||||
from git import Repo
|
||||
url = os.getenv("OBSIDIAN_VAULT_URL")
|
||||
token = os.getenv("OBSIDIAN_VAULT_TOKEN")
|
||||
|
||||
# # return a list ofnotes
|
||||
# return vault.get_notes_with_tag("public")
|
||||
if token:
|
||||
print ("token found")
|
||||
url = f"https://{token}@{url}"
|
||||
|
||||
print (f"building vault from {url} in {dest}")
|
||||
Repo.clone_from(url, dest)
|
||||
print("finished vault!")
|
||||
|
||||
def public_notes(src: str): # return a list of notes tagged with public from an obsidian directory
|
||||
# build vault from source
|
||||
vault = Vault(src)
|
||||
if vault:
|
||||
print ("found vault")
|
||||
else:
|
||||
print("could not find vault")
|
||||
return []
|
||||
|
||||
# return a list ofnotes
|
||||
return vault.get_notes_with_tag("public")
|
||||
|
||||
|
||||
# def buld_public_vault(src: str, dest: str): # build the public vault in dest from an obsidian repo in src
|
||||
# for note in public_notes(src):
|
||||
# print(note.title)
|
||||
# shutil.copy2(f"{note.path}", dest)
|
||||
# def public_vault(dest: str, url = "", token = ""): # build the public vault in dest from an obsidian repo in src
|
||||
# for note in public_notes(src):
|
||||
# print(note.title)
|
||||
# shutil.copy2(f"{note.path}", dest)
|
||||
|
||||
Reference in New Issue
Block a user