simple-web-app

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 0cd96c2e93ae77a6642c362847dd98dde150907f
parent f07178234252bb5e961a6306b6419bd2bcb0e0ae
Author: Silas Brack <silasbrack@gmail.com>
Date:   Sun,  7 Jun 2026 22:03:50 +0200

chore: remove dead code and stale files

- Remove unused search_stories (replaced by WASM guest FTS5)
- Remove unused get_comments endpoint and CommentsTemplate
- Remove stale news_item schema files
- Add traildepot/data/, traildepot/secrets/, guests/rust/target/
  to .gitignore

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Diffstat:
M.gitignore | 5+++++
Dschemas/news_item.json | 37-------------------------------------
Dschemas/news_item_category.json | 20--------------------
Msrc/handlers/comment.rs | 48+-----------------------------------------------
Msrc/routes.rs | 1-
Msrc/templates.rs | 7-------
Msrc/trailbase.rs | 29-----------------------------
7 files changed, 6 insertions(+), 141 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -3,6 +3,11 @@ target/ # Sqlite *.sqlite3* +traildepot/data/ +traildepot/secrets/ + +# WASM guest build artifacts +guests/rust/target/ # Nix result diff --git a/schemas/news_item.json b/schemas/news_item.json @@ -1,37 +0,0 @@ -{ - "properties": { - "author": { - "type": "string" - }, - "created_by": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "language": { - "type": "string" - }, - "published": { - "type": "string" - }, - "text": { - "type": "string" - }, - "title": { - "type": "string" - }, - "url": { - "type": "string" - } - }, - "required": [ - "id", - "title", - "text", - "published", - "language" - ], - "title": "news_item", - "type": "object" -} diff --git a/schemas/news_item_category.json b/schemas/news_item_category.json @@ -1,20 +0,0 @@ -{ - "properties": { - "category_id": { - "type": "integer" - }, - "id": { - "type": "integer" - }, - "news_item_id": { - "type": "integer" - } - }, - "required": [ - "id", - "news_item_id", - "category_id" - ], - "title": "news_item_category", - "type": "object" -} diff --git a/src/handlers/comment.rs b/src/handlers/comment.rs @@ -10,8 +10,7 @@ use serde::Deserialize; use crate::error::AppError; use crate::handlers::auth::get_tokens_from_cookies; use crate::state::AppState; -use crate::db::CommentWithMeta; -use crate::templates::{ApplicationTemplate, CommentsTemplate, ReplyFormTemplate}; +use crate::templates::{ApplicationTemplate, ReplyFormTemplate}; use crate::trailbase; #[derive(Debug, Deserialize)] @@ -57,51 +56,6 @@ pub async fn create_comment( Ok(Redirect::to(&format!("/story/{}", story_id))) } -/// Get comments HTML fragment for HTMX polling -pub async fn get_comments( - State(state): State<AppState>, - jar: CookieJar, - Path(story_id): Path<i64>, -) -> Result<Html<String>, AppError> { - let tokens = get_tokens_from_cookies(&jar); - let client = match &tokens { - Some(t) => trailbase::client_with_tokens(&state.trailbase_url, t)?, - None => trailbase::new_client(&state.trailbase_url)?, - }; - - let comments = trailbase::get_comments_for_story(&client, story_id).await?; - - let comment_ids: Vec<i64> = comments.iter().map(|c| c.id).collect(); - let voted_comment_ids = if tokens.is_some() && !comment_ids.is_empty() { - trailbase::get_user_votes(&client, trailbase::TARGET_TYPE_COMMENT, &comment_ids) - .await - .inspect_err(|e| tracing::error!("Failed to get comment votes: {}", e)) - .unwrap_or_default() - } else { - vec![] - }; - - let mut enriched = Vec::with_capacity(comments.len()); - for comment in comments { - let author = trailbase::get_user_profile_by_id(&client, &comment.created_by) - .await - .inspect_err(|e| tracing::error!("Failed to get profile for {}: {}", comment.created_by, e)) - .ok() - .flatten() - .map(|p| p.username); - let time_ago = trailbase::time_ago(&comment.created_at); - let voted = voted_comment_ids.contains(&comment.id); - enriched.push(CommentWithMeta::from_comment(comment, author, time_ago, voted)); - } - - let is_logged_in = tokens.is_some(); - let template = CommentsTemplate { - comments: enriched, - is_logged_in, - }; - Ok(Html(template.render()?)) -} - /// Show reply form for a comment pub async fn show_reply_form( State(state): State<AppState>, diff --git a/src/routes.rs b/src/routes.rs @@ -72,7 +72,6 @@ pub fn create_router(state: AppState) -> Router { .route("/story/{id}/edit", post(handlers::edit_story)) // Comments - .route("/story/{id}/comments", get(handlers::get_comments)) .route("/story/{id}/comment", post(handlers::create_comment)) .route("/comment/{id}/reply", get(handlers::show_reply_form)) .route("/comment/{id}/reply", post(handlers::submit_reply)) diff --git a/src/templates.rs b/src/templates.rs @@ -31,13 +31,6 @@ pub struct StoryTemplate { } #[derive(Template)] -#[template(path = "comments.html")] -pub struct CommentsTemplate { - pub comments: Vec<CommentWithMeta>, - pub is_logged_in: bool, -} - -#[derive(Template)] #[template(path = "submit.html")] pub struct SubmitTemplate { pub error: Option<String>, diff --git a/src/trailbase.rs b/src/trailbase.rs @@ -644,35 +644,6 @@ pub async fn remove_all_tags_from_story( // ============================================================================ -// Search functions -// ============================================================================ - -pub async fn search_stories( - client: &Client, - query: &str, - limit: usize, -) -> Result<Vec<SearchResult>, ClientError> { - // Add wildcards for substring matching - let pattern = format!("%{}%", query); - let args = ListArguments::new() - .with_pagination(Pagination::new().with_limit(limit)) - .with_filters(Filter::new("title", CompareOp::Like, &pattern)); - - let response = client.records("story").list::<Story>(args).await?; - Ok(response - .records - .into_iter() - .map(|s| SearchResult { - id: s.id, - title: s.title, - text: s.text, - score: s.score, - comment_count: s.comment_count, - }) - .collect()) -} - -// ============================================================================ // Auth functions // ============================================================================