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 • 12.72 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
DB_PASSWORD: str = os.environ.get("DB_PASSWORD")
7
DB_URI: str = f"postgresql://root:{DB_PASSWORD}@localhost/roundabout"
8
REDIS_URI: str = "redis://localhost"
9
MAIL_SERVER: str = "localhost"
10
NOTIFICATION_EMAIL: str = "notifications@roundabout-host.com"
11
CONTACT_EMAIL: str = "root@roundabout-host.com"
12
13
REPOS_PATH: str = "./repos"
14
USERDATA_PATH: str = "./userdata"
15
DEFAULT_AVATARS_PATH: str = "default_avatars"
16
BASE_DOMAIN: str = "localhost"
17
SERVER_IPS: set = {"127.0.0.1", "localhost", "0.0.0.0"}
18
AUTH_REALM: str = "roundabout"
19
20
AVATAR_SIZE: tuple = (192, 192)
21
22
HASHING_ROUNDS: int = 11
23
RESERVED_NAMES: tuple = ("git", "settings", "logout", "accounts", "info", "notifications", "about", "newrepo", "favourites",)
24
25
suggest_https: bool = True
26
27
available_locales: list[str] = ["ro_RO", "en_GB"]
28
29
folder_icon: str = "mdi:folder"
30
unknown_icon: str = "mdi:file"
31
file_icons: dict = {
32
"text/plain": "ic:baseline-text-snippet",
33
"text/css": "simple-icons:css3",
34
"text/csv": "mdi:table",
35
"text/html": "simple-icons:html5",
36
"text/calendar": "mdi:calendar",
37
"text/javascript": "simple-icons:javascript",
38
"text/xml": "mdi:xml",
39
"text/markdown": "simple-icons:markdown",
40
41
"application/octet-stream": "mdi:numeric-10-box",
42
"application/x-abiword": "mdi:file-document",
43
"application/x-msword": "mdi:file-document",
44
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": "mdi:file-document",
45
"application/vnd.oasis.opendocument.text": "mdi:file-document",
46
"application/rtf": "mdi:file-document",
47
"application/x-dvi": "mdi:file-document",
48
"application/epub+zip": "mdi:book-open-variant",
49
"application/pdf": "mdi:book-open-variant",
50
"application/x-freearc": "mdi:archive",
51
"application/x-bzip": "mdi:archive",
52
"application/x-bzip2": "mdi:archive",
53
"application/gzip": "mdi:archive",
54
"application/x-tar": "mdi:archive",
55
"application/zip": "mdi:archive",
56
"application/x-7z-compressed": "mdi:archive",
57
"application/vnd.rar": "mdi:archive",
58
"application/x-rar-compressed": "mdi:archive",
59
"application/java-archive": "simple-icons:openjdk",
60
"application/vnd.amazon.ebook": "mdi:cellphone-text",
61
"application/x-cdf": "mdi:disc-player",
62
"application/x-csh": "ic:baseline-terminal",
63
"application/x-sh": "ic:baseline-terminal",
64
"application/xml": "mdi:xml",
65
"application/json": "mdi:code-json",
66
"application/ld+json": "mdi:code-json",
67
"application/vnd.apple.installer+xml": "simple-icons:apple",
68
"application/vnd.oasis.opendocument.presentation": "mdi:presentation",
69
"application/vnd.ms-powerpoint": "mdi:presentation",
70
"application/vnd.openxmlformats-officedocument.presentationml.presentation": "mdi:presentation",
71
"application/vnd.oasis.opendocument.spreadsheet": "mdi:table-large",
72
"application/vnd.ms-excel": "mdi:table-large",
73
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "mdi:table-large",
74
"application/x-httpd-php": "mdi:server",
75
"application/xhtml+xml": "simple-icons:html5",
76
"application/vnd.android.package-archive": "bi:android2",
77
"application/x-x509-ca-cert": "mdi:certificate",
78
"application/x-shockwave-flash": "simple-icons:adobe",
79
"application/font-woff": "mdi:format-text",
80
"application/x-font-truetype": "mdi:format-text",
81
"application/x-font-opentype": "mdi:format-text",
82
"application/vnd.ms-fontobject": "mdi:format-text",
83
84
"audio/aac": "mdi:music",
85
"audio/mp3": "mdi:music",
86
"audio/ogg": "mdi:music",
87
"audio/opus": "mdi:music",
88
"audio/wav": "mdi:music",
89
"audio/webm": "mdi:music",
90
"audio/3gpp": "mdi:music",
91
"audio/3gpp2": "mdi:music",
92
"audio/midi": "mdi:piano",
93
"audio/x-midi": "mdi:piano",
94
"audio/flac": "mdi:music",
95
"audio/x-ms-wma": "mdi:music",
96
97
"image/avif": "mdi:image",
98
"image/jpeg": "mdi:image",
99
"image/png": "mdi:image",
100
"image/tiff": "mdi:image",
101
"image/webp": "mdi:image",
102
"image/gif": "mdi:image-multiple",
103
"image/vnd.microsoft.icon": "mdi:bookmark-multiple",
104
"image/x-icon": "simple-icons:windowsxp",
105
"image/bmp": "mdi:brush",
106
"image/svg+xml": "mdi:vector-curve",
107
108
"video/mp4": "mdi:video",
109
"video/mpeg": "mdi:video",
110
"video/ogg": "mdi:video",
111
"video/webm": "mdi:video",
112
"video/3gpp": "mdi:video",
113
"video/3gpp2": "mdi:video",
114
"video/x-flv": "mdi:video",
115
"video/mp2t": "ic:baseline-live-tv",
116
"video/x-msvideo": "mdi:video-vintage",
117
}
118
119
120
def match_icon(name):
121
if name.startswith(("LICENCE", "LICENSE", "COPYING")):
122
return "ic:gavel"
123
if name.startswith("README"):
124
return "mdi:book-information-variant"
125
if name.startswith(".gitignore"):
126
return "simple-icons:git"
127
128
129
footer = """
130
<x-hbox>
131
<a href="/help">Help</a>
132
<a href="mailto:{{ config.CONTACT_EMAIL }}">Contact Us</a>
133
</x-hbox>
134
<hr>
135
<p>
136
Alpha testing. Not for production use.
137
</p>
138
<p>
139
Application &copy; 2023 Roundabout developers. Content belongs to the repository contributors,
140
unless otherwise stated.
141
</p>
142
<p>
143
Made in Romania 🇷🇴
144
</p>
145
<p>
146
<a href="/about">Powered by Roundabout (alpha testing)</a>
147
</p>
148
"""
149
150
mail_footer = """
151
<small>
152
For any inquiries, write to <a href="mailto:{{ config.CONTACT_EMAIL }}"></a><br>. To adjust your email
153
notification preferences, log in to your account in a browser and visit
154
<a href="{{ config.web_protocol }}://{{ config.BASE_DOMAIN }}/settings">your user settings</a>.
155
</small>
156
"""
157
158
mail_header = """
159
<img src="{{ config.web_protocol }}://{{ config.BASE_DOMAIN }}/static/logo.svg" width="48">
160
"""
161
162
mail_footer_plain = """
163
For any inquiries, write to <{{ config.CONTACT_EMAIL }}>.
164
To adjust your email notification preferences, log in to your account in a browser and visit your user settings at
165
<{{ config.web_protocol }}://{{ config.BASE_DOMAIN }}/settings>.
166
"""
167
168
www_protocol = f"http{'s' if suggest_https else ''}"
169
170
faqs = """
171
<h1>FAQs and rules</h1>
172
<dl>
173
<dt><h2>How do I add my project?</h2></dt>
174
<dd>
175
<p>
176
It's easy. Click the sign-up button, then click Create in the corner, give it a name, and you're all
177
set.
178
</p>
179
</dd>
180
<dt><h2>Do I need to have an account?</h2></dt>
181
<dd>
182
<p>
183
No, using the service is allowed without registering. However, to post your own material, as well as
184
to contribute to other projects, you need an account to identify you.
185
</p>
186
</dd>
187
<dt><h2>Do you collect personal information?</h2></dt>
188
<dd>
189
<p>
190
Not at all. We do not log analytics or actions, and all you need to make an account is a username
191
(which can be fictional) and a password.
192
</p>
193
</dd>
194
<dt><h2>Who is the service targeted at?</h2></dt>
195
<dd>
196
<p>
197
The service is primarily targeted at enthusiasts
198
(the modern version of <a href="//en.wikipedia.org/wiki/Hacker_culture">hackers</a> but not security
199
breakers!), and while we will optimise for corporate use, large free software projects and even just
200
personal file storage as well, as an enthusiast myself I try to make it better for my use.
201
</p>
202
</dd>
203
<dt><h2>What projects do you host?</h2></dt>
204
<dd>
205
<p>
206
Anything, as long as it's free software. <i>Free</i> means all users should have the
207
<a href="https://www.gnu.org/philosophy/free-sw.html.en#four-freedoms">Four Freedoms</a>.
208
It does not mean everyone has to be a user, so private projects are <strong>allowed</strong>,
209
but if it's private you may not share it without giving these Four Freedoms.
210
</p>
211
<p>
212
<b>In short &mdash; either you share freely, or you don't share.</b>
213
</p>
214
<p>
215
Additionally, projects designed to operate with nonfree programs or that depend on nonfree libraries
216
are generally allowed, but keep in mind they are useless in the Free World. However, it is advisable
217
to share them, so others could change them to remove the nonfree dependency. It is recommended to
218
add a disclaimer to the top of an important document, just so others won't get too excited about it
219
and realise it's not for them.
220
</p>
221
<p>
222
“Source-available” projects that don't respect the Four Freedoms are considered nonfree and banned
223
from this site.
224
</p>
225
<p>
226
Using this site as a discussion forum for nonfree software is also not allowed, unless it's for
227
a collaborative effort to reverse-engineer it. Forums for more general topics, as well as free
228
software, are allowed though.
229
</p>
230
<p>
231
Moreover, all <em>public</em> material shared here must be appropriate for all ages and not contain
232
any illegal, pornographic, sexual, political, terrorist or other inappropriate material. Mild
233
swearing is allowed, but it must not be used to refer to sex.
234
</p>
235
<p>
236
For private material though, we have no business as long as you're not abusing the site by hosting
237
illegal content or overloading the server.
238
</p>
239
<p>
240
Nonfree <em>artistic, non-functional</em> works are also fine, but due to the nature of the service, the
241
nonfree terms will not be enforced.
242
</p>
243
</dd>
244
<dt><h2>What does it cost?</h2></dt>
245
<dd>
246
<p>
247
Currently, it is zero-price, besides being free software. However, we may start charging for some
248
features in the future, but <strong>only for those that cost us</strong>, and not for the features
249
we already have, assuming a normal usage. We will not put stupid limits such as three collaborators
250
per repository for free accounts, as more doesn't cost us anything.
251
</p>
252
<p>
253
Advertisements may also get added, but they will be only for logged-out users, and won't use
254
JavaScript or animation, most importantly they won't track you either.
255
</p>
256
</dd>
257
<dt><h2>What stack does this instance use?</h2></dt>
258
<dd>
259
<p>
260
Currently, it's a Raspberry Pi 4 (8GB) running Debian, Nginx, Gunicorn and Python with Flask, on top
261
of Postgres and Redis.
262
</p>
263
</dd>
264
<dt><h2>Is email integration supported?</h2></dt>
265
<dd>
266
<p>
267
Mailing lists aren't currently supported, but it would be a nice feature, so we're working on it.
268
</p>
269
</dd>
270
<dt><h2>Is SSH supported?</h2></dt>
271
<dd>
272
<p>
273
Not currently. While SSH is used in many workflows, we currently only support the Git Smart HTTP
274
protocol including with SSL. It does everything Git SSH does. We encourage you to try it, and let us
275
know if SSH is still important to you.
276
</p>
277
<p>
278
We also do not support the <code>git://</code> or Dumb HTTP protocols as they are insecure and don't
279
have any authentication.
280
</p>
281
<p>
282
For credential memory, GitHub's
283
<a href="https://github.com/git-ecosystem/git-credential-manager">Git Credential Manager</a>
284
also works with our app without extra setup.
285
</p>
286
</dd>
287
<dt><h2>Is some form of CI or workflow, or robots supported?</h2></dt>
288
<dd>
289
<p>
290
No, but we are working on it.
291
</p>
292
</dd>
293
<dt><h2>What licence does the app have?</h2></dt>
294
<dd>
295
<p>
296
<a href="https://www.gnu.org/licenses/agpl-3.0.html">AGPL 3.0</a>, or any later version.
297
</p>
298
</dd>
299
<dt><h2>Where does the name come from?</h2></dt>
300
<dd>
301
<p>
302
The name is a play on the word <i>branch</i>, because a roundabout connects many branching roads.
303
It also aligns with our goals to become federated and support collaboration across instances, which
304
we'll call roundabouts.
305
</p>
306
<p>
307
The name is to always be treated like a common noun, so it uses regular capitalisation, articles and
308
plurals.
309
</p>
310
</dd>
311
<dt><h2>What about that logo?</h2></dt>
312
<dd>
313
<p>
314
That is a roundabout sign design commonly used in Europe; it may not be familiar if you live on the
315
other side of the Atlantic.
316
</p>
317
<p>
318
It can also take other meanings, with blue being associated with stability and purity, the arrows
319
could also represent collaboration, a cycle of development and even code reuse and remixing due to
320
the resemblance to the recycling logo.
321
</p>
322
<p>
323
The logo is to be treated as public domain.
324
</p>
325
</dd>
326
</dl>
327
"""
328