diff --git a/src/pages/dash/mod.rs b/src/pages/dash/mod.rs index 31be843..bb3985e 100644 --- a/src/pages/dash/mod.rs +++ b/src/pages/dash/mod.rs @@ -24,6 +24,7 @@ pub use super::{context, Footer, TemplateFile, PAGES, PAYLOAD_KEY, TEMPLATES}; use crate::db::Event; use crate::db::LibrePagesEvent; +pub mod gitea; pub mod home; pub mod sites; @@ -49,9 +50,11 @@ impl From for TemplateSiteEvent { pub fn register_templates(t: &mut tera::Tera) { home::DASH_HOME.register(t).expect(home::DASH_HOME.name); sites::register_templates(t); + gitea::register_templates(t); } pub fn services(cfg: &mut web::ServiceConfig) { home::services(cfg); sites::services(cfg); + gitea::services(cfg); } diff --git a/src/pages/routes.rs b/src/pages/routes.rs index d2a7870..cf1a8ce 100644 --- a/src/pages/routes.rs +++ b/src/pages/routes.rs @@ -72,6 +72,7 @@ pub struct Dash { /// home route pub home: &'static str, pub site: DashSite, + pub gitea_webhook: GiteaWebhook, } impl Dash { @@ -79,7 +80,37 @@ impl Dash { pub const fn new() -> Dash { let home = "/dash"; let site = DashSite::new(); - Dash { home, site } + let gitea_webhook = GiteaWebhook::new(); + Dash { + home, + site, + gitea_webhook, + } + } +} + +#[derive(Serialize)] +/// Dashboard GiteaWebhook routes +pub struct GiteaWebhook { + /// add gitea webhook route + pub add: &'static str, + /// view gitea webhook route + pub view: &'static str, + /// list gitea webhooks route + pub list: &'static str, +} + +impl GiteaWebhook { + /// create new instance of GiteaWebhook route + pub const fn new() -> GiteaWebhook { + let add = "/dash/gitea/webhook/add"; + let list = "/dash/gitea/webhook/list"; + let view = "/dash/gitea/webhook/view/{auth_token}"; + GiteaWebhook { add, view, list } + } + + pub fn get_view(&self, auth_token: &str) -> String { + self.view.replace("{auth_token}", auth_token) } }