mirror of
https://github.com/KingDuckZ/kamokan.git
synced 2025-05-06 09:03:37 +00:00
Change namespace of kamokan-specific stuff.
This commit is contained in:
parent
a912b1e3d4
commit
e5f7f60e8b
32 changed files with 268 additions and 246 deletions
|
@ -57,16 +57,16 @@ namespace {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
std::unique_ptr<tawashi::Response> make_response (
|
||||
const Kakoune::SafePtr<tawashi::SettingsBag>& parSettings,
|
||||
const Kakoune::SafePtr<tawashi::cgi::Env>& parCgiEnv
|
||||
std::unique_ptr<kamokan::Response> make_response (
|
||||
const Kakoune::SafePtr<kamokan::SettingsBag>& parSettings,
|
||||
const Kakoune::SafePtr<kamokan::cgi::Env>& parCgiEnv
|
||||
) {
|
||||
return static_cast<std::unique_ptr<tawashi::Response>>(
|
||||
return static_cast<std::unique_ptr<kamokan::Response>>(
|
||||
std::make_unique<T>(parSettings, &std::cout, parCgiEnv)
|
||||
);
|
||||
}
|
||||
|
||||
void fill_defaults (tawashi::SettingsBag& parSettings) {
|
||||
void fill_defaults (kamokan::SettingsBag& parSettings) {
|
||||
parSettings.add_default("redis_server", "127.0.0.1");
|
||||
parSettings.add_default("redis_port", "6379");
|
||||
parSettings.add_default("redis_mode", "sock");
|
||||
|
@ -105,9 +105,9 @@ namespace {
|
|||
std::cout << "config_file_path(): \"" << config_file_path() << "\"\n";
|
||||
}
|
||||
|
||||
curry::SafeStackObject<tawashi::IniFile> load_ini() {
|
||||
curry::SafeStackObject<kamokan::IniFile> load_ini() {
|
||||
using curry::SafeStackObject;
|
||||
using tawashi::IniFile;
|
||||
using kamokan::IniFile;
|
||||
using std::istream_iterator;
|
||||
|
||||
std::ifstream conf(config_file_path());
|
||||
|
@ -115,7 +115,7 @@ namespace {
|
|||
return SafeStackObject<IniFile>(istream_iterator<char>(conf), istream_iterator<char>());
|
||||
}
|
||||
|
||||
std::shared_ptr<spdlog::logger> setup_logging (const tawashi::SettingsBag& parSettings) {
|
||||
std::shared_ptr<spdlog::logger> setup_logging (const kamokan::SettingsBag& parSettings) {
|
||||
//Prepare the logger
|
||||
spdlog::set_pattern("[%Y-%m-%d %T %z] - %v");
|
||||
spdlog::set_level(spdlog::level::trace); //set to maximum possible here
|
||||
|
@ -134,12 +134,12 @@ namespace {
|
|||
|
||||
int main (int parArgc, char* parArgv[], char* parEnvp[]) {
|
||||
using curry::SafeStackObject;
|
||||
using tawashi::IndexResponse;
|
||||
using tawashi::SubmitPasteResponse;
|
||||
using tawashi::QuickSubmitPasteResponse;
|
||||
using tawashi::PastieResponse;
|
||||
using tawashi::ErrorResponse;
|
||||
using tawashi::Response;
|
||||
using kamokan::IndexResponse;
|
||||
using kamokan::SubmitPasteResponse;
|
||||
using kamokan::QuickSubmitPasteResponse;
|
||||
using kamokan::PastieResponse;
|
||||
using kamokan::ErrorResponse;
|
||||
using kamokan::Response;
|
||||
using tawashi::RequestMethodType;
|
||||
|
||||
if (2 == parArgc and boost::string_view(parArgv[1]) == "--show-paths") {
|
||||
|
@ -147,8 +147,8 @@ int main (int parArgc, char* parArgv[], char* parEnvp[]) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
SafeStackObject<tawashi::IniFile> ini = load_ini();
|
||||
auto settings = SafeStackObject<tawashi::SettingsBag>(ini, "kamokan");
|
||||
SafeStackObject<kamokan::IniFile> ini = load_ini();
|
||||
auto settings = SafeStackObject<kamokan::SettingsBag>(ini, "kamokan");
|
||||
fill_defaults(*settings);
|
||||
|
||||
auto statuslog = setup_logging(*settings);
|
||||
|
@ -158,7 +158,7 @@ int main (int parArgc, char* parArgv[], char* parEnvp[]) {
|
|||
statuslog->info("Loaded config: \"{}\"", config_file_path());
|
||||
|
||||
auto cgi_env = SafeStackObject<tawashi::cgi::Env>(parEnvp, settings->at("host_path"));
|
||||
tawashi::ResponseFactory resp_factory(settings, cgi_env);
|
||||
kamokan::ResponseFactory resp_factory(settings, cgi_env);
|
||||
SPDLOG_TRACE(statuslog, "Registering makers in the response factory");
|
||||
resp_factory.register_maker("index.cgi", RequestMethodType::GET, &make_response<IndexResponse>);
|
||||
resp_factory.register_maker("", RequestMethodType::GET, &make_response<IndexResponse>);
|
||||
|
|
|
@ -47,8 +47,8 @@ target_compile_definitions(${PROJECT_NAME}
|
|||
PRIVATE BOOST_SPIRIT_USE_PHOENIX_V3=1
|
||||
PUBLIC $<$<CONFIG:Debug>:SPDLOG_DEBUG_ON>
|
||||
PUBLIC $<$<CONFIG:Debug>:SPDLOG_TRACE_ON>
|
||||
PUBLIC $<$<BOOL:${BUILD_TESTING}>:tawashi_virtual_testing=virtual>
|
||||
PUBLIC $<$<NOT:$<BOOL:${BUILD_TESTING}>>:tawashi_virtual_testing=>
|
||||
PUBLIC $<$<BOOL:${BUILD_TESTING}>:kamokan_virtual_testing=virtual>
|
||||
PUBLIC $<$<NOT:$<BOOL:${BUILD_TESTING}>>:kamokan_virtual_testing=>
|
||||
PUBLIC $<$<BOOL:${BUILD_TESTING}>:KAMOKAN_WITH_TESTING>
|
||||
)
|
||||
target_compile_options(${PROJECT_NAME}
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/* Copyright 2017, Michele Santullo
|
||||
* This file is part of "tawashi".
|
||||
* This file is part of "kamokan".
|
||||
*
|
||||
* "tawashi" is free software: you can redistribute it and/or modify
|
||||
* "kamokan" is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* "tawashi" is distributed in the hope that it will be useful,
|
||||
* "kamokan" is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with "tawashi". If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with "kamokan". If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "error_response.hpp"
|
||||
|
@ -26,7 +26,7 @@
|
|||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
namespace tawashi {
|
||||
namespace kamokan {
|
||||
ErrorResponse::ErrorResponse (
|
||||
const Kakoune::SafePtr<SettingsBag>& parSettings,
|
||||
std::ostream* parStreamOut,
|
||||
|
@ -37,6 +37,8 @@ namespace tawashi {
|
|||
}
|
||||
|
||||
void ErrorResponse::on_mustache_prepare (mstch::map& parContext) {
|
||||
using tawashi::ErrorReasons;
|
||||
|
||||
auto get = cgi_env().query_string_split();
|
||||
const int reason_int = boost::lexical_cast<int>(get["reason"]);
|
||||
ErrorReasons reason_code(ErrorReasons::UnkownReason);
|
||||
|
@ -55,7 +57,7 @@ namespace tawashi {
|
|||
"Unsupported CONTENT_TYPE.",
|
||||
"Invalid pastie token."
|
||||
};
|
||||
constexpr const auto lengths = string_lengths(err_descs);
|
||||
constexpr const auto lengths = tawashi::string_lengths(err_descs);
|
||||
static_assert(err_descs.static_size == lengths.static_size, "Mismatching array sizes between strings and their lengths");
|
||||
|
||||
#if !defined(NDEBUG)
|
||||
|
@ -67,4 +69,4 @@ namespace tawashi {
|
|||
parContext["error_message"] = std::string(err_descs[reason_code], lengths[reason_code]);
|
||||
parContext["error_id"] = std::to_string(reason_code);
|
||||
}
|
||||
} //namespace tawashi
|
||||
} //namespace kamokan
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/* Copyright 2017, Michele Santullo
|
||||
* This file is part of "tawashi".
|
||||
* This file is part of "kamokan".
|
||||
*
|
||||
* "tawashi" is free software: you can redistribute it and/or modify
|
||||
* "kamokan" is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* "tawashi" is distributed in the hope that it will be useful,
|
||||
* "kamokan" is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with "tawashi". If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with "kamokan". If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
@ -20,7 +20,7 @@
|
|||
#include "response.hpp"
|
||||
#include <boost/utility/string_view.hpp>
|
||||
|
||||
namespace tawashi {
|
||||
namespace kamokan {
|
||||
class ErrorResponse : public Response {
|
||||
public:
|
||||
ErrorResponse (
|
||||
|
@ -35,5 +35,5 @@ namespace tawashi {
|
|||
private:
|
||||
virtual void on_mustache_prepare (mstch::map& parContext) override;
|
||||
};
|
||||
} //namespace tawashi
|
||||
} //namespace kamokan
|
||||
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
/* Copyright 2017, Michele Santullo
|
||||
* This file is part of "tawashi".
|
||||
* This file is part of "kamokan".
|
||||
*
|
||||
* "tawashi" is free software: you can redistribute it and/or modify
|
||||
* "kamokan" is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* "tawashi" is distributed in the hope that it will be useful,
|
||||
* "kamokan" is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with "tawashi". If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with "kamokan". If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "index_response.hpp"
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
|
||||
namespace tawashi {
|
||||
namespace kamokan {
|
||||
IndexResponse::IndexResponse (
|
||||
const Kakoune::SafePtr<SettingsBag>& parSettings,
|
||||
std::ostream* parStreamOut,
|
||||
|
@ -27,5 +27,5 @@ namespace tawashi {
|
|||
Response(parSettings, parStreamOut, parCgiEnv, false)
|
||||
{
|
||||
}
|
||||
} //namespace tawashi
|
||||
} //namespace kamokan
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/* Copyright 2017, Michele Santullo
|
||||
* This file is part of "tawashi".
|
||||
* This file is part of "kamokan".
|
||||
*
|
||||
* "tawashi" is free software: you can redistribute it and/or modify
|
||||
* "kamokan" is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* "tawashi" is distributed in the hope that it will be useful,
|
||||
* "kamokan" is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with "tawashi". If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with "kamokan". If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
@ -20,7 +20,7 @@
|
|||
#include "response.hpp"
|
||||
#include <boost/utility/string_view.hpp>
|
||||
|
||||
namespace tawashi {
|
||||
namespace kamokan {
|
||||
class IndexResponse : public Response {
|
||||
public:
|
||||
IndexResponse (
|
||||
|
@ -34,4 +34,4 @@ namespace tawashi {
|
|||
|
||||
private:
|
||||
};
|
||||
} //namespace tawashi
|
||||
} //namespace kamokan
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/* Copyright 2017, Michele Santullo
|
||||
* This file is part of "tawashi".
|
||||
* This file is part of "kamokan".
|
||||
*
|
||||
* "tawashi" is free software: you can redistribute it and/or modify
|
||||
* "kamokan" is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* "tawashi" is distributed in the hope that it will be useful,
|
||||
* "kamokan" is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with "tawashi". If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with "kamokan". If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "ini_file.hpp"
|
||||
|
@ -41,7 +41,7 @@
|
|||
#include <type_traits>
|
||||
#include <iterator>
|
||||
|
||||
namespace tawashi {
|
||||
namespace kamokan {
|
||||
namespace {
|
||||
typedef boost::string_view string_type;
|
||||
|
||||
|
@ -144,4 +144,4 @@ namespace tawashi {
|
|||
}
|
||||
|
||||
IniFile::~IniFile() noexcept = default;
|
||||
} //namespace tawashi
|
||||
} //namespace kamokan
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/* Copyright 2017, Michele Santullo
|
||||
* This file is part of "tawashi".
|
||||
* This file is part of "kamokan".
|
||||
*
|
||||
* "tawashi" is free software: you can redistribute it and/or modify
|
||||
* "kamokan" is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* "tawashi" is distributed in the hope that it will be useful,
|
||||
* "kamokan" is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with "tawashi". If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with "kamokan". If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
@ -24,7 +24,7 @@
|
|||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
namespace tawashi {
|
||||
namespace kamokan {
|
||||
class IniFile : public Kakoune::SafeCountable {
|
||||
public:
|
||||
typedef boost::container::flat_map<boost::string_view, boost::string_view> KeyValueMapType;
|
||||
|
@ -55,4 +55,4 @@ namespace tawashi {
|
|||
assert(parse_success());
|
||||
return m_map;
|
||||
}
|
||||
} //namespace tawashi
|
||||
} //namespace kamokan
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/* Copyright 2017, Michele Santullo
|
||||
* This file is part of "tawashi".
|
||||
* This file is part of "kamokan".
|
||||
*
|
||||
* "tawashi" is free software: you can redistribute it and/or modify
|
||||
* "kamokan" is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* "tawashi" is distributed in the hope that it will be useful,
|
||||
* "kamokan" is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with "tawashi". If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with "kamokan". If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "list_highlight_langs.hpp"
|
||||
|
@ -22,7 +22,7 @@
|
|||
#include <boost/range/algorithm/copy.hpp>
|
||||
#include <boost/range/iterator_range_core.hpp>
|
||||
|
||||
namespace tawashi {
|
||||
namespace kamokan {
|
||||
HighlightLangList list_highlight_langs (const SettingsBag& parSettings) {
|
||||
srchilite::LangMap lang_map(parSettings.as<std::string>("langmap_dir"), "lang.map");
|
||||
lang_map.open();
|
||||
|
@ -30,5 +30,5 @@ namespace tawashi {
|
|||
const auto lang_range = boost::make_iterator_range(lang_map.begin(), lang_map.end());
|
||||
return boost::copy_range<HighlightLangList>(lang_range | boost::adaptors::map_keys);
|
||||
}
|
||||
} //namespace tawashi
|
||||
} //namespace kamokan
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/* Copyright 2017, Michele Santullo
|
||||
* This file is part of "tawashi".
|
||||
* This file is part of "kamokan".
|
||||
*
|
||||
* "tawashi" is free software: you can redistribute it and/or modify
|
||||
* "kamokan" is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* "tawashi" is distributed in the hope that it will be useful,
|
||||
* "kamokan" is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with "tawashi". If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with "kamokan". If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
@ -20,9 +20,9 @@
|
|||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
namespace tawashi {
|
||||
namespace kamokan {
|
||||
class SettingsBag;
|
||||
typedef std::vector<std::string> HighlightLangList;
|
||||
|
||||
HighlightLangList list_highlight_langs (const SettingsBag& parSettings);
|
||||
} //namespace tawashi
|
||||
} //namespace kamokan
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
/* Copyright 2017, Michele Santullo
|
||||
* This file is part of "tawashi".
|
||||
* This file is part of "kamokan".
|
||||
*
|
||||
* "tawashi" is free software: you can redistribute it and/or modify
|
||||
* "kamokan" is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* "tawashi" is distributed in the hope that it will be useful,
|
||||
* "kamokan" is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with "tawashi". If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with "kamokan". If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "num_to_token.hpp"
|
||||
#include <cassert>
|
||||
|
||||
namespace tawashi {
|
||||
namespace kamokan {
|
||||
namespace {
|
||||
//const int g_any_min = 0;
|
||||
//const int g_any_max = g_any_min + 'z' - 'a' - 1;
|
||||
|
@ -61,4 +61,4 @@ namespace tawashi {
|
|||
|
||||
return retval;
|
||||
}
|
||||
} //namespace tawashi
|
||||
} //namespace kamokan
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/* Copyright 2017, Michele Santullo
|
||||
* This file is part of "tawashi".
|
||||
* This file is part of "kamokan".
|
||||
*
|
||||
* "tawashi" is free software: you can redistribute it and/or modify
|
||||
* "kamokan" is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* "tawashi" is distributed in the hope that it will be useful,
|
||||
* "kamokan" is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with "tawashi". If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with "kamokan". If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
@ -21,6 +21,6 @@
|
|||
#include <string>
|
||||
#include <cstdint>
|
||||
|
||||
namespace tawashi {
|
||||
namespace kamokan {
|
||||
std::string num_to_token (int64_t parNum) a_pure;
|
||||
} //namespace tawashi
|
||||
} //namespace kamokan
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/* Copyright 2017, Michele Santullo
|
||||
* This file is part of "tawashi".
|
||||
* This file is part of "kamokan".
|
||||
*
|
||||
* "tawashi" is free software: you can redistribute it and/or modify
|
||||
* "kamokan" is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* "tawashi" is distributed in the hope that it will be useful,
|
||||
* "kamokan" is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with "tawashi". If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with "kamokan". If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "pastie_response.hpp"
|
||||
|
@ -32,7 +32,7 @@
|
|||
#include <boost/algorithm/string/finder.hpp>
|
||||
#include <boost/range/adaptor/transformed.hpp>
|
||||
|
||||
namespace tawashi {
|
||||
namespace kamokan {
|
||||
namespace {
|
||||
const char g_nolang_token[] = "colourless";
|
||||
|
||||
|
@ -101,7 +101,9 @@ namespace tawashi {
|
|||
{
|
||||
}
|
||||
|
||||
HttpHeader PastieResponse::on_process() {
|
||||
tawashi::HttpHeader PastieResponse::on_process() {
|
||||
using tawashi::ErrorReasons;
|
||||
|
||||
if (m_pastie_not_found)
|
||||
return make_error_redirect(ErrorReasons::PastieNotFound);
|
||||
if (m_token_invalid)
|
||||
|
@ -111,7 +113,7 @@ namespace tawashi {
|
|||
const std::string& query_str(cgi_env().query_string());
|
||||
if (get["m"] == "plain" or query_str.empty()) {
|
||||
m_plain_text = true;
|
||||
return make_header_type_text_utf8();
|
||||
return tawashi::make_header_type_text_utf8();
|
||||
}
|
||||
else if (query_str == g_nolang_token) {
|
||||
m_syntax_highlight = false;
|
||||
|
@ -125,7 +127,7 @@ namespace tawashi {
|
|||
if (m_lang_file.empty())
|
||||
m_lang_file = "default.lang";
|
||||
}
|
||||
return make_header_type_html();
|
||||
return tawashi::make_header_type_html();
|
||||
}
|
||||
|
||||
void PastieResponse::on_mustache_prepare (mstch::map& parContext) {
|
||||
|
@ -161,7 +163,7 @@ namespace tawashi {
|
|||
processed_pastie = std::move(*pastie);
|
||||
}
|
||||
else {
|
||||
Escapist houdini;
|
||||
tawashi::Escapist houdini;
|
||||
std::ostringstream oss;
|
||||
oss << R"(<pre><tt><font color="#EDEDED">)";
|
||||
oss << houdini.escape_html(*pastie) << "</font></tt></pre>\n";
|
||||
|
@ -187,4 +189,4 @@ namespace tawashi {
|
|||
else
|
||||
return load_mustache();
|
||||
}
|
||||
} //namespace tawashi
|
||||
} //namespace kamokan
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/* Copyright 2017, Michele Santullo
|
||||
* This file is part of "tawashi".
|
||||
* This file is part of "kamokan".
|
||||
*
|
||||
* "tawashi" is free software: you can redistribute it and/or modify
|
||||
* "kamokan" is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* "tawashi" is distributed in the hope that it will be useful,
|
||||
* "kamokan" is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with "tawashi". If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with "kamokan". If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
@ -21,7 +21,7 @@
|
|||
#include <string>
|
||||
#include <boost/utility/string_view.hpp>
|
||||
|
||||
namespace tawashi {
|
||||
namespace kamokan {
|
||||
class PastieResponse : public Response {
|
||||
public:
|
||||
PastieResponse (
|
||||
|
@ -34,7 +34,7 @@ namespace tawashi {
|
|||
virtual boost::string_view page_basename() const override { return boost::string_view("pastie"); }
|
||||
|
||||
private:
|
||||
virtual HttpHeader on_process() override;
|
||||
virtual tawashi::HttpHeader on_process() override;
|
||||
virtual void on_mustache_prepare (mstch::map& parContext) override;
|
||||
virtual std::string on_mustache_retrieve() override;
|
||||
|
||||
|
@ -45,4 +45,4 @@ namespace tawashi {
|
|||
bool m_pastie_not_found;
|
||||
bool m_token_invalid;
|
||||
};
|
||||
} //namespace tawashi
|
||||
} //namespace kamokan
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
/* Copyright 2017, Michele Santullo
|
||||
* This file is part of "tawashi".
|
||||
* This file is part of "kamokan".
|
||||
*
|
||||
* "tawashi" is free software: you can redistribute it and/or modify
|
||||
* "kamokan" is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* "tawashi" is distributed in the hope that it will be useful,
|
||||
* "kamokan" is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with "tawashi". If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with "kamokan". If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "quick_submit_paste_response.hpp"
|
||||
|
||||
namespace tawashi {
|
||||
namespace kamokan {
|
||||
QuickSubmitPasteResponse::QuickSubmitPasteResponse (
|
||||
const Kakoune::SafePtr<SettingsBag>& parSettings,
|
||||
std::ostream* parStreamOut,
|
||||
|
@ -35,8 +35,8 @@ namespace tawashi {
|
|||
return "{{base_uri}}/{{redirect_to_address}}\n";
|
||||
}
|
||||
|
||||
HttpHeader QuickSubmitPasteResponse::make_success_response (std::string&& parPastieParam) {
|
||||
tawashi::HttpHeader QuickSubmitPasteResponse::make_success_response (std::string&& parPastieParam) {
|
||||
m_redirect_to = std::move(parPastieParam);
|
||||
return HttpHeader();
|
||||
return tawashi::HttpHeader();
|
||||
}
|
||||
} //namespace tawashi
|
||||
} //namespace kamokan
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/* Copyright 2017, Michele Santullo
|
||||
* This file is part of "tawashi".
|
||||
* This file is part of "kamokan".
|
||||
*
|
||||
* "tawashi" is free software: you can redistribute it and/or modify
|
||||
* "kamokan" is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* "tawashi" is distributed in the hope that it will be useful,
|
||||
* "kamokan" is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with "tawashi". If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with "kamokan". If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
@ -22,7 +22,7 @@
|
|||
#include <boost/utility/string_view.hpp>
|
||||
#include <cassert>
|
||||
|
||||
namespace tawashi {
|
||||
namespace kamokan {
|
||||
class QuickSubmitPasteResponse : public SubmitPasteResponse {
|
||||
public:
|
||||
QuickSubmitPasteResponse (
|
||||
|
@ -33,7 +33,7 @@ namespace tawashi {
|
|||
|
||||
protected:
|
||||
virtual boost::string_view page_basename() const override { assert(false); return boost::string_view(""); }
|
||||
virtual HttpHeader make_success_response (std::string&& parPastieParam) override;
|
||||
virtual tawashi::HttpHeader make_success_response (std::string&& parPastieParam) override;
|
||||
|
||||
private:
|
||||
virtual void on_mustache_prepare (mstch::map& parContext) override;
|
||||
|
@ -41,4 +41,4 @@ namespace tawashi {
|
|||
|
||||
std::string m_redirect_to;
|
||||
};
|
||||
} //namespace tawashi
|
||||
} //namespace kamokan
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/* Copyright 2017, Michele Santullo
|
||||
* This file is part of "tawashi".
|
||||
* This file is part of "kamokan".
|
||||
*
|
||||
* "tawashi" is free software: you can redistribute it and/or modify
|
||||
* "kamokan" is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* "tawashi" is distributed in the hope that it will be useful,
|
||||
* "kamokan" is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with "tawashi". If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with "kamokan". If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "response.hpp"
|
||||
|
@ -34,7 +34,7 @@
|
|||
#include <cstdint>
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
namespace tawashi {
|
||||
namespace kamokan {
|
||||
namespace {
|
||||
//boost::string_ref fetch_page_basename (const cgi::Env& parEnv) {
|
||||
// const boost::string_ref& path = parEnv.path_info();
|
||||
|
@ -115,7 +115,7 @@ namespace tawashi {
|
|||
oss << ':' << port;
|
||||
}
|
||||
}
|
||||
else if (not host_port.empty() and seems_valid_number<uint16_t>(host_port)) {
|
||||
else if (not host_port.empty() and tawashi::seems_valid_number<uint16_t>(host_port)) {
|
||||
oss << ':' << host_port;
|
||||
}
|
||||
}
|
||||
|
@ -159,8 +159,8 @@ namespace tawashi {
|
|||
|
||||
Response::~Response() noexcept = default;
|
||||
|
||||
HttpHeader Response::on_process() {
|
||||
return HttpHeader();
|
||||
tawashi::HttpHeader Response::on_process() {
|
||||
return tawashi::HttpHeader();
|
||||
}
|
||||
|
||||
void Response::on_mustache_prepare (mstch::map&) {
|
||||
|
@ -183,7 +183,7 @@ namespace tawashi {
|
|||
m_storage.finalize_connection();
|
||||
|
||||
SPDLOG_TRACE(statuslog, "Raising event on_process");
|
||||
HttpHeader http_header = this->on_process();
|
||||
tawashi::HttpHeader http_header = this->on_process();
|
||||
*m_stream_out << http_header;
|
||||
|
||||
if (http_header.body_required()) {
|
||||
|
@ -239,17 +239,19 @@ namespace tawashi {
|
|||
return *m_settings;
|
||||
}
|
||||
|
||||
HttpHeader Response::make_redirect (HttpStatusCodes parCode, const std::string& parLocation) {
|
||||
tawashi::HttpHeader Response::make_redirect (tawashi::HttpStatusCodes parCode, const std::string& parLocation) {
|
||||
std::ostringstream oss;
|
||||
oss << base_uri() << '/' << parLocation;
|
||||
|
||||
auto statuslog = spdlog::get("statuslog");
|
||||
assert(statuslog);
|
||||
statuslog->info("Redirecting to page \"{}\"", oss.str());
|
||||
return HttpHeader(parCode, oss.str());
|
||||
return tawashi::HttpHeader(parCode, oss.str());
|
||||
}
|
||||
|
||||
HttpHeader Response::make_error_redirect (ErrorReasons parReason) {
|
||||
tawashi::HttpHeader Response::make_error_redirect (tawashi::ErrorReasons parReason) {
|
||||
using tawashi::HttpStatusCodes;
|
||||
|
||||
auto statuslog = spdlog::get("statuslog");
|
||||
assert(statuslog);
|
||||
const HttpStatusCodes redir_code = HttpStatusCodes::Code302_Found;
|
||||
|
@ -259,4 +261,4 @@ namespace tawashi {
|
|||
oss << "error.cgi?reason=" << parReason._to_integral();
|
||||
return make_redirect(redir_code, oss.str());
|
||||
}
|
||||
} //namespace tawashi
|
||||
} //namespace kamokan
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/* Copyright 2017, Michele Santullo
|
||||
* This file is part of "tawashi".
|
||||
* This file is part of "kamokan".
|
||||
*
|
||||
* "tawashi" is free software: you can redistribute it and/or modify
|
||||
* "kamokan" is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* "tawashi" is distributed in the hope that it will be useful,
|
||||
* "kamokan" is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with "tawashi". If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with "kamokan". If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
@ -29,11 +29,14 @@
|
|||
#include <memory>
|
||||
|
||||
namespace tawashi {
|
||||
class SettingsBag;
|
||||
|
||||
namespace cgi {
|
||||
class Env;
|
||||
} //namespace cgi
|
||||
} //namespace tawashi
|
||||
|
||||
namespace kamokan {
|
||||
class SettingsBag;
|
||||
namespace cgi = tawashi::cgi;
|
||||
|
||||
class Response {
|
||||
public:
|
||||
|
@ -50,18 +53,18 @@ namespace tawashi {
|
|||
);
|
||||
|
||||
const cgi::Env& cgi_env() const;
|
||||
tawashi_virtual_testing const cgi::PostMapType& cgi_post() const;
|
||||
kamokan_virtual_testing const cgi::PostMapType& cgi_post() const;
|
||||
|
||||
const std::string& base_uri() const;
|
||||
virtual boost::string_view page_basename() const = 0;
|
||||
tawashi_virtual_testing const Storage& storage() const;
|
||||
kamokan_virtual_testing const Storage& storage() const;
|
||||
const SettingsBag& settings() const;
|
||||
virtual std::string load_mustache() const;
|
||||
HttpHeader make_redirect (HttpStatusCodes parCode, const std::string& parLocation);
|
||||
HttpHeader make_error_redirect (ErrorReasons parReason);
|
||||
tawashi::HttpHeader make_redirect (tawashi::HttpStatusCodes parCode, const std::string& parLocation);
|
||||
tawashi::HttpHeader make_error_redirect (tawashi::ErrorReasons parReason);
|
||||
|
||||
private:
|
||||
virtual HttpHeader on_process();
|
||||
virtual tawashi::HttpHeader on_process();
|
||||
virtual void on_mustache_prepare (mstch::map& parContext);
|
||||
virtual std::string on_mustache_retrieve();
|
||||
|
||||
|
@ -72,4 +75,4 @@ namespace tawashi {
|
|||
std::string m_base_uri;
|
||||
std::ostream* m_stream_out;
|
||||
};
|
||||
} //namespace tawashi
|
||||
} //namespace kamokan
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/* Copyright 2017, Michele Santullo
|
||||
* This file is part of "tawashi".
|
||||
* This file is part of "kamokan".
|
||||
*
|
||||
* "tawashi" is free software: you can redistribute it and/or modify
|
||||
* "kamokan" is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* "tawashi" is distributed in the hope that it will be useful,
|
||||
* "kamokan" is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with "tawashi". If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with "kamokan". If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "response_factory.hpp"
|
||||
|
@ -24,7 +24,7 @@
|
|||
#include <algorithm>
|
||||
#include <array>
|
||||
|
||||
namespace tawashi {
|
||||
namespace kamokan {
|
||||
namespace {
|
||||
} //unnamed namespace
|
||||
|
||||
|
@ -32,11 +32,11 @@ namespace tawashi {
|
|||
Kakoune::SafePtr<SettingsBag> settings;
|
||||
boost::container::flat_map<std::string, ResponseMakerFunc> makers_get;
|
||||
boost::container::flat_map<std::string, ResponseMakerFunc> makers_post;
|
||||
std::array<ResponseMakerFunc, RequestMethodType::_size()> jolly_makers;
|
||||
Kakoune::SafePtr<cgi::Env> cgi_env;
|
||||
std::array<ResponseMakerFunc, tawashi::RequestMethodType::_size()> jolly_makers;
|
||||
Kakoune::SafePtr<tawashi::cgi::Env> cgi_env;
|
||||
};
|
||||
|
||||
ResponseFactory::ResponseFactory (const Kakoune::SafePtr<SettingsBag>& parSettings, const Kakoune::SafePtr<cgi::Env>& parCgiEnv) :
|
||||
ResponseFactory::ResponseFactory (const Kakoune::SafePtr<SettingsBag>& parSettings, const Kakoune::SafePtr<tawashi::cgi::Env>& parCgiEnv) :
|
||||
m_local_data(std::make_unique<LocalData>())
|
||||
{
|
||||
m_local_data->settings = parSettings;
|
||||
|
@ -46,7 +46,7 @@ namespace tawashi {
|
|||
|
||||
ResponseFactory::~ResponseFactory() noexcept = default;
|
||||
|
||||
std::unique_ptr<Response> ResponseFactory::make_response (const boost::string_view& parName, RequestMethodType parReqType) {
|
||||
std::unique_ptr<Response> ResponseFactory::make_response (const boost::string_view& parName, tawashi::RequestMethodType parReqType) {
|
||||
std::string name(parName.data(), parName.size());
|
||||
spdlog::get("statuslog")->info(
|
||||
"making response object for \"{}\" method {}",
|
||||
|
@ -54,7 +54,11 @@ namespace tawashi {
|
|||
parReqType._to_string()
|
||||
);
|
||||
|
||||
const auto& makers = (static_cast<RequestMethodType>(RequestMethodType::POST) == parReqType ? m_local_data->makers_post : m_local_data->makers_get);
|
||||
const auto& makers = (
|
||||
static_cast<tawashi::RequestMethodType>(tawashi::RequestMethodType::POST) == parReqType ?
|
||||
m_local_data->makers_post : m_local_data->makers_get
|
||||
);
|
||||
|
||||
auto maker_it = makers.find(name);
|
||||
if (makers.end() != maker_it) {
|
||||
return maker_it->second(m_local_data->settings, m_local_data->cgi_env);
|
||||
|
@ -74,18 +78,18 @@ namespace tawashi {
|
|||
m_local_data->makers_post[std::move(parName)] = parMaker;
|
||||
}
|
||||
|
||||
void ResponseFactory::register_maker (std::string&& parName, RequestMethodType parReqType, ResponseMakerFunc parMaker) {
|
||||
void ResponseFactory::register_maker (std::string&& parName, tawashi::RequestMethodType parReqType, ResponseMakerFunc parMaker) {
|
||||
switch (parReqType) {
|
||||
case RequestMethodType::GET:
|
||||
case tawashi::RequestMethodType::GET:
|
||||
m_local_data->makers_get[std::move(parName)] = parMaker;
|
||||
break;
|
||||
case RequestMethodType::POST:
|
||||
case tawashi::RequestMethodType::POST:
|
||||
m_local_data->makers_post[std::move(parName)] = parMaker;
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
void ResponseFactory::register_jolly_maker (ResponseMakerFunc parMaker, RequestMethodType parReqType) {
|
||||
void ResponseFactory::register_jolly_maker (ResponseMakerFunc parMaker, tawashi::RequestMethodType parReqType) {
|
||||
m_local_data->jolly_makers[parReqType] = parMaker;
|
||||
}
|
||||
} //namespace tawashi
|
||||
} //namespace kamokan
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/* Copyright 2017, Michele Santullo
|
||||
* This file is part of "tawashi".
|
||||
* This file is part of "kamokan".
|
||||
*
|
||||
* "tawashi" is free software: you can redistribute it and/or modify
|
||||
* "kamokan" is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* "tawashi" is distributed in the hope that it will be useful,
|
||||
* "kamokan" is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with "tawashi". If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with "kamokan". If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
@ -23,27 +23,30 @@
|
|||
#include <memory>
|
||||
|
||||
namespace tawashi {
|
||||
class SettingsBag;
|
||||
|
||||
namespace cgi {
|
||||
class Env;
|
||||
} //namespace cgi
|
||||
} //namespace tawashi
|
||||
|
||||
namespace kamokan {
|
||||
class SettingsBag;
|
||||
namespace cgi = tawashi::cgi;
|
||||
|
||||
class ResponseFactory {
|
||||
public:
|
||||
typedef std::function<std::unique_ptr<Response>(const Kakoune::SafePtr<SettingsBag>&, const Kakoune::SafePtr<cgi::Env>& parCgiEnv)> ResponseMakerFunc;
|
||||
typedef std::function<std::unique_ptr<Response>(const Kakoune::SafePtr<SettingsBag>&, const Kakoune::SafePtr<tawashi::cgi::Env>& parCgiEnv)> ResponseMakerFunc;
|
||||
|
||||
explicit ResponseFactory (const Kakoune::SafePtr<SettingsBag>& parSettings, const Kakoune::SafePtr<cgi::Env>& parCgiEnv);
|
||||
explicit ResponseFactory (const Kakoune::SafePtr<SettingsBag>& parSettings, const Kakoune::SafePtr<tawashi::cgi::Env>& parCgiEnv);
|
||||
~ResponseFactory() noexcept;
|
||||
|
||||
std::unique_ptr<Response> make_response(const boost::string_view& parName, RequestMethodType parReqType);
|
||||
std::unique_ptr<Response> make_response(const boost::string_view& parName, tawashi::RequestMethodType parReqType);
|
||||
void register_maker (std::string&& parName, ResponseMakerFunc parMaker);
|
||||
void register_maker (std::string&& parName, RequestMethodType parReqType, ResponseMakerFunc parMaker);
|
||||
void register_jolly_maker (ResponseMakerFunc parMaker, RequestMethodType parReqType);
|
||||
void register_maker (std::string&& parName, tawashi::RequestMethodType parReqType, ResponseMakerFunc parMaker);
|
||||
void register_jolly_maker (ResponseMakerFunc parMaker, tawashi::RequestMethodType parReqType);
|
||||
|
||||
private:
|
||||
struct LocalData;
|
||||
|
||||
std::unique_ptr<LocalData> m_local_data;
|
||||
};
|
||||
} //namespace tawashi
|
||||
} //namespace kamokan
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/* Copyright 2017, Michele Santullo
|
||||
* This file is part of "tawashi".
|
||||
* This file is part of "kamokan".
|
||||
*
|
||||
* "tawashi" is free software: you can redistribute it and/or modify
|
||||
* "kamokan" is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* "tawashi" is distributed in the hope that it will be useful,
|
||||
* "kamokan" is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with "tawashi". If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with "kamokan". If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "settings_bag.hpp"
|
||||
|
@ -24,9 +24,9 @@
|
|||
#include <sstream>
|
||||
#include <iostream>
|
||||
|
||||
namespace tawashi {
|
||||
namespace kamokan {
|
||||
namespace {
|
||||
const IniFile::KeyValueMapType* get_tawashi_node (const IniFile& parIni, boost::string_view parSectionName) {
|
||||
const IniFile::KeyValueMapType* get_kamokan_node (const IniFile& parIni, boost::string_view parSectionName) {
|
||||
auto it_found = parIni.parsed().find(parSectionName);
|
||||
if (parIni.parsed().end() != it_found) {
|
||||
return &it_found->second;
|
||||
|
@ -41,7 +41,7 @@ namespace tawashi {
|
|||
|
||||
SettingsBag::SettingsBag (const Kakoune::SafePtr<IniFile>& parIni, boost::string_view parSectionName) :
|
||||
m_ini(parIni),
|
||||
m_values(get_tawashi_node(*parIni, parSectionName))
|
||||
m_values(get_kamokan_node(*parIni, parSectionName))
|
||||
{
|
||||
assert(m_values);
|
||||
}
|
||||
|
@ -97,4 +97,4 @@ namespace tawashi {
|
|||
template bool SettingsBag::as<bool> (boost::string_view parIndex) const;
|
||||
template uint16_t SettingsBag::as<uint16_t> (boost::string_view parIndex) const;
|
||||
template uint32_t SettingsBag::as<uint32_t> (boost::string_view parIndex) const;
|
||||
} //namespace tawashi
|
||||
} //namespace kamokan
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/* Copyright 2017, Michele Santullo
|
||||
* This file is part of "tawashi".
|
||||
* This file is part of "kamokan".
|
||||
*
|
||||
* "tawashi" is free software: you can redistribute it and/or modify
|
||||
* "kamokan" is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* "tawashi" is distributed in the hope that it will be useful,
|
||||
* "kamokan" is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with "tawashi". If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with "kamokan". If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
@ -27,7 +27,7 @@
|
|||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
namespace tawashi {
|
||||
namespace kamokan {
|
||||
class SettingsBag : public Kakoune::SafeCountable {
|
||||
typedef std::map<boost::string_view, boost::string_view> MapType;
|
||||
public:
|
||||
|
@ -56,4 +56,4 @@ namespace tawashi {
|
|||
#endif
|
||||
return (*this)[parIndex];
|
||||
}
|
||||
} //namespace tawashi
|
||||
} //namespace kamokan
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/* Copyright 2017, Michele Santullo
|
||||
* This file is part of "tawashi".
|
||||
* This file is part of "kamokan".
|
||||
*
|
||||
* "tawashi" is free software: you can redistribute it and/or modify
|
||||
* "kamokan" is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* "tawashi" is distributed in the hope that it will be useful,
|
||||
* "kamokan" is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with "tawashi". If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with "kamokan". If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "storage.hpp"
|
||||
|
@ -28,7 +28,7 @@
|
|||
#include <utility>
|
||||
#include <algorithm>
|
||||
|
||||
namespace tawashi {
|
||||
namespace kamokan {
|
||||
namespace {
|
||||
redis::IncRedis make_incredis (const SettingsBag& parSettings) {
|
||||
using redis::IncRedis;
|
||||
|
@ -48,10 +48,11 @@ namespace tawashi {
|
|||
}
|
||||
|
||||
Storage::SubmissionResult make_submission_result (std::string&& parToken) {
|
||||
using tawashi::ErrorReasons;
|
||||
return Storage::SubmissionResult { std::move(parToken), boost::optional<ErrorReasons>() };
|
||||
}
|
||||
|
||||
Storage::SubmissionResult make_submission_result (ErrorReasons parError) {
|
||||
Storage::SubmissionResult make_submission_result (tawashi::ErrorReasons parError) {
|
||||
return Storage::SubmissionResult { std::string(), boost::make_optional(parError) };
|
||||
}
|
||||
} //unnamed namespace
|
||||
|
@ -84,7 +85,7 @@ namespace tawashi {
|
|||
m_redis->wait_for_connect();
|
||||
auto batch = m_redis->make_batch();
|
||||
batch.select(m_settings->as<uint32_t>("redis_db"));
|
||||
batch.client_setname("tawashi_v" STRINGIZE(VERSION_MAJOR) "." STRINGIZE(VERSION_MINOR) "." STRINGIZE(VERSION_PATCH));
|
||||
batch.client_setname("kamokan_v" STRINGIZE(VERSION_MAJOR) "." STRINGIZE(VERSION_MINOR) "." STRINGIZE(VERSION_PATCH));
|
||||
batch.throw_if_failed();
|
||||
}
|
||||
}
|
||||
|
@ -95,6 +96,8 @@ namespace tawashi {
|
|||
const boost::string_view& parLang,
|
||||
const std::string& parRemoteIP
|
||||
) const {
|
||||
using tawashi::ErrorReasons;
|
||||
|
||||
if (not is_connected())
|
||||
return make_submission_result(ErrorReasons::RedisDisconnected);
|
||||
|
||||
|
@ -110,7 +113,7 @@ namespace tawashi {
|
|||
statuslog->info(
|
||||
"Submitting pastie of size {} to redis -> \"{}\"",
|
||||
parText.size(),
|
||||
truncated_string(parText, 30)
|
||||
tawashi::truncated_string(parText, 30)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -155,4 +158,4 @@ namespace tawashi {
|
|||
return *m_settings;
|
||||
}
|
||||
#endif
|
||||
} //namespace tawashi
|
||||
} //namespace kamokan
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/* Copyright 2017, Michele Santullo
|
||||
* This file is part of "tawashi".
|
||||
* This file is part of "kamokan".
|
||||
*
|
||||
* "tawashi" is free software: you can redistribute it and/or modify
|
||||
* "kamokan" is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* "tawashi" is distributed in the hope that it will be useful,
|
||||
* "kamokan" is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with "tawashi". If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with "kamokan". If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
@ -29,30 +29,30 @@ namespace redis {
|
|||
class IncRedis;
|
||||
} //namespace redis
|
||||
|
||||
namespace tawashi {
|
||||
namespace kamokan {
|
||||
class SettingsBag;
|
||||
|
||||
class Storage {
|
||||
public:
|
||||
struct SubmissionResult {
|
||||
std::string token;
|
||||
boost::optional<ErrorReasons> error;
|
||||
boost::optional<tawashi::ErrorReasons> error;
|
||||
};
|
||||
|
||||
explicit Storage (const Kakoune::SafePtr<SettingsBag>& parSettings);
|
||||
tawashi_virtual_testing ~Storage();
|
||||
kamokan_virtual_testing ~Storage();
|
||||
|
||||
tawashi_virtual_testing void connect_async();
|
||||
tawashi_virtual_testing bool is_connected() const;
|
||||
tawashi_virtual_testing void finalize_connection();
|
||||
tawashi_virtual_testing SubmissionResult submit_pastie (
|
||||
kamokan_virtual_testing void connect_async();
|
||||
kamokan_virtual_testing bool is_connected() const;
|
||||
kamokan_virtual_testing void finalize_connection();
|
||||
kamokan_virtual_testing SubmissionResult submit_pastie (
|
||||
const boost::string_view& parText,
|
||||
uint32_t parExpiry,
|
||||
const boost::string_view& parLang,
|
||||
const std::string& parRemoteIP
|
||||
) const;
|
||||
|
||||
tawashi_virtual_testing boost::optional<std::string> retrieve_pastie (const boost::string_view& parToken) const;
|
||||
kamokan_virtual_testing boost::optional<std::string> retrieve_pastie (const boost::string_view& parToken) const;
|
||||
|
||||
#if defined(KAMOKAN_WITH_TESTING)
|
||||
const SettingsBag& settings() const;
|
||||
|
@ -62,4 +62,4 @@ namespace tawashi {
|
|||
std::unique_ptr<redis::IncRedis> m_redis;
|
||||
Kakoune::SafePtr<SettingsBag> m_settings;
|
||||
};
|
||||
} //namespace tawashi
|
||||
} //namespace kamokan
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/* Copyright 2017, Michele Santullo
|
||||
* This file is part of "tawashi".
|
||||
* This file is part of "kamokan".
|
||||
*
|
||||
* "tawashi" is free software: you can redistribute it and/or modify
|
||||
* "kamokan" is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* "tawashi" is distributed in the hope that it will be useful,
|
||||
* "kamokan" is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with "tawashi". If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with "kamokan". If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "submit_paste_response.hpp"
|
||||
|
@ -29,17 +29,17 @@
|
|||
#include <cstdint>
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
namespace tawashi {
|
||||
namespace kamokan {
|
||||
namespace {
|
||||
const char g_post_key[] = "pastie";
|
||||
const char g_language_key[] = "lang";
|
||||
const char g_duration_key[] = "ttl";
|
||||
|
||||
class MissingPostVarError : public TawashiException {
|
||||
class MissingPostVarError : public tawashi::TawashiException {
|
||||
public:
|
||||
explicit MissingPostVarError(const boost::string_view& parKey) :
|
||||
TawashiException(
|
||||
ErrorReasons::MissingPostVariable,
|
||||
tawashi::ErrorReasons::MissingPostVariable,
|
||||
"Error retrieving POST variable \"" + std::string(parKey.begin(), parKey.end()) + "\""
|
||||
)
|
||||
{}
|
||||
|
@ -94,7 +94,9 @@ namespace tawashi {
|
|||
{
|
||||
}
|
||||
|
||||
HttpHeader SubmitPasteResponse::on_process() {
|
||||
tawashi::HttpHeader SubmitPasteResponse::on_process() {
|
||||
using tawashi::ErrorReasons;
|
||||
|
||||
boost::string_view pastie;
|
||||
boost::string_view lang;
|
||||
boost::string_view duration;
|
||||
|
@ -109,14 +111,14 @@ namespace tawashi {
|
|||
lang = get_value_from_post_log_failure(post, make_string_view(g_language_key));
|
||||
duration = get_value_from_post_log_failure(post, make_string_view(g_duration_key));
|
||||
}
|
||||
catch (const UnsupportedContentTypeException& err) {
|
||||
catch (const tawashi::UnsupportedContentTypeException& err) {
|
||||
statuslog->info(
|
||||
"Unsupported content type exception: \"{}\"",
|
||||
err.what()
|
||||
);
|
||||
return make_error_redirect(ErrorReasons::UnsupportedContentType);
|
||||
}
|
||||
catch (const TawashiException& e) {
|
||||
catch (const tawashi::TawashiException& e) {
|
||||
statuslog->error(e.what());
|
||||
return make_error_redirect(e.reason());
|
||||
}
|
||||
|
@ -163,15 +165,16 @@ namespace tawashi {
|
|||
const boost::string_view& parLang
|
||||
) -> StringOrHeader {
|
||||
auto& storage = this->storage();
|
||||
std::string remote_ip = guess_real_remote_ip(cgi_env());
|
||||
std::string remote_ip = tawashi::guess_real_remote_ip(cgi_env());
|
||||
Storage::SubmissionResult submission_res = storage.submit_pastie(parText, parExpiry, parLang, remote_ip);
|
||||
if (not submission_res.error)
|
||||
return std::make_pair(boost::make_optional(std::move(submission_res.token)), HttpHeader());
|
||||
return std::make_pair(boost::make_optional(std::move(submission_res.token)), tawashi::HttpHeader());
|
||||
else
|
||||
return std::make_pair(boost::optional<std::string>(), make_error_redirect(*submission_res.error));
|
||||
}
|
||||
|
||||
HttpHeader SubmitPasteResponse::make_success_response (std::string&& parPastieParam) {
|
||||
tawashi::HttpHeader SubmitPasteResponse::make_success_response (std::string&& parPastieParam) {
|
||||
using tawashi::HttpStatusCodes;
|
||||
return this->make_redirect(HttpStatusCodes::Code303_SeeOther, std::move(parPastieParam));
|
||||
}
|
||||
} //namespace tawashi
|
||||
} //namespace kamokan
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/* Copyright 2017, Michele Santullo
|
||||
* This file is part of "tawashi".
|
||||
* This file is part of "kamokan".
|
||||
*
|
||||
* "tawashi" is free software: you can redistribute it and/or modify
|
||||
* "kamokan" is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* "tawashi" is distributed in the hope that it will be useful,
|
||||
* "kamokan" is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with "tawashi". If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with "kamokan". If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
@ -24,7 +24,7 @@
|
|||
#include <cassert>
|
||||
#include <utility>
|
||||
|
||||
namespace tawashi {
|
||||
namespace kamokan {
|
||||
class SubmitPasteResponse : public Response {
|
||||
public:
|
||||
#if defined(KAMOKAN_WITH_TESTING)
|
||||
|
@ -44,12 +44,12 @@ namespace tawashi {
|
|||
|
||||
protected:
|
||||
virtual boost::string_view page_basename() const override { assert(false); return boost::string_view(""); }
|
||||
virtual HttpHeader make_success_response (std::string&& parPastieParam);
|
||||
virtual tawashi::HttpHeader make_success_response (std::string&& parPastieParam);
|
||||
|
||||
private:
|
||||
typedef std::pair<boost::optional<std::string>, HttpHeader> StringOrHeader;
|
||||
typedef std::pair<boost::optional<std::string>, tawashi::HttpHeader> StringOrHeader;
|
||||
|
||||
virtual HttpHeader on_process() override;
|
||||
virtual tawashi::HttpHeader on_process() override;
|
||||
StringOrHeader submit_to_storage (const boost::string_view& parText, uint32_t parExpiry, const boost::string_view& parLang);
|
||||
};
|
||||
} //namespace tawashi
|
||||
} //namespace kamokan
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include <utility>
|
||||
#include <algorithm>
|
||||
|
||||
namespace tawashi {
|
||||
namespace kamokan {
|
||||
FakeStorage::FakeStorage (const Kakoune::SafePtr<SettingsBag>& parSettings, bool parItsConnected) :
|
||||
Storage(parSettings),
|
||||
m_submission_num(1),
|
||||
|
@ -77,4 +77,4 @@ namespace tawashi {
|
|||
const std::vector<FakeStorage::SubmittedPastie>& FakeStorage::submitted_pasties() const {
|
||||
return m_submitted_pasties;
|
||||
}
|
||||
} //namespace tawashi
|
||||
} //namespace kamokan
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
# error "Can't compile this class if test mode is disabled"
|
||||
#endif
|
||||
|
||||
namespace tawashi {
|
||||
namespace kamokan {
|
||||
class FakeStorage : public Storage {
|
||||
public:
|
||||
struct SubmittedPastie {
|
||||
|
@ -38,19 +38,19 @@ namespace tawashi {
|
|||
};
|
||||
|
||||
FakeStorage (const Kakoune::SafePtr<SettingsBag>& parSettings, bool parItsConnected);
|
||||
tawashi_virtual_testing ~FakeStorage();
|
||||
kamokan_virtual_testing ~FakeStorage();
|
||||
|
||||
tawashi_virtual_testing void connect_async();
|
||||
tawashi_virtual_testing bool is_connected() const;
|
||||
tawashi_virtual_testing void finalize_connection();
|
||||
tawashi_virtual_testing SubmissionResult submit_pastie (
|
||||
kamokan_virtual_testing void connect_async();
|
||||
kamokan_virtual_testing bool is_connected() const;
|
||||
kamokan_virtual_testing void finalize_connection();
|
||||
kamokan_virtual_testing SubmissionResult submit_pastie (
|
||||
const boost::string_view& parText,
|
||||
uint32_t parExpiry,
|
||||
const boost::string_view& parLang,
|
||||
const std::string& parRemoteIP
|
||||
) const;
|
||||
|
||||
tawashi_virtual_testing boost::optional<std::string> retrieve_pastie (const boost::string_view& parToken) const;
|
||||
kamokan_virtual_testing boost::optional<std::string> retrieve_pastie (const boost::string_view& parToken) const;
|
||||
|
||||
const std::vector<SubmittedPastie>& submitted_pasties() const;
|
||||
|
||||
|
@ -59,4 +59,4 @@ namespace tawashi {
|
|||
mutable int64_t m_submission_num;
|
||||
bool m_its_connected;
|
||||
};
|
||||
} //namespace tawashi
|
||||
} //namespace kamokan
|
||||
|
|
|
@ -55,7 +55,7 @@ R"(Content-type: text/html
|
|||
)";
|
||||
} //unnamed namespace
|
||||
|
||||
namespace tawashi {
|
||||
namespace kamokan {
|
||||
class IndexResponseCustomMustache : public IndexResponse {
|
||||
public:
|
||||
IndexResponseCustomMustache (
|
||||
|
@ -71,7 +71,7 @@ namespace tawashi {
|
|||
return g_mustache_html;
|
||||
}
|
||||
};
|
||||
} //namespace tawashi
|
||||
} //namespace kamokan
|
||||
|
||||
TEST_CASE ("Index response", "[index][response]") {
|
||||
using curry::SafeStackObject;
|
||||
|
@ -109,12 +109,12 @@ TEST_CASE ("Index response", "[index][response]") {
|
|||
" host_path = /\n"
|
||||
" host_port =\n"
|
||||
);
|
||||
SafeStackObject<tawashi::IniFile> ini(std::move(kamokan_settings));
|
||||
SafeStackObject<tawashi::SettingsBag> settings(ini, "kamokan");
|
||||
SafeStackObject<kamokan::IniFile> ini(std::move(kamokan_settings));
|
||||
SafeStackObject<kamokan::SettingsBag> settings(ini, "kamokan");
|
||||
|
||||
std::stringstream response_stream;
|
||||
|
||||
tawashi::IndexResponseCustomMustache response(settings, &response_stream, fake_env);
|
||||
kamokan::IndexResponseCustomMustache response(settings, &response_stream, fake_env);
|
||||
response.send();
|
||||
|
||||
response_stream.seekg(0);
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include <sstream>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
namespace tawashi {
|
||||
namespace kamokan {
|
||||
class SubmitPasteResponseWithFakeStorage : public SubmitPasteResponse {
|
||||
public:
|
||||
SubmitPasteResponseWithFakeStorage (
|
||||
|
@ -62,7 +62,7 @@ namespace tawashi {
|
|||
FakeStorage m_fake_storage;
|
||||
std::string m_post_data;
|
||||
};
|
||||
} //namespace tawashi
|
||||
} //namespace kamokan
|
||||
|
||||
TEST_CASE ("Submit paste response", "[submitpaste][response]") {
|
||||
using curry::SafeStackObject;
|
||||
|
@ -121,11 +121,11 @@ TEST_CASE ("Submit paste response", "[submitpaste][response]") {
|
|||
" min_pastie_size = 1\n"
|
||||
" truncate_long_pasties = no\n"
|
||||
);
|
||||
SafeStackObject<tawashi::IniFile> ini(std::move(kamokan_settings));
|
||||
SafeStackObject<tawashi::SettingsBag> settings(ini, "kamokan");
|
||||
SafeStackObject<kamokan::IniFile> ini(std::move(kamokan_settings));
|
||||
SafeStackObject<kamokan::SettingsBag> settings(ini, "kamokan");
|
||||
|
||||
std::ostringstream oss;
|
||||
tawashi::SubmitPasteResponseWithFakeStorage submit_response(
|
||||
kamokan::SubmitPasteResponseWithFakeStorage submit_response(
|
||||
settings,
|
||||
&oss,
|
||||
fake_env,
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include <ciso646>
|
||||
|
||||
TEST_CASE ("Test parsing an ini text", "[ini][parser]") {
|
||||
using tawashi::IniFile;
|
||||
using kamokan::IniFile;
|
||||
|
||||
//empty data
|
||||
{
|
||||
|
|
|
@ -26,8 +26,8 @@
|
|||
#include <stdexcept>
|
||||
|
||||
TEST_CASE ("Add and retrieve values from SettingsBag", "[settings][ini]") {
|
||||
using tawashi::SettingsBag;
|
||||
using tawashi::IniFile;
|
||||
using kamokan::SettingsBag;
|
||||
using kamokan::IniFile;
|
||||
using curry::SafeStackObject;
|
||||
|
||||
auto statuslog = spdlog::stdout_logger_st("statuslog");
|
||||
|
|
Loading…
Add table
Reference in a new issue