Compare commits
5 Commits
04e9d83cdc
...
fb7b0d727d
Author | SHA1 | Date |
---|---|---|
Amber | fb7b0d727d | |
Amber | a46ca2bdb6 | |
Amber | 6dce6b723d | |
Amber | b5e1841885 | |
Amber | 11f6a2e38d |
4
TODO
4
TODO
|
@ -2,5 +2,7 @@ Multiple template files
|
|||
Nice HTML tabs
|
||||
Don't hard-code timezone
|
||||
Build system
|
||||
Take input file as a command-line arguement
|
||||
Take input file as a command-line arguement, search multiple places for theme
|
||||
title, template, markdown
|
||||
Figure out licencing
|
||||
#Try to replace beautifulsoup
|
|
@ -0,0 +1,43 @@
|
|||
/* 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;
|
||||
}*/
|
|
@ -0,0 +1,28 @@
|
|||
/* 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,2 +1,39 @@
|
|||
#!/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,3 +7,6 @@
|
|||
<meta name="created" content="CREATEDATE"/>
|
||||
<meta name="changed" content="MODDATE"/>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
|
|
58
main.py
58
main.py
|
@ -2,17 +2,14 @@
|
|||
|
||||
import readFile
|
||||
import datetime
|
||||
import header
|
||||
|
||||
#outFile = outFile + ".html"
|
||||
timeCreate = ""
|
||||
timeMod = ""
|
||||
m2h = "" # markdown 2 html
|
||||
headerStr = ""
|
||||
footStr = "\n</html>"
|
||||
footStr = "\n</body>\n</html>"
|
||||
|
||||
|
||||
def printHtml(head, body, foot, outFile):
|
||||
print("placeholder")
|
||||
file = open(outFile, 'w')
|
||||
file.write(str(head + body + foot))
|
||||
|
||||
|
@ -23,55 +20,14 @@ def parseMd(inFile):
|
|||
m2h = str(readFile.readMarkdown(inFile))
|
||||
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():
|
||||
metadata("sample.md")
|
||||
# metadata("sample.md")
|
||||
parseMd("sample.md")
|
||||
printHtml(headerStr, m2h, footStr, "outdir/index.html")
|
||||
|
||||
|
||||
humanReadableArg = str(header.readHead("Big Grand Tigle"))
|
||||
printHtml(humanReadableArg, m2h, footStr, "outdir/index.html")
|
||||
|
||||
def test():
|
||||
#print(readFile.readMarkdown("/home/amber/website.sh/sample.md"))
|
||||
print(parseMd("sample.md"))
|
||||
|
||||
metadata("sample.md")
|
||||
print(str(header.readHead("string")) + str(parseMd("sample.md")) + footStr)
|
||||
|
||||
main()
|
||||
#test()
|
||||
|
|
11
readFile.py
11
readFile.py
|
@ -12,18 +12,15 @@ class readMarkdown():
|
|||
self.mdFile = mdFile
|
||||
|
||||
|
||||
def markdown(self, mdFile):
|
||||
print("placeholder")
|
||||
|
||||
def markdown(self):
|
||||
file = open(self.mdFile, 'r')
|
||||
#middleVar = file.read()
|
||||
self.outStr = str(markdown.markdown(file.read())) #TODO: I really want nice tab indentations
|
||||
outStr = str(markdown.markdown(file.read())) #TODO: I really want nice tab indentations
|
||||
file.close()
|
||||
return(self.outStr)
|
||||
return(outStr)
|
||||
|
||||
|
||||
def __str__(self):
|
||||
return(str(self.markdown(self.mdFile)))
|
||||
return(str(self.markdown()))
|
||||
|
||||
# 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
|
|
@ -0,0 +1,40 @@
|
|||
#!/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