Works on template
Use uri! to generate links instead of hardcoded urls Fix #110 Fix invalid links needing to be POST forms Translate login message for boost and like directly from template Put js for search in its own file
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
@use template_utils::*;
|
||||
@use plume_models::blogs::Blog;
|
||||
@use plume_models::posts::Post;
|
||||
@use routes::*;
|
||||
|
||||
@(ctx: BaseContext, blogs: Vec<Blog>, drafts: Vec<Post>)
|
||||
|
||||
@@ -16,11 +17,11 @@
|
||||
<div class="cards">
|
||||
@for blog in blogs {
|
||||
<div class="card">
|
||||
<h3><a href="/~/@blog.actor_id/">@blog.title</a></h3>
|
||||
<h3><a href="@uri!(blogs::details: name = blog.actor_id)">@blog.title</a></h3>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<a class="button" href="/blogs/new">@i18n!(ctx.1, "Start a new blog")</a>
|
||||
<a class="button" href="@uri!(blogs::new)">@i18n!(ctx.1, "Start a new blog")</a>
|
||||
</section>
|
||||
|
||||
@if !drafts.is_empty() {
|
||||
@@ -36,6 +37,6 @@
|
||||
|
||||
<section>
|
||||
<h2>@i18n!(ctx.1, "Your media")</h2>
|
||||
<a class="button" href="/medias">@i18n!(ctx.1, "Go to your gallery")</a>
|
||||
<a class="button" href="@uri!(medias::list)">@i18n!(ctx.1, "Go to your gallery")</a>
|
||||
</section>
|
||||
})
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
@use template_utils::*;
|
||||
@use plume_models::posts::Post;
|
||||
@use plume_models::users::User;
|
||||
@use routes::*;
|
||||
|
||||
@(ctx: BaseContext, user: User, follows: bool, is_remote: bool, remote_url: String, recents: Vec<Post>, reshares: Vec<Post>)
|
||||
|
||||
@@ -9,14 +10,14 @@
|
||||
@:header(ctx, &user, follows, is_remote, remote_url)
|
||||
|
||||
@tabs(&[
|
||||
(&format!("/@/{}", user.get_fqn(ctx.0)), i18n!(ctx.1, "Articles"), true),
|
||||
(&format!("/@/{}/followers", user.get_fqn(ctx.0)), i18n!(ctx.1, "Followers"), false)
|
||||
(&uri!(user::details: name= user.get_fqn(ctx.0)).to_string(), i18n!(ctx.1, "Articles"), true),
|
||||
(&uri!(user::followers: name = user.get_fqn(ctx.0)).to_string(), i18n!(ctx.1, "Followers"), false)
|
||||
])
|
||||
|
||||
@if !recents.is_empty() {
|
||||
<h2>
|
||||
@i18n!(ctx.1, "Latest articles")
|
||||
<small><a href="/@@/@user.get_fqn(ctx.0)/atom.xml" title="@i18n!(ctx.1, "Atom feed")">@icon!("rss")</a></small>
|
||||
<small><a href="@uri!(user::atom_feed: name = user.get_fqn(ctx.0))" title="@i18n!(ctx.1, "Atom feed")">@icon!("rss")</a></small>
|
||||
</h2>
|
||||
<div class="cards">
|
||||
@for article in recents {
|
||||
|
||||
@@ -2,29 +2,32 @@
|
||||
@use template_utils::*;
|
||||
@use routes::user::UpdateUserForm;
|
||||
@use validator::ValidationErrors;
|
||||
@use routes::*;
|
||||
|
||||
@(ctx: BaseContext, form: UpdateUserForm, errors: ValidationErrors)
|
||||
|
||||
@:base(ctx, "Edit your account", {}, {}, {
|
||||
<h1>@i18n!(ctx.1, "Your Profile")</h1>
|
||||
<form method="post">
|
||||
<!-- Rocket hack to use various HTTP methods -->
|
||||
<input type=hidden name="_method" value="put">
|
||||
@if let Some(u) = ctx.2.clone() {
|
||||
<h1>@i18n!(ctx.1, "Your Profile")</h1>
|
||||
<form method="post" action="@uri!(user::update: _name = u.username.clone())">
|
||||
<!-- Rocket hack to use various HTTP methods -->
|
||||
<input type=hidden name="_method" value="put">
|
||||
|
||||
@input!(ctx.1, display_name (text), "Display name", form, errors.clone())
|
||||
@input!(ctx.1, email (text), "Email", form, errors.clone())
|
||||
@input!(ctx.1, summary (text), "Summary", form, errors)
|
||||
@input!(ctx.1, display_name (text), "Display name", form, errors.clone())
|
||||
@input!(ctx.1, email (text), "Email", form, errors.clone())
|
||||
@input!(ctx.1, summary (text), "Summary", form, errors)
|
||||
|
||||
<input type="submit" value="@i18n!(ctx.1, "Update account")"/>
|
||||
</form>
|
||||
|
||||
<h2>@i18n!(ctx.1, "Danger zone")</h2>
|
||||
<p>@i18n!(ctx.1, "Be very careful, any action taken here can't be cancelled.")
|
||||
@if !ctx.2.clone().expect("Editing profile while not connected").is_admin {
|
||||
<form method="post" action="/@@/@ctx.2.clone().expect("Editing profile while not connected").get_fqn(ctx.0)/delete">
|
||||
<input type="submit" class="inline-block button destructive" value="@i18n!(ctx.1, "Delete your account")">
|
||||
<input type="submit" value="@i18n!(ctx.1, "Update account")"/>
|
||||
</form>
|
||||
} else {
|
||||
<p>@i18n!(ctx.1, "Sorry, but as an admin, you can't leave your instance.")</p>
|
||||
|
||||
<h2>@i18n!(ctx.1, "Danger zone")</h2>
|
||||
<p>@i18n!(ctx.1, "Be very careful, any action taken here can't be cancelled.")
|
||||
@if !u.is_admin {
|
||||
<form method="post" action="@uri!(user::delete: name = u.username)">
|
||||
<input type="submit" class="inline-block button destructive" value="@i18n!(ctx.1, "Delete your account")">
|
||||
</form>
|
||||
} else {
|
||||
<p>@i18n!(ctx.1, "Sorry, but as an admin, you can't leave your instance.")</p>
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
@use templates::{base, users::header};
|
||||
@use template_utils::*;
|
||||
@use plume_models::users::User;
|
||||
@use routes::*;
|
||||
|
||||
@(ctx: BaseContext, user: User, follows: bool, is_remote: bool, remote_url: String, followers: Vec<User>, page: i32, n_pages: i32)
|
||||
|
||||
@@ -8,14 +9,14 @@
|
||||
@:header(ctx, &user, follows, is_remote, remote_url)
|
||||
|
||||
@tabs(&[
|
||||
(&format!("/@/{}", user.get_fqn(ctx.0)), i18n!(ctx.1, "Articles"), false),
|
||||
(&format!("/@/{}/followers", user.get_fqn(ctx.0)), i18n!(ctx.1, "Followers"), true)
|
||||
(&uri!(user::details: name= user.get_fqn(ctx.0)).to_string(), i18n!(ctx.1, "Articles"), false),
|
||||
(&uri!(user::followers: name = user.get_fqn(ctx.0)).to_string(), i18n!(ctx.1, "Followers"), true)
|
||||
])
|
||||
|
||||
<div class="cards">
|
||||
@for follower in followers {
|
||||
<div class="card">
|
||||
<h3><a href="/@@/@follower.get_fqn(ctx.0)/">@follower.name(ctx.0)</a> <small>@format!("@{}", follower.get_fqn(ctx.0))</small></h3>
|
||||
<h3><a href="@uri!(user::details: name = follower.get_fqn(ctx.0))">@follower.name(ctx.0)</a> <small>@format!("@{}", follower.get_fqn(ctx.0))</small></h3>
|
||||
<main><p>@Html(follower.summary)</p></main>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
@use template_utils::*;
|
||||
@use plume_models::users::User;
|
||||
@use routes::*;
|
||||
|
||||
@(ctx: BaseContext, user: &User, follows: bool, is_remote: bool, instance_url: String)
|
||||
|
||||
@@ -19,7 +20,7 @@
|
||||
|
||||
@if ctx.2.clone().map(|u| u.id == user.id).unwrap_or(false) {
|
||||
<span class="badge">@i18n!(ctx.1, "It is you")</span>
|
||||
<a href="/@@/@user.username/edit" class="button inline-block">@i18n!(ctx.1, "Edit your profile")</a>
|
||||
<a href="@uri!(user::edit: name = &user.username)" class="button inline-block">@i18n!(ctx.1, "Edit your profile")</a>
|
||||
}
|
||||
</p>
|
||||
</div>
|
||||
@@ -29,7 +30,7 @@
|
||||
}
|
||||
|
||||
@if ctx.2.clone().map(|u| u.id != user.id).unwrap_or(false) {
|
||||
<form class="inline" method="post" action="/@@/@user.get_fqn(ctx.0)/follow/">
|
||||
<form class="inline" method="post" action="@uri!(user::follow: name = user.get_fqn(ctx.0))">
|
||||
@if follows {
|
||||
<input type="submit" value="@i18n!(ctx.1, "Unfollow")">
|
||||
} else {
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
@use template_utils::*;
|
||||
@use routes::user::NewUserForm;
|
||||
@use validator::ValidationErrors;
|
||||
@use routes::*;
|
||||
|
||||
@(ctx: BaseContext, enabled: bool, form: &NewUserForm, errors: ValidationErrors)
|
||||
|
||||
@:base(ctx, "Edit your account", {}, {}, {
|
||||
@if enabled {
|
||||
<h1>@i18n!(ctx.1, "Create an account")</h1>
|
||||
<form method="post">
|
||||
<form method="post" action="@uri!(user::create)">
|
||||
@input!(ctx.1, username (text), "Username", form, errors.clone(), "minlenght=\"1\"")
|
||||
@input!(ctx.1, email (text), "Email", form, errors.clone())
|
||||
@input!(ctx.1, password (password), "Password", form, errors.clone(), "minlenght=\"8\"")
|
||||
|
||||
Reference in New Issue
Block a user