aboutsummaryrefslogtreecommitdiff
path: root/src/content/blog
diff options
context:
space:
mode:
authorToni Uhlig <matzeton@googlemail.com>2021-10-01 17:59:24 +0200
committerToni Uhlig <matzeton@googlemail.com>2021-10-01 17:59:24 +0200
commit5ff3d7a51be30a0052b12f9330fdf54f3c104739 (patch)
tree07f6780c4196205fe70b4caf6486b13fba80e30f /src/content/blog
parent2186064e52ec4029fd060323b51de973da4cee5f (diff)
Added Markdown and Static content module.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'src/content/blog')
-rw-r--r--src/content/blog/Blog.cpp32
-rw-r--r--src/content/blog/Blog.hpp9
2 files changed, 33 insertions, 8 deletions
diff --git a/src/content/blog/Blog.cpp b/src/content/blog/Blog.cpp
index 56a23c1..b473bf3 100644
--- a/src/content/blog/Blog.cpp
+++ b/src/content/blog/Blog.cpp
@@ -1,7 +1,11 @@
#include "Blog.hpp"
-Blog::Blog(std::string uriBasePath, std::string mainTemplatePath)
- : Content(), m_UriBasePath(uriBasePath), m_MainTemplatePath(mainTemplatePath)
+Blog::Blog(std::string uriBasePath, std::string mainTemplatePath, std::string blogPath)
+ : Content(),
+ m_UriBasePath(uriBasePath),
+ m_MainTemplatePath(mainTemplatePath),
+ m_BlogPath(blogPath),
+ m_BlogEntries("", blogPath)
{
m_Redirections.push_back(uriBasePath + "/");
m_Redirections.push_back(uriBasePath + "/index.html");
@@ -9,18 +13,34 @@ Blog::Blog(std::string uriBasePath, std::string mainTemplatePath)
bool Blog::Init()
{
+ std::cout << "Blog entries path: " << m_BlogPath << std::endl;
+
+ std::vector<std::string> extensions = {"json"};
+
+ if (m_BlogEntriesMetadata.Scan(m_BlogPath, extensions, false) == false)
+ {
+ return false;
+ }
+
+ m_BlogEntries.Init();
+
return true;
}
void Blog::Shutdown()
{
+ std::cout << "Blog module shutdown" << std::endl;
+
+ m_BlogEntries.Shutdown();
}
-bool Blog::Render(RequestResponse & rr, RenderData & rd)
+bool Blog::Render(RequestResponse & rr, RenderData & rd, std::string & out)
{
- rd["blah"] = "Yoh!";
- rr.UseOutputHeader();
- rr.AddOutputHeader("bla", "blubb");
+ (void)rr;
+ (void)rd;
+ (void)out;
+
+ rd["blah"] = "Yooooh!";
return true;
}
diff --git a/src/content/blog/Blog.hpp b/src/content/blog/Blog.hpp
index 086acc7..970c7fd 100644
--- a/src/content/blog/Blog.hpp
+++ b/src/content/blog/Blog.hpp
@@ -2,15 +2,17 @@
#define BLOG_H 1
#include "../../Content.hpp"
+#include "../../Filesystem.hpp"
+#include "../markdown/Markdown.hpp"
class Blog : public Content
{
public:
- explicit Blog(std::string uriBasePath, std::string mainTemplatePath);
+ explicit Blog(std::string uriBasePath, std::string mainTemplatePath, std::string blogPath);
bool Init();
void Shutdown();
- bool Render(RequestResponse & rr, RenderData & rd);
+ bool Render(RequestResponse & rr, RenderData & rd, std::string & out);
std::string const & GetUriBasePath() const;
std::string const & GetMainTemplate() const;
@@ -19,7 +21,10 @@ public:
private:
std::string m_UriBasePath;
std::string m_MainTemplatePath;
+ std::string m_BlogPath;
Redirections m_Redirections;
+ Filesystem m_BlogEntriesMetadata;
+ Markdown m_BlogEntries;
};
#endif