config.py
Python script, Unicode text, UTF-8 text executable
1import os 2from dotenv import load_dotenv 3load_dotenv("secrets.env") 4 5DB_PASSWORD: str = os.environ.get("DB_PASSWORD") 6DB_URI: str = f"postgresql://root:{DB_PASSWORD}@localhost/roundabout" 7REDIS_URI: str = "redis://localhost" 8MAIL_SERVER: str = "localhost" 9NOTIFICATION_EMAIL: str = "notifications@roundabout-host.com" 10CONTACT_EMAIL: str = "root@roundabout-host.com" 11 12REPOS_PATH: str = "./repos" 13USERDATA_PATH: str = "./userdata" 14DEFAULT_AVATARS_PATH: str = "default_avatars" 15BASE_DOMAIN: str = "localhost" 16SERVER_IPS: set = {"127.0.0.1", "localhost", "0.0.0.0"} 17AUTH_REALM: str = "roundabout" 18 19AVATAR_SIZE: tuple = (192, 192) 20 21HASHING_ROUNDS: int = 11 22RESERVED_NAMES: tuple = ("git", "settings", "logout", "accounts", "info", "notifications", "about", "newrepo", "favourites",) 23 24suggest_https: bool = True 25 26folder_icon: str = "mdi:folder" 27unknown_icon: str = "mdi:file" 28file_icons: dict = { 29"text/plain": "ic:baseline-text-snippet", 30"text/css": "simple-icons:css3", 31"text/csv": "mdi:table", 32"text/html": "simple-icons:html5", 33"text/calendar": "mdi:calendar", 34"text/javascript": "simple-icons:javascript", 35"text/xml": "mdi:xml", 36"text/markdown": "simple-icons:markdown", 37 38"application/octet-stream": "mdi:numeric-10-box", 39"application/x-abiword": "mdi:file-document", 40"application/x-msword": "mdi:file-document", 41"application/vnd.openxmlformats-officedocument.wordprocessingml.document": "mdi:file-document", 42"application/vnd.oasis.opendocument.text": "mdi:file-document", 43"application/rtf": "mdi:file-document", 44"application/x-dvi": "mdi:file-document", 45"application/epub+zip": "mdi:book-open-variant", 46"application/pdf": "mdi:book-open-variant", 47"application/x-freearc": "mdi:archive", 48"application/x-bzip": "mdi:archive", 49"application/x-bzip2": "mdi:archive", 50"application/gzip": "mdi:archive", 51"application/x-tar": "mdi:archive", 52"application/zip": "mdi:archive", 53"application/x-7z-compressed": "mdi:archive", 54"application/vnd.rar": "mdi:archive", 55"application/x-rar-compressed": "mdi:archive", 56"application/java-archive": "simple-icons:openjdk", 57"application/vnd.amazon.ebook": "mdi:cellphone-text", 58"application/x-cdf": "mdi:disc-player", 59"application/x-csh": "ic:baseline-terminal", 60"application/x-sh": "ic:baseline-terminal", 61"application/xml": "mdi:xml", 62"application/json": "mdi:code-json", 63"application/ld+json": "mdi:code-json", 64"application/vnd.apple.installer+xml": "simple-icons:apple", 65"application/vnd.oasis.opendocument.presentation": "mdi:presentation", 66"application/vnd.ms-powerpoint": "mdi:presentation", 67"application/vnd.openxmlformats-officedocument.presentationml.presentation": "mdi:presentation", 68"application/vnd.oasis.opendocument.spreadsheet": "mdi:table-large", 69"application/vnd.ms-excel": "mdi:table-large", 70"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "mdi:table-large", 71"application/x-httpd-php": "mdi:server", 72"application/xhtml+xml": "simple-icons:html5", 73"application/vnd.android.package-archive": "bi:android2", 74"application/x-x509-ca-cert": "mdi:certificate", 75"application/x-shockwave-flash": "simple-icons:adobe", 76"application/font-woff": "mdi:format-text", 77"application/x-font-truetype": "mdi:format-text", 78"application/x-font-opentype": "mdi:format-text", 79"application/vnd.ms-fontobject": "mdi:format-text", 80 81"audio/aac": "mdi:music", 82"audio/mp3": "mdi:music", 83"audio/ogg": "mdi:music", 84"audio/opus": "mdi:music", 85"audio/wav": "mdi:music", 86"audio/webm": "mdi:music", 87"audio/3gpp": "mdi:music", 88"audio/3gpp2": "mdi:music", 89"audio/midi": "mdi:piano", 90"audio/x-midi": "mdi:piano", 91"audio/flac": "mdi:music", 92"audio/x-ms-wma": "mdi:music", 93 94"image/avif": "mdi:image", 95"image/jpeg": "mdi:image", 96"image/png": "mdi:image", 97"image/tiff": "mdi:image", 98"image/webp": "mdi:image", 99"image/gif": "mdi:image-multiple", 100"image/vnd.microsoft.icon": "mdi:bookmark-multiple", 101"image/x-icon": "simple-icons:windowsxp", 102"image/bmp": "mdi:brush", 103"image/svg+xml": "mdi:vector-curve", 104 105"video/mp4": "mdi:video", 106"video/mpeg": "mdi:video", 107"video/ogg": "mdi:video", 108"video/webm": "mdi:video", 109"video/3gpp": "mdi:video", 110"video/3gpp2": "mdi:video", 111"video/x-flv": "mdi:video", 112"video/mp2t": "ic:baseline-live-tv", 113"video/x-msvideo": "mdi:video-vintage", 114} 115 116 117def match_icon(name): 118if name.startswith(("LICENCE", "LICENSE", "COPYING")): 119return "ic:gavel" 120if name.startswith("README"): 121return "mdi:book-information-variant" 122if name.startswith(".gitignore"): 123return "simple-icons:git" 124 125 126footer = """ 127<x-hbox> 128<a href="/help">Help</a> 129<a href="mailto:{{ config.CONTACT_EMAIL }}">Contact Us</a> 130</x-hbox> 131<hr> 132<p> 133Alpha testing. Not for production use. 134</p> 135<p> 136Application © 2023 Roundabout developers. Content belongs to the repository contributors, 137unless otherwise stated. 138</p> 139<p> 140Made in Romania 🇷🇴 141</p> 142<p> 143<a href="/about">Powered by Roundabout (alpha testing)</a> 144</p> 145""" 146 147mail_footer = """ 148<small> 149For any inquiries, write to <a href="mailto:{{ config.CONTACT_EMAIL }}"></a><br>. To adjust your email 150notification preferences, log in to your account in a browser and visit 151<a href="{{ config.web_protocol }}://{{ config.BASE_DOMAIN }}/settings">your user settings</a>. 152</small> 153""" 154 155mail_header = """ 156<img src="{{ config.web_protocol }}://{{ config.BASE_DOMAIN }}/static/logo.svg" width="48"> 157""" 158 159mail_footer_plain = """ 160For any inquiries, write to <{{ config.CONTACT_EMAIL }}>. 161To adjust your email notification preferences, log in to your account in a browser and visit your user settings at 162<{{ config.web_protocol }}://{{ config.BASE_DOMAIN }}/settings>. 163""" 164 165www_protocol = f"http{'s' if suggest_https else ''}" 166