mirror of
https://github.com/Nutomic/ibis.git
synced 2024-11-22 07:51:09 +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 chrono::{DateTime, Local, Utc};
|
||||
use leptos::*;
|
||||
|
||||
pub mod api;
|
||||
|
@ -45,3 +46,10 @@ fn user_link(person: &DbPerson) -> impl IntoView {
|
|||
let creator_path = format!("/user/{}", person.username);
|
||||
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,
|
||||
extract_domain,
|
||||
pages::article_resource,
|
||||
render_date_time,
|
||||
user_link,
|
||||
};
|
||||
use leptos::*;
|
||||
|
@ -35,15 +36,10 @@ pub fn ArticleHistory() -> impl IntoView {
|
|||
extract_domain(&article.article.ap_id),
|
||||
edit.edit.hash.0,
|
||||
);
|
||||
let label = format!(
|
||||
"{} ({})",
|
||||
edit.edit.summary,
|
||||
edit.edit.created.to_rfc2822(),
|
||||
);
|
||||
view! {
|
||||
<li>
|
||||
<a href=path>{label}</a>
|
||||
" by "
|
||||
{render_date_time(edit.edit.created)}": "
|
||||
<a href=path>{edit.edit.summary}</a> " by "
|
||||
{user_link(&edit.creator)}
|
||||
</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_router::*;
|
||||
|
||||
|
@ -25,7 +30,7 @@ pub fn EditDiff() -> impl IntoView {
|
|||
let label = format!(
|
||||
"{} ({})",
|
||||
edit.edit.summary,
|
||||
edit.edit.created.to_rfc2822(),
|
||||
render_date_time(edit.edit.created),
|
||||
);
|
||||
view! {
|
||||
<div class="item-view">
|
||||
|
|
Loading…
Reference in a new issue