B introduces a coherent room-route encoding abstraction (room_route_segment/room_id_from_route_segment), consistently applies it across server routes, tests, and Clojure fixtures, and adds real URL-normalization logic (YouTube canonicalization, query sorting) with substantial unit tests, delivering concrete bugfixes/consistency improvements. A adds a new UI action/template system which is architecturally interesting but is more speculative plumbing (new form-template DSL, ui_html endpoint) without the breadth of test coverage or demonstrated end-to-end correctness that B shows across many call sites.
constitution · epochs · watch · epoch 3
c_48edc893c5b0 (tommy-mor) vs c_45dfa34511fe (tommy-mor)
download prompt · raw event · cmp_c1a43fa1c5f742
council reasoning
A adds lasting architecture: form-template hole fill, HtmlUiAction parsing, a unified POST /ui handler, and shared run_* web-post paths plus progressive new-thread UI—new capability with tests. B’s room URL collapse to /r/{short}{slug} and route churn is mostly mechanical; its real upside (room_route helpers and HTTP identity/YouTube normalization) is narrower than A’s UI command surface.
Side A adds substantial new infrastructure: a new `/ui` endpoint with `HtmlUiAction` parsing, JSON form-template substitution (`form_template.rs`), reusable web-post handlers, and UI expansion flows for thread forms, introducing a reusable browser UI command architecture. Side B is largely a refactor that centralizes room URL encoding/decoding (`room_route_segment`/`room_id_from_route_segment`) and updates routes plus some URL normalization utilities, which improves consistency but is narrower in scope and mostly restructures existing behavior.
sides
A — c_48edc893c5b0 (tommy-mor)
message
[3f35edab] progress
diff preview
diff --git a/server/src/api/mod.rs b/server/src/api/mod.rs
index a10ce662105cff8fad949c6b83f7035ce79bed18..a986f706ea4b261cbaf004c02b4cf84184b41371 100644
--- a/server/src/api/mod.rs
+++ b/server/src/api/mod.rs
@@ -3,6 +3,7 @@ mod helpers;
mod rpc;
mod stream;
mod validate;
+mod ui_html;
mod web_post;
pub use auth::{
@@ -33,6 +34,7 @@ pub use stream::{get_html_stream, get_stream};
pub use validate::{normalize_room_and_thread, validate_ingest_document, ValidatedIngest};
+pub use ui_html::post_ui_html;
pub use web_post::{check_web_ingest, post_web_ingest, post_web_redact};
#[cfg(test)]
diff --git a/server/src/api/ui_html.rs b/server/src/api/ui_html.rs
new file mode 100644
index 0000000000000000000000000000000000000000..2b40a72059981d558768f73d189b991f3448c257
--- /dev/null
+++ b/server/src/api/ui_html.rs
@@ -0,0 +1,139 @@
+//! Single `POST /ui` entry for browser [`crate::html::ui_action::HtmlUiAction`] (JSON in `__rpc__` + holes).
+
+use axum::{
+ body::Body,
+ extract::State,
+ http::{header, HeaderMap, StatusCode},
+ response::{IntoResponse, Response},
+ Form,
+};
+use axum_extra::extract::cookie::CookieJar;
+use std::collections::HashMap;
+
+use crate::{
+ api::{
+ auth::optional_principal,
+ web_post::{run_check_web_ingest, run_post_web_ingest, run_post_web_redact, WebPostForm, WebRedactForm},
+ },
+ html::{
+ fragment_public_new_thread_form, fragment_room_new_thread_form, login_to_post_hint_markup,
+ parse_html_ui_from_form, user_can_post_room, user_can_view_room, HtmlUiAction, JsBuilder,
+ ThreadNav,
+ },
+ state::AppState,
+};
+
+pub async fn post_ui_html(
+ State(state): State<AppState>,
+ headers: HeaderMap,
+ jar: CookieJar,
+ Form(form): Form<HashMap<String, String>>,
+) -> impl IntoResponse {
+ let action = match parse_html_ui_from_form(&form) {
+ Ok(a) => a,
+ Err(e) => return ui_js_warn(&e.to_string()).into_response(),
+ };
+
+ match action {
+ HtmlUiAction::PostIngest {
+ room,
+ thread_tag,
+ text,
+ error_target,
+ form_id,
+ } => {
+ run_post_web_ingest(
+ &state,
+ &headers,
+ &jar,
+ WebPostForm {
+ room,
+ thread_tag,
+ text,
+ error_target,
+ form_id,
+ },
+ )
+ .await
+ }
+ HtmlUiAction::CheckIngest {
+ room,
+ thread_tag,
+ text,
+ error_target,
+ form_id,
+ } => {
+ run_check_web_ingest(
+ &state,
+ &headers,
+ &jar,
+ WebPostForm {
+ room,
+ thread_tag,
+ text,
+ error_target,
+ form_id,
+ },
+ )
+ .await
+ }
+ HtmlUiAction::RedactPost { post_id } => {
+ run_post_web_redact(&state, &headers, &jar, WebRedactForm { post_id }).await
+ }
+ HtmlUiAction::ExpandPublicNewThreadForm => {
+ let reduced = state.reduced.read().await;
+ let user = optional_principal(&headers, &jar, &reduced);
+ drop(reduced);
+ let markup = if user.is_some() {
+ fragment_public_new_thread_form(true)
+ } else {
+ login_to_post_hint_markup()
+ };
+ JsBuilder::new()
+ .morph_selector("#public-new-thread-ui-slot", markup)
+ .into_response()
+ }
+ HtmlUiAction::ExpandRoomNewThreadForm { room_wire } => {
+ let room_wire = room_wire.trim().to_string();
+ if room_wire.is_empty() {
+ return ui_js_warn("missing room").into_response();
+ }
+ let reduced = state.reduced.read().await;
+ let user = optional_principal(&headers, &jar, &reduced);
+ if !reduced.rooms.contains(&room_wire) {
+ drop(reduced);
+ return ui_js_warn("room not found").into_response();
+ }
+ if !user_can_view_room(&reduced, &room_wire, user.as_deref()) {
+ drop(reduced);
+ return ui_js_warn("forbidden").into_response();
+ }
+ let can_post = user
+ .as_ref()
+ .map(|u| user_can_post_room(&reduced, &room_wire, u))
+ .unwrap_or(false);
+ drop(reduced);
+ let Some(nav) = ThreadNav::from_room_id(&room_wire) else {
+ return ui_js_warn("bad room").into_response();
+ };
+ let markup = if can_post {
+ fragment_room_new_thread_form(&nav, true)
+ } else {
+ login_to_post_hint_markup()
+ };
+ JsBuilder::new()
+ .morph_selector("#room-new-thread-ui-slot", markup)
+ .into_response()
+ }
+ }
+}
+
+fn ui_js_warn(msg: &str) -> Response {
+ use crate::html::js_string_literal;
+ let js = format!("console.warn({});", js_string_literal(msg));
+ Response::builder()
+ .status(StatusCode::OK)
+ .header(header::CONTENT_TYPE, "text/javascript; charset=utf-8")
+ .body(Body::from(js))
+ .unwrap()
+}
diff --git a/server/src/api/web_post.rs b/server/src/api/web_post.rs
index a64010e382d3039821c836a5529adad0fe67cce5..265025f41ff1548d05b2d2d5d84202245388053f 100644
--- a/server/src/api/web_post.rs
+++ b/server/src/api/web_post.rs
@@ -222,8 +222,18 @@ pub async fn post_web_redact(
jar: CookieJar,
Form(form): Form<WebRedactForm>,
) -> impl IntoResponse {
+ run_post_web_redact(&state, &headers, &jar, form).await
+}
+
+/// Shared with [`crate::api::ui_html::post_ui_html`].
+pub(crate) async fn run_post_web_redact(
+ state: &AppState,
+ headers: &HeaderMap,
+ jar: &CookieJar,
+ form: WebRedactForm,
+) -> Response {
let reduced = state.reduced.read().await;
- let Some(_username) = optional_principal(&headers, &jar, &reduced) else {
+ let Some(_username) = optional_principal(headers, jar, &reduced) else {
drop(reduced);
return js_redirect("/login").into_response();
};
@@ -239,8 +249,8 @@ pub async fn post_web_redact(
return js_redirect("/login").into_response();
};
- match rpc_post_redact(&state, &headers, form.post_id).await {
- Ok(RpcResult::RedactPostOk {}) => redact_success_response(&state).await.into_response(),
+ match rpc_post_redact(state, headers, form.post_id).await {
+ Ok(RpcResult::RedactPostOk {}) => redact_success_response(state).await.into_response(),
Ok(_) => (StatusCode::BAD_REQUEST, "unexpected response").into_response(),
Err((msg, hint)) => {
let detail = hint.as_deref().unwrap_or("");
@@ -255,8 +265,18 @@ pub async fn post_web_ingest(
jar: CookieJar,
Form(form): Form<WebPostForm>,
) -> impl IntoResponse {
+ run_post_web_ingest(&state, &headers, &jar, form).await
+}
+
+/// Shared with [`crate::api::ui_html::post_ui_html`] (`POST /ui`).
+pub(crate) async fn run_post_web_ingest(
+ state: &AppState,
+ headers: &HeaderMap,
+ jar: &CookieJar,
+ form: WebPostForm,
+) -> Response {
let reduced = state.reduced.read().await;
- let Some(_username) = optional_principal(&headers, &jar, &reduced) else {
+ let Some(_username) = optional_principal(headers, jar, &reduced) else {
drop(reduced);
return js_redirect("/login").into_response();
};
@@ -282,8 +302,8 @@ pub async fn post_web_ingest(
.into_response();
}
- match rpc_post_with_bearer(&state, &bearer, room.clone(), thread_tag.clone(), text).await {
- Ok(RpcResult::PostOk { .. }) => post_success_response(&state, &form, &headers, &jar)
+ match rpc_post_with_bearer(state, &bearer, room.clone(), thread_tag.clone(), text).await {
+ Ok(RpcResult::PostOk { .. }) => post_success_response(state, &form, headers, jar)
.await
.into_response(),
Ok(_) => form_js_error(&form, "unexpected response", "Post did not return PostOk.").into_response(),
@@ -297,8 +317,18 @@ pub async fn check_web_ingest(
jar: CookieJar,
Form(form): Form<WebPostForm>,
) -> impl IntoResponse {
+ run_check_web_ingest(&state, &headers, &jar, form).await
+}
+
+/// Shared with [`crate::api::ui_html::post_ui_html`] (`POST /ui`).
+pub(crate) async fn run_check_web_ingest(
+ state: &AppState,
+ headers: &HeaderMap,
+ jar: &CookieJar,
+ form: WebPostForm,
+) -> Response {
let reduced = state.reduced.read().await;
- let Some(_username) = optional_principal(&headers, &jar, &reduced) else {
+ let Some(_username) = optional_principal(headers, jar, &reduced) else {
drop(reduced);
return js_redirect("/login").into_response();
};
@@ -324,7 +354,7 @@ pub async fn check_web_ingest(
return js_clear_errors(&form_error_target(&form)).into_response();
}
- match rpc_check_with_bearer(&state, &bearer, room, form.text.clone()).await {
+ match rpc_check_with_bearer(state, &bearer, room, form.text.clone()).await {
Ok(RpcResult::CheckOk { .. }) => js_clear_errors(&form_error_target(&form)).into_response(),
Ok(_) => form_js_error(&form, "unexpected response", "Check did not return CheckOk.").into_response(),
Err((msg, hint)) => form_js_error(&form, &msg, hint.as_deref().unwrap_or("")).into_response(),
diff --git a/server/src/form_template.rs b/server/src/form_template.rs
new file mode 100644
index 0000000000000000000000000000000000000000..3709c2c09a859da006e4af173413d5d235bc19be
--- /dev/null
+++ b/server/src/form_template.rs
@@ -0,0 +1,142 @@
+//! Plan2-style JSON templates with `{"$form": "field_name"}` holes, filled from
+//! `application/x-www-form-urlencoded` (or any `String` → `String` map) **before**
+//! deserializing into a typed struct.
+//!
+//! # Wire format
+//!
+//! Templates are **compact JSON** (`serde_json::to_string`): one line, no pretty
+//! printing, strings escaped per JSON rules (`\"`, `\n`, etc.). Embed that string
+//! in HTML attributes or text nodes with normal HTML escaping (e.g. maud), not
+//! bespoke encodings.
+//!
+//! # Power vs flat hidden fields
+//!
+//! A form is always a string→string map. You can fake depth with dotted keys (`a.b.c`),
+//! but one structured blob (`__rpc__` = compact JSON) gives you nested objects,
+//! arrays, and optional fields without inventing a new naming scheme each time.
+//!
+//! # Security
+//!
+//! Substitution runs **before** `serde` into your command type. It does not fix
+//! authorization: if the client can replace the hidden `__rpc__` value, they can
+//! change the command shape unless you validate (signed blob, server-side session
+//! context, or treat the blob as hints only). Same threat model as any hidden field.
+
+use serde::Serialize;
+use serde_json::Value;
+use std::collections::HashMap;
+
+/// Serialize a value to compact JSON for a hidden `__rpc__` (or similar) field.
+pub fn template_json_compact<T: Serialize>(v: &T) -> serde_json::Result<String> {
+ serde_json::to_string(v)
+}
+
+/// Recursively walk the JSON AST and replace `{"$form": "key"}` with the submitted
+/// string for `key` (empty if missing). Other keys are unchanged.
+pub fn substitute_form_vars(val: &mut Value, form_data: &HashMap<String, String>) {
+ match val {
+ Value::Object(map) => {
+ if map.len() == 1 {
+ if let Some(Value::String(field_name)) = map.get("$form") {
+ let submitted = form_data
+ .get(field_name.as_str())
+ .map(|s| s.as_str())
+ .unwrap_or("");
+
… preview truncated; 13,273 characters omittedB — c_45dfa34511fe (tommy-mor)
message
[5ca518f6] url refactor
diff preview
diff --git a/Cargo.lock b/Cargo.lock
index 67a09a3b54f778fa7e857fdd589c3ed9c92e1322..ad7e4fe6d4ba2f2b033916194c1ef1ed873f1d46 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1757,6 +1757,7 @@ name = "slug-types"
version = "0.1.0"
dependencies = [
"serde",
+ "url",
]
[[package]]
@@ -2272,6 +2273,7 @@ dependencies = [
"idna",
"percent-encoding",
"serde",
+ "serde_derive",
]
[[package]]
diff --git a/server/src/api/ui_html.rs b/server/src/api/ui_html.rs
index 606f7d6f97a4428efb90d1e0d544934c861fc4c5..cd3e0f0afd972d9ad9e7e4b92c5fa4c22bb8f620 100644
--- a/server/src/api/ui_html.rs
+++ b/server/src/api/ui_html.rs
@@ -270,10 +270,10 @@ fn post_redirect_location(room: &str, thread_tag: &str) -> String {
format!("/t/{tag}")
} else {
let room = room.trim();
- let Some((a, b)) = room.split_once('/') else {
+ let Some(seg) = slug_types::room_route_segment(room) else {
return "/".to_string();
};
- format!("/r/{a}/{b}/t/{tag}")
+ format!("/r/{seg}/t/{tag}")
}
}
diff --git a/server/src/api/write_actor.rs b/server/src/api/write_actor.rs
index cb78d2f3f95b1bc163c1fb064d1d5f657e18000f..f9c3b8bd3fbf8fcb9c035e1a1572fef0b08fa8a9 100644
--- a/server/src/api/write_actor.rs
+++ b/server/src/api/write_actor.rs
@@ -19,13 +19,15 @@ use crate::{
use super::auth::{issue_token_for_user, verify_token};
use super::helpers::{now_ms, resolve_item};
use super::validate::{normalize_room_and_thread, validate_ingest_document};
-use slug_types::RpcResult;
+use slug_types::{room_route_segment, RpcResult, ROOM_SHORT_ID_LEN};
fn gen_short_id() -> String {
use rand::Rng;
const ALPHABET: &[u8] = b"0123456789abcdefghijklmnopqrstuvwxyz";
let mut rng = rand::thread_rng();
- (0..7).map(|_| ALPHABET[rng.gen_range(0..ALPHABET.len())] as char).collect()
+ (0..ROOM_SHORT_ID_LEN)
+ .map(|_| ALPHABET[rng.gen_range(0..ALPHABET.len())] as char)
+ .collect()
}
fn parse_capability(s: &str) -> Result<crate::events::ThreadCapability, String> {
@@ -55,8 +57,8 @@ async fn broadcast_web_refresh(state: &AppState, room_key: &str, thread_id: &str
let feed_id = if room_key == "public" { "thread-feed" } else { "room-thread-feed" };
let thread_url = if room_key == "public" {
format!("/t/{thread_id}")
- } else if let Some((short, slug)) = room_key.split_once('/') {
- format!("/r/{short}/{slug}/t/{thread_id}")
+ } else if let Some(seg) = room_route_segment(room_key) {
+ format!("/r/{seg}/t/{thread_id}")
} else {
format!("/t/{thread_id}")
};
@@ -78,8 +80,8 @@ async fn broadcast_web_refresh(state: &AppState, room_key: &str, thread_id: &str
let js = builder.build();
let mut path_prefixes = vec![if room_key == "public" {
"/".to_string()
- } else if let Some((short, slug)) = room_key.split_once('/') {
- format!("/r/{short}/{slug}")
+ } else if let Some(seg) = room_route_segment(room_key) {
+ format!("/r/{seg}")
} else {
"/".to_string()
}];
diff --git a/server/src/html/forum/nav.rs b/server/src/html/forum/nav.rs
index 0ee33d91160fc5542817b5e3e9ab4fee1d0e600f..48fe11e46731670874ff8b6b05baa6f09ae0b7e4 100644
--- a/server/src/html/forum/nav.rs
+++ b/server/src/html/forum/nav.rs
@@ -1,7 +1,8 @@
use crate::canonical_path::canonicalize_item;
use crate::reducer::ScopeId;
+use slug_types::room_route_segment;
-/// URL helpers for public `/t/…` and private room threads `/r/{short}/{slug}/t/…`.
+/// URL helpers for public `/t/…` and private room threads `/r/{short}{slug}/t/…`.
#[derive(Clone)]
pub struct ThreadNav {
pub room_wire: String,
@@ -22,18 +23,15 @@ impl ThreadNav {
}
}
- /// `room_id` wire form `shortid/slug`.
+ /// `room_id` wire form `shortid/slug` (HTTP uses [`slug_types::room_route_segment`]).
pub(crate) fn from_room_id(room_id: &str) -> Option<Self> {
- let (short, slug) = room_id.split_once('/')?;
- if short.is_empty() || slug.is_empty() {
- return None;
- }
+ let room_seg = room_route_segment(room_id)?;
Some(Self {
room_wire: room_id.to_string(),
scope: ScopeId::Room(room_id.to_string()),
- room_path: format!("/r/{short}/{slug}"),
- thread_path_prefix: format!("/r/{short}/{slug}/t"),
- garden_path_prefix: format!("/r/{short}/{slug}/~"),
+ room_path: format!("/r/{room_seg}"),
+ thread_path_prefix: format!("/r/{room_seg}/t"),
+ garden_path_prefix: format!("/r/{room_seg}/~"),
})
}
diff --git a/server/src/html/forum/post_single.rs b/server/src/html/forum/post_single.rs
index c316f8f836df9d4ef9c05ebd9e54f699540e6d72..473747b3da3d4d7a54b5e0c63165d2533df643e1 100644
--- a/server/src/html/forum/post_single.rs
+++ b/server/src/html/forum/post_single.rs
@@ -93,12 +93,14 @@ pub async fn thread_post_view(
pub async fn room_thread_post_view(
State(state): State<AppState>,
- Path((room_short, room_slug, tag, index_str)): Path<(String, String, String, String)>,
+ Path((room_key, tag, index_str)): Path<(String, String, String)>,
headers: HeaderMap,
jar: CookieJar,
uri: Uri,
) -> impl IntoResponse {
- let room_id = format!("{room_short}/{room_slug}");
+ let Some(room_id) = slug_types::room_id_from_route_segment(&room_key) else {
+ return (StatusCode::NOT_FOUND, "bad room path").into_response();
+ };
let reduced = state.reduced.read().await;
let user = optional_principal(&headers, &jar, &reduced);
if !user_can_view_room(&reduced, &room_id, user.as_deref()) {
diff --git a/server/src/html/forum/views.rs b/server/src/html/forum/views.rs
index be5df1745ef580891a167c23c3dd6c06f804f295..1ec421f84335cbfe7f9db775b73a8ed24b197174 100644
--- a/server/src/html/forum/views.rs
+++ b/server/src/html/forum/views.rs
@@ -183,16 +183,18 @@ pub async fn thread_view(
thread_view_inner(state, tag, q, ThreadNav::public(), headers, jar, uri).await
}
-/// Room thread — `/r/:short/:slug/t/:tag`
+/// Room thread — `/r/:room_key/t/:tag` (`room_key` = `{short}{slug}`).
pub async fn room_thread_view(
State(state): State<AppState>,
- Path((room_short, room_slug, tag)): Path<(String, String, String)>,
+ Path((room_key, tag)): Path<(String, String)>,
Query(q): Query<ThreadViewQuery>,
headers: HeaderMap,
jar: CookieJar,
uri: Uri,
) -> impl IntoResponse {
- let room_id = format!("{room_short}/{room_slug}");
+ let Some(room_id) = slug_types::room_id_from_route_segment(&room_key) else {
+ return (StatusCode::NOT_FOUND, "bad room path").into_response();
+ };
let reduced = state.reduced.read().await;
let user = optional_principal(&headers, &jar, &reduced);
if !user_can_view_room(&reduced, &room_id, user.as_deref()) {
@@ -226,15 +228,17 @@ pub(super) fn room_not_found_page(jar: &CookieJar, uri: &Uri) -> impl IntoRespon
(StatusCode::NOT_FOUND, Html(page.into_string()))
}
-/// Private room index — `/r/:short/:slug`
+/// Private room index — `/r/:room_key`
pub async fn room_page(
State(state): State<AppState>,
- Path((room_short, room_slug)): Path<(String, String)>,
+ Path(room_key): Path<String>,
headers: HeaderMap,
jar: CookieJar,
uri: Uri,
) -> impl IntoResponse {
- let room_id = format!("{room_short}/{room_slug}");
+ let Some(room_id) = slug_types::room_id_from_route_segment(&room_key) else {
+ return (StatusCode::NOT_FOUND, "room not found").into_response();
+ };
let now = now_ms();
let reduced = state.reduced.read().await;
if !reduced.rooms.contains(&room_id) {
@@ -266,7 +270,10 @@ pub async fn room_page(
let audit_cli = format!("npx slugsocial private {room_id} audit");
drop(reduced);
- let slug_display = room_slug.as_str();
+ let slug_display = room_id
+ .split_once('/')
+ .map(|(_, slug)| slug)
+ .unwrap_or(room_id.as_str());
let page = layout(
&format!("room {slug_display} — slug.social"),
"view-thread",
diff --git a/server/src/html/garden.rs b/server/src/html/garden.rs
index 423f23fd8c9ad7b7f454d6ea7a9a7607a4c9c5b9..e615dd356bcf634232d85610c0a26235ead125fd 100644
--- a/server/src/html/garden.rs
+++ b/server/src/html/garden.rs
@@ -309,12 +309,14 @@ pub async fn external_ontology_path(
pub async fn room_garden_index(
State(state): State<AppState>,
- Path((room_short, room_slug)): Path<(String, String)>,
+ Path(room_key): Path<String>,
headers: HeaderMap,
jar: CookieJar,
uri: Uri,
) -> impl IntoResponse {
- let room_id = format!("{room_short}/{room_slug}");
+ let Some(room_id) = slug_types::room_id_from_route_segment(&room_key) else {
+ return (StatusCode::NOT_FOUND, "bad room path").into_response();
+ };
let Some(nav) = ThreadNav::from_room_id(&room_id) else {
return (StatusCode::NOT_FOUND, "bad room path").into_response();
};
@@ -341,12 +343,14 @@ pub async fn room_garden_index(
pub async fn room_external_garden_index(
State(state): State<AppState>,
- Path((room_short, room_slug)): Path<(String, String)>,
+ Path(room_key): Path<String>,
headers: HeaderMap,
jar: CookieJar,
uri: Uri,
) -> impl IntoResponse {
- let room_id = format!("{room_short}/{room_slug}");
+ let Some(room_id) = slug_types::room_id_from_route_segment(&room_key) else {
+ return (StatusCode::NOT_FOUND, "bad room path").into_response();
+ };
let Some(nav) = ThreadNav::from_room_id(&room_id) else {
return (StatusCode::NOT_FOUND, "bad room path").into_response();
};
@@ -416,12 +420,14 @@ pub async fn room_external_garden_index(
pub async fn room_external_ontology_path(
State(state): State<AppState>,
- Path((room_short, room_slug, path)): Path<(String, String, String)>,
+ Path((room_key, path)): Path<(String, String)>,
headers: HeaderMap,
jar: CookieJar,
uri: Uri,
) -> impl IntoResponse {
- let room_id = format!("{room_short}/{room_slug}");
+ let Some(room_id) = slug_types::room_id_from_route_segment(&room_key) else {
+ return (StatusCode::NOT_FOUND, "bad room path").into_response();
+ };
let Some(nav) = ThreadNav::from_room_id(&room_id) else {
return (StatusCode::NOT_FOUND, "bad room path").into_response();
};
@@ -442,12 +448,14 @@ pub async fn room_external_ontology_path(
pub async fn room_ontology_path(
State(state): State<AppState>,
- Path((room_short, room_slug, path)): Path<(String, String, String)>,
+ Path((room_key, path)): Path<(String, String)>,
headers: HeaderMap,
jar: CookieJar,
uri: Uri,
) -> impl IntoResponse {
- let room_id = format!("{room_short}/{room_slug}");
+ let Some(room_id) = slug_types::room_id_from_route_segment(&room_key) else {
+ return (StatusCode::NOT_FOUND, "bad room path").into_response();
+ };
let Some(nav) = ThreadNav::from_room_id(&room_id) else {
return (StatusCode::NOT_FOUND, "bad room path").into_response();
};
diff --git a/server/src/html/search.rs b/server/src/html/search.rs
index 43e6ebf36cf0fe72c96f0f9d850bea51ac094c43..f01732f7edb32c68fcc10c39545c8f56476adb27 100644
--- a/server/src/html/search.rs
+++ b/server/src/html/search.rs
@@ -351,8 +351,8 @@ fn render_search_results(results: &SearchResults, query: &str) -> Markup {
ul class="search-posts" {
@for r in &results.posts {
@let (post_href, post_label) = if let Some((room, tag)) = r.thread.split_once("/#") {
- if let Some((short, slug)) = room.split_once('/') {
- (format!("/r/{short}/{slug}/t/{tag}"), format!("{room}/#{tag}"))
+ if let Some(seg) = slug_types::room_route_segment(room) {
+
… preview truncated; 35,812 characters omittedHardlinks — judgments / attempts / prompt
judgments
attempts
Prompt text is loaded only by the download route.