8 Commits

Author SHA1 Message Date
venus
f8725658a5 docker works 2026-03-04 16:22:41 -06:00
venus
e07c75d857 updated compose and moved dockerfile 2026-03-04 16:09:55 -06:00
venus
f8a791a4fe changed to __init__.py 2026-03-04 16:08:22 -06:00
venus
58ba0b1444 added gitignore 2026-03-04 16:07:56 -06:00
venus
994a96a0be updated requirements from deleted build.py 2026-03-04 16:07:05 -06:00
venus
8acb06764a removed public vault dir 2026-03-04 16:05:00 -06:00
venus
24b6b700be removed dir 2026-03-04 16:02:28 -06:00
venus
0d06f1c085 unsure 2026-03-04 16:01:53 -06:00
8 changed files with 57 additions and 84 deletions

3
.env
View File

@@ -1,5 +1,2 @@
obsidian_vault=/home/venus/Documents/Personal-Wiki obsidian_vault=/home/venus/Documents/Personal-Wiki
obsidian_vault_url=git.riverrooks.dev/Personal-Wiki
OBSIDIAN_VAULT_URL=git.riverrooks.dev/Personal-Wiki
obsidian_vault_token=bd8cd9301ae2c1c5bacfb3340492acb5e862686a

View File

@@ -1,29 +1,15 @@
FROM python:3.14-slim FROM python:3.14-slim
#install git
RUN apt-get update && apt-get install -y \
git \
&& rm -rf /var/lib/apt/lists/*
#install dependencies
RUN mkdir /app
COPY app/requirements.txt /app
RUN pip3 install -r /app/requirements.txt
#parse from .env file
ARG DEBUG_MODE=0 ARG DEBUG_MODE=0
ARG obsidian_vault=/home/venus/Documents/Personal-Wiki
ARG OBSIDIAN_VAULT_URL=git.riverrooks.dev/venus/Personal-Wiki
ARG obsidian_vault_token=bd8cd9301ae2c1c5bacfb3340492acb5e862686a
ENV FLASK_DEBUG=$DEBUG_MODE ENV FLASK_DEBUG=$DEBUG_MODE
ENV FLASK_APP=app ENV FLASK_APP=app
# ENV OBSIDIAN_VAULT=$obsidian_vault
ENV OBSIDIAN_VAULT_URL=$OBSIDIAN_VAULT_URL
ENV OBSIDIAN_VAULT_TOKEN=$obsidian_vault_token
RUN mkdir /app
COPY app/requirements.txt /app
RUN pip3 install -r /app/requirements.txt
COPY app /app COPY app /app
ENTRYPOINT ["flask"] ENTRYPOINT ["flask"]
CMD ["run", "--host=0.0.0.0", "--port=80"] CMD ["--app", "app", "run", "--host=0.0.0.0", "--port=80"]

View File

@@ -1,34 +1,35 @@
from flask import Flask from flask import Flask
from app import build
from pathlib import Path
import markdown import markdown
import os from pathlib import Path
from dotenv import load_dotenv
vault_path = os.getenv("VAULT_PATH", "/vault") # Optional default value
app = Flask(__name__) app = Flask(__name__)
CONTENT_DIR = Path("/content") CONTENT_DIR = Path(__file__).parent.parent / "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("/hello")
def hello_world():
return "<h1>Hello, World!</h1>"
@app.route("/") @app.route("/")
def index(): def index():
# Write your markdown content # Write your markdown content
md_content = "# Welcome to my blog!\nThis is rendered from **Markdown**.\n##[test](http://localhost/test)" md_content = "# Welcome to my blog!\nThis is rendered from **Markdown**."
# Convert it to HTML # Convert it to HTML
html_content = markdown.markdown(md_content) html_content = markdown.markdown(md_content)
return html_content return html_content
@app.route ("/<filename>") # renders a filename if not otherwise specified @app.route ("/post/<filename>")
def render_post(filename): def render_markdown_file(filename):
return build.render_file(filename, CONTENT_DIR) filePath = CONTENT_DIR / f"{filename}.md"
# 3. Protect against missing files
if not filePath.is_file():
return f"<h1>404</h1><p>Could not find {filename}.md in {filePath}</p>", 404
# else:
# return f"<h1> found</h1> <p> found {filename} in {filePath}</p>"
# 4. Open, read, and convert the file
with open(filePath, "r", encoding="utf-8") as f:
textContent = f.read()
htmlContent = markdown.markdown(textContent)
return htmlContent

View File

@@ -1,37 +1,11 @@
from obsidian_parser import Vault from obsidian_parser import Vault
import shutil import shutil
import markdown from git import Repo
from pathlib import Path
import os
def render_file(filename: str, contentPath: Path): #renders markwown from filename
filePath = contentPath / f"{filename}.md"
# 3. Protect against missing files
if not filePath.is_file():
return f"<h1>404</h1><p>Could not find {filename}.md in {filePath}</p>", 404
# open the file for reading
with open(filePath, "r", encoding="utf-8") as f:
textContent = f.read()
# convert it to markdown
htmlContent = markdown.markdown(textContent)
return htmlContent
def obsidian_vault(dest = "/vault"): # makes sure there is a vault in dest def clone_secure_repo(url: str, token: str = "", dest: str): # clone a gittea repo using optional security token into dest dirand return a path to the directory
if os.path.exists(dest): return dest
return "vault exists"
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}"
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 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
@@ -46,7 +20,7 @@ def public_notes(src: str): # return a list of notes tagged with public from an
return vault.get_notes_with_tag("public") return vault.get_notes_with_tag("public")
# def public_vault(dest: str, url = "", token = ""): # build the public vault in dest from an obsidian repo in src 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): for note in public_notes(src):
# print(note.title) print(note.title)
# shutil.copy2(f"{note.path}", dest) shutil.copy2(f"{note.path}", dest)

View File

@@ -2,4 +2,3 @@ flask
markdown markdown
obsidianmd-parser obsidianmd-parser
GitPython GitPython
python-dotenv

View File

@@ -3,16 +3,7 @@ services:
build: build:
args: args:
- DEBUG_MODE=1 - DEBUG_MODE=1
- obsidian_vault_url=https://git.riverrooks.dev/Personal-Wiki
- obsidian_vault_token=bd8cd9301ae2c1c5bacfb3340492acb5e862686a
ports: ports:
- '80:80' - '80:80'
volumes: volumes:
- ./content:/content - ./content:/content
# - /home/venus/Documents/Personal-Wiki:/vault
# public_vault_builder:
# build:
# context: public_vault_builder
# volumes:
# - ./public_vault:/content

3
content/index.md Executable file
View File

@@ -0,0 +1,3 @@
# This is a test
and this is p
*italics*

22
readme.md Normal file
View File

@@ -0,0 +1,22 @@
# Architecture
/app
> containts all of the files to build and run the docker container.Docker containter runs the application
/content
> contains all of the publicly accessible files
templates
notes
index
...
compose # compose file to mount content to app
build.sh #optional file to build the app
.env # enviroment var files for location of existing public directory. will depricate
# Dockerfile
> builds the flask application and sets it to run.
- runs the site
# app
- clones the public repo (from env var url)
- finds public notes and moves to content vault
- exposes webhook to update vault and public notes