aboutsummaryrefslogtreecommitdiff
path: root/server/src/ui/node.rs
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/ui/node.rs')
-rw-r--r--server/src/ui/node.rs27
1 files changed, 21 insertions, 6 deletions
diff --git a/server/src/ui/node.rs b/server/src/ui/node.rs
index 87b8446..14c90c1 100644
--- a/server/src/ui/node.rs
+++ b/server/src/ui/node.rs
@@ -3,6 +3,7 @@
which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
Copyright (C) 2026 metamuffin <metamuffin.org>
*/
+
use super::error::MyResult;
use crate::{request_info::RequestInfo, ui_responder::UiResponse};
use anyhow::Result;
@@ -12,6 +13,7 @@ use jellycommon::{
};
use jellydb::{Filter, MultiBehaviour, Query, Sort, SortOrder, Transaction, ValueSort};
use rocket::get;
+use std::collections::BTreeMap;
#[get("/n/<slug>")]
pub fn r_node(ri: RequestInfo<'_>, slug: &str) -> MyResult<UiResponse> {
@@ -113,14 +115,11 @@ fn c_credits(
txn: &mut dyn Transaction,
nku: &Object,
) -> Result<()> {
- let mut list = ObjectBufferBuilder::default();
- list.push(NODELIST_DISPLAYSTYLE, NLSTYLE_INLINE);
- list.push(NODELIST_TITLE, "node.credits");
-
if !nku.get(NKU_NODE).unwrap_or_default().has(NO_CREDIT.0) {
return Ok(());
}
+ let mut cats = BTreeMap::<_, Vec<_>>::new();
for cred in nku.get(NKU_NODE).unwrap_or_default().iter(NO_CREDIT) {
let mut o = ObjectBuffer::empty();
if let Some(row) = cred.get(CR_NODE) {
@@ -130,10 +129,26 @@ fn c_credits(
if let Some(role) = cred.get(CR_ROLE) {
o = o.as_object().insert(NKU_ROLE, role)
}
- list.push(NODELIST_ITEM, o.as_object());
+ cats.entry(cred.get(CR_KIND).unwrap_or(CRCAT_CREW))
+ .or_default()
+ .push(o);
+ }
+ let mut cats = cats.into_iter().collect::<Vec<_>>();
+ cats.sort_by_key(|(c, _)| match *c {
+ CRCAT_CAST => 0,
+ CRCAT_CREW => 1,
+ _ => 100,
+ });
+ for (cat, elems) in cats {
+ let mut list = ObjectBufferBuilder::default();
+ list.push(NODELIST_DISPLAYSTYLE, NLSTYLE_INLINE);
+ list.push(NODELIST_TITLE, &format!("tag.cred.kind.{cat}"));
+ for item in elems {
+ list.push(NODELIST_ITEM, item.as_object());
+ }
+ page.push(VIEW_NODE_LIST, list.finish().as_object());
}
- page.push(VIEW_NODE_LIST, list.finish().as_object());
Ok(())
}