git ssb

0+

Grey the earthling / gkn.me.uk



Tree: e9e0d6d17453d5cf4876648c94e0eb11f6e9427b

Files: e9e0d6d17453d5cf4876648c94e0eb11f6e9427b / generator / templates / series.py

3554 bytesRaw
1import common
2
3
4def atom(entries, series):
5 return (
6 """<?xml version="1.0" encoding="utf-8"?>"""
7 """<feed xmlns="http://www.w3.org/2005/Atom">"""
8 "<title>" + series + "</title>"
9 "<id>" + common.base_url + common.url_of_series(series) + "</id>"
10 f"""<link href="{common.base_url}{common.url_of_series(series)}" rel="alternate"/>"""
11 f"""<link href="{common.base_url}{common.url_of_series_feed(series)}" rel="self"/>"""
12 "<author><name>Grey Nicholson</name></author>"
13 "<icon>" + common.base_url + "/style/icon.svg</icon>"
14 "<updated>"
15 + common.updated.isoformat()
16 + "</updated>"
17 + "\n"
18 + "\n".join(
19 common.atom_entry(id)
20 for id in reversed(entries)
21 if "series" in common.entries[id]
22 and common.slugify(series) == common.slugify(common.entries[id]["series"])
23 )
24 + "\n"
25 + "</feed>"
26 )
27
28
29def html(entries, series):
30 colour_class = common.slugify(series)
31 head = f"""<link href="{common.url_of_series_feed(series)}" rel="alternate" type="application/atom+xml" title="{series}">"""
32 list_of_entries = (
33 "<ol reversed>"
34 + "".join(
35 ("<li>" + common.link_to_entry(entry) + "</li>")
36 for entry in reversed(entries)
37 if "series" in entries[entry]
38 and common.slugify(series) == common.slugify(entries[entry]["series"])
39 )
40 + "</ol>"
41 )
42 list_of_series = (
43 (
44 "<h2>Series:</h2>"
45 + "<ul>"
46 + "".join(
47 (
48 "<li>"
49 + (
50 f"<strong>{series}</strong>"
51 if a_series == series
52 else (
53 f'<a href="{common.url_of_series(a_series)}">{a_series}</a>'
54 )
55 )
56 + "</li>"
57 )
58 for a_series in common.series
59 )
60 + "</ul>"
61 )
62 if len(common.series) > 0
63 else ""
64 )
65
66 return common.print_html(
67 f"""<!doctype html>
68 <html>
69 <head>
70 {common.head}
71 {head}
72 <title>{series}</title>
73 </head>
74 <body class="{colour_class}">
75 <header>
76 <div class="decoration"></div>
77 <h1>{series}</h1>
78 </header>
79 <main>
80 <hr/>
81 <nav>
82 {list_of_entries}
83 </nav>
84 <footer>
85 <hr/>
86 <nav>
87 <a href="{common.url_of_series_feed(series)}" rel="alternate" type="application/atom+xml">
88 <strong>Subscribe · {series}</strong>
89 </a>
90 </nav>
91 </footer>
92 </main>
93 <footer id="menu">
94 <hr/>
95 <nav class="menu">
96 <a href="/entries"><strong>All entries</strong></a>
97 {list_of_series}
98 </nav>
99 </footer>
100 {common.footer}
101 </body>
102 </html>
103 """
104 )
105

Built with git-ssb-web