From f62c7f2a8cc143454779dc99334ca9fc80ddabd5 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Tue, 29 Apr 2025 11:10:21 +0200 Subject: still just moving code around --- common/src/lib.rs | 4 ++-- common/src/routes.rs | 24 ++++++++++++++++++++---- 2 files changed, 22 insertions(+), 6 deletions(-) (limited to 'common') diff --git a/common/src/lib.rs b/common/src/lib.rs index 26bf361..8993d22 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -30,7 +30,7 @@ macro_rules! url_enum { impl $i { pub const ALL: &'static [$i] = &[$($i::$vi),*]; pub fn to_str(&self) -> &'static str { match self { $(Self::$vi => $vk),* } } - pub fn from_str(s: &str) -> Option { match s { $($vk => Some(Self::$vi) ),*, _ => None } } + pub fn from_str_opt(s: &str) -> Option { match s { $($vk => Some(Self::$vi) ),*, _ => None } } } impl std::fmt::Display for $i { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { @@ -40,7 +40,7 @@ macro_rules! url_enum { impl std::str::FromStr for $i { type Err = (); fn from_str(s: &str) -> Result { - Self::from_str(s).ok_or(()) + Self::from_str_opt(s).ok_or(()) } } }; diff --git a/common/src/routes.rs b/common/src/routes.rs index e510e22..9472c85 100644 --- a/common/src/routes.rs +++ b/common/src/routes.rs @@ -3,7 +3,7 @@ which is licensed under the GNU Affero General Public License (version 3); see /COPYING. Copyright (C) 2025 metamuffin */ -use crate::{user::ApiWatchedState, NodeID, PeopleGroup}; +use crate::{api::NodeFilterSort, user::ApiWatchedState, NodeID, PeopleGroup}; pub fn u_home() -> String { "/home".to_owned() @@ -46,6 +46,25 @@ pub fn u_node_slug_update_rating(node: &str) -> String { pub fn u_node_slug_progress(node: &str, time: f64) -> String { format!("/n/{node}/progress?t={time}") } +pub fn u_items() -> String { + format!("/items") +} +pub fn u_items_filter(page: usize, _filter: &NodeFilterSort) -> String { + // TODO + format!("/items?page={page}") +} +pub fn u_admin_users() -> String { + format!("/admin/users") +} +pub fn u_admin_user(name: &str) -> String { + format!("/admin/user/{name}") +} +pub fn u_admin_user_permission(name: &str) -> String { + format!("/admin/user/{name}/update_permissions") +} +pub fn u_admin_user_remove(name: &str) -> String { + format!("/admin/user/{name}/remove") +} pub fn u_account_register() -> String { "/account/register".to_owned() } @@ -67,6 +86,3 @@ pub fn u_stats() -> String { pub fn u_search() -> String { "/search".to_owned() } -pub fn u_items() -> String { - "/items".to_owned() -} -- cgit v1.2.3-70-g09d2