From 8b5a71dd3a490718540a7e9d48da2a220256a628 Mon Sep 17 00:00:00 2001 From: Naz Date: Mon, 15 Sep 2025 14:50:08 +0100 Subject: =?UTF-8?q?=E2=9C=A8feat:=20dirty=20commit=20bringing=20basic=20fu?= =?UTF-8?q?nctionality?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/handlers.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/handlers.rs (limited to 'src/handlers.rs') diff --git a/src/handlers.rs b/src/handlers.rs new file mode 100644 index 0000000..b235c84 --- /dev/null +++ b/src/handlers.rs @@ -0,0 +1,28 @@ +use askama::Template; +use axum::{extract::State, response::Html}; + +use crate::{ + Result, + config::Config, + models::{Bookmarks, Section}, +}; + +#[derive(Template)] +#[template(path = "index.html")] +pub struct MyTemplate { + bookmarks: Vec
, +} + +pub async fn handler(State(config): State) -> Result> { + let bookmarks = std::fs::read_to_string(config.bookmarks_file)?; + + let bookmarks: Bookmarks = serde_json::from_str(&bookmarks)?; + + let template = MyTemplate { + bookmarks: bookmarks.sections, + }; + + let html = template.render()?; + + Ok(Html(html)) +} -- cgit v1.2.3