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