summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/generate-static-menu.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/scripts/generate-static-menu.py b/scripts/generate-static-menu.py
new file mode 100644
index 0000000..7c9fd64
--- /dev/null
+++ b/scripts/generate-static-menu.py
@@ -0,0 +1,18 @@
+import json, os, sys
+
+from bs4 import BeautifulSoup as bs4
+
+config_file = sys.argv[1]
+base_directory = sys.argv[2]
+menu_directory = sys.argv[3]
+
+for menu_item in json.load(file(config_file)):
+ href = os.path.relpath(
+ os.path.join(base_directory, menu_item['url']),
+ menu_directory
+ )
+ 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']
+ print link.a