diff --git a/header.py b/header.py index 67a8dd0..a198e8e 100755 --- a/header.py +++ b/header.py @@ -1,51 +1,33 @@ #!/usr/bin/python -from bs4 import BeautifulSoup as bs import datetime -import re - class readHead(): - inFile = "" outHead = "" sTime = [] sTitle = "" - footStr = "\n\n" - def __init__(self, headerFile, sTitle): - self.inFile = headerFile + def __init__(self, sTitle): self.sTitle = sTitle - self.outHead = "" +# self.outHead = "" self.stime = [] - self.footStr = "\n\n" - - def getTime(self): - gettime = datetime.datetime.now() - modDate = 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 - createDate = modDate #TODO: make this seperate - global sTime - self.sTime.append(str(modDate)) - self.sTime.append(str(createDate)) - return(self.sTime) - - def read(self): - file = open(self.inFile, "r") - headStr = file.read() - file.close() - return(headStr) def __str__(self): - return(str(self.sed())) + return(str(self.genHead())) #TODO: pick css theme and append to output + +# Start genHead() + def genHead(self): + + # Generate html 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 = "\n\n\n\t\n\t" + headerStr1 = "\n\t\n\t\n\t\n\n\n\t" - def sed(self): - stdin = (str(self.read())) - #soupSed = soup(stdin, "lxml") - self.getTime() - stdin = str(re.sub("CREATEDATE", str(self.sTime[0]), stdin)) - stdin = str(re.sub("MODDATE", str(self.sTime[1]), stdin)) - - soup = bs(stdin, "lxml") - soup.head.title = str(self.sTitle) - - return(soup) + outHead = headerStr + str(self.sTitle) + headerStr1 + timeMod + headerStr2 + timeCreate + headerStr3 + return(outHead) diff --git a/main.py b/main.py index 5ff442d..b23f130 100755 --- a/main.py +++ b/main.py @@ -24,42 +24,6 @@ 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 = """\ -# -# -# -# -# """ -# headerStr1 = """ -# -# -# -# -# -#""" -# -# headerStr = headerStr + str(title) + headerStr1 + timeMod + headerStr2 + timeCreate + headerStr3 -# -# return(str(headerStr)) - - def css(): print("placeholder") @@ -68,14 +32,8 @@ def main(): parseMd("sample.md") printHtml(headerStr, 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("htmlTemplate/header.html", "string"))) + print(str(header.readHead("string")) + str(parseMd("sample.md")) + footStr) #main() test()