diff options
author | metamuffin <metamuffin@disroot.org> | 2025-04-29 11:10:21 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-04-29 11:10:21 +0200 |
commit | f62c7f2a8cc143454779dc99334ca9fc80ddabd5 (patch) | |
tree | f31dbb908715d2deb2860e2097fa13dd41d759d5 /common/src | |
parent | 73d2d5eb01fceae9e0b1c58afb648822000c878a (diff) | |
download | jellything-f62c7f2a8cc143454779dc99334ca9fc80ddabd5.tar jellything-f62c7f2a8cc143454779dc99334ca9fc80ddabd5.tar.bz2 jellything-f62c7f2a8cc143454779dc99334ca9fc80ddabd5.tar.zst |
still just moving code around
Diffstat (limited to 'common/src')
-rw-r--r-- | common/src/lib.rs | 4 | ||||
-rw-r--r-- | common/src/routes.rs | 24 |
2 files changed, 22 insertions, 6 deletions
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<Self> { match s { $($vk => Some(Self::$vi) ),*, _ => None } } + pub fn from_str_opt(s: &str) -> Option<Self> { 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, Self::Err> { - 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 <metamuffin.org> */ -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() -} |