config.py
Python script, Unicode text, UTF-8 text executable
1import os 2from dotenv import load_dotenv 3 4load_dotenv("secrets.env") 5 6DB_PASSWORD: str = os.environ.get("DB_PASSWORD") 7DB_URI: str = f"postgresql://root:{DB_PASSWORD}@localhost/roundabout" 8REDIS_URI: str = "redis://localhost" 9MAIL_SERVER: str = "localhost" 10NOTIFICATION_EMAIL: str = "notifications@roundabout-host.com" 11CONTACT_EMAIL: str = "root@roundabout-host.com" 12 13REPOS_PATH: str = "./repos" 14USERDATA_PATH: str = "./userdata" 15DEFAULT_AVATARS_PATH: str = "default_avatars" 16BASE_DOMAIN: str = "localhost" 17SERVER_IPS: set = {"127.0.0.1", "localhost", "0.0.0.0"} 18AUTH_REALM: str = "roundabout" 19 20AVATAR_SIZE: tuple = (192, 192) 21 22HASHING_ROUNDS: int = 11 23RESERVED_NAMES: tuple = ("git", "settings", "logout", "accounts", "info", "notifications", "about", "newrepo", "favourites",) 24 25suggest_https: bool = True 26 27available_locales: list[str] = ["ro_RO", "en_GB"] 28 29folder_icon: str = "mdi:folder" 30unknown_icon: str = "mdi:file" 31file_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 120def match_icon(name): 121if name.startswith(("LICENCE", "LICENSE", "COPYING")): 122return "ic:gavel" 123if name.startswith("README"): 124return "mdi:book-information-variant" 125if name.startswith(".gitignore"): 126return "simple-icons:git" 127 128 129footer = """ 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> 136Alpha testing. Not for production use. 137</p> 138<p> 139Application © 2023 Roundabout developers. Content belongs to the repository contributors, 140unless otherwise stated. 141</p> 142<p> 143Made in Romania 🇷🇴 144</p> 145<p> 146<a href="/about">Powered by Roundabout (alpha testing)</a> 147</p> 148""" 149 150mail_footer = """ 151<small> 152For any inquiries, write to <a href="mailto:{{ config.CONTACT_EMAIL }}"></a><br>. To adjust your email 153notification 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 158mail_header = """ 159<img src="{{ config.web_protocol }}://{{ config.BASE_DOMAIN }}/static/logo.svg" width="48"> 160""" 161 162mail_footer_plain = """ 163For any inquiries, write to <{{ config.CONTACT_EMAIL }}>. 164To 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 168www_protocol = f"http{'s' if suggest_https else ''}" 169 170faqs = """ 171<h1>FAQs and rules</h1> 172<dl> 173<dt><h2>How do I add my project?</h2></dt> 174<dd> 175<p> 176It's easy. Click the sign-up button, then click Create in the corner, give it a name, and you're all 177set. 178</p> 179</dd> 180<dt><h2>Do I need to have an account?</h2></dt> 181<dd> 182<p> 183No, using the service is allowed without registering. However, to post your own material, as well as 184to 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> 190Not 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> 197The service is primarily targeted at enthusiasts 198(the modern version of <a href="//en.wikipedia.org/wiki/Hacker_culture">hackers</a> but not security 199breakers!), and while we will optimise for corporate use, large free software projects and even just 200personal 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> 206Anything, 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>. 208It does not mean everyone has to be a user, so private projects are <strong>allowed</strong>, 209but if it's private you may not share it without giving these Four Freedoms. 210</p> 211<p> 212<b>In short — either you share freely, or you don't share.</b> 213</p> 214<p> 215Additionally, projects designed to operate with nonfree programs or that depend on nonfree libraries 216are generally allowed, but keep in mind they are useless in the Free World. However, it is advisable 217to share them, so others could change them to remove the nonfree dependency. It is recommended to 218add a disclaimer to the top of an important document, just so others won't get too excited about it 219and 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 223from this site. 224</p> 225<p> 226Using this site as a discussion forum for nonfree software is also not allowed, unless it's for 227a collaborative effort to reverse-engineer it. Forums for more general topics, as well as free 228software, are allowed though. 229</p> 230<p> 231Moreover, all <em>public</em> material shared here must be appropriate for all ages and not contain 232any illegal, pornographic, sexual, political, terrorist or other inappropriate material. Mild 233swearing is allowed, but it must not be used to refer to sex. 234</p> 235<p> 236For private material though, we have no business as long as you're not abusing the site by hosting 237illegal content or overloading the server. 238</p> 239<p> 240Nonfree <em>artistic, non-functional</em> works are also fine, but due to the nature of the service, the 241nonfree terms will not be enforced. 242</p> 243</dd> 244<dt><h2>What does it cost?</h2></dt> 245<dd> 246<p> 247Currently, it is zero-price, besides being free software. However, we may start charging for some 248features in the future, but <strong>only for those that cost us</strong>, and not for the features 249we already have, assuming a normal usage. We will not put stupid limits such as three collaborators 250per repository for free accounts, as more doesn't cost us anything. 251</p> 252<p> 253Advertisements may also get added, but they will be only for logged-out users, and won't use 254JavaScript 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> 260Currently, it's a Raspberry Pi 4 (8GB) running Debian, Nginx, Gunicorn and Python with Flask, on top 261of Postgres and Redis. 262</p> 263</dd> 264<dt><h2>Is email integration supported?</h2></dt> 265<dd> 266<p> 267Mailing 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> 273Not currently. While SSH is used in many workflows, we currently only support the Git Smart HTTP 274protocol including with SSL. It does everything Git SSH does. We encourage you to try it, and let us 275know if SSH is still important to you. 276</p> 277<p> 278We also do not support the <code>git://</code> or Dumb HTTP protocols as they are insecure and don't 279have any authentication. 280</p> 281<p> 282For credential memory, GitHub's 283<a href="https://github.com/git-ecosystem/git-credential-manager">Git Credential Manager</a> 284also 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> 290No, 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> 302The name is a play on the word <i>branch</i>, because a roundabout connects many branching roads. 303It also aligns with our goals to become federated and support collaboration across instances, which 304we'll call roundabouts. 305</p> 306<p> 307The name is to always be treated like a common noun, so it uses regular capitalisation, articles and 308plurals. 309</p> 310</dd> 311<dt><h2>What about that logo?</h2></dt> 312<dd> 313<p> 314That is a roundabout sign design commonly used in Europe; it may not be familiar if you live on the 315other side of the Atlantic. 316</p> 317<p> 318It can also take other meanings, with blue being associated with stability and purity, the arrows 319could also represent collaboration, a cycle of development and even code reuse and remixing due to 320the resemblance to the recycling logo. 321</p> 322<p> 323The logo is to be treated as public domain. 324</p> 325</dd> 326</dl> 327""" 328