aboutsummaryrefslogtreecommitdiff
path: root/src/handlers/talks.rs
diff options
context:
space:
mode:
authorXe Iaso <me@christine.website>2022-11-25 19:01:10 -0500
committerGitHub <noreply@github.com>2022-11-25 19:01:10 -0500
commitcc933b31fd23bb06e95bf41f848a1c99353d44ae (patch)
treeaf8288dbd4db2ad886d6b326bffb1c9d5b568de3 /src/handlers/talks.rs
parent551e0384c923ff3ee98cfddf7e3eb42c6dbb2941 (diff)
downloadxesite-cc933b31fd23bb06e95bf41f848a1c99353d44ae.tar.xz
xesite-cc933b31fd23bb06e95bf41f848a1c99353d44ae.zip
Start version 3 (#573)
* Start version 3 * Change version to 3.0.0 in Cargo.toml * Add metadata for series * Change types for signal boosts * Add start of LaTeX resume generation at Nix time * Add start of proper author tagging for posts in JSONFeed and ldjson * Convert templates to use Maud * Add start of dynamic resume generation from dhall * Make patrons page embed thumbnails TODO: * [ ] Remove the rest of the old templates * [ ] Bring in Xeact for the share on mastodon button * [ ] Site update post Signed-off-by: Xe <me@christine.website> * fix nix builds Signed-off-by: Xe Iaso <me@christine.website> * fix dhall build Signed-off-by: Xe Iaso <me@christine.website> * fix non-flakes build Signed-off-by: Xe Iaso <me@christine.website> * make new mastodon share button Signed-off-by: Xe Iaso <me@christine.website> * remove the rest of the ructe templates that I can remove Signed-off-by: Xe Iaso <me@christine.website> * refactor blogposts to its own file Signed-off-by: Xe Iaso <me@christine.website> * move resume to be generated by nix Signed-off-by: Xe Iaso <me@christine.website> * write article Signed-off-by: Xe Iaso <me@christine.website> * blog/site-update-v3: hero image Signed-off-by: Xe Iaso <me@christine.website> * add site update series tag to site updates Signed-off-by: Xe Iaso <me@christine.website> Signed-off-by: Xe <me@christine.website> Signed-off-by: Xe Iaso <me@christine.website>
Diffstat (limited to 'src/handlers/talks.rs')
-rw-r--r--src/handlers/talks.rs28
1 files changed, 11 insertions, 17 deletions
diff --git a/src/handlers/talks.rs b/src/handlers/talks.rs
index 59d8676..262e481 100644
--- a/src/handlers/talks.rs
+++ b/src/handlers/talks.rs
@@ -1,11 +1,9 @@
-use super::{Error::*, Result};
-use crate::{app::State, post::Post, templates};
-use axum::{
- extract::{Extension, Path},
- response::Html,
-};
-use http::header::HeaderMap;
+use super::Result;
+use crate::{app::State, post::Post, tmpl};
+use axum::extract::{Extension, Path};
+use http::{header::HeaderMap, StatusCode};
use lazy_static::lazy_static;
+use maud::Markup;
use prometheus::{opts, register_int_counter_vec, IntCounterVec};
use std::sync::Arc;
use tracing::instrument;
@@ -19,11 +17,9 @@ lazy_static! {
}
#[instrument(skip(state))]
-pub async fn index(Extension(state): Extension<Arc<State>>) -> Result {
+pub async fn index(Extension(state): Extension<Arc<State>>) -> Result<Markup> {
let state = state.clone();
- let mut result: Vec<u8> = vec![];
- templates::talkindex_html(&mut result, state.talks.clone())?;
- Ok(Html(result))
+ Ok(tmpl::post_index(&state.talks, "Talks", false))
}
#[instrument(skip(state, headers))]
@@ -31,7 +27,7 @@ pub async fn post_view(
Path(name): Path<String>,
Extension(state): Extension<Arc<State>>,
headers: HeaderMap,
-) -> Result {
+) -> Result<(StatusCode, Markup)> {
let mut want: Option<Post> = None;
let want_link = format!("talks/{}", name);
@@ -49,15 +45,13 @@ pub async fn post_view(
};
match want {
- None => Err(PostNotFound(name).into()),
+ None => Ok((StatusCode::NOT_FOUND, tmpl::not_found(want_link))),
Some(post) => {
HIT_COUNTER
.with_label_values(&[name.clone().as_str()])
.inc();
- let body = templates::Html(post.body_html.clone());
- let mut result: Vec<u8> = vec![];
- templates::talkpost_html(&mut result, post, body, referer)?;
- Ok(Html(result))
+ let body = maud::PreEscaped(&post.body_html);
+ Ok((StatusCode::OK, tmpl::blog::talk(&post, body, referer)))
}
}
}