add a WIP index page

This commit is contained in:
Fries 2023-07-03 23:59:56 -07:00
parent 33f0b6a5e9
commit 79e88cb2f4
5 changed files with 73 additions and 35 deletions

View File

@ -23,6 +23,11 @@ body {
color: var(--text-color)
}
a {
color: var(--link-color);
font-size: 22px;
}
p {
font-size: 22px;
}

View File

@ -3,6 +3,7 @@ use std::borrow::Cow;
use askama_rocket::Template;
use rocket::http::Status;
use rust_embed::RustEmbed;
use shared::names::Site;
#[derive(RustEmbed)]
#[folder = "public/"]
@ -23,6 +24,12 @@ pub struct ErrorTemplate<'a> {
pub error_description: &'a str
}
#[derive(Template)]
#[template(path = "index.html")]
pub struct IndexTemplate {
pub sites: Vec<Site>
}
#[derive(Responder)]
pub struct ErrorTemplateResponder<'a> {
template: ErrorTemplate<'a>

View File

@ -1,5 +1,5 @@
use crate::{
assets::ErrorTemplate,
assets::{ErrorTemplate, IndexTemplate},
links::{next_url, previous_url},
sites::get_global_names,
};
@ -23,8 +23,8 @@ pub struct JsonResponse {
}
#[get("/")]
pub fn index() -> &'static str {
"Like, this is a webring, meow!"
pub async fn index() -> IndexTemplate {
IndexTemplate { sites: get_global_names().await }
}
#[get("/previous?<source_url>")]

26
templates/index.html Normal file
View File

@ -0,0 +1,26 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<title>Meowy Webring</title>
<link rel="stylesheet" href="/public/style.css" />
</head>
<body>
<main>
<h1>Welcome</h1>
<h2>Sites</h2>
{% for site in sites %}
{% match site.name %}
{% when Some with (value) %}
<p><a href="{{ site.url }}">{{ value }}</a></p>
{% when None %}
<p><a href="{{ site.url }}">{{ site.url }}</a></p>
{% endmatch %}
{% endfor %}
</main>
</body>
</html>