diff --git a/src/main.rs b/src/main.rs index c058e3fa..f8dde60d 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 b78e5ece..8f2f6cd4 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 00000000..8bf6c649 --- /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 %}