aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/EventManager.cpp2
-rw-r--r--src/RequestResponse.cpp27
-rw-r--r--src/RequestResponse.hpp6
-rw-r--r--src/content/markdown/Markdown.cpp21
4 files changed, 49 insertions, 7 deletions
diff --git a/src/EventManager.cpp b/src/EventManager.cpp
index 2f2da36..1faea6d 100644
--- a/src/EventManager.cpp
+++ b/src/EventManager.cpp
@@ -63,7 +63,7 @@ extern "C"
GenerateInternalErrorPage(req, "EvContentManagerInterceptor: path == nullptr");
return;
}
-#if 1
+#if 0
std::cout << "URI Path: " << path << std::endl;
#endif
diff --git a/src/RequestResponse.cpp b/src/RequestResponse.cpp
index c3247e9..535de78 100644
--- a/src/RequestResponse.cpp
+++ b/src/RequestResponse.cpp
@@ -73,7 +73,32 @@ bool RequestResponse::GetInputHeader(std::string const key, std::string value)
return GetInputHeaderByRef(key, value);
}
-bool RequestResponse::QueryValueEquals(std::string key, std::string value)
+bool RequestResponse::GetQueryValue(std::string & key, std::string & value)
+{
+ std::string const k = key;
+ return GetQueryValue(k, value);
+}
+
+bool RequestResponse::GetQueryValue(std::string const key, std::string & value)
+{
+ char const * const v = evhttp_find_header(&m_Query, key.c_str());
+
+ if (v == nullptr)
+ {
+ return false;
+ }
+
+ value = v;
+ return true;
+}
+
+bool RequestResponse::QueryValueEquals(std::string & key, std::string value)
+{
+ std::string const k = key;
+ return QueryValueEquals(k, value);
+}
+
+bool RequestResponse::QueryValueEquals(std::string const key, std::string value)
{
char const * const v = evhttp_find_header(&m_Query, key.c_str());
diff --git a/src/RequestResponse.hpp b/src/RequestResponse.hpp
index 3dccd54..d3d3551 100644
--- a/src/RequestResponse.hpp
+++ b/src/RequestResponse.hpp
@@ -30,7 +30,11 @@ public:
bool GetInputHeaderByRef(std::string const & key, std::string & value);
bool GetInputHeader(std::string const key, std::string value);
- bool QueryValueEquals(std::string key, std::string value);
+ bool GetQueryValue(std::string & key, std::string & value);
+ bool GetQueryValue(std::string const key, std::string & value);
+
+ bool QueryValueEquals(std::string & key, std::string value);
+ bool QueryValueEquals(std::string const key, std::string value);
private:
char const * const m_UriPath;
diff --git a/src/content/markdown/Markdown.cpp b/src/content/markdown/Markdown.cpp
index 903fcec..2b0bcc6 100644
--- a/src/content/markdown/Markdown.cpp
+++ b/src/content/markdown/Markdown.cpp
@@ -88,13 +88,26 @@ bool Markdown::Render(RequestResponse & rr, RenderData & rd, std::string & out)
rr.GetUriPath() == m_UriBasePath + "/index.html")
{
rr.UseUri();
- if (rr.QueryValueEquals("get", "bla") == true)
+ std::string requested_markdown;
+
+ rd["uri"] = rr.GetUriPath();
+ if (rr.GetQueryValue("get", requested_markdown) == true)
{
- rd["content"] = "bla";
+ requested_markdown += ".md";
+ if (HasMarkdownFile(requested_markdown) == true)
+ {
+ rd["content"] = *GetMarkdownHTML(requested_markdown);
+ } else if (HasMarkdownFile("index.md") == true) {
+ rd["content"] = *GetMarkdownHTML("index.md");
+ } else {
+ return false;
+ }
}
- else
+ else if (HasMarkdownFile("index.md") == true)
{
- rd["content"] = "blubb";
+ rd["content"] = *GetMarkdownHTML("index.md");
+ } else {
+ return false;
}
}
else