By using this site, you agree to have cookies stored on your device, strictly for functional purposes, such as storing your session and preferences.

Dismiss

 config.py

View raw Download
text/x-script.python • 5.95 kiB
Python script, Unicode text, UTF-8 text executable
        
            
1
import os
2
from dotenv import load_dotenv
3
4
load_dotenv("secrets.env")
5
6
site_name: str = "roundabout-host.com"
7
8
DB_PASSWORD: str = os.environ.get("DB_PASSWORD")
9
DB_URI: str = f"postgresql://root:{DB_PASSWORD}@localhost/roundabout"
10
REDIS_URI: str = "redis://localhost"
11
MAIL_SERVER: str = "localhost"
12
NOTIFICATION_EMAIL: str = "notifications@roundabout-host.com"
13
CONTACT_EMAIL: str = "root@roundabout-host.com"
14
15
REPOS_PATH: str = "./repos"
16
USERDATA_PATH: str = "./userdata"
17
DEFAULT_AVATARS_PATH: str = "default_avatars"
18
BASE_DOMAIN: str = "localhost"
19
SERVER_IPS: set = {"127.0.0.1", "localhost", "0.0.0.0"}
20
AUTH_REALM: str = "roundabout"
21
MAX_PAYLOAD_SIZE: int = 4 * 1024**3
22
23
AVATAR_SIZE: tuple = (192, 192)
24
25
HASHING_ROUNDS: int = 11
26
RESERVED_NAMES: tuple = ("git", "settings", "logout", "accounts", "info", "notifications", "about", "newrepo", "favourites",)
27
28
suggest_https: bool = True
29
30
available_locales: list[str] = ["ro_RO", "en_GB"]
31
32
folder_icon: str = "mdi:folder"
33
unknown_icon: str = "mdi:file"
34
file_icons: dict = {
35
"text/plain": "ic:baseline-text-snippet",
36
"text/css": "simple-icons:css3",
37
"text/csv": "mdi:table",
38
"text/html": "simple-icons:html5",
39
"text/calendar": "mdi:calendar",
40
"text/javascript": "simple-icons:javascript",
41
"text/xml": "mdi:xml",
42
"text/markdown": "simple-icons:markdown",
43
44
"application/octet-stream": "mdi:numeric-10-box",
45
"application/x-abiword": "mdi:file-document",
46
"application/x-msword": "mdi:file-document",
47
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": "mdi:file-document",
48
"application/vnd.oasis.opendocument.text": "mdi:file-document",
49
"application/rtf": "mdi:file-document",
50
"application/x-dvi": "mdi:file-document",
51
"application/epub+zip": "mdi:book-open-variant",
52
"application/pdf": "mdi:book-open-variant",
53
"application/x-freearc": "mdi:archive",
54
"application/x-bzip": "mdi:archive",
55
"application/x-bzip2": "mdi:archive",
56
"application/gzip": "mdi:archive",
57
"application/x-tar": "mdi:archive",
58
"application/zip": "mdi:archive",
59
"application/x-7z-compressed": "mdi:archive",
60
"application/vnd.rar": "mdi:archive",
61
"application/x-rar-compressed": "mdi:archive",
62
"application/java-archive": "simple-icons:openjdk",
63
"application/vnd.amazon.ebook": "mdi:cellphone-text",
64
"application/x-cdf": "mdi:disc-player",
65
"application/x-csh": "ic:baseline-terminal",
66
"application/x-sh": "ic:baseline-terminal",
67
"application/xml": "mdi:xml",
68
"application/json": "mdi:code-json",
69
"application/ld+json": "mdi:code-json",
70
"application/vnd.apple.installer+xml": "simple-icons:apple",
71
"application/vnd.oasis.opendocument.presentation": "mdi:presentation",
72
"application/vnd.ms-powerpoint": "mdi:presentation",
73
"application/vnd.openxmlformats-officedocument.presentationml.presentation": "mdi:presentation",
74
"application/vnd.oasis.opendocument.spreadsheet": "mdi:table-large",
75
"application/vnd.ms-excel": "mdi:table-large",
76
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "mdi:table-large",
77
"application/x-httpd-php": "mdi:server",
78
"application/xhtml+xml": "simple-icons:html5",
79
"application/vnd.android.package-archive": "bi:android2",
80
"application/x-x509-ca-cert": "mdi:certificate",
81
"application/x-shockwave-flash": "simple-icons:adobe",
82
"application/font-woff": "mdi:format-text",
83
"application/x-font-truetype": "mdi:format-text",
84
"application/x-font-opentype": "mdi:format-text",
85
"application/vnd.ms-fontobject": "mdi:format-text",
86
87
"audio/aac": "mdi:music",
88
"audio/mp3": "mdi:music",
89
"audio/ogg": "mdi:music",
90
"audio/opus": "mdi:music",
91
"audio/wav": "mdi:music",
92
"audio/webm": "mdi:music",
93
"audio/3gpp": "mdi:music",
94
"audio/3gpp2": "mdi:music",
95
"audio/midi": "mdi:piano",
96
"audio/x-midi": "mdi:piano",
97
"audio/flac": "mdi:music",
98
"audio/x-ms-wma": "mdi:music",
99
100
"image/avif": "mdi:image",
101
"image/jpeg": "mdi:image",
102
"image/png": "mdi:image",
103
"image/tiff": "mdi:image",
104
"image/webp": "mdi:image",
105
"image/gif": "mdi:image-multiple",
106
"image/vnd.microsoft.icon": "mdi:bookmark-multiple",
107
"image/x-icon": "simple-icons:windowsxp",
108
"image/bmp": "mdi:brush",
109
"image/svg+xml": "mdi:vector-curve",
110
111
"video/mp4": "mdi:video",
112
"video/mpeg": "mdi:video",
113
"video/ogg": "mdi:video",
114
"video/webm": "mdi:video",
115
"video/3gpp": "mdi:video",
116
"video/3gpp2": "mdi:video",
117
"video/x-flv": "mdi:video",
118
"video/mp2t": "ic:baseline-live-tv",
119
"video/x-msvideo": "mdi:video-vintage",
120
}
121
122
123
def match_icon(name):
124
if name.startswith(("LICENCE", "LICENSE", "COPYING")):
125
return "ic:gavel"
126
if name.startswith("README"):
127
return "mdi:book-information-variant"
128
if name.startswith(".gitignore"):
129
return "simple-icons:git"
130
131
132
footer = f"""
133
<x-hbox>
134
<a href="/help">Help</a>
135
<a href="mailto:{CONTACT_EMAIL}">Contact Us</a>
136
</x-hbox>
137
<hr>
138
<p>
139
Alpha testing. Not for production use.
140
</p>
141
<p>
142
Application &copy; 2023 Roundabout developers. Content belongs to the repository contributors,
143
unless otherwise stated.
144
</p>
145
<p>
146
Made in Romania 🇷🇴
147
</p>
148
<p>
149
<a href="/about">Powered by Roundabout (alpha testing)</a>
150
</p>
151
"""
152
153
mail_footer = """
154
<small>
155
For any inquiries, write to <a href="mailto:{{ config.CONTACT_EMAIL }}"></a><br>. To adjust your email
156
notification preferences, log in to your account in a browser and visit
157
<a href="{{ config.web_protocol }}://{{ config.BASE_DOMAIN }}/settings">your user settings</a>.
158
</small>
159
"""
160
161
mail_header = """
162
<img src="{{ config.web_protocol }}://{{ config.BASE_DOMAIN }}/static/logo.svg" width="48">
163
"""
164
165
mail_footer_plain = """
166
For any inquiries, write to <{{ config.CONTACT_EMAIL }}>.
167
To adjust your email notification preferences, log in to your account in a browser and visit your user settings at
168
<{{ config.web_protocol }}://{{ config.BASE_DOMAIN }}/settings>.
169
"""
170
171
www_protocol = f"http{'s' if suggest_https else ''}"
172