diff options
author | Roland Reichwein <mail@reichwein.it> | 2020-04-24 17:15:05 +0200 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2020-04-24 17:15:05 +0200 |
commit | 58da9654563d89039a58e4bf14a3b0e383fe93c8 (patch) | |
tree | afde44be6c0885cdfdd03ddd9ac74e6a02236473 /plugins/weblog | |
parent | 1b6682c78518228b705cab2afd5a9eb595a90bbd (diff) |
Fix impressum link
Diffstat (limited to 'plugins/weblog')
-rw-r--r-- | plugins/weblog/weblog.cpp | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/plugins/weblog/weblog.cpp b/plugins/weblog/weblog.cpp index 92162db..7ace0fb 100644 --- a/plugins/weblog/weblog.cpp +++ b/plugins/weblog/weblog.cpp @@ -238,13 +238,18 @@ namespace { class HtmlPage { - static const std::string header; - static const std::string footer; - + std::function<std::string(const std::string& key)>& mGetRequestParam; std::string mContents; + std::string mHeader; + const std::string mFooter; public: - HtmlPage(std::string s = ""s): mContents(s) + HtmlPage(std::function<std::string(const std::string& key)>& GetRequestParam, + std::string s = ""s) + : mGetRequestParam(GetRequestParam) + , mContents(s) + , mHeader("<!DOCTYPE html><html><head><meta charset=\"utf-8\"/></head><body>") + , mFooter("<br/><br/><br/><a href=\"" + mGetRequestParam("plugin_path") + "/impressum.html\">Impressum, Datenschutzerklärung</a></body></html>") { } @@ -256,19 +261,16 @@ namespace { operator std::string() const { - return header + mContents + footer; + return mHeader + mContents + mFooter; } }; - - const std::string HtmlPage::header{"<!DOCTYPE html><html><head><meta charset=\"utf-8\"/></head><body>"}; - const std::string HtmlPage::footer{"<br/><br/><br/><a href=\"impressum.html\">Impressum, Datenschutzerklärung</a></body></html>"}; std::string generateIndexPage(fs::path& path, std::function<std::string(const std::string& key)>& GetRequestParam, std::function<plugin_interface_setter_type>& SetResponseHeader) { try { - HtmlPage htmlPage{"<h1>"s + GetRequestParam("WEBLOG_NAME") + "</h1>"s}; + HtmlPage htmlPage{GetRequestParam, "<h1>"s + GetRequestParam("WEBLOG_NAME") + "</h1>"s}; fs::path link{ GetRequestParam("rel_target")}; @@ -292,6 +294,7 @@ namespace { } std::string generateArticlePage(fs::path& path, + std::function<std::string(const std::string& key)>& GetRequestParam, std::function<plugin_interface_setter_type>& SetResponseHeader) { try { @@ -309,7 +312,7 @@ namespace { if (it != metaData.end() && it->second == "text/plain") data = verbatimText(data); - HtmlPage htmlPage{"<h1>"s + metaData.at("Subject") + "</h1>"s + metaData.at("Date") + "<br/><br/>"s + data}; + HtmlPage htmlPage{GetRequestParam, "<h1>"s + metaData.at("Subject") + "</h1>"s + metaData.at("Date") + "<br/><br/>"s + data}; return htmlPage; } catch (const std::exception& ex) { @@ -381,7 +384,7 @@ std::string weblog_plugin::generate_page( return generateIndexPage(path, GetRequestParam, SetResponseHeader); if (is_article_page(rel_target, path)) - return generateArticlePage(path, SetResponseHeader); + return generateArticlePage(path, GetRequestParam, SetResponseHeader); if (is_index_file(rel_target, path) || is_article_file(rel_target, path)) return generateStaticFile(path, SetResponseHeader); |