Coverage for an_website/soundboard/__init__.py: 100.000%

10 statements  

« prev     ^ index     » next       coverage.py v7.6.4, created at 2024-11-16 19: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/>. 

13 

14"""Create the required stuff for the soundboard from the info in info.json.""" 

15 

16from __future__ import annotations 

17 

18from typing import Final 

19 

20from tornado.web import RedirectHandler 

21 

22from .. import DIR as ROOT_DIR 

23from ..utils.static_file_from_traversable import TraversableStaticFileHandler 

24from ..utils.utils import ModuleInfo, PageInfo 

25from .soundboard import SoundboardHTMLHandler, SoundboardRSSHandler 

26 

27DIR: Final = ROOT_DIR / "soundboard" 

28 

29 

30def get_module_info() -> ModuleInfo: 

31 """Create and return the ModuleInfo for this module.""" 

32 return ModuleInfo( 

33 name="Känguru-Soundboard", 

34 short_name="Soundboard", 

35 description=( 

36 "Ein Soundboard mit coolen Sprüchen und Sounds aus den " 

37 "Känguru-Chroniken" 

38 ), 

39 path="/soundboard", 

40 keywords=("Soundboard", "Känguru", "Witzig", "Sprüche"), 

41 handlers=( 

42 ( 

43 r"/soundboard/files/(.*mp3)", 

44 TraversableStaticFileHandler, 

45 {"root": DIR / "files", "hashes": {}}, 

46 ), 

47 ( 

48 r"/soundboard/feed", 

49 SoundboardRSSHandler, 

50 ), 

51 ( 

52 r"/soundboard/feed\.(rss|xml)", 

53 RedirectHandler, 

54 {"url": "/soundboard/feed"}, 

55 ), 

56 ( # redirect handler for legacy reasons 

57 r"/soundboard/k(ä|%C3%A4)nguru(/.+|)", 

58 RedirectHandler, 

59 {"url": "/soundboard/kaenguru{1}"}, 

60 ), 

61 ( 

62 r"/soundboard/([^./]+)/feed", 

63 SoundboardRSSHandler, 

64 ), 

65 ( 

66 r"/soundboard/([^/]+)(\.(rss|xml)|/feed\.(rss|xml))", 

67 RedirectHandler, 

68 {"url": "/soundboard/{0}/feed"}, 

69 ), 

70 ( 

71 r"/soundboard", 

72 SoundboardHTMLHandler, 

73 ), 

74 ( 

75 r"/soundboard/([^./]+)", 

76 SoundboardHTMLHandler, 

77 ), 

78 ), 

79 sub_pages=( 

80 PageInfo( 

81 name="Soundboard-Suche", 

82 description="Durchsuche das Soundboard", 

83 path="/soundboard/suche", 

84 keywords=("Suche",), 

85 ), 

86 PageInfo( 

87 name="Soundboard-Personen", 

88 description="Das Soundboard mit Sortierung nach Personen", 

89 path="/soundboard/personen", 

90 keywords=("Personen",), 

91 ), 

92 ), 

93 aliases=( 

94 "/kaenguru-soundboard", 

95 "/känguru-soundboard", 

96 "/k%C3%A4nguru-soundboard", 

97 ), 

98 )