updated gitignore and build.py works to update vault
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
||||
app/__pychache__
|
||||
public-vault
|
||||
|
||||
@@ -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 ("/<filename>") # 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)
|
||||
|
||||
15
app/build.py
15
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
|
||||
|
||||
@@ -10,4 +10,4 @@ services:
|
||||
- '80:80'
|
||||
volumes:
|
||||
- ./content:/content
|
||||
- /home/venus/Documents/Personal-Wiki:/vault
|
||||
- ./public-vault:/vault
|
||||
|
||||
Reference in New Issue
Block a user