add: journal note tags and directories

This commit is contained in:
trisua 2025-06-21 19:44:28 -04:00
parent a37312fecf
commit af6fbdf04e
16 changed files with 722 additions and 78 deletions

View file

@ -158,14 +158,6 @@ pub async fn view_request(
}
}
// ...
let notes = match data.0.get_notes_by_journal(journal.id).await {
Ok(p) => Some(p),
Err(e) => {
return Err(Html(render_error(e, &jar, &data, &user).await));
}
};
// ...
let note = if !selected_note.is_empty() {
match data
@ -199,7 +191,7 @@ pub async fn view_request(
context.insert("note", &note);
context.insert("owner", &owner);
context.insert("notes", &notes);
context.insert::<[i8; 0], &str>("notes", &[]);
context.insert("view_mode", &true);
context.insert("is_editor", &false);
@ -213,6 +205,7 @@ pub async fn index_view_request(
jar: CookieJar,
Extension(data): Extension<State>,
Path((owner, selected_journal)): Path<(String, String)>,
Query(props): Query<JournalsAppQuery>,
) -> impl IntoResponse {
let data = data.read().await;
let user = match get_user_from_token!(jar, data.0) {
@ -257,10 +250,23 @@ pub async fn index_view_request(
}
// ...
let notes = match data.0.get_notes_by_journal(journal.id).await {
Ok(p) => Some(p),
Err(e) => {
return Err(Html(render_error(e, &jar, &data, &user).await));
let notes = if props.tag.is_empty() {
match data.0.get_notes_by_journal(journal.id).await {
Ok(p) => Some(p),
Err(e) => {
return Err(Html(render_error(e, &jar, &data, &user).await));
}
}
} else {
match data
.0
.get_notes_by_journal_tag(journal.id, &props.tag)
.await
{
Ok(p) => Some(p),
Err(e) => {
return Err(Html(render_error(e, &jar, &data, &user).await));
}
}
};
@ -281,6 +287,7 @@ pub async fn index_view_request(
context.insert("view_mode", &true);
context.insert("is_editor", &false);
context.insert("tag", &props.tag);
// return
Ok(Html(data.1.render("journals/app.html", &context).unwrap()))