[bugfix] fixed footer output to produce valid html when using a logo

new parameters in for paramters.yaml file:
  - added parameter logo_alt_text
  - added parameter logo_height
This commit is contained in:
Kasper D. Fischer 2025-04-03 15:01:00 +02:00
parent a905386ee8
commit f1d25a7809
2 changed files with 11 additions and 8 deletions

View File

@ -537,11 +537,13 @@ class SurveillanceBot(object):
# write footer with optional logo
logo_file = self.parameters.get('html_logo')
logo_alt_text = self.parameters.get('logo_alt_text')
logo_height = self.parameters.get('logo_height')
if not os.path.isfile(pjoin(self.outpath_html, logo_file)):
logging.info(f'Specified file {logo_file} not found.')
logo_file = None
outfile.write(html_footer(footer_logo=logo_file))
outfile.write(html_footer(footer_logo=logo_file, alt_text=logo_alt_text, height=logo_height))
except Exception as e:
logging.info(f'Could not write HTML table to {fnout}:')

View File

@ -48,14 +48,15 @@ def finish_html_table():
return '</table>\n'
def html_footer(footer_logo=None):
footer = ['</body>']
def html_footer(footer_logo=None, alt_text='Logo', height=30):
if footer_logo:
logo_items = [f'<div class="footer">',
f' <img style="float: right; padding: 10px;" src="{footer_logo}" height=30px>',
f'</div>']
footer += logo_items
footer.append('</html>\n')
footer = [f'<div class="footer">',
f' <img style="float: right; padding: 10px;" src="{footer_logo}" height={height} alt="{alt_text}">',
f'</div>']
else:
footer = []
footer.append('</body>')
footer.append('</html>')
footer = _convert_to_textstring(footer)
return footer