Milestone 1.

This commit is contained in:
2025-08-18 20:14:56 +02:00
parent 9d1623c739
commit 1646d7b827
23 changed files with 1684 additions and 1275 deletions

View File

@@ -1,4 +1,4 @@
from flask import Blueprint, current_app, render_template
from flask import Blueprint, current_app, render_template, url_for
bp = Blueprint("home", __name__)
@@ -7,4 +7,4 @@ bp = Blueprint("home", __name__)
def home():
vault_path = current_app.config.get("KB_VAULT_PATH")
has_vault = bool(vault_path)
return render_template("home.html", vault_path=vault_path, has_vault=has_vault)
return render_template("home.html", vault_path=vault_path, has_vault=has_vault, notes_url=url_for("notes.notes_index"))

50
app/routes/notes.py Normal file
View File

@@ -0,0 +1,50 @@
from __future__ import annotations
from flask import Blueprint, abort, redirect, render_template, request, url_for
from app.services.notes_fs import create_note, list_notes, load_note_by_id, update_note_body
bp = Blueprint("notes", __name__, url_prefix="/notes")
@bp.get("/")
def notes_index():
notes = list_notes()
return render_template("notes/list.html", notes=notes)
@bp.get("/new")
def notes_new():
return render_template("notes/new.html")
@bp.post("/")
def notes_create():
title = (request.form.get("title") or "").strip()
body = (request.form.get("body") or "").strip()
tags_raw = (request.form.get("tags") or "").strip()
tags = [t.strip() for t in tags_raw.split(",") if t.strip()] if tags_raw else []
if not title:
return render_template("notes/new.html", error="Title is required", title=title, body=body, tags_raw=tags_raw), 400
note = create_note(title=title, body=body, tags=tags)
return redirect(url_for("notes.notes_view", note_id=note.id))
@bp.get("/<note_id>")
def notes_view(note_id: str):
note = load_note_by_id(note_id)
if not note:
abort(404)
# M2 will render Markdown; for now show raw body and metadata
return render_template("notes/view.html", note=note)
@bp.post("/<note_id>/body")
def notes_update_body(note_id: str):
new_body = request.form.get("body") or ""
note = update_note_body(note_id, new_body)
if not note:
abort(404)
return redirect(url_for("notes.notes_view", note_id=note.id))