diff --git a/src/main.rs b/src/main.rs index c058e3f..f8dde60 100644 --- a/src/main.rs +++ b/src/main.rs @@ -61,6 +61,8 @@ fn main() { routes::instance::local, routes::instance::paginated_feed, routes::instance::feed, + routes::instance::paginated_federated, + routes::instance::federated, routes::instance::admin, routes::instance::update_settings, routes::instance::shared_inbox, diff --git a/src/routes/instance.rs b/src/routes/instance.rs index b78e5ec..8f2f6cd 100644 --- a/src/routes/instance.rs +++ b/src/routes/instance.rs @@ -79,6 +79,22 @@ fn paginated_feed(conn: DbConn, user: User, page: Page) -> Template { })) } +#[get("/federated")] +fn federated(conn: DbConn, user: Option) -> Template { + paginated_federated(conn, user, Page::first()) +} + +#[get("/federated?")] +fn paginated_federated(conn: DbConn, user: Option, page: Page) -> Template { + let articles = Post::get_recents_page(&*conn, page.limits()); + Template::render("instance/federated", json!({ + "account": user.map(|u| u.to_json(&*conn)), + "page": page.page, + "n_pages": Page::total(Post::count_local(&*conn) as i32), + "articles": articles.into_iter().map(|p| p.to_json(&*conn)).collect::>() + })) +} + #[get("/admin")] fn admin(conn: DbConn, admin: Admin) -> Template { Template::render("instance/admin", json!({ diff --git a/templates/instance/federated.html.tera b/templates/instance/federated.html.tera new file mode 100644 index 0000000..8bf6c64 --- /dev/null +++ b/templates/instance/federated.html.tera @@ -0,0 +1,17 @@ +{% extends "base" %} +{% import "macros" as macros %} + +{% block title %} +{{ "All the articles of the Fediverse" | _ }} +{% endblock title %} + +{% block content %} +

{{ "All the articles of the Fediverse" | _ }}

+ +
+ {% for article in articles %} + {{ macros::post_card(article=article) }} + {% endfor %} +
+ {{ macros::paginate(page=page, total=n_pages) }} +{% endblock content %}