70af57c6e1
All the template are now compiled at compile-time with the `ructe` crate. I preferred to use it instead of askama because it allows more complex Rust expressions, where askama only supports a small subset of expressions and doesn't allow them everywhere (for instance, `{{ macro!() | filter }}` would result in a parsing error). The diff is quite huge, but there is normally no changes in functionality. Fixes #161 and unblocks #110 and #273
35 lines
1.4 KiB
HTML
35 lines
1.4 KiB
HTML
@use templates::{base, partials::*};
|
|
@use template_utils::*;
|
|
@use plume_models::instance::Instance;
|
|
@use plume_models::posts::Post;
|
|
|
|
@(ctx: BaseContext, instance: Instance, n_users: i32, n_articles: i32, local: Vec<Post>, federated: Vec<Post>, user_feed: Option<Vec<Post>>)
|
|
|
|
@:base(ctx, instance.name.clone().as_ref(), {}, {}, {
|
|
<h1>@i18n!(ctx.1, "Welcome on {}"; instance.name.as_str())</h1>
|
|
|
|
@if ctx.2.is_some() {
|
|
@tabs(&[
|
|
("/", i18n!(ctx.1, "Latest articles"), true),
|
|
("/feed", i18n!(ctx.1, "Your feed"), false),
|
|
("/federated", i18n!(ctx.1, "Federated feed"), false),
|
|
("/local", i18n!(ctx.1, "Local feed"), false),
|
|
])
|
|
|
|
@:home_feed(ctx, user_feed.unwrap_or_default(), "/feed", "Your feed")
|
|
@:home_feed(ctx, federated, "/federated", "Federated feed")
|
|
@:home_feed(ctx, local, "/local", "Local feed")
|
|
@:instance_description(ctx, instance, n_users, n_articles)
|
|
} else {
|
|
@tabs(&[
|
|
("/", i18n!(ctx.1, "Latest articles"), true),
|
|
("/federated", i18n!(ctx.1, "Federated feed"), false),
|
|
("/local", i18n!(ctx.1, "Local feed"), false),
|
|
])
|
|
|
|
@:home_feed(ctx, federated, "/federated", "Federated feed")
|
|
@:home_feed(ctx, local, "/local", "Local feed")
|
|
@:instance_description(ctx, instance, n_users, n_articles)
|
|
}
|
|
})
|