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