mirror of
https://github.com/KingDuckZ/kamokan.git
synced 2024-11-27 00:43:47 +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
|
@ -3,3 +3,4 @@ redis_server = 127.0.0.1
|
|||
redis_port = 6379
|
||||
redis_mode = inet
|
||||
base_uri = http://127.0.0.1:8080
|
||||
website_root = /home/michele/dev/code/cpp/tawashi/html
|
||||
|
|
|
@ -56,6 +56,7 @@ namespace tawashi {
|
|||
auto& redis = this->redis();
|
||||
opt_string pastie = redis.get(token);
|
||||
if (not pastie) {
|
||||
assert(false);
|
||||
}
|
||||
|
||||
if (m_plain_text) {
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -59,6 +59,7 @@ namespace tawashi {
|
|||
cgi::Env m_cgi_env;
|
||||
std::string m_resp_value;
|
||||
boost::string_ref m_base_uri;
|
||||
std::string m_website_root;
|
||||
std::string m_page_basename;
|
||||
Types m_resp_type;
|
||||
std::unique_ptr<redis::IncRedis> m_redis;
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace tawashi {
|
|||
|
||||
void SubmitPasteResponse::on_send (std::ostream& parStream) {
|
||||
assert(not m_error_message.empty());
|
||||
parStream << "something happened? :/<br>\n" <<
|
||||
parStream << "something happened? :/\n" <<
|
||||
m_error_message << '\n';
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue