Reorganize the homepage

This commit is contained in:
Bat 2018-09-05 18:03:02 +01:00
parent 39342d2f72
commit b66d4f73ce
13 changed files with 85 additions and 52 deletions

View file

@ -542,5 +542,8 @@ msgstr ""
msgid "Articles from {{ instance.name }}" msgid "Articles from {{ instance.name }}"
msgstr "Über {{ instance_name }}" msgstr "Über {{ instance_name }}"
msgid "View all"
msgstr ""
#~ msgid "Your password should be at least 8 characters long" #~ msgid "Your password should be at least 8 characters long"
#~ msgstr "Das Passwort sollte mindestens 8 Zeichen lang sein" #~ msgstr "Das Passwort sollte mindestens 8 Zeichen lang sein"

View file

@ -528,3 +528,6 @@ msgstr ""
#, fuzzy #, fuzzy
msgid "Articles from {{ instance.name }}" msgid "Articles from {{ instance.name }}"
msgstr "Welcome on {{ instance_name }}" msgstr "Welcome on {{ instance_name }}"
msgid "View all"
msgstr ""

View file

@ -536,3 +536,6 @@ msgstr "Tous les articles de la Fédiverse"
msgid "Articles from {{ instance.name }}" msgid "Articles from {{ instance.name }}"
msgstr "Articles de {{ instance.name }}" msgstr "Articles de {{ instance.name }}"
msgid "View all"
msgstr "Tout afficher"

View file

@ -532,3 +532,6 @@ msgstr ""
#, fuzzy #, fuzzy
msgid "Articles from {{ instance.name }}" msgid "Articles from {{ instance.name }}"
msgstr "Acerca de {{ instance_name }}" msgstr "Acerca de {{ instance_name }}"
msgid "View all"
msgstr ""

View file

@ -546,6 +546,9 @@ msgstr ""
msgid "Articles from {{ instance.name }}" msgid "Articles from {{ instance.name }}"
msgstr "Om {{ instance_name }}" msgstr "Om {{ instance_name }}"
msgid "View all"
msgstr ""
#~ msgid "One reshare" #~ msgid "One reshare"
#~ msgid_plural "{{ count }} reshares" #~ msgid_plural "{{ count }} reshares"
#~ msgstr[0] "Én deling" #~ msgstr[0] "Én deling"

View file

@ -545,6 +545,9 @@ msgstr ""
msgid "Articles from {{ instance.name }}" msgid "Articles from {{ instance.name }}"
msgstr "O {{ instance_name }}" msgstr "O {{ instance_name }}"
msgid "View all"
msgstr ""
#~ msgid "One reshare" #~ msgid "One reshare"
#~ msgid_plural "{{ count }} reshares" #~ msgid_plural "{{ count }} reshares"
#~ msgstr[0] "Jedno udostępnienie" #~ msgstr[0] "Jedno udostępnienie"

View file

@ -516,3 +516,6 @@ msgstr ""
msgid "Articles from {{ instance.name }}" msgid "Articles from {{ instance.name }}"
msgstr "" msgstr ""
msgid "View all"
msgstr ""

View file

@ -55,7 +55,6 @@ fn main() {
routes::comments::create, routes::comments::create,
routes::instance::paginated_index,
routes::instance::index, routes::instance::index,
routes::instance::paginated_local, routes::instance::paginated_local,
routes::instance::local, routes::instance::local,

View file

@ -15,18 +15,23 @@ use plume_models::{
use inbox::Inbox; use inbox::Inbox;
use routes::Page; use routes::Page;
#[get("/?<page>")] #[get("/")]
fn paginated_index(conn: DbConn, user: Option<User>, page: Page) -> Template { fn index(conn: DbConn, user: Option<User>) -> Template {
match Instance::get_local(&*conn) { match Instance::get_local(&*conn) {
Some(inst) => { Some(inst) => {
let recents = Post::get_recents_page(&*conn, page.limits()); let federated = Post::get_recents_page(&*conn, Page::first().limits());
let local = Post::get_instance_page(&*conn, inst.id, Page::first().limits());
let user_feed = user.clone().map(|user| {
let followed = user.get_following(&*conn);
Post::user_feed_page(&*conn, followed.into_iter().map(|u| u.id).collect(), Page::first().limits())
});
Template::render("instance/index", json!({ Template::render("instance/index", json!({
"instance": inst, "instance": inst,
"account": user.map(|u| u.to_json(&*conn)), "account": user.map(|u| u.to_json(&*conn)),
"recents": recents.into_iter().map(|p| p.to_json(&*conn)).collect::<Vec<serde_json::Value>>(), "federated": federated.into_iter().map(|p| p.to_json(&*conn)).collect::<Vec<serde_json::Value>>(),
"page": page.page, "local": local.into_iter().map(|p| p.to_json(&*conn)).collect::<Vec<serde_json::Value>>(),
"n_pages": Page::total(Post::count(&*conn) as i32), "user_feed": user_feed.map(|f| f.into_iter().map(|p| p.to_json(&*conn)).collect::<Vec<serde_json::Value>>()),
"n_users": User::count_local(&*conn), "n_users": User::count_local(&*conn),
"n_articles": Post::count_local(&*conn) "n_articles": Post::count_local(&*conn)
})) }))
@ -39,11 +44,6 @@ fn paginated_index(conn: DbConn, user: Option<User>, page: Page) -> Template {
} }
} }
#[get("/")]
fn index(conn: DbConn, user: Option<User>) -> Template {
paginated_index(conn, user, Page::first())
}
#[get("/local?<page>")] #[get("/local?<page>")]
fn paginated_local(conn: DbConn, user: Option<User>, page: Page) -> Template { fn paginated_local(conn: DbConn, user: Option<User>, page: Page) -> Template {
let instance = Instance::get_local(&*conn).unwrap(); let instance = Instance::get_local(&*conn).unwrap();

View file

@ -41,6 +41,10 @@
margin: 4rem 0; margin: 4rem 0;
} }
.cards.spaced {
margin: 1rem 0 5rem;
}
.banner { .banner {
background: #DADADA; background: #DADADA;
padding-top: 2em; padding-top: 2em;

View file

@ -0,0 +1,32 @@
<section class="spaced">
<div class="cards">
<div class="presentation card">
<h2>{{ "What is Plume?" | _ }}</h2>
<main>
<p>{{ "Plume is a decentralized blogging engine." | _ }}</p>
<p>{{ "Authors can manage various blogs from an unique website." | _ }}</p>
<p>{{ "Articles are also visible on other Plume websites, and you can interact with them directly from other platforms like Mastodon." | _ }}</p>
</main>
<a href="/users/new">{{ "Create your account" | _ }}</a>
</div>
<div class="presentation card">
<h2>{{ "About {{ instance_name }}" | _(instance_name=instance.name) }}</h2>
<main>
{{ instance.short_description_html | safe }}
<section class="stats">
<div>
<p>{{ "Home to" | _ }}</p>
<em>{{ n_users }}</em>
<p>{{ "people" | _ }}</p>
</div>
<div>
<p>{{ "Who wrote" | _ }}</p>
<em>{{ n_articles }}</em>
<p>{{ "articles" | _ }}</p>
</div>
</section>
</main>
<a href="/about">{{ "Read the detailed rules" | _ }}</a>
</div>
</div>
</section>

View file

@ -10,47 +10,16 @@
{% if account %} {% if account %}
{{ macros::tabs(links=['/', '/feed', '/federated', '/local'], titles=['Latest articles', 'Your feed', 'Federated feed', 'Local feed'], selected=1) }} {{ macros::tabs(links=['/', '/feed', '/federated', '/local'], titles=['Latest articles', 'Your feed', 'Federated feed', 'Local feed'], selected=1) }}
{{ macros::home_feed(title='Your feed', link='/feed', articles=user_feed) }}
{{ macros::home_feed(title='Federated feed', link='/federated', articles=federated) }}
{{ macros::home_feed(title='Local feed', link='/local', articles=local) }}
{% include "instance/description" %}
{% else %} {% else %}
{{ macros::tabs(links=['/', '/federated', '/local'], titles=['Latest articles', 'Federated feed', 'Local feed'], selected=1) }} {{ macros::tabs(links=['/', '/federated', '/local'], titles=['Latest articles', 'Federated feed', 'Local feed'], selected=1) }}
{{ macros::home_feed(title='Federated feed', link='/federated', articles=federated) }}
{% include "instance/description" %}
{{ macros::home_feed(title='Local feed', link='/local', articles=local) }}
{% endif %} {% endif %}
<div class="cards">
{% for article in recents %}
{{ macros::post_card(article=article) }}
{% endfor %}
</div>
{{ macros::paginate(page=page, total=n_pages) }}
<section class="spaced">
<div class="cards">
<div class="presentation card">
<h2>{{ "What is Plume?" | _ }}</h2>
<main>
<p>{{ "Plume is a decentralized blogging engine." | _ }}</p>
<p>{{ "Authors can manage various blogs from an unique website." | _ }}</p>
<p>{{ "Articles are also visible on other Plume websites, and you can interact with them directly from other platforms like Mastodon." | _ }}</p>
</main>
<a href="/users/new">{{ "Create your account" | _ }}</a>
</div>
<div class="presentation card">
<h2>{{ "About {{ instance_name }}" | _(instance_name=instance.name) }}</h2>
<main>
{{ instance.short_description_html | safe }}
<section class="stats">
<div>
<p>{{ "Home to" | _ }}</p>
<em>{{ n_users }}</em>
<p>{{ "people" | _ }}</p>
</div>
<div>
<p>{{ "Who wrote" | _ }}</p>
<em>{{ n_articles }}</em>
<p>{{ "articles" | _ }}</p>
</div>
</section>
</main>
<a href="/about">{{ "Read the detailed rules" | _ }}</a>
</div>
</div>
</section>
{% endblock content %} {% endblock content %}

View file

@ -76,3 +76,11 @@
<use xlink:href="/static/images/feather-sprite.svg#{{ name }}"/> <use xlink:href="/static/images/feather-sprite.svg#{{ name }}"/>
</svg> </svg>
{% endmacro %} {% endmacro %}
{% macro home_feed(title, link, articles) %}
<h2>{{ title | _ }} &mdash; <a href="{{ link }}">{{ "View all" | _ }}</a></h2>
<div class="cards spaced">
{% for article in articles %}
{{ macros::post_card(article=article) }}
{% endfor %}
</div>
{% endmacro %}