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