From d0661965e79b77774d8fd6d80ffe96ac459c4384 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A1imon=20Kala?= Date: Sun, 13 Oct 2024 14:01:37 +0200 Subject: [PATCH] Buildlog added simple highlighting --- src/app.py | 12 +++++++++++- src/templates/buildlog.html.jinja | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) 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