1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
/*
This file is part of jellything (https://codeberg.org/metamuffin/jellything)
which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
Copyright (C) 2026 metamuffin <metamuffin.org>
*/
pub mod components;
pub(crate) mod format;
mod scaffold;
use std::borrow::Cow;
pub use jellyui_client_scripts::*;
pub use jellyui_client_style::*;
pub use jellyui_locale::tr;
use jellycommon::jellyobject::Object;
use markup::DynRender;
pub use scaffold::Scaffold;
use serde::{Deserialize, Serialize};
#[rustfmt::skip]
#[derive(Debug, Deserialize, Serialize, Default)]
pub struct Config {
pub brand: String,
pub slogan: String,
pub logo: bool,
}
pub trait Page {
fn title(&self) -> Cow<'static, str>;
fn ri(&self) -> &RenderInfo<'_>;
fn render(&self) -> DynRender<'_>;
}
pub struct RenderInfo<'a> {
pub user: Option<Object<'a>>,
pub message: Option<(&'a str, &'a str)>,
pub lang: &'a str,
pub status_message: Option<&'a str>,
pub config: &'a Config,
}
#[macro_export]
macro_rules! page {
($t:ty, $title:stmt) => {
impl $crate::Page for $t {
fn title(&self) -> std::borrow::Cow<'static, str> {
let x: fn(&$t) -> std::borrow::Cow<'static, str> = {$title};
x(self)
}
fn ri(&self) -> &$crate::RenderInfo<'_> {
self.ri
}
fn render(&self) -> markup::DynRender<'_> {
markup::new!(@self)
}
}
};
}
|