# super simple

import os
import sys
import html

title = "Blog - Paper's website"

def addtitle(out_str, title):
    # add stuff here
    # The title in question:
    out_str += """	<div class="entry">\n		<h1>%s</h1>\n		<div class="pre">\n""" % html.escape(title.strip())
    return out_str

def main(argv):
    file = open(argv[1], 'r')
    out = open(argv[2], 'w')
    out_str = (
    """<!DOCTYPE html>
<head>
    <title>%s</title>
    <meta name="viewport" content="width=device-width;initial-scale=1.0" />
    <link rel="stylesheet" type="text/css" href="blog.css" />
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/2.3.2/css/bootstrap.min.css" rel="stylesheet" media="screen">
</head>
<body>
    <div class="navbar-wrapper">
		<div class="container" style="width: 100%-2%;margin-top:1%;">
			<div class="navbar navbar-inverse" style="box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.5)">
				<div class="navbar-inner">
					<a class="brand" href="#">Paper's website</a>
					<ul class="nav">
						<li><a href="../">Home</a></li>
						<li><a href="../music.html">Music</a></li>
						<li><a href="../projects.html">Projects</a></li>
						<li class="active"><a href="#">Blog</a></li>
					</ul>
				</div>
			</div>
		</div>
    </div>
""" % (title))
    lines = file.readlines()
    for line in range(len(lines)):
        if lines[line][0] == "#":
            out_str = addtitle(out_str, lines[line][1:])
            continue
        # this sucks.
        if lines[line][0:3] == "---":
            out_str += "		</div>\n	</div>\n"
            continue
        out_str += """%s\n""" % html.escape(lines[line].strip())
    out_str += "</body>"
    print(out_str, file=out)

if __name__ == "__main__":
    main(sys.argv)
