Add support for remote interact (#519)
Add support for remote interaction ([this thing](https://eldritch.cafe/users/Barmaid/remote_follow) in mastodon) - [x] create the endpoint dispatching remote interactions to local pages - [x] add this endpoint to web-finger - [x] propose remote interaction when following and not connected - [x] propose remote interaction when liking/sharing and not connected - [x] propose remote interaction when commenting and not connected - [x] fetch posts/comments we don't know but remote interaction was requested for ?
This commit is contained in:
committed by
Baptiste Gelez
parent
12efe721cc
commit
0d708e1639
@@ -110,20 +110,23 @@
|
||||
</form>
|
||||
</div>
|
||||
} else {
|
||||
<p class="center">@i18n!(ctx.1, "Log in, or use your Fediverse account to interact with this article")</p>
|
||||
<p class="center">@Html(i18n!(ctx.1, "{0}Log in{1}, or {2}use your Fediverse account{3} to interact with this article";
|
||||
format!("<a href='{}'>", uri!(session::new: m = _)), "</a>",
|
||||
format!("<a href='{}'>", uri!(posts::remote_interact: blog_name = &blog.fqn, slug = &article.slug)), "</a>"
|
||||
))</p>
|
||||
<div class="actions">
|
||||
<div class="likes">
|
||||
<p aria-label="@i18n!(ctx.1, "One like", "{0} likes"; n_likes)" title="@i18n!(ctx.1, "One like", "{0} likes"; n_likes)">
|
||||
@n_likes
|
||||
</p>
|
||||
<a href="@uri!(session::new: m = i18n!(ctx.1, "Log in to like"))" class="action">@icon!("heart") @i18n!(ctx.1, "Add yours")</a>
|
||||
<a href="@uri!(posts::remote_interact: blog_name = &blog.fqn, slug = &article.slug)" class="action">@icon!("heart") @i18n!(ctx.1, "Add yours")</a>
|
||||
</div>
|
||||
|
||||
<div class="reshares">
|
||||
<p aria-label="@i18n!(ctx.1, "One boost", "{0} boost"; n_reshares)" title="@i18n!(ctx.1, "One boost", "{0} boosts"; n_reshares)">
|
||||
@n_reshares
|
||||
</p>
|
||||
<a href="@uri!(session::new: m = i18n!(ctx.1, "Log in to boost"))" class="action">@icon!("repeat") @i18n!(ctx.1, "Boost")</a>
|
||||
<a href="@uri!(posts::remote_interact: blog_name = &blog.fqn, slug = &article.slug)" class="action">@icon!("repeat") @i18n!(ctx.1, "Boost")</a>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
@use templates::remote_interact_base;
|
||||
@use templates::partials::post_card;
|
||||
@use plume_models::posts::Post;
|
||||
@use routes::RemoteForm;
|
||||
@use routes::session::LoginForm;
|
||||
@use template_utils::*;
|
||||
@use validator::ValidationErrors;
|
||||
|
||||
@(ctx: BaseContext, post: Post, login_form: LoginForm, login_errs: ValidationErrors, remote_form: RemoteForm, remote_errs: ValidationErrors)
|
||||
|
||||
@:remote_interact_base(ctx, i18n!(ctx.1, "Interact with {}"; post.title.clone()), i18n!(ctx.1, "Log in to interact"), i18n!(ctx.1, "Enter your full username to interact"), {
|
||||
<h1>@i18n!(ctx.1, "Interact with {}"; post.title.clone())</h1>
|
||||
@:post_card(ctx, post)
|
||||
}, login_form, login_errs, remote_form, remote_errs)
|
||||
@@ -0,0 +1,32 @@
|
||||
@use templates::base;
|
||||
@use routes::session::LoginForm;
|
||||
@use routes::RemoteForm;
|
||||
@use template_utils::*;
|
||||
@use validator::ValidationErrors;
|
||||
|
||||
@(ctx: BaseContext, title: String, login_msg: String, remote_msg: String, header: Content, login_form: LoginForm, login_errs: ValidationErrors, remote_form: RemoteForm, remote_errs: ValidationErrors)
|
||||
|
||||
@:base(ctx, title, {}, {}, {
|
||||
<div>
|
||||
<header class="center">
|
||||
@:header()
|
||||
</header>
|
||||
|
||||
<div class="split">
|
||||
<form method="post" action="/login">
|
||||
<h2>@i18n!(ctx.1, "I'm from this instance")</h2>
|
||||
<p>@login_msg</p>
|
||||
@input!(ctx.1, email_or_name (text), "Username, or email", login_form, login_errs.clone(), "minlenght=\"1\"")
|
||||
@input!(ctx.1, password (password), "Password", login_form, login_errs, "minlenght=\"1\"")
|
||||
<input type="submit" value="@i18n!(ctx.1, "Log in")" />
|
||||
</form>
|
||||
|
||||
<form method="post">
|
||||
<h2>@i18n!(ctx.1, "I'm from another instance")</h2>
|
||||
<p>@remote_msg</p>
|
||||
@input!(ctx.1, remote (text), "Username", "Example: user@plu.me", remote_form, remote_errs.clone(), "minlenght=\"1\"")
|
||||
<input type="submit" value="@i18n!(ctx.1, "Continue to your instance")"/>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
})
|
||||
@@ -0,0 +1,14 @@
|
||||
@use templates::remote_interact_base;
|
||||
@use plume_models::users::User;
|
||||
@use routes::RemoteForm;
|
||||
@use routes::session::LoginForm;
|
||||
@use template_utils::*;
|
||||
@use validator::ValidationErrors;
|
||||
|
||||
@(ctx: BaseContext, user: User, login_form: LoginForm, login_errs: ValidationErrors, remote_form: RemoteForm, remote_errs: ValidationErrors)
|
||||
|
||||
@:remote_interact_base(ctx, i18n!(ctx.1, "Follow {}"; user.name()), i18n!(ctx.1, "Login to follow"), i18n!(ctx.1, "Enter your full username to follow"), {
|
||||
<h1>@i18n!(ctx.1, "Follow {}"; user.name())</h1>
|
||||
@avatar(ctx.0, &user, Size::Medium, false, ctx.1)
|
||||
<small>@@@user.fqn</small>
|
||||
}, login_form, login_errs, remote_form, remote_errs)
|
||||
@@ -32,7 +32,7 @@
|
||||
<a class="u-url" href="@user.ap_url"></a>
|
||||
}
|
||||
|
||||
@if ctx.2.clone().map(|u| u.id != user.id).unwrap_or(false) {
|
||||
@if ctx.2.clone().map(|u| u.id != user.id).unwrap_or(true) {
|
||||
<form class="inline" method="post" action="@uri!(user::follow: name = &user.fqn)">
|
||||
@if follows {
|
||||
<input type="submit" value="@i18n!(ctx.1, "Unsubscribe")">
|
||||
|
||||
Reference in New Issue
Block a user