diff options
author | emkael <emkael@tlen.pl> | 2021-11-21 16:16:42 +0100 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2021-11-21 16:16:42 +0100 |
commit | fb020853caf99d085340c7efeae046eb8a9beb7c (patch) | |
tree | 427c529a9ed13ddca43a37d67b14fb31cf88009d | |
parent | 0d07462fac19b41f31701044306b9bcd475b42a9 (diff) |
Hand records WWW generator - 1+2 after 4 matches
-rw-r--r-- | boards/config/centralne.json | 48 | ||||
-rw-r--r-- | boards/generate.py | 50 | ||||
-rw-r--r-- | boards/template/centralne.html | 40 | ||||
-rw-r--r-- | boards/template/centralne.logo.html | 20 |
4 files changed, 158 insertions, 0 deletions
diff --git a/boards/config/centralne.json b/boards/config/centralne.json new file mode 100644 index 0000000..14c6885 --- /dev/null +++ b/boards/config/centralne.json @@ -0,0 +1,48 @@ +{ + "sections": [ + { + "title": "I i II liga", + "sets": [ + { + "title": "Zjazd 1 (20.11.2021-21.11.2021)", + "files": [ + { + "path": "dmp202122_r1", + "name": "Mecz 1 (sobota, 10:00)", + "title": "DMP 2021/22 R1", + "enabled": 1 + }, + { + "path": "dmp202122_r2", + "name": "Mecz 2 (sobota, 15:00)", + "title": "DMP 2021/22 R2", + "enabled": 1 + }, + { + "path": "dmp202122_r3", + "name": "Mecz 3 (sobota, 19:30)", + "title": "DMP 2021/22 R3", + "enabled": 1 + }, + { + "path": "dmp202122_r4", + "name": "Mecz 4 (niedziela, 9:00)", + "title": "DMP 2021/22 R4", + "enabled": 1 + }, + { + "path": "dmp202122_r5", + "name": "Mecz 5 (niedziela, 13:30)", + "title": "DMP 2021/22 R5", + "enabled": 0 + } + ], + "zip": { + "id": "dmp202122_z1", + "title": "wszytkie mecze" + } + } + ] + } + ] +} diff --git a/boards/generate.py b/boards/generate.py new file mode 100644 index 0000000..13c7d72 --- /dev/null +++ b/boards/generate.py @@ -0,0 +1,50 @@ +import json, sys +from datetime import datetime +from pathlib import Path + + +config_dir = Path('config') +for config_path in config_dir.glob('*.json'): + config_name = config_path.stem + print('Found config "%s" in %s' % (config_name, config_path), file=sys.stderr) + with open(config_path) as config_file: + config = json.load(config_file) + + output_dir = Path('output') / config_name + output_dir.mkdir(parents=True, exist_ok=True) + + content = '' + for section in config['sections']: + content += '<tr><td class="bdnt12" colspan="3">%s</td></tr>' % (section['title']) + for dealset in section['sets']: + set_enabled = False + set_finished = True + set_content = '<tr><td class="bdcc1" colspan="3">%s</td></tr>' % (dealset['title']) + for pbn in dealset['files']: + if pbn.get('enabled', 0): + set_enabled = True + set_content += '<tr>' + set_content += '<td class="bd1">%s</td>' % (pbn['name']) + for filetype in ('pbn', 'pdf'): + set_content += '<td class="bdc"><a class="zb" href="files/%s.%s">%s</a></td>' % (pbn['path'], filetype, filetype) + set_content += '</tr>' + else: + set_finished = False + if set_finished: + set_content += '<tr>' + set_content += '<td class="bd1" colspan="2">%s</td>' % (dealset['zip'].get('title', 'cały mecz')) + set_content += '<td class="bdc"><a class="zb" href="files/%s.zip">zip</a></td>' % (dealset['zip']['id']) + set_content += '</tr>' + if set_enabled: + content += set_content + content += '<tr><td class="e" colspan="3"> </td></tr>' + + with open('template/%s.html' % (config_name)) as template_file: + template = template_file.read() + with open('template/%s.logo.html' % (config_name)) as logoh_file: + template = template.replace('<!---[LOGOH]--->', logoh_file.read()) + template = template.replace('<!---[CONTENT]--->', content) + template = template.replace('<!---[GENDATE]--->', datetime.now().strftime('%Y-%m-%d %X')) + + with open(output_dir / 'index.html', 'w') as output_file: + output_file.write(template) diff --git a/boards/template/centralne.html b/boards/template/centralne.html new file mode 100644 index 0000000..a620d7e --- /dev/null +++ b/boards/template/centralne.html @@ -0,0 +1,40 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<html> + <head> + <meta http-equiv="Pragma" content="no-cache"> + <meta http-equiv="Cache-Control" content="no-cache"> + <meta name="robots" content="noarchive"> + <meta http-equiv="expires" content="0"> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + <meta name="Generator" content="Skrypt napisany Palcami Klichowicza"> + <title>I i II liga DMP 2021/22 - Round Robin: ROZKŁADY</title> + <link rel="stylesheet" type="text/css" href="../butler/css/kolorki.css"> + </head> + <body class="all"> + <table cellspacing="0"> + <tr> + <td colspan="3"> + <span id="logo"> + <!---[LOGOH]---> + </span> + </td> + </tr> + <tr> + <td class="e" colspan="3"> </td> + </tr> + <tr> + <td class="bdnt12" colspan="3">ROZKŁADY ROZDAŃ</td> + </tr> + <tr> + <td class="e" colspan="3"> </td> + </tr> + <!---[CONTENT]---> + <tr> + <td colspan="21"> + <p class="vs"></p> + <p class="f"> Strona wygenerowana <!---[GENDATE]--->, nie wiem, co innego tu napisać, optymalizowana dla rozdzielczości 1024x768.</p> + </td> + </tr> + </table> + </body> +</html> diff --git a/boards/template/centralne.logo.html b/boards/template/centralne.logo.html new file mode 100644 index 0000000..dd26d35 --- /dev/null +++ b/boards/template/centralne.logo.html @@ -0,0 +1,20 @@ +<table cellspacing="0" cellpadding="0" border="0"><tr> +<td valign="center"><img src="../butler/images/pzbs.gif"></td> +<td align="center"> +<font size="5">I i II liga DMP 2021/22</font><br> +<font size="4">rozkłady rozdań</font><br><br> +Wyniki fazy zasadniczej:<br /> +[<a class="zb" target="_blank" href="../1liga/n/nrrleaderb.html"> grupa N </a>] +[<a class="zb" target="_blank" href="../1liga/s/srrleaderb.html"> grupa S </a>]<br> +[<a class="zb" target="_blank" href="../2liga/ne/nerrleaderb.html"> grupa NE </a>] +[<a class="zb" target="_blank" href="../2liga/nw/nwrrleaderb.html"> grupa NW </a>] +[<a class="zb" target="_blank" href="../2liga/se/serrleaderb.html"> grupa SE </a>] +[<a class="zb" target="_blank" href="../2liga/sw/swrrleaderb.html"> grupa SW </a>]<!--<br /><br /> +Play-off:<br /> +[<a class="zb" target="_blank" href="../1liga/n/playoff.html"> grupa N </a>] +[<a class="zb" target="_blank" href="../1liga/s/playoff.html"> grupa S </a>]<br> +[<a class="zb" target="_blank" href="../2liga/ne/playoff.html"> grupa NE </a>] +[<a class="zb" target="_blank" href="../2liga/nw/playoff.html"> grupa NW </a>] +[<a class="zb" target="_blank" href="../2liga/se/playoff.html"> grupa SE </a>] +[<a class="zb" target="_blank" href="../2liga/sw/playoff.html"> grupa SW </a>]--> +</td></tr></table> |