Commit 815bb2c1 authored by diesys's avatar diesys 🎈

better index templates html, now main index too

parent 0d92962b
This diff is collapsed.
......@@ -326,26 +326,57 @@ def partiteHtml(torneo):
return partiteTable
# print("</table>")
def costruisciIndexHtml(torneo):
partite = partiteHtml(torneo)
ranking = rankingHtml(torneo)
giocatori = selectGiocatoriHtml(torneo)
def costruisciIndexHtml(torneo_in):
# is going to build the main index
if(torneo_in == '_ALL_'):
costruisciIndexHtml('index')
for torneo_nome in listTornei():
# torneo = importaTorneo(torneo_nome)
# print(torneo)
costruisciIndexHtml(torneo_nome)
elif(torneo_in == 'index'):
index_template = open('templates/index.html', 'r')
new_index = open('index.html', 'w')
tornei = listTornei('html')
new_index_content = index_template.read().format(TORNEI=tornei)
new_index.write(new_index_content)
index_template.close()
new_index.close()
else:
torneo = importaTorneo(torneo_in)
partite = partiteHtml(torneo)
ranking = rankingHtml(torneo)
giocatori = selectGiocatoriHtml(torneo)
index_template = open('templates/tournament_index.html', 'r')
new_index = open(torneo['FOLDER'] + '/' + 'index.html', 'w')
index_template = open('templates/tournament_index.html', 'r')
new_index = open(torneo['FOLDER'] + '/' + 'index.html', 'w')
new_index_content = index_template.read().format(MATCH=partite, RANKING=ranking, GIOCATORI=giocatori)
new_index_content = index_template.read().format(TORNEO=torneo['NOME'], MATCH=partite, RANKING=ranking, GIOCATORI=giocatori)
new_index.write(new_index_content)
index_template.close()
new_index.close()
# T E S T
# print(new_index_content)
new_index.write(new_index_content)
index_template.close()
new_index.close()
def listTornei():
for torneo in os.listdir(tornei_dir):
print(torneo)
def listTornei(out='none'):
dirs = os.listdir(tornei_dir)
if(out == 'stout'):
for torneo in dirs:
print(torneo)
return
elif(out == 'html'):
select = ''
for torneo in dirs:
select += "<option value='" + torneo + "'>" + torneo + "</option>\n"
return select
else:
return os.listdir(tornei_dir)
######################################################################################################################################################
#COMANDO: A COSA SERVE:
......@@ -372,7 +403,7 @@ if(len(sys.argv) > 1): # getting parameters if exist
## lista dei tornei
if(options[1] == '-l' or options[1] == '--list'):
listTornei()
listTornei('print')
## HELP
elif(options[1] == '-h' or options[1] == '--help'):
......@@ -391,8 +422,9 @@ if(len(sys.argv) > 1): # getting parameters if exist
print("Torneo creato, segui l'help per popolarlo")
elif(option_arg == '--gen-index'):
torneo = importaTorneo(torneo_arg)
costruisciIndexHtml(torneo)
# if (torneo_arg != 'index' and torneo_arg != '_ALL_'):
# torneo = importaTorneo(torneo_arg)
costruisciIndexHtml(torneo_arg)
elif(option_arg == '-i' or option_arg == '--import'):
torneo = importaTorneo(torneo_arg)
......
......@@ -2,7 +2,7 @@
<html lang='it'>
<head>
<!-- Required meta tags -->
<title>Pomelo</title>
<title>singolo | Pomelo</title>
<meta charset='utf-8'>
<meta name='description' content='Pomelo is a self-hosted opensource tournament web-server and local script' />
<meta name='viewport' content='width=device-width, initial-scale=1, shrink-to-fit=no'>
......@@ -40,7 +40,7 @@
<img id='logo' src='img/logo.gif' height='90px' width='90px' alt='Logo description' />
<span id='titolo'>
<h1 id='itolo'>Torneo #2</h1>
<h1 id='itolo'>singolo</h1>
<!-- <a href='admin.php' class='adminButton'> -->
<!-- <a href='#' onclick="$('#menu').collapse('toggle')" class='adminButton'> -->
<a href='#' id="admin_button" class='adminButton'>
......
......@@ -2,7 +2,7 @@
<html lang='it'>
<head>
<!-- Required meta tags -->
<title>Pomelo</title>
<title>{TORNEO} | Pomelo</title>
<meta charset='utf-8'>
<meta name='description' content='Pomelo is a self-hosted opensource tournament web-server and local script' />
<meta name='viewport' content='width=device-width, initial-scale=1, shrink-to-fit=no'>
......@@ -40,7 +40,7 @@
<img id='logo' src='img/logo.gif' height='90px' width='90px' alt='Logo description' />
<span id='titolo'>
<h1 id='itolo'>Torneo #2</h1>
<h1 id='itolo'>{TORNEO}</h1>
<!-- <a href='admin.php' class='adminButton'> -->
<!-- <a href='#' onclick="$('#menu').collapse('toggle')" class='adminButton'> -->
<a href='#' id="admin_button" class='adminButton'>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment