diff --git a/ContentConverter.py b/ContentConverter.py index 443a9a6..dd0a3f7 100644 --- a/ContentConverter.py +++ b/ContentConverter.py @@ -61,6 +61,7 @@ renderedDictionary = {} def updateRenderedCache(): global renderedCache + global renderedDictionary renderedCache = [] # Get all rendered files for root, dirs, files in os.walk(renderedDirectory): @@ -73,6 +74,17 @@ def updateRenderedCache(): print("\t'{}' = '{}'".format(contentPath, renderedFile)) # No use for the value yet, we just want fast key lookups renderedDictionary[contentPath] = renderedFile + +""" +Interface +""" + +def getAllPostsList(): + allPosts = [] + for key, value in renderedDictionary.items(): + allPosts.append(key) + + return allPosts def getRenderedBody(contentPath): body = None diff --git a/SimpleBlogServer.py b/SimpleBlogServer.py index 5b30fd1..8547d1d 100644 --- a/SimpleBlogServer.py +++ b/SimpleBlogServer.py @@ -18,9 +18,8 @@ import ContentConverter class HomeHandler(tornado.web.RequestHandler): def get(self): - self.write(''' -

{}

- '''.format("Hello, world!")) + allPosts = ContentConverter.getAllPostsList() + self.render("templates/Home.html", allPosts=allPosts) class BlogHandler(tornado.web.RequestHandler): def get(self, request): diff --git a/templates/BlogPost.html b/templates/BlogPost.html index 9b64a6e..8fd008a 100644 --- a/templates/BlogPost.html +++ b/templates/BlogPost.html @@ -1,9 +1,9 @@ {{ title }} - + - {{ postBody }} + {% raw postBody %} diff --git a/templates/Home.html b/templates/Home.html new file mode 100644 index 0000000..f09f81b --- /dev/null +++ b/templates/Home.html @@ -0,0 +1,11 @@ + + + Home + + + + {% for post in allPosts %} + {{post}} + {% end %} + +