git ssb

0+

Grey the earthling / gkn.me.uk



Tree: 305411b620accbb0d285152dac313c556e5c02c3

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

3628 bytesRaw
1import common
2
3
4def atom(entries, tag):
5 return (
6 """<?xml version="1.0" encoding="utf-8"?>"""
7 """<feed xmlns="http://www.w3.org/2005/Atom">"""
8 "<title>" + common.title(tag) + "</title>"
9 "<id>" + common.base_url + common.url_of_tag(tag) + "</id>"
10 f"""<link href="{common.base_url}{common.url_of_tag(tag)}" rel="alternate"/>"""
11 f"""<link href="{common.base_url}{common.url_of_tag_feed(tag)}" 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 "tags" in common.entries[id]
22 and common.slugify(tag) in map(common.slugify, common.entries[id]["tags"])
23 )
24 + "\n"
25 + "</feed>"
26 )
27
28
29def html(entries, tag):
30 head = f"""<link href="{common.url_of_tag_feed(tag)}" rel="alternate" type="application/atom+xml" title="{common.title(tag)}">"""
31 list_of_entries = (
32 "<ol reversed>"
33 + "".join(
34 ("<li>" + common.link_to_entry(entry) + "</li>")
35 for entry in reversed(entries)
36 if "tags" in entries[entry]
37 and common.slugify(tag) in map(common.slugify, entries[entry]["tags"])
38 )
39 + "</ol>"
40 )
41 list_of_tags = (
42 (
43 "<h2>Tags:</h2>"
44 + "<ul>"
45 + "".join(
46 (
47 "<li>"
48 + (
49 f"<strong>{repeated_tag}</strong>"
50 if repeated_tag == tag
51 else (
52 f'<a href="{common.url_of_tag(repeated_tag)}">{repeated_tag}</a>'
53 )
54 )
55 + "</li>"
56 )
57 for repeated_tag in common.repeated_tags
58 )
59 + "</ul>"
60 )
61 if len(common.repeated_tags) > 0
62 else ""
63 )
64
65 return common.print_html(
66 f"""<!doctype html>
67 <html>
68 <head>
69 {common.head}
70 {head}
71 <title>{common.title(tag)}</title>
72 </head>
73 <body class="{common.colour_class}">
74 <header>
75 <h1>{tag}</h1>
76 <nav>
77 <a href="#menu"><strong>Other lists of entries ↓</strong></a>
78 </nav>
79 </header>
80 <main>
81 <hr/>
82 <nav>
83 {list_of_entries}
84 </nav>
85 <footer>
86 <hr/>
87 <nav>
88 <a href="{common.url_of_tag_feed(tag)}" rel="alternate" type="application/atom+xml">
89 <strong>Subscribe · {tag}</strong>
90 </a>
91 </nav>
92 </footer>
93 </main>
94 <footer id="menu">
95 <hr/>
96 <nav class="menu">
97 <a href="/entries"><strong>All entries</strong></a>
98 {list_of_tags}
99 </nav>
100 </footer>
101 {common.footer}
102 </body>
103 </html>
104 """
105 )
106

Built with git-ssb-web