[bugfix] fixed html output to produce valid html.

This commit is contained in:
Kasper D. Fischer 2025-04-03 14:25:03 +02:00
parent a64aeaa5ac
commit a905386ee8

View File

@ -17,7 +17,7 @@ def get_html_text(text):
def get_html_header(refresh_rate=10):
header = ['<!DOCTYPE html>',
'<html>',
'<html lang="en">',
'<head>',
' <title>SurvBot status</title>',
' <link rel="stylesheet" media="only screen and (max-width: 400px)" href="mobile.css">',
@ -26,7 +26,7 @@ def get_html_header(refresh_rate=10):
' <meta charset="utf-8">',
' <meta name="viewport" content="width=device-width, initial-scale=1">',
'</head>',
'<body>']
'<body>\n']
header = _convert_to_textstring(header)
return header
@ -86,8 +86,14 @@ def get_html_row(items, html_key='td'):
text_str = get_html_link(text, hyperlink) if hyperlink else text
html_class = item.get('html_class')
class_str = f' class="{html_class}"' if html_class else ''
row_string += 2 * default_space + f'<{html_key}{class_str} bgcolor="{color}" title="{tooltip}"' \
+ f'style="color:{font_color}">{text_str}</{html_key}>\n'
row_string += 2 * default_space + f'<{html_key}{class_str} '
row_string += f'title="{tooltip}" ' if tooltip else ''
row_string += 'style="' if color or font_color else ''
row_string += f'background-color: {color};' if color else 'style="'
row_string += ' ' if font_color else ''
row_string += f'color: {font_color};' if font_color else ''
row_string += '" ' if color or font_color else ''
row_string += f'>{text_str}</{html_key}>\n'
row_string += default_space + '</tr>\n'
return row_string