From fb020853caf99d085340c7efeae046eb8a9beb7c Mon Sep 17 00:00:00 2001 From: emkael Date: Sun, 21 Nov 2021 16:16:42 +0100 Subject: Hand records WWW generator - 1+2 after 4 matches --- boards/config/centralne.json | 48 +++++++++++++++++++++++++++++++++++ boards/generate.py | 50 +++++++++++++++++++++++++++++++++++++ boards/template/centralne.html | 40 +++++++++++++++++++++++++++++ boards/template/centralne.logo.html | 20 +++++++++++++++ 4 files changed, 158 insertions(+) create mode 100644 boards/config/centralne.json create mode 100644 boards/generate.py create mode 100644 boards/template/centralne.html create mode 100644 boards/template/centralne.logo.html 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 += '%s' % (section['title']) + for dealset in section['sets']: + set_enabled = False + set_finished = True + set_content = '%s' % (dealset['title']) + for pbn in dealset['files']: + if pbn.get('enabled', 0): + set_enabled = True + set_content += '' + set_content += '%s' % (pbn['name']) + for filetype in ('pbn', 'pdf'): + set_content += '%s' % (pbn['path'], filetype, filetype) + set_content += '' + else: + set_finished = False + if set_finished: + set_content += '' + set_content += '%s' % (dealset['zip'].get('title', 'cały mecz')) + set_content += 'zip' % (dealset['zip']['id']) + set_content += '' + if set_enabled: + content += set_content + content += ' ' + + 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_file.read()) + template = template.replace('', content) + template = template.replace('', 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 @@ + + + + + + + + + + I i II liga DMP 2021/22 - Round Robin: ROZKŁADY + + + + + + + + + + + + + + + + + + + + +
+ +
 
ROZKŁADY ROZDAŃ
 
+

+

 Strona wygenerowana , nie wiem, co innego tu napisać, optymalizowana dla rozdzielczości 1024x768.

+
+ + 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 @@ + + +
+I i II liga DMP 2021/22
+rozkłady rozdań

+Wyniki fazy zasadniczej:
+[ grupa N ]  +[ grupa S ]
+[ grupa NE ]  +[ grupa NW ]  +[ grupa SE ]  +[ grupa SW ] +
-- cgit v1.2.3