Compare commits
No commits in common. "fb7b0d727d8b2b09d462b5b3e57ce00b04fed426" and "04e9d83cdcc08932510ef54dad18b4d10b156971" have entirely different histories.
fb7b0d727d
...
04e9d83cdc
4
TODO
4
TODO
|
@ -2,7 +2,5 @@ Multiple template files
|
||||||
Nice HTML tabs
|
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, search multiple places for theme
|
Take input file as a command-line arguement
|
||||||
title, template, markdown
|
|
||||||
Figure out licencing
|
Figure out licencing
|
||||||
#Try to replace beautifulsoup
|
|
43
css/home.css
43
css/home.css
|
@ -1,43 +0,0 @@
|
||||||
/* CSS stolen from https://www.alm.website with permission */
|
|
||||||
|
|
||||||
body {
|
|
||||||
font-family: sans-serif;
|
|
||||||
}
|
|
||||||
|
|
||||||
code {
|
|
||||||
font-family: monospace;
|
|
||||||
background-color: #eee;
|
|
||||||
border-radius: 3px;
|
|
||||||
}
|
|
||||||
|
|
||||||
pre {
|
|
||||||
font-family: monospace;
|
|
||||||
background-color: #eee;
|
|
||||||
border-radius: 3px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.align-left {
|
|
||||||
float: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.align-right {
|
|
||||||
float: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
.align-center {
|
|
||||||
margin: auto;
|
|
||||||
width: 50%;
|
|
||||||
}
|
|
||||||
|
|
||||||
table, th, td {
|
|
||||||
border: solid 1px black;
|
|
||||||
border-collapse: collapse;
|
|
||||||
}
|
|
||||||
|
|
||||||
th, td {
|
|
||||||
margin: 2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*nav {
|
|
||||||
speak: always;
|
|
||||||
}*/
|
|
|
@ -1,28 +0,0 @@
|
||||||
/* Stolen from www.alm.website with permission */
|
|
||||||
|
|
||||||
nav {
|
|
||||||
display: flow;
|
|
||||||
border: solid 2px black;
|
|
||||||
margin: auto;
|
|
||||||
width: fit-content;
|
|
||||||
text-align: center;
|
|
||||||
justify-content: center;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
nav li {
|
|
||||||
list-style: none;
|
|
||||||
border: solid 1px black;
|
|
||||||
margin: 2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
nav h1 {
|
|
||||||
margin-top: 0;
|
|
||||||
margin-bottom: 0;
|
|
||||||
margin-right: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
nav strong {
|
|
||||||
font-family: serif;
|
|
||||||
font-size: x-large;
|
|
||||||
}
|
|
37
header.py
37
header.py
|
@ -1,39 +1,2 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
|
||||||
import datetime
|
|
||||||
import theme
|
|
||||||
|
|
||||||
|
|
||||||
class readHead():
|
|
||||||
#outHead = ""
|
|
||||||
sTime = []
|
|
||||||
sTitle = ""
|
|
||||||
sTheme = "basicTheme"
|
|
||||||
|
|
||||||
def __init__(self, sTitle, sTheme = "basicTheme"):
|
|
||||||
self.sTitle = sTitle
|
|
||||||
# self.outHead = ""
|
|
||||||
self.stime = []
|
|
||||||
self.sTheme = sTheme
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return(str(self.genHead())) #TODO: Append CSS, navbar, sidebar, footer
|
|
||||||
|
|
||||||
# Start genHead()
|
|
||||||
def genHead(self):
|
|
||||||
|
|
||||||
# Generate html <head> element
|
|
||||||
getTime = datetime.datetime.now()
|
|
||||||
timeMod = str(getTime.strftime("%A, %B %d, %Y at %X UTC−06:00")) #TODO: I don't want to hard-code this but the %z utc offset isn't printing
|
|
||||||
timeCreate = timeMod
|
|
||||||
|
|
||||||
headerStr = "<!DOCTYPE HTML>\n<html>\n<head>\n\t<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\"/>\n\t<title>"
|
|
||||||
headerStr1 = "</title>\n\t<meta name=\"generator\" content=\"HTML.xonsh https://git.nixnet.services/amber/html.xonsh\"/>\n\t<meta name=\"created\" content=\""
|
|
||||||
headerStr2 = "\">\n\t<meta name=\"changed\" content=\""
|
|
||||||
headerStr3 = "\n</head>\n<body>\n\t"
|
|
||||||
|
|
||||||
outHead = headerStr + str(self.sTitle) + headerStr1 + timeMod + headerStr2 + timeCreate
|
|
||||||
#append css
|
|
||||||
outHead = outHead + "\">" + str(theme.css())
|
|
||||||
outHead = outHead + headerStr3
|
|
||||||
return(outHead)
|
|
||||||
|
|
|
@ -7,6 +7,3 @@
|
||||||
<meta name="created" content="CREATEDATE"/>
|
<meta name="created" content="CREATEDATE"/>
|
||||||
<meta name="changed" content="MODDATE"/>
|
<meta name="changed" content="MODDATE"/>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
58
main.py
58
main.py
|
@ -2,14 +2,17 @@
|
||||||
|
|
||||||
import readFile
|
import readFile
|
||||||
import datetime
|
import datetime
|
||||||
import header
|
|
||||||
|
|
||||||
#outFile = outFile + ".html"
|
#outFile = outFile + ".html"
|
||||||
|
timeCreate = ""
|
||||||
|
timeMod = ""
|
||||||
m2h = "" # markdown 2 html
|
m2h = "" # markdown 2 html
|
||||||
footStr = "\n</body>\n</html>"
|
headerStr = ""
|
||||||
|
footStr = "\n</html>"
|
||||||
|
|
||||||
|
|
||||||
def printHtml(head, body, foot, outFile):
|
def printHtml(head, body, foot, outFile):
|
||||||
|
print("placeholder")
|
||||||
file = open(outFile, 'w')
|
file = open(outFile, 'w')
|
||||||
file.write(str(head + body + foot))
|
file.write(str(head + body + foot))
|
||||||
|
|
||||||
|
@ -20,14 +23,55 @@ def parseMd(inFile):
|
||||||
m2h = str(readFile.readMarkdown(inFile))
|
m2h = str(readFile.readMarkdown(inFile))
|
||||||
return(m2h)
|
return(m2h)
|
||||||
|
|
||||||
|
def metadata(inFile):
|
||||||
|
# Read metadata from possible file
|
||||||
|
## Pretend there's code here
|
||||||
|
|
||||||
|
# Generate metadata
|
||||||
|
getTime = datetime.datetime.now()
|
||||||
|
timeMod = str(getTime.strftime("%A, %B %d, %Y at %X UTC−06:00")) #TODO: I don't want to hard-code this but the %z utc offset isn't printing
|
||||||
|
timeCreate = timeMod
|
||||||
|
|
||||||
|
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():
|
def main():
|
||||||
# metadata("sample.md")
|
metadata("sample.md")
|
||||||
parseMd("sample.md")
|
parseMd("sample.md")
|
||||||
humanReadableArg = str(header.readHead("Big Grand Tigle"))
|
printHtml(headerStr, m2h, footStr, "outdir/index.html")
|
||||||
printHtml(humanReadableArg, m2h, footStr, "outdir/index.html")
|
|
||||||
|
|
||||||
|
|
||||||
def test():
|
def test():
|
||||||
print(str(header.readHead("string")) + str(parseMd("sample.md")) + footStr)
|
#print(readFile.readMarkdown("/home/amber/website.sh/sample.md"))
|
||||||
|
print(parseMd("sample.md"))
|
||||||
|
|
||||||
|
metadata("sample.md")
|
||||||
|
|
||||||
main()
|
main()
|
||||||
#test()
|
|
||||||
|
|
11
readFile.py
11
readFile.py
|
@ -12,15 +12,18 @@ class readMarkdown():
|
||||||
self.mdFile = mdFile
|
self.mdFile = mdFile
|
||||||
|
|
||||||
|
|
||||||
def markdown(self):
|
def markdown(self, mdFile):
|
||||||
|
print("placeholder")
|
||||||
|
|
||||||
file = open(self.mdFile, 'r')
|
file = open(self.mdFile, 'r')
|
||||||
outStr = str(markdown.markdown(file.read())) #TODO: I really want nice tab indentations
|
#middleVar = file.read()
|
||||||
|
self.outStr = str(markdown.markdown(file.read())) #TODO: I really want nice tab indentations
|
||||||
file.close()
|
file.close()
|
||||||
return(outStr)
|
return(self.outStr)
|
||||||
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return(str(self.markdown()))
|
return(str(self.markdown(self.mdFile)))
|
||||||
|
|
||||||
# might want to find a way to diff html from a file and readMarkdown()'s output if I want to update pages
|
# might want to find a way to diff html from a file and readMarkdown()'s output if I want to update pages
|
||||||
# Edit: just keep the original markdown files dumbass
|
# Edit: just keep the original markdown files dumbass
|
40
theme.py
40
theme.py
|
@ -1,40 +0,0 @@
|
||||||
#!/usr/bin/python
|
|
||||||
|
|
||||||
# Add argparse support, create themes
|
|
||||||
# Default theme will use the stuff I currently have on the home page
|
|
||||||
# TODO: don't hard-code theme, look into extensability
|
|
||||||
|
|
||||||
basic = {
|
|
||||||
"navCss": "css/navbar.css",
|
|
||||||
"bodyCss": "css/home.css",
|
|
||||||
"headerCss": "",
|
|
||||||
"footCss": ""
|
|
||||||
}
|
|
||||||
|
|
||||||
class css():
|
|
||||||
# sTheme = ""
|
|
||||||
|
|
||||||
def __init__(self, sTheme = basic):
|
|
||||||
self.sTheme = sTheme
|
|
||||||
|
|
||||||
def getTheme(self):
|
|
||||||
outStr = ""
|
|
||||||
|
|
||||||
for i in self.sTheme:
|
|
||||||
outStr = outStr + "\n\t<link rel=\"stylesheet\" href=\""
|
|
||||||
outStr = outStr + str(self.sTheme[i])
|
|
||||||
outStr = outStr + "\" media=\"\">"
|
|
||||||
return(outStr)
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return(self.getTheme())
|
|
||||||
|
|
||||||
|
|
||||||
#def test(sTheme):
|
|
||||||
# outStr = ""
|
|
||||||
#
|
|
||||||
# for i in sTheme.values():
|
|
||||||
# print(str(i))
|
|
||||||
|
|
||||||
|
|
||||||
#test(basic)
|
|
Loading…
Reference in New Issue