diff --git a/paste_bin/config.py b/paste_bin/config.py index 33fcf33..132c3d3 100644 --- a/paste_bin/config.py +++ b/paste_bin/config.py @@ -4,6 +4,7 @@ from pydantic import BaseModel, BaseSettings, validator, SecretStr from pytz import all_timezones_set +import json class StorageTypes(str, Enum): @@ -74,16 +75,30 @@ def ensure_valid(self): class Settings(BaseSettings): - TIME_ZONE: str = "Europe/London" - NEW_AT_INDEX: bool = False + TIME_ZONE: str = "Europe/Warsaw" + NEW_AT_INDEX: bool = True ENABLE_PUBLIC_LIST: bool = False USE_LONG_ID: bool = False UI_DEFAULT: DefaultsSettings = DefaultsSettings() BRANDING: BrandSettings = BrandSettings() STORAGE: StorageSettings = StorageSettings() CACHE: CacheSettings = CacheSettings() - # SYNTAX_HIGHLIGHTING_LANGUAGES: list[str] = ['c', 'cpp', 'python'] - SYNTAX_HIGHLIGHTING_LANGUAGES: list[str] = [] + SYNTAX_HIGHLIGHTING_LANGUAGES: list[str] = [ + 'c', + 'cpp', + 'python', + 'rust', + 'java', + 'csharp', + 'bash', + 'json', + 'csv' + ] + + def get_syntax_highlighting_languages(self) -> list[str]: + with open('/app/syntax_highlighting.json') as f: + return list(json.load(f)) + MAX_BODY_SIZE: int = 2*(10**6) LOG_LEVEL: str = "WARNING" diff --git a/paste_bin/core/renderer.py b/paste_bin/core/renderer.py index f722fbc..c075737 100644 --- a/paste_bin/core/renderer.py +++ b/paste_bin/core/renderer.py @@ -19,7 +19,7 @@ def get_highlighter_names() -> Generator[str, None, None]: :yield: Each highlighter name """ try: - allowed_highlighters = get_settings().SYNTAX_HIGHLIGHTING_LANGUAGES + allowed_highlighters = get_settings().get_syntax_highlighting_languages() except AttributeError: allowed_highlighters = [] if allowed_highlighters is not None and len(allowed_highlighters) > 0: