#ifndef BLOG_H #define BLOG_H 1 #include #include "../../Content.hpp" #include "../../Filesystem.hpp" #include "../markdown/Markdown.hpp" struct blog_entry { explicit blog_entry(std::string const & filename) : filename(filename) { } std::string const filename; std::string title; std::vector tags; std::string author; std::time_t createDate; std::time_t publishDate; bool published; }; using BlogMetadata = inja::json; using BlogEntry = std::shared_ptr; using BlogEntries = std::vector; class Blog : public Content { public: explicit Blog(std::string uriBasePath, std::string blogPath, std::string mainTemplatePath); bool Init(); void Shutdown(); bool Render(RequestResponse & rr, RenderData & rd, std::string & out); std::string & GetUriBasePath(); std::string const & GetMainTemplate() const; Redirections & GetRedirections(); static bool ValidateAndSetMetdadata(BlogMetadata const & blogMetadata, BlogEntry & blogEntry); bool ValidateEntries() const; void GenerateBlogListing(RenderData & rd); private: std::string m_UriBasePath; std::string m_MainTemplatePath; std::string m_BlogPath; Redirections m_Redirections; Markdown m_BlogContents; BlogEntries m_BlogEntriesSortedByDate; }; #endif