added basic page generation

This commit is contained in:
Amber 2022-03-03 20:40:32 -06:00
parent 85ed6f60a1
commit 04e9d83cdc
3 changed files with 36 additions and 7 deletions

1
TODO
View File

@ -3,3 +3,4 @@ Nice HTML tabs
Don't hard-code timezone Don't hard-code timezone
Build system Build system
Take input file as a command-line arguement Take input file as a command-line arguement
Figure out licencing

40
main.py
View File

@ -3,22 +3,24 @@
import readFile import readFile
import datetime import datetime
outFile = ""
#outFile = outFile + ".html" #outFile = outFile + ".html"
timeCreate = "" timeCreate = ""
timeMod = "" timeMod = ""
m2h = "" # markdown 2 html m2h = "" # markdown 2 html
headerStr = ""
footStr = "\n</html>"
def printHtml(body): def printHtml(head, body, foot, outFile):
print("placeholder") print("placeholder")
file = open(outFile, 'w') file = open(outFile, 'w')
file.write(str(body)) file.write(str(head + body + foot))
file.close() file.close()
def parseMd(inFile): def parseMd(inFile):
m2h = readFile.readMarkdown(inFile) global m2h
m2h = str(readFile.readMarkdown(inFile))
return(m2h) return(m2h)
def metadata(inFile): def metadata(inFile):
@ -32,13 +34,39 @@ def metadata(inFile):
title = inFile.split(".") title = inFile.split(".")
title = str(title[0]) #TODO: figure out a way to make longer titles without putting spaces in the filename title = str(title[0]) #TODO: figure out a way to make longer titles without putting spaces in the filename
# Take title as optional command-line arguement
# Generate html
global headerStr
headerStr = """\
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>"""
headerStr1 = """</title>
<meta name="generator" content="HTML.xonsh https://git.nixnet.services/amber/html.xonsh"/>
<meta name="created" content=" """
headerStr2 = """"/>
<meta name="changed" content=" """
headerStr3 = """"/>
</head>
"""
headerStr = headerStr + str(title) + headerStr1 + timeMod + headerStr2 + timeCreate + headerStr3
return(str(headerStr))
def css(): def css():
print("placeholder") print("placeholder")
def main(): def main():
print("placeholder") metadata("sample.md")
parseMd("sample.md")
printHtml(headerStr, m2h, footStr, "outdir/index.html")
def test(): def test():
#print(readFile.readMarkdown("/home/amber/website.sh/sample.md")) #print(readFile.readMarkdown("/home/amber/website.sh/sample.md"))
@ -46,4 +74,4 @@ def test():
metadata("sample.md") metadata("sample.md")
test() main()

View File

@ -15,7 +15,7 @@ class readMarkdown():
def markdown(self, mdFile): def markdown(self, mdFile):
print("placeholder") print("placeholder")
file = open(mdFile, 'r') file = open(self.mdFile, 'r')
#middleVar = file.read() #middleVar = file.read()
self.outStr = str(markdown.markdown(file.read())) #TODO: I really want nice tab indentations self.outStr = str(markdown.markdown(file.read())) #TODO: I really want nice tab indentations
file.close() file.close()