add a WIP index page
This commit is contained in:
parent
33f0b6a5e9
commit
79e88cb2f4
5 changed files with 73 additions and 35 deletions
|
@ -23,6 +23,11 @@ body {
|
||||||
color: var(--text-color)
|
color: var(--text-color)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: var(--link-color);
|
||||||
|
font-size: 22px;
|
||||||
|
}
|
||||||
|
|
||||||
p {
|
p {
|
||||||
font-size: 22px;
|
font-size: 22px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ use std::borrow::Cow;
|
||||||
use askama_rocket::Template;
|
use askama_rocket::Template;
|
||||||
use rocket::http::Status;
|
use rocket::http::Status;
|
||||||
use rust_embed::RustEmbed;
|
use rust_embed::RustEmbed;
|
||||||
|
use shared::names::Site;
|
||||||
|
|
||||||
#[derive(RustEmbed)]
|
#[derive(RustEmbed)]
|
||||||
#[folder = "public/"]
|
#[folder = "public/"]
|
||||||
|
@ -23,6 +24,12 @@ pub struct ErrorTemplate<'a> {
|
||||||
pub error_description: &'a str
|
pub error_description: &'a str
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Template)]
|
||||||
|
#[template(path = "index.html")]
|
||||||
|
pub struct IndexTemplate {
|
||||||
|
pub sites: Vec<Site>
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Responder)]
|
#[derive(Responder)]
|
||||||
pub struct ErrorTemplateResponder<'a> {
|
pub struct ErrorTemplateResponder<'a> {
|
||||||
template: ErrorTemplate<'a>
|
template: ErrorTemplate<'a>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
assets::ErrorTemplate,
|
assets::{ErrorTemplate, IndexTemplate},
|
||||||
links::{next_url, previous_url},
|
links::{next_url, previous_url},
|
||||||
sites::get_global_names,
|
sites::get_global_names,
|
||||||
};
|
};
|
||||||
|
@ -23,8 +23,8 @@ pub struct JsonResponse {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/")]
|
#[get("/")]
|
||||||
pub fn index() -> &'static str {
|
pub async fn index() -> IndexTemplate {
|
||||||
"Like, this is a webring, meow!"
|
IndexTemplate { sites: get_global_names().await }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/previous?<source_url>")]
|
#[get("/previous?<source_url>")]
|
||||||
|
|
26
templates/index.html
Normal file
26
templates/index.html
Normal 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>
|
Loading…
Reference in a new issue