#!/usr/bin/python3

import sys
import os

hist = open("HISTORY").read()
hist = hist.replace("&", "&amp;")
hist = hist.replace("<", "&lt;")
hist = hist.replace(">", "&gt;")

title = "Plus42 History"

try:
    os.mkdir("packages", 0o755)
except:
    pass

html = open("packages/history.html", "w")
html.write("<html>\n"
        + "<head>\n"
        + "  <title>" + title + "</title>\n"
        + "  <link rel=\"icon\" type=\"image/png\" href=\"images/plus42-icon.png\">\n"
        + "  <link rel=\"stylesheet\" href=\"../styles/default.css\">\n"
        + "  <style>\n"
        + "    .crumb { color: DeepPink }\n"
        + "    .crumb:link { text-decoration: none; }\n"
        + "    .crumb:visited {text-decoration: none; }\n"
        + "    .crumb:active { text-decoration: none; }\n"
        + "    .crumb:hover { text-decoration: underline; }\n"
        + "  </style>\n"
        + "</head>\n"
        + "<body>\n"
        + "<h1>" + title + "</h1>\n"
        + "<pre><a href=\"..\" class=\"crumb\">Home</a> &gt; <a href=\".\" class=\"crumb\">Plus42</a> &gt; History</pre>\n"
        + "<pre>" + hist + "</pre>\n"
        + "<p>\n"
        + "<a href=\".\">Go to Plus42 home page</a>\n"
        + "</body>\n"
        + "</html>")
html.close()
