Add nav in html and css from previous goes at mailstats html
This commit is contained in:
parent
c647574cb0
commit
1dd11f04f1
59
mailstats.css
Normal file
59
mailstats.css
Normal file
@ -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)
|
@ -1,9 +1,40 @@
|
|||||||
<html>
|
<!DOCTYPE html>
|
||||||
<head>
|
<html><head><meta charset="utf-8">
|
||||||
<title>${title}</title>
|
<title>SMEServer Mailstats</title>
|
||||||
|
<link rel='stylesheet' type='text/css' href='mailstats.css' />
|
||||||
|
<!-- Check links -->
|
||||||
|
<script>
|
||||||
|
function LinkCheck(url){
|
||||||
|
var http = new XMLHttpRequest();
|
||||||
|
http.open('HEAD', url, false);
|
||||||
|
http.send();
|
||||||
|
return http.status!=404;
|
||||||
|
}
|
||||||
|
function doNavs() {
|
||||||
|
var aTags = document.getElementsByTagName('a'),
|
||||||
|
atl = aTags.length,i;
|
||||||
|
for (i = 0; i < atl; i++) {
|
||||||
|
if (aTags[i].innerText == "Previous") {
|
||||||
|
if (!LinkCheck(aTags[i].href)) {
|
||||||
|
aTags[i].style.visibility = "hidden";
|
||||||
|
} else {
|
||||||
|
aTags[i].style.visibility = "visible";
|
||||||
|
}
|
||||||
|
} else if (aTags[i].innerText == "Next") {
|
||||||
|
if (!LinkCheck(aTags[i].href)) {
|
||||||
|
aTags[i].style.visibility = "hidden";
|
||||||
|
} else {
|
||||||
|
aTags[i].style.visibility = "visible";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<!---Navigation here-->
|
||||||
<h1>${title}</h1>
|
<h1>${title}</h1>
|
||||||
|
<br />
|
||||||
<table border="1">
|
<table border="1">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@ -23,5 +54,20 @@
|
|||||||
<!---Add in sub tables here -->
|
<!---Add in sub tables here -->
|
||||||
<br />
|
<br />
|
||||||
<footer>${version}</footer>
|
<footer>${version}</footer>
|
||||||
|
<script>window.onload = function(){doNavs();} </script>
|
||||||
|
<p class="cssvalid">
|
||||||
|
<a href="http://jigsaw.w3.org/css-validator/check/referer">
|
||||||
|
<img style="border:0;width:88px;height:31px"
|
||||||
|
src="http://jigsaw.w3.org/css-validator/images/vcss"
|
||||||
|
alt="Valid CSS!" />
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p class="htmlvalid">
|
||||||
|
<a href="https://validator.w3.org/check?uri=referer"><img
|
||||||
|
src="http://www.w3.org/Icons/valid-xhtml10"
|
||||||
|
alt="Valid XHTML 1.0!" height="31" width="88" /></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -638,12 +638,33 @@ if __name__ == "__main__":
|
|||||||
# Add it to the total
|
# Add it to the total
|
||||||
total_html = insert_string_after(total_html,rendered_html, "<!---Add in sub tables here -->")
|
total_html = insert_string_after(total_html,rendered_html, "<!---Add in sub tables here -->")
|
||||||
|
|
||||||
|
#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 = "<div class='linksattop'>\
|
||||||
|
<a class='prevlink' href='http://${DomainName}/mailstats/mailstats_for_${PreviousDate}.html'>Previous</a>\
|
||||||
|
<div class='divseeinbrowser'><a class='seeinbrowser' href='http://${DomainName}/mailstats/mailstats-${TodayDate}.html'>See in browser</a></div>\
|
||||||
|
<a class='nextlink' href='http://${DomainName}/mailstats/mailstats_for_${NextDate}.html'>Next</a>\
|
||||||
|
</div>"
|
||||||
|
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, "<!---Navigation here-->")
|
||||||
|
|
||||||
# Write the rendered HTML to a file
|
# Write the rendered HTML to a file
|
||||||
output_path = data_file_path+'mailstats_for_'+formatted_yesterday
|
output_path = data_file_path+'mailstats_for_'+formatted_yesterday
|
||||||
output_path = output_path.replace(' ','_')
|
output_path = output_path.replace(' ','_')
|
||||||
with open(output_path+'.html', 'w') as output_file:
|
with open(output_path+'.html', 'w') as output_file:
|
||||||
output_file.write(total_html)
|
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':
|
if get_html2text_version() == '2019.9.26':
|
||||||
html_to_text(output_path+'.html',output_path+'.txt')
|
html_to_text(output_path+'.html',output_path+'.txt')
|
||||||
print(f"Rendered HTML saved to {output_path}.html/txt")
|
print(f"Rendered HTML saved to {output_path}.html/txt")
|
||||||
|
Loading…
Reference in New Issue
Block a user