9 changed files with 166 additions and 16 deletions
@ -0,0 +1,56 @@
@@ -0,0 +1,56 @@
|
||||
import sqlite3 as sql |
||||
import subprocess |
||||
|
||||
def getmaps(database): |
||||
output = [] |
||||
con = sql.connect(database) |
||||
with con: |
||||
cursor = con.cursor() |
||||
try: |
||||
# get all maps in database |
||||
cursor.execute("select distinct mapid from Cts_times;") |
||||
output = cursor.fetchall() |
||||
except sql.Error: |
||||
print("Shit is fucked.") |
||||
return output |
||||
|
||||
# if there is no query then it outputs the index file. |
||||
def getcontent(query=None): |
||||
cmd = [("./cts")] |
||||
proc = subprocess.Popen(cmd, env=query, stdout=subprocess.PIPE, shell=True) |
||||
# communicate returns 'bytes' class with function 'decode' |
||||
return proc.communicate()[0].decode('utf-8') |
||||
|
||||
def renderindex(template): |
||||
# no env variable |
||||
table = getcontent() |
||||
filename = "./output/index.html" |
||||
with open(filename, 'w+') as fout: |
||||
fout.write(template % (table)) |
||||
fout.close |
||||
pass |
||||
|
||||
def main(): |
||||
template = "" |
||||
with open("template.html", 'r') as fin: |
||||
template = fin.read() |
||||
renderindex(template) |
||||
maps = getmaps("db/cts.db") |
||||
with open("template_map.html", 'r') as fin: |
||||
template = fin.read() |
||||
# for each map generate an html file. |
||||
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) |
||||
filename = ("./output/maps/%s.html" % map_name) |
||||
with open(filename, 'w+') as fout: |
||||
title = map_name |
||||
fout.write(template % (title, map_name, table)) |
||||
pass |
||||
|
||||
if __name__ == "__main__": |
||||
print("allmaps.py - Generating .html files for all maps.") |
||||
main() |
||||
pass |
@ -0,0 +1,17 @@
@@ -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; |
||||
} |
||||
|
@ -0,0 +1,18 @@
@@ -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> |
@ -0,0 +1,20 @@
@@ -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> |
Loading…
Reference in new issue