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