8 Commits

Author SHA1 Message Date
venus
bacbd48d30 added gitignore again 2026-03-04 18:03:05 -06:00
venus
62dcfab912 updated to render md from content dir 2026-03-04 18:00:42 -06:00
venus
6c6cccae49 added repo key 2026-03-04 16:37:17 -06:00
venus
7612837e82 updated .env 2026-03-04 16:32:39 -06:00
venus
fdbced9192 updated dockerfile and flask app name 2026-03-04 16:29:41 -06:00
venus
99a0df522e moved dockerfile 2026-03-04 16:27:53 -06:00
venus
1b177e3d86 removed some folders 2026-03-04 16:27:30 -06:00
venus
d3c8d6e544 docker works 2026-03-04 16:23:43 -06:00
14 changed files with 75 additions and 140 deletions

2
.env
View File

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

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
app/__pychache__

16
Dockerfile Executable file
View File

@@ -0,0 +1,16 @@
FROM python:3.14-slim
ARG DEBUG_MODE=0
ENV FLASK_DEBUG=$DEBUG_MODE
ENV FLASK_APP=app
RUN mkdir /app
COPY app/requirements.txt /app
RUN pip3 install -r /app/requirements.txt
COPY app /app
ENTRYPOINT ["flask"]
CMD ["run", "--host=0.0.0.0", "--port=80"]

View File

@@ -1,21 +0,0 @@
FROM python:3.10-slim AS builder
ARG DEBUG_MODE=0
ENV FLASK_DEBUG=$DEBUG_MODE
ENV FLASK_APP=app
COPY requirements.txt
RUN pip3 install -r requirements.txt
COPY . .
EXPOSE 443
ENTRYPOINT ["flask"]
# CMD [ "run", "--host=0.0.0.0", "--port=80"]
CMD ["--app", "app", "run", "--host=0.0.0.0", "--port=443"]

View File

@@ -1,35 +0,0 @@
from flask import Flask
import markdown
from pathlib import Path
app = Flask(__name__)
CONTENT_DIR = Path(__file__).parent.parent / "content"
@app.route("/hello")
def hello_world():
return "<h1>Hello, World!</h1>"
@app.route("/")
def index():
# Write your markdown content
md_content = "# Welcome to my blog!\nThis is rendered from **Markdown**."
# Convert it to HTML
html_content = markdown.markdown(md_content)
return html_content
@app.route ("/post/<filename>")
def render_markdown_file(filename):
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

23
app/__init__.py Normal file
View File

@@ -0,0 +1,23 @@
from flask import Flask
from app import build
from pathlib import Path
import markdown
app = Flask(__name__)
CONTENT_DIR = Path("/content")
@app.route("/")
def index():
# Write your markdown content
md_content = "# Welcome to my blog!\nThis is rendered from **Markdown**.\n##[test](http://localhost/test)"
# Convert it to HTML
html_content = markdown.markdown(md_content)
return html_content
@app.route ("/<filename>")
def render_post(filename):
return build.render_file(filename, CONTENT_DIR)
# return "test"
# return rm(filename)

View File

@@ -1,26 +1,39 @@
from obsidian_parser import Vault from obsidian_parser import Vault
import shutil import shutil
from git import Repo import markdown
from pathlib import Path
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 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 print("build imported")
return dest # 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 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
vault = Vault(src) # vault = Vault(src)
if vault: # if vault:
print ("found vault") # print ("found vault")
else: # else:
print("could not find vault") # print("could not find vault")
return [] # return []
# return a list ofnotes # # return a list ofnotes
return vault.get_notes_with_tag("public") # 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 # 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

@@ -1,2 +1,5 @@
flask flask
markdown markdown
obsidianmd-parser
GitPython
py-gitea

View File

@@ -1,7 +1,6 @@
services: services:
app: app:
build: build:
context: app
args: args:
- DEBUG_MODE=1 - DEBUG_MODE=1
ports: ports:

View File

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

View File

@@ -1,14 +0,0 @@
FROM python:3.12-slim
run mkdir /public-vault
WORKDIR /build
COPY requirements.txt .
RUN pip3 install -r requirements.txt
COPY . .
CMD ["python", "build.py"]

View File

@@ -1,25 +0,0 @@
from obsidian_parser import Vault
import shutil
from git import Repo
# repo_url = "https://gitlab.com/username/my-vault.git"
dest = "/content"
src = "Personal-Wiki"
# Load a vault
vault = Vault(src)
if vault:
print ("found vault")
else:
print("could not find vault")
# Find notes by exact name
note = vault.get_note("test")
# Findd all public notes
publicNotes = vault.get_notes_with_tag("public")
for note in publicNotes:
print(note.title)
shutil.copy2(f"{note.path}", dest)

View File

@@ -1,2 +0,0 @@
obsidianmd-parser
GitPython

View File

@@ -1,22 +0,0 @@
# 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