Added html template files

This commit is contained in:
- 2022-02-16 17:41:34 -08:00
parent 7bfa64ca81
commit f09c05fd1a
4 changed files with 61 additions and 12 deletions

View File

@ -24,14 +24,9 @@ def getcontent(query=None):
def renderindex(template):
# no env variable
table = getcontent()
title = "XDF Leaderboards - Xonotie"
filename = "./output/index.html"
header = '''<h3>Xonotic DeFrag Server Leaderboards</h3>
<p><b>Server Name: </b>/v/ Xonotie 0.8.2 - Pacific / US West<br>
<b>Stats: </b><a href="http://stats.xonotic.org/server/6459">http://stats.xonotic.org/server/6459</a></p>
'''
with open(filename, 'w+') as fout:
fout.write(template % (title, header + table))
fout.write(template % (table))
fout.close
pass
@ -41,19 +36,18 @@ def main():
with open("template.html", 'r') as fin:
template = fin.read()
renderindex(template)
title_text = "%s - XDF Leaderboards - Xonotie"
maps = getmaps("db/cts.db")
with open("template_map.html", 'r') as fin:
template = fin.read()
for game_map in maps:
# game_map is a tuple obj.
map_name = game_map[0]
query = {"QUERY_STRING" : ("map=%s" % map_name)}
table = getcontent(query)
header = "<h3>%s</h3>" % map_name
filename = ("./output/%s.html" % map_name)
filename = ("./output/maps/%s.html" % map_name)
with open(filename, 'w+') as fout:
title = title_text % map_name
fout.write(template % (title, header + table))
fout.close()
title = map_name
fout.write(template % (title, map_name, table))
pass
if __name__ == "__main__":

17
output/leaderboard.css Normal file
View File

@ -0,0 +1,17 @@
.footer {
margin:auto;
}
table, th, td {
border: 1px solid grey;
border-collapse: collapse;
}
table {
width:100%;
}
th, td {
width:auto;
text-align:center;
word-wrap: break-word;
margin: 1em 1em 1em 1em;
}

18
template.html Normal file
View File

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CTS Leaderboards - Add your title here</title>
<link href="./leaderboard.css" rel="stylesheet" type="text/css" media="all">
</head>
<div class = "content">
%s
<div class = "footer">
<center><p> Page generated using <a href="https://git.teknik.io/scuti/xdfcgi">xdfcgi</a> by scuti.</p></center>
</div>
</div>
</html>

20
template_map.html Normal file
View File

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>%s - CTS Leaderboards - Add your title here</title>
<link href="../leaderboard.css" rel="stylesheet" type="text/css" media="all">
</head>
<div class = "content">
<h3>%s</h3>
%s
<div class = "footer">
<center><p> Page generated using <a href="https://git.teknik.io/scuti/xdfcgi">xdfcgi</a> by scuti.</p></center>
</div>
</div>
</html>