mirror of
https://github.com/Nutomic/ibis.git
synced 2024-11-22 07:11:08 +00:00
Better rendering of edit history (fixes #57)
This commit is contained in:
parent
b530495acc
commit
b1f9510417
3 changed files with 18 additions and 9 deletions
|
@ -1,4 +1,5 @@
|
||||||
use crate::common::{utils::extract_domain, DbArticle, DbPerson};
|
use crate::common::{utils::extract_domain, DbArticle, DbPerson};
|
||||||
|
use chrono::{DateTime, Local, Utc};
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
|
|
||||||
pub mod api;
|
pub mod api;
|
||||||
|
@ -45,3 +46,10 @@ fn user_link(person: &DbPerson) -> impl IntoView {
|
||||||
let creator_path = format!("/user/{}", person.username);
|
let creator_path = format!("/user/{}", person.username);
|
||||||
view! { <a href=creator_path>{user_title(person)}</a> }
|
view! { <a href=creator_path>{user_title(person)}</a> }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn render_date_time(date_time: DateTime<Utc>) -> String {
|
||||||
|
date_time
|
||||||
|
.with_timezone(&Local)
|
||||||
|
.format("%Y-%m-%d %H:%M:%S")
|
||||||
|
.to_string()
|
||||||
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ use crate::frontend::{
|
||||||
components::article_nav::ArticleNav,
|
components::article_nav::ArticleNav,
|
||||||
extract_domain,
|
extract_domain,
|
||||||
pages::article_resource,
|
pages::article_resource,
|
||||||
|
render_date_time,
|
||||||
user_link,
|
user_link,
|
||||||
};
|
};
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
|
@ -35,15 +36,10 @@ pub fn ArticleHistory() -> impl IntoView {
|
||||||
extract_domain(&article.article.ap_id),
|
extract_domain(&article.article.ap_id),
|
||||||
edit.edit.hash.0,
|
edit.edit.hash.0,
|
||||||
);
|
);
|
||||||
let label = format!(
|
|
||||||
"{} ({})",
|
|
||||||
edit.edit.summary,
|
|
||||||
edit.edit.created.to_rfc2822(),
|
|
||||||
);
|
|
||||||
view! {
|
view! {
|
||||||
<li>
|
<li>
|
||||||
<a href=path>{label}</a>
|
{render_date_time(edit.edit.created)}": "
|
||||||
" by "
|
<a href=path>{edit.edit.summary}</a> " by "
|
||||||
{user_link(&edit.creator)}
|
{user_link(&edit.creator)}
|
||||||
</li>
|
</li>
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
use crate::frontend::{components::article_nav::ArticleNav, pages::article_resource, user_link};
|
use crate::frontend::{
|
||||||
|
components::article_nav::ArticleNav,
|
||||||
|
pages::article_resource,
|
||||||
|
render_date_time,
|
||||||
|
user_link,
|
||||||
|
};
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
use leptos_router::*;
|
use leptos_router::*;
|
||||||
|
|
||||||
|
@ -25,7 +30,7 @@ pub fn EditDiff() -> impl IntoView {
|
||||||
let label = format!(
|
let label = format!(
|
||||||
"{} ({})",
|
"{} ({})",
|
||||||
edit.edit.summary,
|
edit.edit.summary,
|
||||||
edit.edit.created.to_rfc2822(),
|
render_date_time(edit.edit.created),
|
||||||
);
|
);
|
||||||
view! {
|
view! {
|
||||||
<div class="item-view">
|
<div class="item-view">
|
||||||
|
|
Loading…
Reference in a new issue