mirror of
https://github.com/KingDuckZ/kamokan.git
synced 2025-07-02 14:04:16 +00:00
Set the html root from the config file.
This commit is contained in:
parent
e92866251b
commit
00aa06282d
5 changed files with 18 additions and 2 deletions
|
@ -20,6 +20,7 @@
|
|||
#include "ini_file.hpp"
|
||||
#include "tawashiConfig.h"
|
||||
#include "duckhandy/stringize.h"
|
||||
#include "pathname/pathname.hpp"
|
||||
#include <utility>
|
||||
#include <cassert>
|
||||
#include <fstream>
|
||||
|
@ -39,6 +40,17 @@ namespace tawashi {
|
|||
// return path.substr(start_index, substr_len);
|
||||
//}
|
||||
|
||||
std::string make_root_path (const IniFile::KeyValueMapType& parSettings) {
|
||||
const auto it_found = parSettings.find("website_root");
|
||||
if (parSettings.end() == it_found) {
|
||||
return "";
|
||||
}
|
||||
else {
|
||||
mchlib::PathName retval(it_found->second);
|
||||
return retval.path() + '/';
|
||||
}
|
||||
}
|
||||
|
||||
redis::IncRedis make_incredis (const tawashi::IniFile::KeyValueMapType& parSettings) {
|
||||
using redis::IncRedis;
|
||||
|
||||
|
@ -61,6 +73,7 @@ namespace tawashi {
|
|||
m_resp_value(std::move(parValue)),
|
||||
m_base_uri(parIni.parsed().at("tawashi").at("base_uri")),
|
||||
//m_page_basename(fetch_page_basename(m_cgi_env)),
|
||||
m_website_root(make_root_path(parIni.parsed().at("tawashi"))),
|
||||
m_page_basename(std::move(parPageBaseName)),
|
||||
m_resp_type(parRespType),
|
||||
m_header_sent(false)
|
||||
|
@ -133,7 +146,7 @@ namespace tawashi {
|
|||
|
||||
std::string Response::load_mustache() const {
|
||||
std::ostringstream oss;
|
||||
oss << "html/" << page_basename() << ".html.mstch";
|
||||
oss << m_website_root << page_basename() << ".html.mstch";
|
||||
std::cerr << "Trying to load \"" << oss.str() << "\"\n";
|
||||
std::ifstream if_mstch(oss.str(), std::ios::binary | std::ios::in);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue