diff --git a/src/modes/server/pages.rs b/src/modes/server/pages.rs index fb6967c..8f3e27a 100644 --- a/src/modes/server/pages.rs +++ b/src/modes/server/pages.rs @@ -34,6 +34,7 @@ pub fn add_routes(app: axum::Router) -> axum::Router { app .route("/", axum::routing::get(list_items)) .route("/item/{item_id}", axum::routing::get(show_item)) + .route("/style.css", axum::routing::get(style_css)) } async fn list_items( @@ -87,12 +88,7 @@ fn build_item_list(conn: &Connection, params: &ListQueryParams, columns: &[Colum let mut html = String::new(); html.push_str("Items"); - html.push_str(""); + html.push_str(""); html.push_str(""); html.push_str("

Items

"); html.push_str("

API Documentation

"); @@ -191,6 +187,55 @@ fn build_item_list(conn: &Connection, params: &ListQueryParams, columns: &[Colum Ok(html) } +async fn style_css() -> &'static str { + r#" + body { + font-family: Arial, sans-serif; + margin: 0; + padding: 20px; + background-color: #f5f5f5; + } + h1, h2 { + color: #333; + } + table { + border-collapse: collapse; + width: 100%; + background-color: white; + box-shadow: 0 1px 3px rgba(0,0,0,0.1); + } + th, td { + border: 1px solid #ddd; + padding: 12px; + text-align: left; + } + th { + background-color: #f2f2f2; + position: sticky; + top: 0; + } + tr:nth-child(even) { + background-color: #f9f9f9; + } + tr:hover { + background-color: #f1f1f1; + } + a { + color: #0066cc; + text-decoration: none; + } + a:hover { + text-decoration: underline; + } + .pagination { + margin: 20px 0; + } + .actions { + white-space: nowrap; + } + "# +} + async fn show_item( State(state): State, Path(id): Path, @@ -215,7 +260,9 @@ fn build_item_details(conn: &Connection, id: i64) -> Result { let metas = db::get_item_meta(conn, &item)?; let mut html = String::new(); - html.push_str("Item Details"); + html.push_str("Item Details"); + html.push_str(""); + html.push_str(""); html.push_str(&format!("

Item #{}

", id)); html.push_str(""); html.push_str(&format!("", item.id.unwrap_or(0)));
ID:{}