diff --git a/src/app.rs b/src/app.rs index 7a663eb..31d9fdd 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1,10 +1,10 @@ use std::collections::HashMap; use std::sync::Arc; -use axum::Router; +use axum::{routing::get, Router}; use tower_http::trace::TraceLayer; -use crate::{feeds::Feed, routes}; +use crate::{css_handler::stylesheet_handler, feeds::Feed, routes}; #[derive(Debug)] pub struct AppState { @@ -15,6 +15,7 @@ pub fn create(feeds: HashMap) -> Router { let app_state = Arc::new(AppState { feeds }); Router::new() + .route("/styles.css", get(stylesheet_handler)) .nest("/", routes::all()) .with_state(app_state) .layer(TraceLayer::new_for_http()) diff --git a/src/css_handler.rs b/src/css_handler.rs new file mode 100644 index 0000000..db0d672 --- /dev/null +++ b/src/css_handler.rs @@ -0,0 +1,12 @@ +use axum::http::StatusCode; +use axum::{http::Response, response::IntoResponse}; + +static STYLESHEET: &str = include_str!("../static/styles.css"); + +pub async fn stylesheet_handler() -> Result { + let response = Response::builder() + .header("Content-Type", "text/css") + .body(STYLESHEET.to_string()); + + response.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR) +} diff --git a/src/main.rs b/src/main.rs index 6865f3d..2d22f9c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,6 +4,7 @@ use crate::{config::PenguinConfig, feeds::enrich_feeds}; mod app; mod config; +mod css_handler; mod feeds; mod hash; mod logging; diff --git a/static/styles.css b/static/styles.css new file mode 100644 index 0000000..9c9568e --- /dev/null +++ b/static/styles.css @@ -0,0 +1,19 @@ +body { + max-width: 35em; + margin: 0 auto; +} + +ul { + list-style: none; + margin: 0; + + padding: 0; +} + +li { + display: flex; + justify-content: space-between; + align-items: center; + padding: 1em; + border-bottom: 1px solid #ccc; +} diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 0000000..6d21f48 --- /dev/null +++ b/templates/base.html @@ -0,0 +1,12 @@ + + + + + + Find Penguins Feeds + + + + {% block content %}{% endblock %} + + diff --git a/templates/feeds.html b/templates/feeds.html index a623df3..2d29877 100644 --- a/templates/feeds.html +++ b/templates/feeds.html @@ -1,7 +1,9 @@ +{% extends "base.html" %} {% block content %} \ No newline at end of file + {% for f in feeds %} +
  • + {{ f.title }}Feed +
  • + {% endfor %} + +{% endblock content %}