Coverage for an_website/soundboard/__init__.py: 100.000%
9 statements
« prev ^ index » next coverage.py v7.14.1, created at 2026-06-10 18:56 +0000
« prev ^ index » next coverage.py v7.14.1, created at 2026-06-10 18:56 +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"""Create the required stuff for the soundboard from the info in info.json."""
16from typing import Final
18from tornado.web import RedirectHandler
20from .. import DIR as ROOT_DIR
21from ..utils.static_file_from_traversable import TraversableStaticFileHandler
22from ..utils.utils import ModuleInfo, PageInfo
23from .soundboard import SoundboardHTMLHandler, SoundboardRSSHandler
25DIR: Final = ROOT_DIR / "soundboard"
28def get_module_info() -> ModuleInfo:
29 """Create and return the ModuleInfo for this module."""
30 return ModuleInfo(
31 name="Känguru-Soundboard",
32 short_name="Soundboard",
33 description=(
34 "Ein Soundboard mit coolen Sprüchen und Sounds aus den "
35 "Känguru-Chroniken"
36 ),
37 path="/soundboard",
38 keywords=("Soundboard", "Känguru", "Witzig", "Sprüche"),
39 handlers=(
40 (
41 r"/soundboard/files/(.*mp3)",
42 TraversableStaticFileHandler,
43 {"root": DIR / "files", "hashes": {}},
44 ),
45 (
46 r"/soundboard/feed",
47 SoundboardRSSHandler,
48 ),
49 (
50 r"/soundboard/feed\.(rss|xml)",
51 RedirectHandler,
52 {"url": "/soundboard/feed"},
53 ),
54 ( # redirect handler for legacy reasons
55 r"/soundboard/k(ä|%C3%A4)nguru(/.+|)",
56 RedirectHandler,
57 {"url": "/soundboard/kaenguru{1}"},
58 ),
59 (
60 r"/soundboard/([^./]+)/feed",
61 SoundboardRSSHandler,
62 ),
63 (
64 r"/soundboard/([^/]+)(\.(rss|xml)|/feed\.(rss|xml))",
65 RedirectHandler,
66 {"url": "/soundboard/{0}/feed"},
67 ),
68 (
69 r"/soundboard",
70 SoundboardHTMLHandler,
71 ),
72 (
73 r"/soundboard/([^./]+)",
74 SoundboardHTMLHandler,
75 ),
76 ),
77 sub_pages=(
78 PageInfo(
79 name="Soundboard-Suche",
80 description="Durchsuche das Soundboard",
81 path="/soundboard/suche",
82 keywords=("Suche",),
83 ),
84 PageInfo(
85 name="Soundboard-Personen",
86 description="Das Soundboard mit Sortierung nach Personen",
87 path="/soundboard/personen",
88 keywords=("Personen",),
89 ),
90 ),
91 aliases=(
92 "/kaenguru-soundboard",
93 "/känguru-soundboard",
94 "/k%C3%A4nguru-soundboard",
95 ),
96 )