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