From 389ebf62b78dd97fea3f8ca917d2fa000d779473 Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Mon, 18 May 2020 00:48:59 -0400 Subject: [PATCH] Experimental approach to HTML minification that tries to minify the jinja template --- CTFd/__init__.py | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/CTFd/__init__.py b/CTFd/__init__.py index 4faeda20..5bc5bc0c 100644 --- a/CTFd/__init__.py +++ b/CTFd/__init__.py @@ -1,5 +1,6 @@ import datetime import os +import re import sys import weakref from distutils.version import StrictVersion @@ -116,12 +117,37 @@ class ThemeLoader(FileSystemLoader): if template.startswith("admin/"): template = template[6:] # Strip out admin/ template = "/".join(["admin", "templates", template]) - return super(ThemeLoader, self).get_source(environment, template) + else: + # Load regular theme data + theme = str(utils.get_config("ctf_theme")) + template = "/".join([theme, "templates", template]) + source = super(ThemeLoader, self).get_source(environment, template) - # Load regular theme data - theme = str(utils.get_config("ctf_theme")) - template = "/".join([theme, "templates", template]) - return super(ThemeLoader, self).get_source(environment, template) + html = source[0].split("\n") + lines = [] + start_ignores = r"(