Compare commits
8 Commits
integrate-
...
combine-do
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f8725658a5 | ||
|
|
e07c75d857 | ||
|
|
f8a791a4fe | ||
|
|
58ba0b1444 | ||
|
|
994a96a0be | ||
|
|
8acb06764a | ||
|
|
24b6b700be | ||
|
|
0d06f1c085 |
2
.env
2
.env
@@ -1,4 +1,2 @@
|
||||
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__
|
||||
@@ -7,10 +7,9 @@ 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"]
|
||||
CMD ["--app", "app", "run", "--host=0.0.0.0", "--port=80"]
|
||||
|
||||
|
||||
|
||||
@@ -1,23 +1,35 @@
|
||||
from flask import Flask
|
||||
from app import build
|
||||
from pathlib import Path
|
||||
import markdown
|
||||
from pathlib import Path
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
CONTENT_DIR = Path("/content")
|
||||
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**.\n##[test](http://localhost/test)"
|
||||
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 ("/<filename>")
|
||||
def render_post(filename):
|
||||
return build.render_file(filename, CONTENT_DIR)
|
||||
# return "test"
|
||||
@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()
|
||||
|
||||
# return rm(filename)
|
||||
htmlContent = markdown.markdown(textContent)
|
||||
|
||||
return htmlContent
|
||||
|
||||
47
app/build.py
47
app/build.py
@@ -1,39 +1,26 @@
|
||||
from obsidian_parser import Vault
|
||||
import shutil
|
||||
import markdown
|
||||
from pathlib import Path
|
||||
from git import Repo
|
||||
|
||||
|
||||
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 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
|
||||
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 []
|
||||
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")
|
||||
# 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)
|
||||
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)
|
||||
|
||||
@@ -2,4 +2,3 @@ flask
|
||||
markdown
|
||||
obsidianmd-parser
|
||||
GitPython
|
||||
py-gitea
|
||||
|
||||
@@ -7,8 +7,3 @@ services:
|
||||
- '80:80'
|
||||
volumes:
|
||||
- ./content:/content
|
||||
# public_vault_builder:
|
||||
# build:
|
||||
# context: public_vault_builder
|
||||
# volumes:
|
||||
# - ./public_vault:/content
|
||||
|
||||
3
content/index.md
Executable file
3
content/index.md
Executable file
@@ -0,0 +1,3 @@
|
||||
# This is a test
|
||||
and this is p
|
||||
*italics*
|
||||
22
readme.md
Normal file
22
readme.md
Normal 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
|
||||
Reference in New Issue
Block a user