summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2017-09-07 14:23:19 +0200
committeremkael <emkael@tlen.pl>2017-09-07 14:23:19 +0200
commitac91fdbcb319b7aca5c2b8cc406997e331efbec8 (patch)
tree3757fcee964c69e718851a8db4057460494947af /scripts
parent7b775200ef44e22d2c5ab0dffce6be5f2ca136fa (diff)
Pre-generated menus for static pages (and group tool pages)
Diffstat (limited to 'scripts')
-rw-r--r--scripts/static-menu.py16
1 files changed, 3 insertions, 13 deletions
diff --git a/scripts/static-menu.py b/scripts/static-menu.py
index 9474d12..e30c702 100644
--- a/scripts/static-menu.py
+++ b/scripts/static-menu.py
@@ -2,23 +2,13 @@ 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_file = sys.argv[1]
+menu_content = file(sys.argv[2])
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)
+ menu_container.append(bs4(menu_content, 'html.parser'))
file(content_file, 'w').write(content.prettify().encode('utf-8'))