#!/usr/bin/env python3

from htmlificate import HTML
import subprocess

h = HTML()

h.start_tag('html')
h.start_tag('head')

h.title('BSHS Changelog')
h.link(attr={'rel':'stylesheet','href':'/style.css'})

h.end_tag() # head
h.start_tag('body')

h.h1('Changelog')
h.a('Back',attr={'href':'..'})

h.start_tag('div',attr={'class':'container'})

result = subprocess.run(
	['bshs', '--all-versions'],
	capture_output=True,
	text=True
)
all_versions = result.stdout.split('\n')
all_versions.reverse()

all_versions = [ver for ver in all_versions if ver != '']

for ver in all_versions:
	h.start_tag('div',attr={'class':'text-container'})
	h.start_tag('pre',attr={'style':'font-family: twopixels4x7;'})
	result = subprocess.run(
		['bshs', '--get-log', ver],
		capture_output=True,
		text=True
	)
	changelog = result.stdout
	for line in changelog.split('\n'):
		h.file.append(line)
	h.end_tag() # pre
	h.end_tag() # div

h.end_tag() # div

h.end_tag() # body
h.end_tag() # html

print(h.get())
