Coverage for an_website / quotes / __init__.py: 100.000%
12 statements
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-21 19:24 +0000
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-21 19:24 +0000
1# This program is free software: you can redistribute it and/or modify
2# it under the terms of the GNU Affero General Public License as
3# published by the Free Software Foundation, either version 3 of the
4# License, or (at your option) any later version.
5#
6# This program is distributed in the hope that it will be useful,
7# but WITHOUT ANY WARRANTY; without even the implied warranty of
8# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9# GNU Affero General Public License for more details.
10#
11# You should have received a copy of the GNU Affero General Public License
12# along with this program. If not, see <https://www.gnu.org/licenses/>.
14"""A page with wrong quotes."""
17from tornado.web import RedirectHandler
19from ..utils.utils import ModuleInfo, PageInfo
20from .create import CreatePage1, CreatePage2
21from .generator import QuoteGenerator, QuoteGeneratorAPI
22from .image import QuoteAsImage
23from .info import AuthorsInfoPage, QuotesInfoPage
24from .quote_of_the_day import (
25 QuoteOfTheDayAPI,
26 QuoteOfTheDayRedirect,
27 QuoteOfTheDayRSS,
28)
29from .quotes import QuoteAPIHandler, QuoteById, QuoteMainPage, QuoteRedirectAPI
30from .share import ShareQuote
31from .utils import update_cache_periodically
34def get_module_info() -> ModuleInfo:
35 """Create and return the ModuleInfo for this module."""
36 return ModuleInfo(
37 handlers=(
38 (r"/zitate", QuoteMainPage),
39 # {1,10} is too much, but better too much than not enough
40 (r"/zitate/([0-9]{1,10})-([0-9]{1,10})", QuoteById),
41 (r"/zitate/([0-9]{1,10})", QuoteById),
42 (
43 r"/zitate/-([0-9]{1,10})",
44 RedirectHandler,
45 {"url": "/zitate/info/a/{0}"},
46 ),
47 (
48 r"/zitate/([0-9]{1,10})-",
49 RedirectHandler,
50 {"url": "/zitate/info/z/{0}"},
51 ),
52 ( # /zitate/69-420.html shouldn't say "unsupported file extension"
53 r"/zitate/([0-9]{1,10})-([0-9]{1,10}).html?",
54 RedirectHandler,
55 {"url": "/zitate/{0}-{1}"},
56 ),
57 ( # redirect to the new URL
58 r"/zitate/([0-9]{1,10})-([0-9]{1,10})/image\.([a-zA-Z]+)",
59 RedirectHandler,
60 {"url": "/zitate/{0}-{1}.{2}"},
61 ),
62 (
63 r"/zitate/([0-9]{1,10})-([0-9]{1,10})\.([a-zA-Z]+)",
64 QuoteAsImage,
65 ),
66 (
67 r"/zitate/([0-9]{1,10})()\.([a-zA-Z]+)",
68 QuoteAsImage,
69 ),
70 (
71 r"/zitate/([0-9]{1,10})-([0-9]{1,10})/image",
72 QuoteAsImage,
73 ),
74 (
75 r"/zitate/([0-9]{1,10})()/(image)",
76 QuoteAsImage,
77 ),
78 ( # redirect to the new URL (changed because of robots.txt)
79 r"/zitate/([0-9]{1,10})-([0-9]{1,10})/share",
80 RedirectHandler,
81 {"url": "/zitate/share/{0}-{1}"},
82 ),
83 (r"/zitate/share/([0-9]{1,10})-([0-9]{1,10})", ShareQuote),
84 (r"/api/zitate(/full|)", QuoteRedirectAPI),
85 (
86 r"/api/zitate/([0-9]{1,10})-([0-9]{1,10})(?:/full|)",
87 QuoteAPIHandler,
88 ),
89 (
90 r"/api/zitate/([0-9]{1,10})(?:/full|)",
91 QuoteAPIHandler,
92 ),
93 # quotes creator
94 (r"/zitate/erstellen", CreatePage1),
95 (r"/zitate/create-wrong-quote", CreatePage2),
96 # quote generator
97 (r"/zitate/generator", QuoteGenerator),
98 (r"/api/zitate/generator", QuoteGeneratorAPI),
99 # quote of the day
100 (r"/zitat-des-tages/feed", QuoteOfTheDayRSS),
101 (r"/zitat-des-tages", QuoteOfTheDayRedirect),
102 (
103 r"/zitat-des-tages/([0-9]{4}-[0-9]{2}-[0-9]{2})",
104 QuoteOfTheDayRedirect,
105 ),
106 (r"/api/zitat-des-tages", QuoteOfTheDayAPI),
107 (
108 r"/api/zitat-des-tages/([0-9]{4}-[0-9]{2}-[0-9]{2})",
109 QuoteOfTheDayAPI,
110 ),
111 (r"/api/zitat-des-tages/full", QuoteOfTheDayAPI),
112 (
113 r"/api/zitat-des-tages/([0-9]{4}-[0-9]{2}-[0-9]{2})/full",
114 QuoteOfTheDayAPI,
115 ),
116 # author/quote info
117 (r"/zitate/info/a/([0-9]{1,10})", AuthorsInfoPage),
118 (r"/zitate/info/z/([0-9]{1,10})", QuotesInfoPage),
119 ),
120 name="Falsch zugeordnete Zitate",
121 short_name="Falsche Zitate",
122 description="Witzige, aber falsch zugeordnete Zitate",
123 path="/zitate",
124 aliases=("/z",),
125 sub_pages=(
126 PageInfo(
127 name="Falsche-Zitate-Ersteller",
128 description="Erstelle witzige falsch zugeordnete Zitate",
129 path="/zitate/erstellen",
130 ),
131 PageInfo(
132 name="Der Zitate-Generator",
133 short_name="Zitate-Generator",
134 description="Lasse falsch zugeordnete Zitate generieren",
135 path="/zitate/generator",
136 keywords=(
137 "Generator",
138 "Falsche Zitate",
139 "Falsch zugeordnete Zitate",
140 ),
141 ),
142 PageInfo(
143 name="Das Zitat des Tages",
144 description="Jeden Tag ein anderes Zitat",
145 path="/zitat-des-tages",
146 keywords=(
147 "Zitate",
148 "Witzig",
149 "Känguru",
150 ),
151 ),
152 PageInfo(
153 name="Zitate API",
154 description="Ein zufälliges falsches Zitat",
155 path="/api/zitate",
156 hidden=True,
157 ),
158 ),
159 keywords=(
160 "falsch zugeordnet",
161 "Zitate",
162 "Witzig",
163 "Känguru",
164 "Marc-Uwe Kling",
165 "falsche Zitate",
166 "falsch zugeordnete Zitate",
167 ),
168 required_background_tasks=frozenset({update_cache_periodically}),
169 )