diff --git a/src/app.py b/src/app.py index 6a51841..f053e4a 100644 --- a/src/app.py +++ b/src/app.py @@ -4,6 +4,8 @@ import tomllib from functools import wraps import magic +import re +from html import escape from repository import Repository from auth import isLoggedIn, registerAuthRoutes, requireLogin @@ -95,7 +97,15 @@ def info(repo: Repository): @requireLogin @repo_required def buildlog(repo: Repository): - return render_template('buildlog.html.jinja', repo_name=repo.name, log=repo.logger.getBuildLog()) + build_log = repo.logger.getBuildLog() + if build_log is None: + highlighted_log = None + else: + warning_pattern = re.compile(r'(warn(ing)*)', re.IGNORECASE) + error_pattern = re.compile(r'(error)', re.IGNORECASE) + highlighted_log = warning_pattern.sub(r'\1', escape(build_log)) + highlighted_log = error_pattern.sub(r'\1', highlighted_log) + return render_template('buildlog.html.jinja', repo_name=repo.name, log=highlighted_log) @app.route('/build/') @requireLogin diff --git a/src/templates/buildlog.html.jinja b/src/templates/buildlog.html.jinja index 7763098..2371df8 100644 --- a/src/templates/buildlog.html.jinja +++ b/src/templates/buildlog.html.jinja @@ -13,7 +13,7 @@ Go to Bottom -
{{ log | e }}
+
{{ log }}
Go to Top