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