summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2017-07-04 15:53:19 +0200
committeremkael <emkael@tlen.pl>2017-07-04 15:55:39 +0200
commitbf0b6154fe7b5a7853b15ab5d401e3f6524f1ec5 (patch)
tree631d5dbc2eef57b8f07c895c126db14bbdbce0e7
parent904770f12304f5e7233a68e4a1eab0f9e0fbc2f7 (diff)
Compiling static links into top menu of the pages
-rw-r--r--config/static.json20
-rw-r--r--http/res/ranking.css11
-rw-r--r--static-menu.py24
-rw-r--r--templates/player.html2
-rw-r--r--templates/ranking.html2
5 files changed, 59 insertions, 0 deletions
diff --git a/config/static.json b/config/static.json
new file mode 100644
index 0000000..542b871
--- /dev/null
+++ b/config/static.json
@@ -0,0 +1,20 @@
+[
+ {
+ "url": ".",
+ "label": "Ranking",
+ "header": "Strona główna Rankingu",
+ "content": ""
+ },
+ {
+ "url": "jak-powstal-ranking.html",
+ "label": "Jak powstał Ranking?",
+ "header": "Jak powstał Ranking?",
+ "content": "ranking.html"
+ },
+ {
+ "url": "metoda-obliczania-rankingu.html",
+ "label": "Metoda obliczania",
+ "header": "Metoda obliczania Rankingu",
+ "content": "metoda.html"
+ }
+]
diff --git a/http/res/ranking.css b/http/res/ranking.css
index 76b67ae..2993dd7 100644
--- a/http/res/ranking.css
+++ b/http/res/ranking.css
@@ -39,3 +39,14 @@
}
.table > thead th { text-align: center }
.table.history > tbody > tr { cursor: auto }
+
+.container { position: relative; }
+.static-menu {
+ position: absolute;
+ display: inline-block;
+ width: auto;
+ top: 0;
+ right: 0;
+ margin: 0 15px;
+}
+.static-menu .btn { border-top-left-radius: 0; border-top-right-radius: 0 }
diff --git a/static-menu.py b/static-menu.py
new file mode 100644
index 0000000..9474d12
--- /dev/null
+++ b/static-menu.py
@@ -0,0 +1,24 @@
+import copy, json, os, sys
+
+from bs4 import BeautifulSoup as bs4
+
+config_file = sys.argv[1]
+content_file = sys.argv[2]
+link_prefix = sys.argv[3] if len(sys.argv) > 3 else ''
+
+content = bs4(file(content_file), 'lxml')
+
+for menu_container in content.select('.static-menu'):
+ menu_container.clear()
+ for menu_item in json.load(file(config_file)):
+ href = os.path.relpath(
+ os.path.join(link_prefix, menu_item['url']),
+ os.path.dirname(content_file)
+ )
+ link = bs4('<a class="btn btn-default"></a>', 'html.parser')
+ link.a['href'] = href
+ link.a['title'] = menu_item['header']
+ link.a.string = menu_item['label']
+ menu_container.append(link.a)
+
+file(content_file, 'w').write(content.prettify().encode('utf-8'))
diff --git a/templates/player.html b/templates/player.html
index 024ce1c..6ea93e6 100644
--- a/templates/player.html
+++ b/templates/player.html
@@ -9,6 +9,8 @@
</head>
<body>
<div class="container">
+ <div class="btn-group static-menu" role="nav">
+ </div>
<div class="page-header">
<h1>
Oficjalny Ranking Brydżowy PZBS
diff --git a/templates/ranking.html b/templates/ranking.html
index dc4d790..19b6297 100644
--- a/templates/ranking.html
+++ b/templates/ranking.html
@@ -9,6 +9,8 @@
</head>
<body>
<div class="container">
+ <div class="btn-group static-menu" role="nav">
+ </div>
<div class="page-header">
<h1>
Oficjalny Ranking Brydżowy PZBS