#!/usr/bin/env python
"""
homepage - Make the Whits Homepage
Author: Sean B. Palmer, inamidst.com
"""

import sys, os
os.chdir(sys.argv[1])
sys.path = ['.'] + sys.path
from code.astraea.notes import notes

def main(): 
   template = open('code/astraea/home.txt', 'rb').read()
   text = ''
   for note in notes(): 
      text += '<div class="note">\n'
      text += '<p class="date"><a href="' + note.path + '">'
      text += note.cite + '</a> &#x2014;</p>\n'
      text += '<p>' + note.content + '</p>\n'
      text += '</div>\n'
   template = template.replace('$notes', text)
   open('index.html', 'wb').write(template)

if __name__ == '__main__': 
   main()
