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