improved readability
This commit is contained in:
@@ -5,15 +5,13 @@ import markdown
|
|||||||
import os
|
import os
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
vault_path = os.getenv("VAULT_PATH", "/vault") # Optional default value
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
PRIVATE_VAULR_DIR = Path("/content")
|
PRIVATE_VAULT_DIR = Path("/vault")
|
||||||
PUBLIC_VAULT_DIR = "/vault"
|
PUBLIC_VAULT_DIR = "/content"
|
||||||
|
|
||||||
build.obsidian_vault(VAULT_DIR) # initialize the private obsidian repo
|
build.obsidian_vault(PRIVATE_VAULT_DIR) # initialize the private obsidian repo
|
||||||
build.public_vault(VAULT_DIR) # initialize the public notes from the private repo
|
build.public_vault(PUBLIC_VAULT_DIR) # initialize the public notes from the private repo
|
||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
def index():
|
def index():
|
||||||
@@ -25,4 +23,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.html_file(filename, CONTENT_DIR)
|
return build.html_file(filename, PUBLIC_VAULT_DIR)
|
||||||
|
|||||||
@@ -26,7 +26,9 @@ def obsidian_vault(dest = "/vault"): # makes sure there is a vault in dest
|
|||||||
print ("token not found, cant build vault")
|
print ("token not found, cant build vault")
|
||||||
raise NameError("tokenNotFound")
|
raise NameError("tokenNotFound")
|
||||||
return 0
|
return 0
|
||||||
url = f"https://{token}@{url}"
|
|
||||||
|
url = f"https://{token}@{url}"
|
||||||
|
|
||||||
if os.path.exists(os.path.join(dest, '.git')):
|
if os.path.exists(os.path.join(dest, '.git')):
|
||||||
#TODO handle merge conflictsjjj
|
#TODO handle merge conflictsjjj
|
||||||
print (f"pulling vault from {url} in {dest}")
|
print (f"pulling vault from {url} in {dest}")
|
||||||
@@ -52,7 +54,8 @@ def public_notes(src: str): # return a list of notes tagged with public from an
|
|||||||
# return a list of notes
|
# return a list of notes
|
||||||
return vault.get_notes_with_tag("public")
|
return vault.get_notes_with_tag("public")
|
||||||
|
|
||||||
def public_vault(dest: str): # build the public vault in dest from an obsidian repo in src
|
|
||||||
|
def public_vault(dest: str, src: str = "/content"): # build the public vault in dest from an obsidian repo in src
|
||||||
for note in public_notes(src):
|
for note in public_notes(src):
|
||||||
print(note.title)
|
print(note.title)
|
||||||
shutil.copy2(f"{note.path}", dest)
|
shutil.copy2(f"{note.path}", dest)
|
||||||
|
|||||||
@@ -9,5 +9,5 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- '80:80'
|
- '80:80'
|
||||||
volumes:
|
volumes:
|
||||||
- ./content:/content
|
- ./content:/content #public
|
||||||
- ./public-vault:/vault
|
- ./public-vault:/vault #private
|
||||||
|
|||||||
Reference in New Issue
Block a user