aboutsummaryrefslogtreecommitdiff
path: root/src/modules/index.rs
blob: 46ffc7469f597b5a0e7626bc714e1cf13a19b026 (plain) (blame)
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
use super::blog::POSTS;

pub fn module(router: &mut windmark::router::Router) {
  crate::route::track_mount(
    router,
    "/",
    "This Gemini capsule's homepage",
    move |context| {
      crate::response::success(
        &format!(
          r#"# Fuwn[.me]

I enjoy writing for archaic systems in dated languages and with artificially imposed constraints, all while aiming for peak performance and minimal design.

=> https://github.com/Fuwn Projects (GitHub)

## Recent Posts

{}

## More

I write a lot of software and tooling for the Gemini protocol, the backbone of this site. You can learn more over at GemRest.

=> https://github.com/gemrest GemRest (GitHub)

Don't know where to start? Check out the directory or test your luck!

=> /directory Directory
=> /random I'm Feeling Lucky"#,
          {
            (*POSTS).lock().map_or_else(
              |_| "...".to_string(),
              |global_posts| {
                let mut posts = global_posts;

                posts.sort_by(|a, b| b.created_at().cmp(a.created_at()));

                posts
                  .iter()
                  .map(|post| format!("=> {} {}", post.title(), post.link()))
                  .collect::<Vec<String>>()
                  .into_iter()
                  .take(3)
                  .collect::<Vec<String>>()
                  .join("\n")
              },
            )
          }
        ),
        &context,
      )
    },
  );
}