diff options
Diffstat (limited to 'src/content')
-rw-r--r-- | src/content/blog/Blog.cpp | 9 | ||||
-rw-r--r-- | src/content/blog/Blog.hpp | 4 | ||||
-rw-r--r-- | src/content/markdown/Markdown.cpp | 35 | ||||
-rw-r--r-- | src/content/markdown/Markdown.hpp | 4 | ||||
-rw-r--r-- | src/content/static/Static.cpp | 4 | ||||
-rw-r--r-- | src/content/static/Static.hpp | 4 |
6 files changed, 45 insertions, 15 deletions
diff --git a/src/content/blog/Blog.cpp b/src/content/blog/Blog.cpp index ba8638e..47a3292 100644 --- a/src/content/blog/Blog.cpp +++ b/src/content/blog/Blog.cpp @@ -17,7 +17,8 @@ bool Blog::Init() { bool retval = true; - std::cout << "Blog entries path: " << m_BlogPath << std::endl; + std::cout << "Blog entries filesystem path: " << m_BlogPath << std::endl; + std::cout << "Blog entries URI base path: " << m_UriBasePath << std::endl; std::vector<std::string> extensions = {"json"}; Filesystem fs; @@ -39,7 +40,7 @@ bool Blog::Init() } m_BlogEntriesSortedByDate.push_back(be); - m_Redirections.push_back(std::filesystem::path(jfile.first).stem()); + m_Redirections.push_back(m_UriBasePath + "/" + std::string(std::filesystem::path(jfile.first).stem())); } std::sort(m_BlogEntriesSortedByDate.begin(), m_BlogEntriesSortedByDate.end(), @@ -81,7 +82,7 @@ bool Blog::Render(RequestResponse & rr, RenderData & rd, std::string & out) return true; } -std::string const & Blog::GetUriBasePath() const +std::string & Blog::GetUriBasePath() { return m_UriBasePath; } @@ -91,7 +92,7 @@ std::string const & Blog::GetMainTemplate() const return m_MainTemplatePath; } -Redirections const & Blog::GetRedirections() const +Redirections & Blog::GetRedirections() { return m_Redirections; } diff --git a/src/content/blog/Blog.hpp b/src/content/blog/Blog.hpp index d99185a..d58cd72 100644 --- a/src/content/blog/Blog.hpp +++ b/src/content/blog/Blog.hpp @@ -38,9 +38,9 @@ public: void Shutdown(); bool Render(RequestResponse & rr, RenderData & rd, std::string & out); - std::string const & GetUriBasePath() const; + std::string & GetUriBasePath(); std::string const & GetMainTemplate() const; - Redirections const & GetRedirections() const; + Redirections & GetRedirections(); static bool ValidateAndSetMetdadata(BlogMetadata const & blogMetadata, BlogEntry & blogEntry); bool ValidateEntries() const; diff --git a/src/content/markdown/Markdown.cpp b/src/content/markdown/Markdown.cpp index a85f333..903fcec 100644 --- a/src/content/markdown/Markdown.cpp +++ b/src/content/markdown/Markdown.cpp @@ -8,6 +8,11 @@ Markdown::Markdown(std::string uriBasePath, std::string markdownFilesPath, std:: m_MainTemplatePath(mainTemplatePath), m_MarkdownFilesPath(markdownFilesPath) { + if (m_MainTemplatePath.empty() == false) + { + m_Redirections.push_back(uriBasePath + "/"); + m_Redirections.push_back(uriBasePath + "/index.html"); + } } extern "C" void markdown_to_html_conversion(const MD_CHAR * const text, MD_SIZE size, void * const userdata) @@ -20,6 +25,10 @@ extern "C" void markdown_to_html_conversion(const MD_CHAR * const text, MD_SIZE bool Markdown::Init() { std::cout << "Markdown files path: " << m_MarkdownFilesPath << std::endl; + if (m_UriBasePath.empty() == false) + { + std::cout << "Markdown files URI base path: " << m_UriBasePath << std::endl; + } std::vector<std::string> extensions = {"md"}; @@ -68,15 +77,35 @@ bool Markdown::Render(RequestResponse & rr, RenderData & rd, std::string & out) (void)rd; (void)out; + std::string md_file; + if (m_MainTemplatePath.empty() == true) { return false; } - return false; /* TODO: Make markdown module usable as standalone module?! */ + if (rr.GetUriPath() == m_UriBasePath || rr.GetUriPath() == m_UriBasePath + "/" || + rr.GetUriPath() == m_UriBasePath + "/index.html") + { + rr.UseUri(); + if (rr.QueryValueEquals("get", "bla") == true) + { + rd["content"] = "bla"; + } + else + { + rd["content"] = "blubb"; + } + } + else + { + return false; + } + + return true; } -std::string const & Markdown::GetUriBasePath() const +std::string & Markdown::GetUriBasePath() { return m_UriBasePath; } @@ -86,7 +115,7 @@ std::string const & Markdown::GetMainTemplate() const return m_MainTemplatePath; } -Redirections const & Markdown::GetRedirections() const +Redirections & Markdown::GetRedirections() { return m_Redirections; } diff --git a/src/content/markdown/Markdown.hpp b/src/content/markdown/Markdown.hpp index 9c4d3c4..fa14b3a 100644 --- a/src/content/markdown/Markdown.hpp +++ b/src/content/markdown/Markdown.hpp @@ -15,9 +15,9 @@ public: void Shutdown(); bool Render(RequestResponse & rr, RenderData & rd, std::string & out); - std::string const & GetUriBasePath() const; + std::string & GetUriBasePath(); std::string const & GetMainTemplate() const; - Redirections const & GetRedirections() const; + Redirections & GetRedirections(); bool HasMarkdownFile(std::string filePath) const; bool HasMarkdownURI(std::string uriPath) const; diff --git a/src/content/static/Static.cpp b/src/content/static/Static.cpp index 132f0a0..93f9905 100644 --- a/src/content/static/Static.cpp +++ b/src/content/static/Static.cpp @@ -44,7 +44,7 @@ bool Static::Render(RequestResponse & rr, RenderData & rd, std::string & out) return true; } -std::string const & Static::GetUriBasePath() const +std::string & Static::GetUriBasePath() { return m_UriBasePath; } @@ -54,7 +54,7 @@ std::string const & Static::GetMainTemplate() const return m_MainTemplatePath; } -Redirections const & Static::GetRedirections() const +Redirections & Static::GetRedirections() { return m_Redirections; } diff --git a/src/content/static/Static.hpp b/src/content/static/Static.hpp index b9de983..8d702ec 100644 --- a/src/content/static/Static.hpp +++ b/src/content/static/Static.hpp @@ -13,9 +13,9 @@ public: void Shutdown(); bool Render(RequestResponse & rr, RenderData & rd, std::string & out); - std::string const & GetUriBasePath() const; + std::string & GetUriBasePath(); std::string const & GetMainTemplate() const; - Redirections const & GetRedirections() const; + Redirections & GetRedirections(); private: std::string m_UriBasePath; |