Files: b7eb7affd192e749bbc9858b3faada3dbf0d7ccc / generator / templates / series.py
4227 bytesRaw
1 | import common |
2 | |
3 | |
4 | def 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 | |
29 | def html(entries, series): |
30 | colour_class = common.slugify(series) |
31 | description_text = ( |
32 | "An occasional blog in which I recommend " |
33 | "interesting, obscure and underheard music" |
34 | if series == "the Friday Fetch-it" |
35 | else ( |
36 | "A stream-of-consciousness–type blog about " |
37 | "decay, perception, and dodgy assumptions" |
38 | ) |
39 | if series == "Walking Dataloss" |
40 | else "" |
41 | ) |
42 | description = ( |
43 | f'<p class="description">{description_text}</p>' if description_text else "" |
44 | ) |
45 | head = f"""<link href="{common.url_of_series_feed(series)}" rel="alternate" type="application/atom+xml" title="{series}">""" |
46 | list_of_entries = ( |
47 | "<ol>" |
48 | + "".join( |
49 | ("<li>" + common.link_to_entry(entry, omit_series=True) + "</li>") |
50 | for entry in entries |
51 | if "series" in entries[entry] |
52 | and common.slugify(series) == common.slugify(entries[entry]["series"]) |
53 | ) |
54 | + "</ol>" |
55 | ) |
56 | list_of_series = ( |
57 | ( |
58 | "<h2>Series:</h2>" |
59 | + "<ul>" |
60 | + "".join( |
61 | ( |
62 | "<li>" |
63 | + ( |
64 | f"<strong>{series}</strong>" |
65 | if a_series == series |
66 | else ( |
67 | f'<a href="{common.url_of_series(a_series)}">{a_series}</a>' |
68 | ) |
69 | ) |
70 | + "</li>" |
71 | ) |
72 | for a_series in common.series |
73 | ) |
74 | + "</ul>" |
75 | ) |
76 | if len(common.series) > 0 |
77 | else "" |
78 | ) |
79 | |
80 | return common.print_html( |
81 | f"""<!doctype html> |
82 | <html> |
83 | <head> |
84 | {common.head} |
85 | {head} |
86 | <title>{series}</title> |
87 | </head> |
88 | <body class="{colour_class}"> |
89 | <header> |
90 | <div class="decoration"></div> |
91 | <h1>{series}</h1> |
92 | {description} |
93 | <nav> |
94 | <a href="#menu"><strong>Other lists of entries ↓</strong></a> |
95 | </nav> |
96 | </header> |
97 | <main> |
98 | <hr/> |
99 | <nav> |
100 | {list_of_entries} |
101 | </nav> |
102 | <footer> |
103 | <hr/> |
104 | <nav> |
105 | <a href="{common.url_of_series_feed(series)}" rel="alternate" type="application/atom+xml"> |
106 | <strong>Subscribe · {series}</strong> |
107 | </a> |
108 | </nav> |
109 | </footer> |
110 | </main> |
111 | <footer id="menu"> |
112 | <hr/> |
113 | <nav class="menu"> |
114 | <a href="/entries"><strong>All entries</strong></a> |
115 | {list_of_series} |
116 | </nav> |
117 | </footer> |
118 | {common.footer} |
119 | </body> |
120 | </html> |
121 | """ |
122 | ) |
123 |
Built with git-ssb-web