From 58da9654563d89039a58e4bf14a3b0e383fe93c8 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Fri, 24 Apr 2020 17:15:05 +0200 Subject: Fix impressum link --- plugins/weblog/weblog.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'plugins') 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& mGetRequestParam; std::string mContents; + std::string mHeader; + const std::string mFooter; public: - HtmlPage(std::string s = ""s): mContents(s) + HtmlPage(std::function& GetRequestParam, + std::string s = ""s) + : mGetRequestParam(GetRequestParam) + , mContents(s) + , mHeader("") + , mFooter("


Impressum, Datenschutzerklärung") { } @@ -256,19 +261,16 @@ namespace { operator std::string() const { - return header + mContents + footer; + return mHeader + mContents + mFooter; } }; - - const std::string HtmlPage::header{""}; - const std::string HtmlPage::footer{"


Impressum, Datenschutzerklärung"}; std::string generateIndexPage(fs::path& path, std::function& GetRequestParam, std::function& SetResponseHeader) { try { - HtmlPage htmlPage{"

"s + GetRequestParam("WEBLOG_NAME") + "

"s}; + HtmlPage htmlPage{GetRequestParam, "

"s + GetRequestParam("WEBLOG_NAME") + "

"s}; fs::path link{ GetRequestParam("rel_target")}; @@ -292,6 +294,7 @@ namespace { } std::string generateArticlePage(fs::path& path, + std::function& GetRequestParam, std::function& SetResponseHeader) { try { @@ -309,7 +312,7 @@ namespace { if (it != metaData.end() && it->second == "text/plain") data = verbatimText(data); - HtmlPage htmlPage{"

"s + metaData.at("Subject") + "

"s + metaData.at("Date") + "

"s + data}; + HtmlPage htmlPage{GetRequestParam, "

"s + metaData.at("Subject") + "

"s + metaData.at("Date") + "

"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); -- cgit v1.2.3