Articles page
This commit is contained in:
1 parent
9e86897dcd
commit
d1a7e29f58
6 files changed
+68
-7
No files matched your search
@@ -9,7 +9,7 @@ use super::response::HtmlResponse;
|
|||||||
|
|
||||||
pub async fn handle(Extension(posts): Extension<ConcurrentPostsStore>) -> HtmlResponse {
|
pub async fn handle(Extension(posts): Extension<ConcurrentPostsStore>) -> HtmlResponse {
|
||||||
HtmlResponse::new()
|
HtmlResponse::new()
|
||||||
.with_title_static("Placeholder title")
|
.with_title_static("Pantonshire")
|
||||||
.with_crawler_permissive()
|
.with_crawler_permissive()
|
||||||
.with_head(html! {
|
.with_head(html! {
|
||||||
link href="/static/styles/main.css" rel="stylesheet";
|
link href="/static/styles/main.css" rel="stylesheet";
|
||||||
@@ -26,7 +26,7 @@ pub async fn handle(Extension(posts): Extension<ConcurrentPostsStore>) -> HtmlRe
|
|||||||
egg-shaped body and a smiling face, and is doing a little dance next \
|
egg-shaped body and a smiling face, and is doing a little dance next \
|
||||||
to a Raspberry Pi."
|
to a Raspberry Pi."
|
||||||
width="256";
|
width="256";
|
||||||
figcaption {
|
figcaption .quiet {
|
||||||
"Drawn by "
|
"Drawn by "
|
||||||
a href="https://twitter.com/smolrobots" { "@smolrobots" }
|
a href="https://twitter.com/smolrobots" { "@smolrobots" }
|
||||||
}
|
}
|
||||||
@@ -41,12 +41,15 @@ pub async fn handle(Extension(posts): Extension<ConcurrentPostsStore>) -> HtmlRe
|
|||||||
section .content_section {
|
section .content_section {
|
||||||
h2 { "Articles" }
|
h2 { "Articles" }
|
||||||
ul {
|
ul {
|
||||||
@for post in posts.read().await.iter_by_created().rev() {
|
@for post in posts.read().await.iter_by_created().rev().take(5) {
|
||||||
li {
|
li {
|
||||||
a href={"/articles/" (post.id_str())} { (post.title()) }
|
a href={"/articles/" (post.id_str())} { (post.title()) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
p {
|
||||||
|
a href="/articles" { "See all" }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
mod index;
|
mod index;
|
||||||
mod posts;
|
mod post;
|
||||||
|
mod posts_list;
|
||||||
mod response;
|
mod response;
|
||||||
mod site;
|
mod site;
|
||||||
mod static_content;
|
mod static_content;
|
||||||
|
|||||||
File renamed without changes.
@@ -0,0 +1,35 @@
|
|||||||
|
use axum::extract::Extension;
|
||||||
|
use maud::html;
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
posts_store::ConcurrentPostsStore,
|
||||||
|
template,
|
||||||
|
};
|
||||||
|
use super::response::HtmlResponse;
|
||||||
|
|
||||||
|
pub async fn handle(Extension(posts): Extension<ConcurrentPostsStore>) -> HtmlResponse {
|
||||||
|
HtmlResponse::new()
|
||||||
|
.with_title_static("Articles")
|
||||||
|
.with_crawler_permissive()
|
||||||
|
.with_head(html! {
|
||||||
|
link href="/static/styles/main.css" rel="stylesheet";
|
||||||
|
})
|
||||||
|
.with_body(template::main_page(html! {
|
||||||
|
section .content_section {
|
||||||
|
h1 { "Articles" }
|
||||||
|
p {
|
||||||
|
"A collection of words I have written, against my better judgement."
|
||||||
|
}
|
||||||
|
ul {
|
||||||
|
@for post in posts.read().await.iter_by_created().rev() {
|
||||||
|
li {
|
||||||
|
a href={"/articles/" (post.id_str())} { (post.title()) }
|
||||||
|
span class="quiet" {
|
||||||
|
" — " (post.created().format("%Y/%m/%d"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
}
|
||||||
@@ -14,7 +14,8 @@ use tracing::info;
|
|||||||
use crate::posts_store::ConcurrentPostsStore;
|
use crate::posts_store::ConcurrentPostsStore;
|
||||||
use super::{
|
use super::{
|
||||||
index,
|
index,
|
||||||
posts,
|
post,
|
||||||
|
posts_list,
|
||||||
response::ErrorResponse,
|
response::ErrorResponse,
|
||||||
static_content,
|
static_content,
|
||||||
};
|
};
|
||||||
@@ -27,7 +28,8 @@ pub fn service(
|
|||||||
{
|
{
|
||||||
Router::new()
|
Router::new()
|
||||||
.route("/", get(index::handle))
|
.route("/", get(index::handle))
|
||||||
.route("/articles/:post_id", get(posts::handle))
|
.route("/articles", get(posts_list::handle))
|
||||||
|
.route("/articles/:post_id", get(post::handle))
|
||||||
.nest("/static", static_content::service(static_dir))
|
.nest("/static", static_content::service(static_dir))
|
||||||
.fallback(handle_fallback.into_service())
|
.fallback(handle_fallback.into_service())
|
||||||
.layer(ConcurrencyLimitLayer::new(concurrency_limit))
|
.layer(ConcurrencyLimitLayer::new(concurrency_limit))
|
||||||
|
|||||||
+21
-1
@@ -146,7 +146,19 @@ body {
|
|||||||
margin-bottom: 2rem;
|
margin-bottom: 2rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.quiet {
|
||||||
|
color: #898989;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
font-size: 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
h2 {
|
h2 {
|
||||||
|
font-size: 1.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1, h2 {
|
||||||
margin-top: 0.5rem;
|
margin-top: 0.5rem;
|
||||||
margin-bottom: 0.5rem;
|
margin-bottom: 0.5rem;
|
||||||
}
|
}
|
||||||
@@ -161,13 +173,21 @@ figure {
|
|||||||
figcaption {
|
figcaption {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
color: #898989;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
figcaption a {
|
figcaption a {
|
||||||
color: inherit;
|
color: inherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ul {
|
||||||
|
list-style-type: circle;
|
||||||
|
}
|
||||||
|
|
||||||
|
li {
|
||||||
|
margin-top: 0.5rem;
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Palette
|
Palette
|
||||||
#94BFBE
|
#94BFBE
|
||||||
|
|||||||
Reference in new issue
Block a user