From b66d4f73ceaa324b59792d3f3ff483aecdd005cf Mon Sep 17 00:00:00 2001 From: Bat Date: Wed, 5 Sep 2018 18:03:02 +0100 Subject: [PATCH] Reorganize the homepage --- po/de.po | 3 ++ po/en.po | 3 ++ po/fr.po | 3 ++ po/gl.po | 3 ++ po/nb.po | 3 ++ po/pl.po | 3 ++ po/plume.pot | 3 ++ src/main.rs | 1 - src/routes/instance.rs | 22 +++++------ static/css/main.css | 4 ++ templates/instance/description.html.tera | 32 ++++++++++++++++ templates/instance/index.html.tera | 49 +++++------------------- templates/macros.html.tera | 8 ++++ 13 files changed, 85 insertions(+), 52 deletions(-) create mode 100644 templates/instance/description.html.tera diff --git a/po/de.po b/po/de.po index c68c290f..011e3f3a 100644 --- a/po/de.po +++ b/po/de.po @@ -542,5 +542,8 @@ msgstr "" msgid "Articles from {{ instance.name }}" msgstr "Über {{ instance_name }}" +msgid "View all" +msgstr "" + #~ msgid "Your password should be at least 8 characters long" #~ msgstr "Das Passwort sollte mindestens 8 Zeichen lang sein" diff --git a/po/en.po b/po/en.po index 088a8966..7e6333e9 100644 --- a/po/en.po +++ b/po/en.po @@ -528,3 +528,6 @@ msgstr "" #, fuzzy msgid "Articles from {{ instance.name }}" msgstr "Welcome on {{ instance_name }}" + +msgid "View all" +msgstr "" diff --git a/po/fr.po b/po/fr.po index bb93cb5a..6df847d8 100644 --- a/po/fr.po +++ b/po/fr.po @@ -536,3 +536,6 @@ msgstr "Tous les articles de la Fédiverse" msgid "Articles from {{ instance.name }}" msgstr "Articles de {{ instance.name }}" + +msgid "View all" +msgstr "Tout afficher" diff --git a/po/gl.po b/po/gl.po index 5e540067..576e4309 100644 --- a/po/gl.po +++ b/po/gl.po @@ -532,3 +532,6 @@ msgstr "" #, fuzzy msgid "Articles from {{ instance.name }}" msgstr "Acerca de {{ instance_name }}" + +msgid "View all" +msgstr "" diff --git a/po/nb.po b/po/nb.po index 616c28c1..ed08eeab 100644 --- a/po/nb.po +++ b/po/nb.po @@ -546,6 +546,9 @@ msgstr "" msgid "Articles from {{ instance.name }}" msgstr "Om {{ instance_name }}" +msgid "View all" +msgstr "" + #~ msgid "One reshare" #~ msgid_plural "{{ count }} reshares" #~ msgstr[0] "Én deling" diff --git a/po/pl.po b/po/pl.po index de3db664..d5f7d282 100644 --- a/po/pl.po +++ b/po/pl.po @@ -545,6 +545,9 @@ msgstr "" msgid "Articles from {{ instance.name }}" msgstr "O {{ instance_name }}" +msgid "View all" +msgstr "" + #~ msgid "One reshare" #~ msgid_plural "{{ count }} reshares" #~ msgstr[0] "Jedno udostępnienie" diff --git a/po/plume.pot b/po/plume.pot index f7afb413..f4d25180 100644 --- a/po/plume.pot +++ b/po/plume.pot @@ -516,3 +516,6 @@ msgstr "" msgid "Articles from {{ instance.name }}" msgstr "" + +msgid "View all" +msgstr "" diff --git a/src/main.rs b/src/main.rs index f8dde60d..aff653a5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -55,7 +55,6 @@ fn main() { routes::comments::create, - routes::instance::paginated_index, routes::instance::index, routes::instance::paginated_local, routes::instance::local, diff --git a/src/routes/instance.rs b/src/routes/instance.rs index 8f2f6cd4..1125da4a 100644 --- a/src/routes/instance.rs +++ b/src/routes/instance.rs @@ -15,18 +15,23 @@ use plume_models::{ use inbox::Inbox; use routes::Page; -#[get("/?")] -fn paginated_index(conn: DbConn, user: Option, page: Page) -> Template { +#[get("/")] +fn index(conn: DbConn, user: Option) -> Template { match Instance::get_local(&*conn) { 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!({ "instance": inst, "account": user.map(|u| u.to_json(&*conn)), - "recents": recents.into_iter().map(|p| p.to_json(&*conn)).collect::>(), - "page": page.page, - "n_pages": Page::total(Post::count(&*conn) as i32), + "federated": federated.into_iter().map(|p| p.to_json(&*conn)).collect::>(), + "local": local.into_iter().map(|p| p.to_json(&*conn)).collect::>(), + "user_feed": user_feed.map(|f| f.into_iter().map(|p| p.to_json(&*conn)).collect::>()), "n_users": User::count_local(&*conn), "n_articles": Post::count_local(&*conn) })) @@ -39,11 +44,6 @@ fn paginated_index(conn: DbConn, user: Option, page: Page) -> Template { } } -#[get("/")] -fn index(conn: DbConn, user: Option) -> Template { - paginated_index(conn, user, Page::first()) -} - #[get("/local?")] fn paginated_local(conn: DbConn, user: Option, page: Page) -> Template { let instance = Instance::get_local(&*conn).unwrap(); diff --git a/static/css/main.css b/static/css/main.css index 683cc725..adc4bdce 100644 --- a/static/css/main.css +++ b/static/css/main.css @@ -41,6 +41,10 @@ margin: 4rem 0; } + .cards.spaced { + margin: 1rem 0 5rem; + } + .banner { background: #DADADA; padding-top: 2em; diff --git a/templates/instance/description.html.tera b/templates/instance/description.html.tera new file mode 100644 index 00000000..ab289506 --- /dev/null +++ b/templates/instance/description.html.tera @@ -0,0 +1,32 @@ +
+
+
+

{{ "What is Plume?" | _ }}

+
+

{{ "Plume is a decentralized blogging engine." | _ }}

+

{{ "Authors can manage various blogs from an unique website." | _ }}

+

{{ "Articles are also visible on other Plume websites, and you can interact with them directly from other platforms like Mastodon." | _ }}

+
+ {{ "Create your account" | _ }} +
+
+

{{ "About {{ instance_name }}" | _(instance_name=instance.name) }}

+
+ {{ instance.short_description_html | safe }} +
+
+

{{ "Home to" | _ }}

+ {{ n_users }} +

{{ "people" | _ }}

+
+
+

{{ "Who wrote" | _ }}

+ {{ n_articles }} +

{{ "articles" | _ }}

+
+
+
+ {{ "Read the detailed rules" | _ }} +
+
+
diff --git a/templates/instance/index.html.tera b/templates/instance/index.html.tera index f9c69e1b..339ae791 100644 --- a/templates/instance/index.html.tera +++ b/templates/instance/index.html.tera @@ -10,47 +10,16 @@ {% if account %} {{ 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 %} {{ 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 %} - -
- {% for article in recents %} - {{ macros::post_card(article=article) }} - {% endfor %} -
- {{ macros::paginate(page=page, total=n_pages) }} - -
-
-
-

{{ "What is Plume?" | _ }}

-
-

{{ "Plume is a decentralized blogging engine." | _ }}

-

{{ "Authors can manage various blogs from an unique website." | _ }}

-

{{ "Articles are also visible on other Plume websites, and you can interact with them directly from other platforms like Mastodon." | _ }}

-
- {{ "Create your account" | _ }} -
-
-

{{ "About {{ instance_name }}" | _(instance_name=instance.name) }}

-
- {{ instance.short_description_html | safe }} -
-
-

{{ "Home to" | _ }}

- {{ n_users }} -

{{ "people" | _ }}

-
-
-

{{ "Who wrote" | _ }}

- {{ n_articles }} -

{{ "articles" | _ }}

-
-
-
- {{ "Read the detailed rules" | _ }} -
-
-
{% endblock content %} diff --git a/templates/macros.html.tera b/templates/macros.html.tera index 15c0f8aa..f1c9343b 100644 --- a/templates/macros.html.tera +++ b/templates/macros.html.tera @@ -76,3 +76,11 @@ {% endmacro %} +{% macro home_feed(title, link, articles) %} +

{{ title | _ }} — {{ "View all" | _ }}

+
+ {% for article in articles %} + {{ macros::post_card(article=article) }} + {% endfor %} +
+{% endmacro %}