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