added basic page generation
This commit is contained in:
parent
85ed6f60a1
commit
04e9d83cdc
1
TODO
1
TODO
|
@ -3,3 +3,4 @@ Nice HTML tabs
|
|||
Don't hard-code timezone
|
||||
Build system
|
||||
Take input file as a command-line arguement
|
||||
Figure out licencing
|
40
main.py
40
main.py
|
@ -3,22 +3,24 @@
|
|||
import readFile
|
||||
import datetime
|
||||
|
||||
outFile = ""
|
||||
#outFile = outFile + ".html"
|
||||
timeCreate = ""
|
||||
timeMod = ""
|
||||
m2h = "" # markdown 2 html
|
||||
headerStr = ""
|
||||
footStr = "\n</html>"
|
||||
|
||||
|
||||
def printHtml(body):
|
||||
def printHtml(head, body, foot, outFile):
|
||||
print("placeholder")
|
||||
file = open(outFile, 'w')
|
||||
file.write(str(body))
|
||||
file.write(str(head + body + foot))
|
||||
|
||||
file.close()
|
||||
|
||||
def parseMd(inFile):
|
||||
m2h = readFile.readMarkdown(inFile)
|
||||
global m2h
|
||||
m2h = str(readFile.readMarkdown(inFile))
|
||||
return(m2h)
|
||||
|
||||
def metadata(inFile):
|
||||
|
@ -32,13 +34,39 @@ def metadata(inFile):
|
|||
|
||||
title = inFile.split(".")
|
||||
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():
|
||||
print("placeholder")
|
||||
|
||||
def main():
|
||||
print("placeholder")
|
||||
metadata("sample.md")
|
||||
parseMd("sample.md")
|
||||
printHtml(headerStr, m2h, footStr, "outdir/index.html")
|
||||
|
||||
|
||||
|
||||
def test():
|
||||
#print(readFile.readMarkdown("/home/amber/website.sh/sample.md"))
|
||||
|
@ -46,4 +74,4 @@ def test():
|
|||
|
||||
metadata("sample.md")
|
||||
|
||||
test()
|
||||
main()
|
|
@ -15,7 +15,7 @@ class readMarkdown():
|
|||
def markdown(self, mdFile):
|
||||
print("placeholder")
|
||||
|
||||
file = open(mdFile, 'r')
|
||||
file = open(self.mdFile, 'r')
|
||||
#middleVar = file.read()
|
||||
self.outStr = str(markdown.markdown(file.read())) #TODO: I really want nice tab indentations
|
||||
file.close()
|
||||
|
|
Loading…
Reference in New Issue