Author | zPlus <zplus@peers.community> 2024-11-20 12:43:06 |
Committer | zPlus <zplus@peers.community> 2024-11-20 12:43:06 |
Commit | 13e68e2 (patch) |
Tree | 157ed65 |
Parent(s) |
-rwxr-xr-x | app.py | 29 | ||
-rw-r--r-- | pages/library.html | 3 | ||
?--------- | pages/templates/library/opds/books.tpl | 77 | ||
?--------- | pages/templates/library/opds/others.tpl | 78 | ||
?--------- | pages/templates/library/opds/root.tpl | 28 |
index ed3d417..d8dc38a | |||
old size: 12K - new size: 12K | |||
@@ -187,35 +187,6 @@ def library(): | |||
187 | 187 | return template('library.html', authors=authors, licenses=licenses, items=items, | |
188 | 188 | filters_author=filters_author, filters_license=filters_license) | |
189 | 189 | ||
190 | - | @bottle.get('/library/opds.xml', name='library_opds') | |
191 | - | def library_opds(): | |
192 | - | """ | |
193 | - | Serve OPDS Atom RSS feeds | |
194 | - | """ | |
195 | - | ||
196 | - | #response.content_type = 'text/xml; charset=utf-8' | |
197 | - | return template('templates/library/opds/root.tpl') | |
198 | - | ||
199 | - | @bottle.get('/library/opds/books.xml', name='library_opds_books') | |
200 | - | def library_opds_books(): | |
201 | - | """ | |
202 | - | Serve OPDS Atom RSS feeds. | |
203 | - | Items of type "books" only | |
204 | - | """ | |
205 | - | ||
206 | - | #response.content_type = 'text/xml; charset=utf-8' | |
207 | - | return template('templates/library/opds/books.tpl') | |
208 | - | ||
209 | - | @bottle.get('/library/opds/others.xml', name='library_opds_others') | |
210 | - | def library_opds_others(): | |
211 | - | """ | |
212 | - | Serve OPDS Atom RSS feeds. | |
213 | - | Uncategorized items only | |
214 | - | """ | |
215 | - | ||
216 | - | #response.content_type = 'text/xml; charset=utf-8' | |
217 | - | return template('templates/library/opds/others.tpl') | |
218 | - | ||
219 | 190 | @bottle.get('/library/<item_id>', name='library_item') | |
220 | 191 | def library_item(item_id): | |
221 | 192 | """ |
index 570f7d1..4e8db50 | |||
old size: 2K - new size: 2K | |||
@@ -6,9 +6,6 @@ | |||
6 | 6 | ||
7 | 7 | <div class="library"> | |
8 | 8 | ||
9 | - | <b>The library is also available via OPDS. Add this link to your OPDS client: https://dokk.org/library/opds.xml</b> | |
10 | - | <br /><br /><br /> | |
11 | - | ||
12 | 9 | <details> | |
13 | 10 | <summary>Filters</summary> | |
14 | 11 |
index b9df393..0000000 | |||
old size: 3K - new size: 0B | |||
deleted file mode: -rw-r--r-- |
@@ -1,77 +0,0 @@ | |||
1 | - | <?xml version="1.0" encoding="UTF-8"?> | |
2 | - | ||
3 | - | {% set data = query(""" | |
4 | - | PREFIX library: <dokk:library:> | |
5 | - | PREFIX license: <dokk:license:> | |
6 | - | ||
7 | - | CONSTRUCT { | |
8 | - | ?item library:title ?title; | |
9 | - | library:author ?author ; | |
10 | - | library:license ?license . | |
11 | - | ?license license:id ?license_id ; | |
12 | - | license:name ?license_name . | |
13 | - | } | |
14 | - | WHERE { | |
15 | - | ?item library:type 'book' ; | |
16 | - | library:title ?title ; | |
17 | - | library:author ?author ; | |
18 | - | library:license ?license . | |
19 | - | ||
20 | - | OPTIONAL { | |
21 | - | ?license license:id ?license_id_optional ; | |
22 | - | license:name ?license_name_optional . | |
23 | - | } | |
24 | - | ||
25 | - | BIND(COALESCE(?license_id_optional, SUBSTR(STR(?license), 14)) AS ?license_id) | |
26 | - | BIND(COALESCE(?license_name_optional, SUBSTR(STR(?license), 14)) AS ?license_name) | |
27 | - | } | |
28 | - | """, | |
29 | - | { | |
30 | - | '@context': { | |
31 | - | 'library': 'dokk:library:', | |
32 | - | 'license': 'dokk:license:', | |
33 | - | 'library:author': { '@container': '@set' }, | |
34 | - | 'library:license': { '@container': '@set' } | |
35 | - | }, | |
36 | - | 'library:title': {} | |
37 | - | }) | |
38 | - | %} | |
39 | - | ||
40 | - | <feed xmlns="http://www.w3.org/2005/Atom" | |
41 | - | xmlns:dc="http://purl.org/dc/terms/" | |
42 | - | xmlns:opds="http://opds-spec.org/2010/catalog"> | |
43 | - | ||
44 | - | <link rel="start" href="/library/opds.xml" type="application/atom+xml;profile=opds-catalog;kind=navigation"/> | |
45 | - | <link rel="self" href="/library/opds/books.xml" type="application/atom+xml;profile=opds-catalog;kind=acquisition"/> | |
46 | - | ||
47 | - | <id>urn:uuid:1ad42a21-f98f-44a9-b37a-7c4496ab661d</id> | |
48 | - | <title>DOKK Library Books</title> | |
49 | - | <updated>{{ now() }}</updated> | |
50 | - | <author> | |
51 | - | <name>DOKK</name> | |
52 | - | <uri>https://dokk.org</uri> | |
53 | - | </author> | |
54 | - | ||
55 | - | {% for item in data["@graph"]|sort(attribute="library:title") %} | |
56 | - | <entry> | |
57 | - | <title>{{ item['library:title'] }}</title> | |
58 | - | ||
59 | - | {% for author in item["library:author"]|sort() %} | |
60 | - | <author> | |
61 | - | <name>{{ author }}</name> | |
62 | - | </author> | |
63 | - | {% endfor%} | |
64 | - | ||
65 | - | {% for license in item["library:license"]|sort(attribute="license:id") %} | |
66 | - | <rights>{{ license['license:id'] }}</rights> | |
67 | - | {% endfor%} | |
68 | - | ||
69 | - | <updated></updated> | |
70 | - | ||
71 | - | <dc:language></dc:language> | |
72 | - | <dc:identifier></dc:identifier> | |
73 | - | <link rel="http://opds-spec.org/acquisition" href="https://blob.dokk.org/pdf/{{ item['@id'][8:] }}.pdf" type="application/pdf" /> | |
74 | - | <link rel="http://opds-spec.org/image" href="https://blob.dokk.org/pdf_cover/{{ item['@id'][8:] }}.pdf.png" type="image/png" /> | |
75 | - | </entry> | |
76 | - | {% endfor %} | |
77 | - | </feed> |
index 93c1025..0000000 | |||
old size: 3K - new size: 0B | |||
deleted file mode: -rw-r--r-- |
@@ -1,78 +0,0 @@ | |||
1 | - | <?xml version="1.0" encoding="UTF-8"?> | |
2 | - | ||
3 | - | {% set data = query(""" | |
4 | - | PREFIX library: <dokk:library:> | |
5 | - | PREFIX license: <dokk:license:> | |
6 | - | ||
7 | - | CONSTRUCT { | |
8 | - | ?item library:title ?title; | |
9 | - | library:author ?author ; | |
10 | - | library:license ?license . | |
11 | - | ?license license:id ?license_id ; | |
12 | - | license:name ?license_name . | |
13 | - | } | |
14 | - | WHERE { | |
15 | - | ?item library:title ?title ; | |
16 | - | library:author ?author ; | |
17 | - | library:license ?license . | |
18 | - | ||
19 | - | FILTER(NOT EXISTS { ?item library:type ?item_type }) | |
20 | - | ||
21 | - | OPTIONAL { | |
22 | - | ?license license:id ?license_id_optional ; | |
23 | - | license:name ?license_name_optional . | |
24 | - | } | |
25 | - | ||
26 | - | BIND(COALESCE(?license_id_optional, SUBSTR(STR(?license), 14)) AS ?license_id) | |
27 | - | BIND(COALESCE(?license_name_optional, SUBSTR(STR(?license), 14)) AS ?license_name) | |
28 | - | } | |
29 | - | """, | |
30 | - | { | |
31 | - | '@context': { | |
32 | - | 'library': 'dokk:library:', | |
33 | - | 'license': 'dokk:license:', | |
34 | - | 'library:author': { '@container': '@set' }, | |
35 | - | 'library:license': { '@container': '@set' } | |
36 | - | }, | |
37 | - | 'library:title': {} | |
38 | - | }) | |
39 | - | %} | |
40 | - | ||
41 | - | <feed xmlns="http://www.w3.org/2005/Atom" | |
42 | - | xmlns:dc="http://purl.org/dc/terms/" | |
43 | - | xmlns:opds="http://opds-spec.org/2010/catalog"> | |
44 | - | ||
45 | - | <link rel="start" href="/library/opds.xml" type="application/atom+xml;profile=opds-catalog;kind=navigation"/> | |
46 | - | <link rel="self" href="/library/opds/others.xml" type="application/atom+xml;profile=opds-catalog;kind=acquisition"/> | |
47 | - | ||
48 | - | <id>urn:uuid:98d6aff1-0df9-4229-8c6e-2ab0ebece9e1</id> | |
49 | - | <title>DOKK Library Other Materials</title> | |
50 | - | <updated>{{ now() }}</updated> | |
51 | - | <author> | |
52 | - | <name>DOKK</name> | |
53 | - | <uri>https://dokk.org</uri> | |
54 | - | </author> | |
55 | - | ||
56 | - | {% for item in data["@graph"]|sort(attribute="library:title") %} | |
57 | - | <entry> | |
58 | - | <title>{{ item['library:title'] }}</title> | |
59 | - | ||
60 | - | {% for author in item["library:author"]|sort() %} | |
61 | - | <author> | |
62 | - | <name>{{ author }}</name> | |
63 | - | </author> | |
64 | - | {% endfor%} | |
65 | - | ||
66 | - | {% for license in item["library:license"]|sort(attribute="license:id") %} | |
67 | - | <rights>{{ license['license:id'] }}</rights> | |
68 | - | {% endfor%} | |
69 | - | ||
70 | - | <updated></updated> | |
71 | - | ||
72 | - | <dc:language></dc:language> | |
73 | - | <dc:identifier></dc:identifier> | |
74 | - | <link rel="http://opds-spec.org/acquisition" href="https://blob.dokk.org/pdf/{{ item['@id'][8:] }}.pdf" type="application/pdf" /> | |
75 | - | <link rel="http://opds-spec.org/image" href="https://blob.dokk.org/pdf_cover/{{ item['@id'][8:] }}.pdf.png" type="image/png" /> | |
76 | - | </entry> | |
77 | - | {% endfor %} | |
78 | - | </feed> |
index e4314a4..0000000 | |||
old size: 1K - new size: 0B | |||
deleted file mode: -rw-r--r-- |
@@ -1,28 +0,0 @@ | |||
1 | - | <?xml version="1.0" encoding="UTF-8"?> | |
2 | - | <feed xmlns="http://www.w3.org/2005/Atom" | |
3 | - | xmlns:dc="http://purl.org/dc/terms/" | |
4 | - | xmlns:opds="http://opds-spec.org/2010/catalog"> | |
5 | - | ||
6 | - | <id>urn:uuid:37a3bc53-cce9-47a2-b557-2c2d5b73d915</id> | |
7 | - | <title>DOKK Library</title> | |
8 | - | <updated>{{ now() }}</updated> | |
9 | - | <author> | |
10 | - | <name>DOKK</name> | |
11 | - | <uri>https://dokk.org</uri> | |
12 | - | </author> | |
13 | - | ||
14 | - | <link rel="start" href="/library/opds.xml" type="application/atom+xml;profile=opds-catalog;kind=navigation"/> | |
15 | - | ||
16 | - | <entry> | |
17 | - | <title>Books</title> | |
18 | - | <link rel="subsection" href="/library/opds/books.xml" type="application/atom+xml;profile=opds-catalog;kind=acquisition"/> | |
19 | - | <updated>{{ now() }}</updated> | |
20 | - | <id>urn:uuid:1ad42a21-f98f-44a9-b37a-7c4496ab661d</id> | |
21 | - | </entry> | |
22 | - | <entry> | |
23 | - | <title>Other Materials</title> | |
24 | - | <link rel="subsection" href="/library/opds/others.xml" type="application/atom+xml;profile=opds-catalog;kind=acquisition"/> | |
25 | - | <updated>{{ now() }}</updated> | |
26 | - | <id>urn:uuid:98d6aff1-0df9-4229-8c6e-2ab0ebece9e1</id> | |
27 | - | </entry> | |
28 | - | </feed> |