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