index : gitrs
A lightweight web interface for browsing Git repositories, implemented in Rust
about summary refs log tree commit diff

Diffstat (limited to 'src/routes/mod.rs')

-rw-r--r-- src/routes/mod.rs 26
 1 file changed, 26 insertions(+)

diff --git a/src/routes/mod.rs b/src/routes/mod.rs
index 1718f92..bba66f6 100644
--- a/src/routes/mod.rs
+++ b/src/routes/mod.rs
@@ -26,6 +26,32 @@
    pub offset: Option<usize>,
}

impl PageQuery {
    pub fn id_param(&self) -> String {
        match &self.id {
            Some(id) => format!("?id={id}"),
            None => String::new(),
        }
    }

    pub fn head_param(&self) -> String {
        match (&self.id, &self.head) {
            (None, Some(head)) => format!("?h={head}"),
            _ => String::new(),
        }
    }

    pub fn id_or_head_param(&self) -> String {
        if let Some(id) = &self.id {
            format!("?id={id}")
        } else if let Some(head) = &self.head {
            format!("?h={head}")
        } else {
            String::new()
        }
    }
}

#[derive(Template)]
#[template(path = "repositorys.html")]
struct ReposPage {