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