diff options
author | emkael <emkael@tlen.pl> | 2017-07-06 00:12:28 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2017-07-06 00:12:28 +0200 |
commit | 489eb40c0a29116ccce98291b3e174cb4531587b (patch) | |
tree | c8b7d205634b14f1fe211c0477555beeb5cf86c7 /static.py | |
parent | 51fcc7cf85cc5438b6a15b6dacfcd37c1a9de818 (diff) |
Ability to compile multiple panels into single static page
Diffstat (limited to 'static.py')
-rw-r--r-- | static.py | 33 |
1 files changed, 27 insertions, 6 deletions
@@ -1,13 +1,34 @@ -import os, sys +import copy, os, sys from bs4 import BeautifulSoup as bs4 -content_file = sys.argv[1] -page_header = sys.argv[2] if len(sys.argv) > 2 else '' +content_files = [] +page_header = '' + +arguments = sys.argv[1:] + +while True: + page_header = arguments[0] + arguments = arguments[1:] + if os.path.exists(page_header): + content_files.append(page_header) + page_header = '' + if len(arguments) == 0: + break template = bs4(file('templates/static.html'), 'lxml') + +content_wrapper = template.find('div', {'id': 'wrapper'}).extract() +del content_wrapper['id'] + template.select('h2 small')[0].string = page_header -template.find('div', {'id': 'content'}).append( - bs4(file(content_file).read(), 'lxml') -) + +footer = template.find('div', {'id': 'footer'}) + +for content_file in content_files: + content = copy.copy(content_wrapper) + content.div.append( + bs4(file(content_file).read(), 'html.parser') + ) + footer.insert_before(content) print template.prettify().encode('utf-8') |