summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2021-11-21 16:16:42 +0100
committeremkael <emkael@tlen.pl>2021-11-21 16:16:42 +0100
commitfb020853caf99d085340c7efeae046eb8a9beb7c (patch)
tree427c529a9ed13ddca43a37d67b14fb31cf88009d
parent0d07462fac19b41f31701044306b9bcd475b42a9 (diff)
Hand records WWW generator - 1+2 after 4 matches
-rw-r--r--boards/config/centralne.json48
-rw-r--r--boards/generate.py50
-rw-r--r--boards/template/centralne.html40
-rw-r--r--boards/template/centralne.logo.html20
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">&nbsp;</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">&nbsp;</td>
+ </tr>
+ <tr>
+ <td class="bdnt12" colspan="3">ROZKŁADY ROZDAŃ</td>
+ </tr>
+ <tr>
+ <td class="e" colspan="3">&nbsp;</td>
+ </tr>
+ <!---[CONTENT]--->
+ <tr>
+ <td colspan="21">
+ <p class="vs"></p>
+ <p class="f">&nbsp;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">&nbsp;grupa N&nbsp;</a>]&nbsp;
+[<a class="zb" target="_blank" href="../1liga/s/srrleaderb.html">&nbsp;grupa S&nbsp;</a>]<br>
+[<a class="zb" target="_blank" href="../2liga/ne/nerrleaderb.html">&nbsp;grupa NE&nbsp;</a>]&nbsp;
+[<a class="zb" target="_blank" href="../2liga/nw/nwrrleaderb.html">&nbsp;grupa NW&nbsp;</a>]&nbsp;
+[<a class="zb" target="_blank" href="../2liga/se/serrleaderb.html">&nbsp;grupa SE&nbsp;</a>]&nbsp;
+[<a class="zb" target="_blank" href="../2liga/sw/swrrleaderb.html">&nbsp;grupa SW&nbsp;</a>]<!--<br /><br />
+Play-off:<br />
+[<a class="zb" target="_blank" href="../1liga/n/playoff.html">&nbsp;grupa N&nbsp;</a>]&nbsp;
+[<a class="zb" target="_blank" href="../1liga/s/playoff.html">&nbsp;grupa S&nbsp;</a>]<br>
+[<a class="zb" target="_blank" href="../2liga/ne/playoff.html">&nbsp;grupa NE&nbsp;</a>]&nbsp;
+[<a class="zb" target="_blank" href="../2liga/nw/playoff.html">&nbsp;grupa NW&nbsp;</a>]&nbsp;
+[<a class="zb" target="_blank" href="../2liga/se/playoff.html">&nbsp;grupa SE&nbsp;</a>]&nbsp;
+[<a class="zb" target="_blank" href="../2liga/sw/playoff.html">&nbsp;grupa SW&nbsp;</a>]-->
+</td></tr></table>