Compare commits
12 Commits
394c70454f
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 17dd144124 | |||
|
|
bacbd48d30 | ||
|
|
62dcfab912 | ||
|
|
6c6cccae49 | ||
|
|
7612837e82 | ||
|
|
fdbced9192 | ||
|
|
99a0df522e | ||
|
|
1b177e3d86 | ||
|
|
d3c8d6e544 | ||
|
|
22ecd5eff5 | ||
| 5b3709cecf | |||
|
|
0834ddc9cb |
4
.env
Normal file
4
.env
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
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
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
app/__pychache__
|
||||||
16
Dockerfile
Executable file
16
Dockerfile
Executable 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"]
|
||||||
|
|
||||||
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
FROM python:3.10-slim AS builder
|
|
||||||
|
|
||||||
ARG DEBUG_MODE=0
|
|
||||||
ENV FLASK_DEBUG=$DEBUG_MODE
|
|
||||||
|
|
||||||
ENV FLASK_APP=app.py
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
COPY . /app
|
|
||||||
|
|
||||||
RUN pip3 install -r requirements.txt
|
|
||||||
|
|
||||||
|
|
||||||
EXPOSE 443
|
|
||||||
ENTRYPOINT ["flask"]
|
|
||||||
CMD ["run", "--host=0.0.0.0", "--port=80"]
|
|
||||||
# CMD ["--app", ".", "run", "--host=0.0.0.0", "--port=443"]
|
|
||||||
|
|
||||||
|
|
||||||
23
app/__init__.py
Normal file
23
app/__init__.py
Normal 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)
|
||||||
35
app/app.py
35
app/app.py
@@ -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
|
|
||||||
39
app/build.py
Normal file
39
app/build.py
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
from obsidian_parser import Vault
|
||||||
|
import shutil
|
||||||
|
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
|
||||||
|
|
||||||
|
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 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)
|
||||||
@@ -1,2 +1,5 @@
|
|||||||
flask
|
flask
|
||||||
markdown
|
markdown
|
||||||
|
obsidianmd-parser
|
||||||
|
GitPython
|
||||||
|
py-gitea
|
||||||
|
|||||||
17
build.sh
Executable file
17
build.sh
Executable file
@@ -0,0 +1,17 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
|
||||||
|
#check for user args
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
echo no args
|
||||||
|
elif [ "$1" = "-b" ]; then
|
||||||
|
build="--build"
|
||||||
|
echo building
|
||||||
|
elif [ "$1" = "-i" ]; then
|
||||||
|
vaultPath="/home/venus/Documents/Personal-Wiki"
|
||||||
|
echo building
|
||||||
|
fi
|
||||||
|
|
||||||
|
#update the .env
|
||||||
|
|
||||||
|
#build public vault
|
||||||
|
docker compose up -d public_vault_builder
|
||||||
@@ -1,11 +1,14 @@
|
|||||||
services:
|
services:
|
||||||
ccu-host:
|
app:
|
||||||
build:
|
build:
|
||||||
# context: /home/venus/code/crimson-clinic/Dockerfile
|
|
||||||
context: app
|
|
||||||
args:
|
args:
|
||||||
- DEBUG_MODE=1
|
- DEBUG_MODE=1
|
||||||
ports:
|
ports:
|
||||||
- '80:80'
|
- '80:80'
|
||||||
volumes:
|
volumes:
|
||||||
- ./content:/content
|
- ./content:/content
|
||||||
|
# public_vault_builder:
|
||||||
|
# build:
|
||||||
|
# context: public_vault_builder
|
||||||
|
# volumes:
|
||||||
|
# - ./public_vault:/content
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
# This is a test
|
# This is a test
|
||||||
and this is p
|
and this is p
|
||||||
|
*italics*
|
||||||
|
|||||||
Reference in New Issue
Block a user