add: following timeline
This commit is contained in:
parent
6141910059
commit
1ee1f29cdf
15 changed files with 176 additions and 9 deletions
|
@ -58,9 +58,48 @@ pub async fn index_request(
|
|||
let mut context = initial_context(&data.0.0, lang, &Some(user)).await;
|
||||
|
||||
context.insert("list", &list);
|
||||
context.insert("page", &req.page);
|
||||
Html(data.1.render("timelines/home.html", &context).unwrap())
|
||||
}
|
||||
|
||||
/// `/following`
|
||||
pub async fn following_request(
|
||||
jar: CookieJar,
|
||||
Extension(data): Extension<State>,
|
||||
Query(req): Query<PaginatedQuery>,
|
||||
) -> impl IntoResponse {
|
||||
let data = data.read().await;
|
||||
let user = match get_user_from_token!(jar, data.0) {
|
||||
Some(ua) => ua,
|
||||
None => {
|
||||
return Err(Html(
|
||||
render_error(Error::NotAllowed, &jar, &data, &None).await,
|
||||
));
|
||||
}
|
||||
};
|
||||
|
||||
let list = match data
|
||||
.0
|
||||
.get_posts_from_user_following(user.id, 12, req.page)
|
||||
.await
|
||||
{
|
||||
Ok(l) => match data.0.fill_posts_with_community(l).await {
|
||||
Ok(l) => l,
|
||||
Err(e) => return Err(Html(render_error(e, &jar, &data, &Some(user)).await)),
|
||||
},
|
||||
Err(e) => return Err(Html(render_error(e, &jar, &data, &Some(user)).await)),
|
||||
};
|
||||
|
||||
let lang = get_lang!(jar, data.0);
|
||||
let mut context = initial_context(&data.0.0, lang, &Some(user)).await;
|
||||
|
||||
context.insert("list", &list);
|
||||
context.insert("page", &req.page);
|
||||
Ok(Html(
|
||||
data.1.render("timelines/following.html", &context).unwrap(),
|
||||
))
|
||||
}
|
||||
|
||||
/// `/popular`
|
||||
pub async fn popular_request(
|
||||
jar: CookieJar,
|
||||
|
@ -82,6 +121,7 @@ pub async fn popular_request(
|
|||
let mut context = initial_context(&data.0.0, lang, &user).await;
|
||||
|
||||
context.insert("list", &list);
|
||||
context.insert("page", &req.page);
|
||||
Html(data.1.render("timelines/popular.html", &context).unwrap())
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ pub fn routes() -> Router {
|
|||
Router::new()
|
||||
// misc
|
||||
.route("/", get(misc::index_request))
|
||||
.route("/following", get(misc::following_request))
|
||||
.route("/popular", get(misc::popular_request))
|
||||
.route("/notifs", get(misc::notifications_request))
|
||||
.route("/doc/{*file_name}", get(misc::markdown_document_request))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue