From 1dd11f04f1ba1920a0edfb61fdf68c5ec1621f81 Mon Sep 17 00:00:00 2001 From: Brian Read Date: Tue, 4 Jun 2024 05:04:59 +0100 Subject: [PATCH] Add nav in html and css from previous goes at mailstats html --- mailstats.css | 59 +++++++++++++++++++++++++++++++++++++++ mailstats.html.pt | 52 ++++++++++++++++++++++++++++++++-- root/usr/bin/mailstats.py | 23 ++++++++++++++- 3 files changed, 130 insertions(+), 4 deletions(-) create mode 100644 mailstats.css diff --git a/mailstats.css b/mailstats.css new file mode 100644 index 0000000..b5403fd --- /dev/null +++ b/mailstats.css @@ -0,0 +1,59 @@ +table { + border:2px solid; + border-collapse:collapse; +} + + +tr,td,th { + border:1px solid; +} + +.mailstats-detail-1stcol{ + width:174px; + } + +thead tr { + border-bottom :2px solid; + color:black; + background-color:darkgrey; +} + +tfoot tr { + border-top:2px solid; + color:black; + font-weight: bold; + background-color:darkgrey; + } + +tbody tr:nth-child(odd) {background-color: #dfdfdf} + +a.prevlink { + float: left; + width:33.33333%; + text-align:left; +} +div.divseeinbrowser { + float: left; + width:33.33333%; + text-align:center; +} +a.nextlink { + float: left; + width:33.33333%; + text-align:right; +}​ + +.cssclass1 {background-color:#ffff99;} +.cssclass2 {background-color:lightcoral;} +.cssclass3 {background-color:lightcyan;} +.cssclass4 {background-color:lightgoldenrodyellow;} +.cssclass5 {background-color:lightgray;} +.cssclass6 {background-color:lightgreen;} +.cssclass7 {background-color:lightpink;} +.cssclass8 {background-color:lightsalmon;} +.cssclass9 {background-color:lightseagreen;} +.cssclass10 {background-color:lightskyblue;} +.cssclass11 {background-color:lightslategray;} +.cssclass12 {background-color:lightsteelblue;} + +p.cssvalid,p.htmlvalid {float:left;margin-right:20px) diff --git a/mailstats.html.pt b/mailstats.html.pt index c0c0ae0..2b80278 100644 --- a/mailstats.html.pt +++ b/mailstats.html.pt @@ -1,9 +1,40 @@ - - - ${title} + + + SMEServer Mailstats + + + +

${title}

+
@@ -23,5 +54,20 @@
+ +

+ + Valid CSS! + +

+ +

+ Valid XHTML 1.0! +

+ diff --git a/root/usr/bin/mailstats.py b/root/usr/bin/mailstats.py index a0f0215..e6b5902 100644 --- a/root/usr/bin/mailstats.py +++ b/root/usr/bin/mailstats.py @@ -637,13 +637,34 @@ if __name__ == "__main__": rendered_html = render_sub_table(geoip_title,geoip_headers,found_countries) # Add it to the total total_html = insert_string_after(total_html,rendered_html, "") + + #Add in navigation html - next/previous/see in browser + day_format = "%Y-%m-%d" + # Convert the time string to a datetime object + date_obj = datetime.strptime(formatted_yesterday, day_format) + # Compute the next date by adding one day + next_date = date_obj + timedelta(days=1) + # Compute the previous date by subtracting one day + previous_date = date_obj - timedelta(days=1) + # Convert the datetime objects back to strings in the desired format + next_date_str = next_date.strftime(day_format) + previous_date_str = previous_date.strftime(day_format) + navigation_str_html = "
\ +Previous\ +\ +Next\ +
" + template = PageTemplate(navigation_str_html) + Nav_str = template(PreviousDate=previous_date_str,NextDate=next_date_str,TodayDate=formatted_yesterday,DomainName=DomainName) + # And insert it + total_html = insert_string_after(total_html,Nav_str, "") # Write the rendered HTML to a file output_path = data_file_path+'mailstats_for_'+formatted_yesterday output_path = output_path.replace(' ','_') with open(output_path+'.html', 'w') as output_file: output_file.write(total_html) - #and create a text version if the local version is suffiicent + #and create a text version if the local version of html2text is suffiicent if get_html2text_version() == '2019.9.26': html_to_text(output_path+'.html',output_path+'.txt') print(f"Rendered HTML saved to {output_path}.html/txt")