#!/usr/bin/python
import json


if __name__ == '__main__':
	with open('webpage.html') as f:
		content = f.readlines()
	# only strip right most and '\n'
	content = [x.rstrip() for x in content]

	converted_content = []
	for x in content:
		escaped = json.dumps(x).strip('"')
		stringised = '"' + escaped + '"'
		converted_content.append(stringised)

	with open('webpage.h', 'w') as f:
		f.write("#ifndef _H_WEBPAGE_\n")
		f.write("#define _H_WEBPAGE_\n")
		f.write("// This file is generated by generate_webpage_header.py\n")
		f.write("String webpage = ");

		for x in converted_content:
			f.write("%s\n" % x)

		f.write(";\n");
		f.write("#endif //_H_WEBPAGE_\n")