From 7ad97251669963ec81eb9e808e9a8890939a1b1a Mon Sep 17 00:00:00 2001 From: emkael Date: Tue, 4 Jul 2017 15:54:31 +0200 Subject: Generating static content from common page template --- static.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 static.py (limited to 'static.py') diff --git a/static.py b/static.py new file mode 100644 index 0000000..3168843 --- /dev/null +++ b/static.py @@ -0,0 +1,13 @@ +import os, sys +from bs4 import BeautifulSoup as bs4 + +content_file = sys.argv[1] +page_header = sys.argv[2] if len(sys.argv) > 2 else '' + +template = bs4(file('templates/static.html'), 'lxml') +template.select('h2 small')[0].string = page_header +template.find('div', {'id': 'content'}).append( + bs4(file(content_file).read(), 'lxml') +) + +print template.prettify().encode('utf-8') -- cgit v1.2.3