use simple styling

This commit is contained in:
Sebastian Hugentobler 2023-11-18 09:50:50 +01:00
parent 0f3fb34d85
commit a94d23bc2c
Signed by: shu
GPG Key ID: BB32CF3CA052C2F0
6 changed files with 55 additions and 8 deletions

View File

@ -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<String, Feed>) -> 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())

12
src/css_handler.rs Normal file
View File

@ -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<impl IntoResponse, StatusCode> {
let response = Response::builder()
.header("Content-Type", "text/css")
.body(STYLESHEET.to_string());
response.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)
}

View File

@ -4,6 +4,7 @@ use crate::{config::PenguinConfig, feeds::enrich_feeds};
mod app;
mod config;
mod css_handler;
mod feeds;
mod hash;
mod logging;

19
static/styles.css Normal file
View File

@ -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;
}

12
templates/base.html Normal file
View File

@ -0,0 +1,12 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="stylesheet" href="/styles.css" />
<title>Find Penguins Feeds</title>
</head>
<body>
{% block content %}{% endblock %}
</body>
</html>

View File

@ -1,7 +1,9 @@
{% extends "base.html" %} {% block content %}
<ul>
{% for f in feeds %}
<li>
<a href="{{ f.url }}">{{ f.title }}</a> - <a href="/feeds/{{f.id}}">Feed</a>
<a href="{{ f.url }}">{{ f.title }}</a><a href="/feeds/{{f.id}}">Feed</a>
</li>
{% endfor %}
</ul>
{% endblock content %}