~/selfhut

selfhut/src/index.rs -rw-r--r-- 596 B
0545f2a7 — Arthur Melton start of stuff working 2 years ago

            
0545f2a7 Arthur Melton
ad9e5164 arthurmelton
94e2262d arthurmelton
ef55c0da arthurmelton
0545f2a7 Arthur Melton
ad9e5164 arthurmelton
0545f2a7 Arthur Melton
ad9e5164 arthurmelton
94e2262d arthurmelton
ad9e5164 arthurmelton
0016c2cc arthurmelton
ad9e5164 arthurmelton
94e2262d arthurmelton
0016c2cc arthurmelton
ad9e5164 arthurmelton
94e2262d arthurmelton
ad9e5164 arthurmelton
0545f2a7 Arthur Melton
ad9e5164 arthurmelton
ef55c0da arthurmelton
ad9e5164 arthurmelton
0016c2cc arthurmelton
ad9e5164 arthurmelton
0545f2a7 Arthur Melton
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use crate::git::repos::get_repos;
use crate::config::CONFIG;

use rocket_dyn_templates::{Template, context};

#[get("/?<page>")]
pub fn index(page: Option<usize>) -> Option<Template> {
    let repos = get_repos()?;
    let page = page.unwrap_or(0);
    let last_item = if repos.len() > (page+1)*25 {
        (page+1)*25
    }
    else {
        repos.len()
    };
    Some(Template::render("index", context! {
        title: "Me",
        user: CONFIG.name.clone(),
        description: markdown::to_html(&CONFIG.description.clone()),
        repos: repos[page*25..last_item].to_vec(),
    }))
}