feat: make item ID clickable link to details page

Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-08-29 12:04:16 -03:00
parent 809a1e6e2c
commit e056678799

View File

@@ -123,7 +123,11 @@ fn build_item_list(conn: &Connection, params: &ListQueryParams, columns: &[Colum
html.push_str("<tr>");
for column in columns {
let value = match column.name.as_str() {
"id" => item.id.map(|id| id.to_string()).unwrap_or_default(),
"id" => {
let id_value = item.id.map(|id| id.to_string()).unwrap_or_default();
// Make the ID a link to the item details page
format!("<a href=\"/item/{}\">{}</a>", item_id, id_value)
},
"time" => item.ts.format("%Y-%m-%d %H:%M:%S").to_string(),
"size" => item.size.map(|s| s.to_string()).unwrap_or_default(),
"tags" => tags.iter().map(|t| t.name.clone()).collect::<Vec<_>>().join(", "),
@@ -141,6 +145,9 @@ fn build_item_list(conn: &Connection, params: &ListQueryParams, columns: &[Colum
let display_value = if let Some(max_len_str) = &column.max_len {
if let Ok(max_len) = max_len_str.parse::<usize>() {
if value.chars().count() > max_len {
// Note: This might truncate HTML, which isn't ideal
// For simplicity, we'll just truncate the text content
// A better approach would be to strip HTML tags first, but that's more complex
let truncated: String = value.chars().take(max_len).collect();
format!("{}...", truncated)
} else {