Files: a0309f1d97b0f84149a012005342f06881034ab3 / generator / templates / series.py
3688 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 | head = f"""<link href="{common.url_of_series_feed(series)}" rel="alternate" type="application/atom+xml" title="{series}">""" |
32 | list_of_entries = ( |
33 | "<ol>" |
34 | + "".join( |
35 | ("<li>" + common.link_to_entry(entry) + "</li>") |
36 | for entry in 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 | <nav> |
79 | <a href="#menu"><strong>Other lists of entries ↓</strong></a> |
80 | </nav> |
81 | </header> |
82 | <main> |
83 | <hr/> |
84 | <nav> |
85 | {list_of_entries} |
86 | </nav> |
87 | <footer> |
88 | <hr/> |
89 | <nav> |
90 | <a href="{common.url_of_series_feed(series)}" rel="alternate" type="application/atom+xml"> |
91 | <strong>Subscribe · {series}</strong> |
92 | </a> |
93 | </nav> |
94 | </footer> |
95 | </main> |
96 | <footer id="menu"> |
97 | <hr/> |
98 | <nav class="menu"> |
99 | <a href="/entries"><strong>All entries</strong></a> |
100 | {list_of_series} |
101 | </nav> |
102 | </footer> |
103 | {common.footer} |
104 | </body> |
105 | </html> |
106 | """ |
107 | ) |
108 |
Built with git-ssb-web