initial commit
This commit is contained in:
parent
46328a92a8
commit
c449f9d9ac
12 changed files with 457 additions and 4 deletions
35
stitcher.py
Normal file
35
stitcher.py
Normal file
|
@ -0,0 +1,35 @@
|
|||
import parser
|
||||
|
||||
# function defs
|
||||
|
||||
def generateBody(infilePath):
|
||||
title = parser.getTitle(infilePath)
|
||||
body = parser.convertFile(infilePath)
|
||||
timestamp = parser.getMetadata(infilePath)["date"]
|
||||
date = parser.convertDate(timestamp)
|
||||
final = "<h1> {} </h1>\n<h3 class=\"date\">{}</h3>\n<hr/>\n{}".format(title, date, body)
|
||||
return final
|
||||
|
||||
def createArticle(infilePath, templatePath, mainTitle = ""):
|
||||
if mainTitle != "":
|
||||
mainTitle = " | " + mainTitle
|
||||
template = open("{}article.html".format(templatePath), 'r').read()
|
||||
navbar = open("{}navbar.html".format(templatePath), 'r').read()
|
||||
foot = open("{}footer.html".format(templatePath), 'r').read()
|
||||
body = generateBody(infilePath)
|
||||
articleTitle = parser.getTitle(infilePath) + mainTitle
|
||||
article = template.format(title = articleTitle, main = body, nav = navbar, footer = foot)
|
||||
return article
|
||||
|
||||
def createMainPage(titles, templatePath, main_title):
|
||||
template = open("{}main.html".format(templatePath), 'r').read()
|
||||
navbar = open("{}navbar.html".format(templatePath), 'r').read()
|
||||
foot = open("{}footer.html".format(templatePath), 'r').read()
|
||||
articles = ""
|
||||
fstring = '<article><h2><a href = "{}">{}</a></h2></article>\n'
|
||||
for title in titles:
|
||||
articles = articles + fstring.format(title[1], title[0])
|
||||
final = template.format(title = main_title, toc = articles, nav = navbar, footer = foot)
|
||||
return final
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue