Add a dedicated page for the federated feed

This commit is contained in:
Bat 2018-09-05 15:37:49 +01:00
parent 1496598a45
commit 79348e06ff
3 changed files with 35 additions and 0 deletions

View file

@ -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,

View file

@ -79,6 +79,22 @@ fn paginated_feed(conn: DbConn, user: User, page: Page) -> Template {
}))
}
#[get("/federated")]
fn federated(conn: DbConn, user: Option<User>) -> Template {
paginated_federated(conn, user, Page::first())
}
#[get("/federated?<page>")]
fn paginated_federated(conn: DbConn, user: Option<User>, 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::<Vec<serde_json::Value>>()
}))
}
#[get("/admin")]
fn admin(conn: DbConn, admin: Admin) -> Template {
Template::render("instance/admin", json!({

View file

@ -0,0 +1,17 @@
{% extends "base" %}
{% import "macros" as macros %}
{% block title %}
{{ "All the articles of the Fediverse" | _ }}
{% endblock title %}
{% block content %}
<h1>{{ "All the articles of the Fediverse" | _ }}</h1>
<div class="cards">
{% for article in articles %}
{{ macros::post_card(article=article) }}
{% endfor %}
</div>
{{ macros::paginate(page=page, total=n_pages) }}
{% endblock content %}