git ssb

0+

Grey the earthling / gkn.me.uk



Tree: 305411b620accbb0d285152dac313c556e5c02c3

Files: 305411b620accbb0d285152dac313c556e5c02c3 / generator / templates / index.py

2256 bytesRaw
1import datetime
2
3import common
4
5
6def html(entries):
7 featured_entries = ["grey"]
8 min_recent_entries = 3
9 max_recent_entries = 20
10 max_age_days = 1461
11 earliest_recent_entries = datetime.datetime.now(
12 datetime.timezone.utc
13 ) - datetime.timedelta(days=max_age_days)
14 displayed_entries = [
15 entry
16 for entry in list(reversed(entries))
17 if entry in featured_entries
18 or list(reversed(entries)).index(entry) < min_recent_entries
19 or (
20 list(reversed(entries)).index(entry) < max_recent_entries
21 and (
22 common.entries[entry]["date"] >= earliest_recent_entries
23 or (
24 "modified" in common.entries[entry]
25 and common.entries[entry]["modified"] >= earliest_recent_entries
26 )
27 )
28 )
29 ]
30 list_of_entries = (
31 "<ol reversed>"
32 + "".join(
33 ("<li>" + common.link_to_entry(entry) + "</li>")
34 for entry in displayed_entries
35 )
36 + "</ol>"
37 )
38
39 return common.print_html(
40 f"""<!doctype html>
41 <html>
42 <head>
43 {common.head}
44 <title>{common.title('')}</title>
45 </head>
46 <body class="{common.colour_class}">
47 <header>
48 <h1>{common.title('')}</h1>
49 </header>
50 <main>
51 <hr/>
52 <section>
53 <p>Hi! I'm Grey. This is a collection of stuff I've written over the years.</p>
54 </section>
55 <hr/>
56 <nav>
57 {list_of_entries}
58 </nav>
59 </main>
60 <footer>
61 <hr/>
62 <nav>
63 <ul>
64 <li>{common.link_to_feed}</li>
65 <li>{common.link_to_all_entries}</li>
66 </ul>
67 </nav>
68 </footer>
69 </body>
70 </html>
71 """
72 )
73

Built with git-ssb-web