1
0
Fork 0
mirror of https://github.com/KingDuckZ/kamokan.git synced 2024-12-27 21:35:41 +00:00

Rename tawashi to duckbin.

The library that used to be "tawashi_implem" now
is simply called tawashi.
This commit is contained in:
King_DuckZ 2017-06-02 21:53:27 +01:00
parent 2f00014758
commit 9cda58d0c0
67 changed files with 155 additions and 127 deletions

View file

@ -1,31 +1,22 @@
cmake_minimum_required(VERSION 3.3 FATAL_ERROR) cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules) list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
project(tawashi_top VERSION 0.1.11 LANGUAGES NONE) project(duckbin_top LANGUAGES NONE)
include(CTest) include(CTest)
option(TAWASHI_WITH_IP_LOGGING "Enable code in Tawashi that may result in users IPs being stored in the DB or in logs" ON)
set(INCREDIS_FORCE_DISABLE_TESTS ON) set(INCREDIS_FORCE_DISABLE_TESTS ON)
set(TAWASHI_SOURCE_ROOT "${CMAKE_CURRENT_SOURCE_DIR}") set(TAWASHI_SOURCE_ROOT "${CMAKE_CURRENT_SOURCE_DIR}")
set(TAWASHI_GEN_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}/include")
set(TAWASHI_CONFIG_PATH "etc" CACHE STRING "Path where config file will be located, absolute or relative to the install prefix")
set(TAWASHI_CONFIG_FILE "tawashi.ini" CACHE STRING "Filename of the config file in TAWASHI_CONFIG_PATH")
configure_file( configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/src/tawashiConfig.h.in" "${CMAKE_CURRENT_SOURCE_DIR}/config/debug_duckbin.ini.in"
"${TAWASHI_GEN_INCLUDE_DIR}/tawashiConfig.h" "${CMAKE_CURRENT_BINARY_DIR}/duckbin.ini"
)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/config/debug_tawashi.ini.in"
"${CMAKE_CURRENT_BINARY_DIR}/tawashi.ini"
) )
add_subdirectory(lib/incredis) add_subdirectory(lib/incredis)
add_subdirectory(lib/mstch) add_subdirectory(lib/mstch)
add_subdirectory(lib/houdini) add_subdirectory(lib/houdini)
add_subdirectory(src/tawashi_implem)
add_subdirectory(src/tawashi) add_subdirectory(src/tawashi)
add_subdirectory(src/duckbin)
install(DIRECTORY html/website/ DESTINATION html) install(DIRECTORY html/website/ DESTINATION html)

View file

@ -1,4 +1,4 @@
[tawashi] [duckbin]
redis_server = 127.0.0.1 redis_server = 127.0.0.1
redis_port = 6379 redis_port = 6379
redis_mode = inet redis_mode = inet
@ -7,4 +7,4 @@ host_port = from_downstream
highlight_css = sh_greenlcd.css highlight_css = sh_greenlcd.css
website_root = @CMAKE_CURRENT_BINARY_DIR@/html website_root = @CMAKE_CURRENT_BINARY_DIR@/html
logging_level = trace logging_level = trace
log_file = @CMAKE_CURRENT_BINARY_DIR@/tawashi.log log_file = @CMAKE_CURRENT_BINARY_DIR@/duckbin.log

View file

@ -1,4 +1,4 @@
[tawashi] [duckbin]
redis_server = 127.0.0.1 redis_server = 127.0.0.1
redis_port = 6379 redis_port = 6379
redis_mode = inet redis_mode = inet

View file

@ -1,6 +1,6 @@
server { server {
listen 8080; listen 8080;
#server_name tawashi.domain.*; #server_name duckbin.domain.*;
server_name 127.0.0.1; server_name 127.0.0.1;
#charset koi8-r; #charset koi8-r;
@ -10,10 +10,10 @@ server {
index index.cgi; index index.cgi;
include uwsgi_params; include uwsgi_params;
uwsgi_modifier1 9; uwsgi_modifier1 9;
uwsgi_pass unix:/run/uwsgi/tawashi.sock; uwsgi_pass unix:/run/uwsgi/duckbin.sock;
} }
location ~ (\.css$|Pictures/) { location ~ (\.css$|Pictures/) {
root /srv/http/tawashi; root /srv/http/duckbin;
} }
#error_page 404 /404.html; #error_page 404 /404.html;

View file

@ -2,9 +2,9 @@
processes = 4 processes = 4
master = 1 master = 1
socket = /run/uwsgi/%n.sock socket = /run/uwsgi/%n.sock
cgi = /srv/http/tawashi/%n.cgi cgi = /srv/http/duckbin/%n.cgi
chmod-socket = 664 chmod-socket = 664
strict = true strict = true
gid = http gid = http
plugins = cgi plugins = cgi
chdir = /srv/http/tawashi chdir = /srv/http/duckbin

View file

@ -0,0 +1,35 @@
project(duckbin VERSION 0.1.0 LANGUAGES CXX)
set(DUCKBIN_CONFIG_PATH "etc" CACHE STRING "Path where config file will be located, absolute or relative to the install prefix")
set(DUCKBIN_CONFIG_FILE "duckbin.ini" CACHE STRING "Filename of the config file in DUCKBIN_CONFIG_PATH")
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_executable(${PROJECT_NAME}
main.cpp
)
target_link_libraries(${PROJECT_NAME}
PRIVATE tawashi
#hack - add duckhandy to the project instead of picking from inside redis
PRIVATE duckhandy
)
set_target_properties(
${PROJECT_NAME}
PROPERTIES SUFFIX .cgi
)
target_include_directories(${PROJECT_NAME}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/include
)
install(TARGETS ${PROJECT_NAME}
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib/static
)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/duckbin_config.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/include/duckbin_config.h"
)

View file

@ -0,0 +1,25 @@
/* Copyright 2017, Michele Santullo
* This file is part of "duckbin".
*
* "duckbin" 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.
*
* "duckbin" 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 "duckbin". If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#define DUCKBIN_CONFIG_PATH "@DUCKBIN_CONFIG_PATH@"
#define DUCKBIN_CONFIG_FILE "@DUCKBIN_CONFIG_FILE@"
#define DUCKBIN_PATH_PREFIX "@CMAKE_INSTALL_PREFIX@"
#define VERSION_MAJOR @PROJECT_VERSION_MAJOR@
#define VERSION_MINOR @PROJECT_VERSION_MINOR@
#define VERSION_PATCH @PROJECT_VERSION_PATCH@

View file

@ -1,21 +1,21 @@
/* Copyright 2017, Michele Santullo /* Copyright 2017, Michele Santullo
* This file is part of "tawashi". * This file is part of "duckbin".
* *
* "tawashi" is free software: you can redistribute it and/or modify * "duckbin" is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* "tawashi" is distributed in the hope that it will be useful, * "duckbin" is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * 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 "duckbin". If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "tawashiConfig.h" #include "duckbin_config.h"
#include "submit_paste_response.hpp" #include "submit_paste_response.hpp"
#include "quick_submit_paste_response.hpp" #include "quick_submit_paste_response.hpp"
#include "pastie_response.hpp" #include "pastie_response.hpp"
@ -43,16 +43,16 @@ namespace {
std::string config_file_path() a_pure; std::string config_file_path() a_pure;
std::string config_file_path() { std::string config_file_path() {
mchlib::PathName config_path(TAWASHI_CONFIG_PATH); mchlib::PathName config_path(DUCKBIN_CONFIG_PATH);
mchlib::PathName full_path(""); mchlib::PathName full_path("");
if (config_path.is_absolute()) { if (config_path.is_absolute()) {
full_path = std::move(config_path); full_path = std::move(config_path);
} }
else { else {
full_path = mchlib::PathName(TAWASHI_PATH_PREFIX); full_path = mchlib::PathName(DUCKBIN_PATH_PREFIX);
full_path.join(config_path); full_path.join(config_path);
} }
full_path.join(TAWASHI_CONFIG_FILE); full_path.join(DUCKBIN_CONFIG_FILE);
return full_path.path(); return full_path.path();
} }
@ -95,9 +95,9 @@ namespace {
std::cout << "no (Debug build)"; std::cout << "no (Debug build)";
#endif #endif
std::cout << '\n'; std::cout << '\n';
std::cout << "TAWASHI_CONFIG_FILE: \"" << TAWASHI_CONFIG_FILE << "\"\n"; std::cout << "DUCKBIN_CONFIG_FILE: \"" << DUCKBIN_CONFIG_FILE << "\"\n";
std::cout << "TAWASHI_CONFIG_PATH: \"" << TAWASHI_CONFIG_PATH << "\"\n"; std::cout << "DUCKBIN_CONFIG_PATH: \"" << DUCKBIN_CONFIG_PATH << "\"\n";
std::cout << "TAWASHI_PATH_PREFIX: \"" << TAWASHI_PATH_PREFIX << "\"\n"; std::cout << "DUCKBIN_PATH_PREFIX: \"" << DUCKBIN_PATH_PREFIX << "\"\n";
std::cout << "VERSION_MAJOR: " << VERSION_MAJOR << '\n'; std::cout << "VERSION_MAJOR: " << VERSION_MAJOR << '\n';
std::cout << "VERSION_MINOR: " << VERSION_MINOR << '\n'; std::cout << "VERSION_MINOR: " << VERSION_MINOR << '\n';
std::cout << "VERSION_PATCH: " << VERSION_PATCH << '\n'; std::cout << "VERSION_PATCH: " << VERSION_PATCH << '\n';
@ -147,11 +147,11 @@ int main (int parArgc, char* parArgv[], char* parEnvp[]) {
} }
SafeStackObject<tawashi::IniFile> ini = load_ini(); SafeStackObject<tawashi::IniFile> ini = load_ini();
auto settings = SafeStackObject<tawashi::SettingsBag>(ini); auto settings = SafeStackObject<tawashi::SettingsBag>(ini, "duckbin");
fill_defaults(*settings); fill_defaults(*settings);
auto statuslog = setup_logging(*settings); auto statuslog = setup_logging(*settings);
SPDLOG_DEBUG(statuslog, "tawashi started"); SPDLOG_DEBUG(statuslog, "duckbin started");
int retval = 0; int retval = 0;
try { try {
statuslog->info("Loaded config: \"{}\"", config_file_path()); statuslog->info("Loaded config: \"{}\"", config_file_path());
@ -178,6 +178,6 @@ int main (int parArgc, char* parArgv[], char* parEnvp[]) {
retval = 1; retval = 1;
} }
SPDLOG_DEBUG(statuslog, "tawashi done, quitting with {}", retval); SPDLOG_DEBUG(statuslog, "duckbin done, quitting with {}", retval);
return retval; return retval;
} }

View file

@ -1,27 +1,70 @@
project(tawashi LANGUAGES CXX) project(tawashi VERSION 0.1.11 LANGUAGES CXX C)
option(TAWASHI_WITH_IP_LOGGING "Enable code in Tawashi that may result in users IPs being stored in the DB or in logs" ON)
find_package(Boost 1.53.0 REQUIRED COMPONENTS program_options filesystem system)
find_package(SourceHighlight REQUIRED)
set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_executable(${PROJECT_NAME} add_library(${PROJECT_NAME} STATIC
main.cpp split_get_vars.cpp
response.cpp
submit_paste_response.cpp
cgi_environment_vars.cpp
cgi_env.cpp
num_to_token.cpp
cgi_post.cpp
escapist.cpp
index_response.cpp
pastie_response.cpp
ini_file.cpp
pathname/pathname.cpp
response_factory.cpp
list_highlight_langs.cpp
settings_bag.cpp
sanitized_utf8.cpp
tiger.c
error_response.cpp
tawashi_exception.cpp
http_header.cpp
quick_submit_paste_response.cpp
ip_utils.cpp
mime_split.cpp
)
target_include_directories(${PROJECT_NAME}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/include
PUBLIC ${TAWASHI_SOURCE_ROOT}/lib/kakoune
PUBLIC ${TAWASHI_SOURCE_ROOT}/lib/mstch/include
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
)
target_include_directories(${PROJECT_NAME} SYSTEM
PUBLIC ${Boost_INCLUDE_DIRS}
PUBLIC ${TAWASHI_SOURCE_ROOT}/lib/better-enums
PRIVATE ${SourceHighlight_INCLUDE_DIR}
PRIVATE ${TAWASHI_SOURCE_ROOT}/lib/utf8_v2_3_4/source
PUBLIC ${TAWASHI_SOURCE_ROOT}/lib/spdlog/include
) )
target_link_libraries(${PROJECT_NAME} target_link_libraries(${PROJECT_NAME}
PRIVATE tawashi_implem PRIVATE ${Boost_LIBRARIES}
#hack - add duckhandy to the project instead of picking from inside redis PRIVATE incredis
PRIVATE duckhandy PRIVATE ${SourceHighlight_LIBRARIES}
PUBLIC mstch
PRIVATE houdini
PRIVATE pthread
) )
target_compile_definitions(${PROJECT_NAME}
set_target_properties( PRIVATE BOOST_SPIRIT_USE_PHOENIX_V3=1
${PROJECT_NAME} PUBLIC $<$<CONFIG:Debug>:SPDLOG_DEBUG_ON>
PROPERTIES SUFFIX .cgi PUBLIC $<$<CONFIG:Debug>:SPDLOG_TRACE_ON>
) )
target_compile_options(${PROJECT_NAME}
target_include_directories(${PROJECT_NAME} PRIVATE -fdiagnostics-color=always
PRIVATE ${TAWASHI_GEN_INCLUDE_DIR}
) )
install(TARGETS ${PROJECT_NAME}
LIBRARY DESTINATION lib configure_file(
RUNTIME DESTINATION bin "${CMAKE_CURRENT_SOURCE_DIR}/tawashi_config.h.in"
ARCHIVE DESTINATION lib/static "${CMAKE_CURRENT_BINARY_DIR}/include/tawashi_config.h"
) )

View file

@ -19,7 +19,7 @@
#include "duckhandy/lexical_cast.hpp" #include "duckhandy/lexical_cast.hpp"
#include "duckhandy/int_to_string_ary.hpp" #include "duckhandy/int_to_string_ary.hpp"
#include "cgi_env.hpp" #include "cgi_env.hpp"
#include "tawashiConfig.h" #include "tawashi_config.h"
#include <spdlog/spdlog.h> #include <spdlog/spdlog.h>
#include <cassert> #include <cassert>
#include <algorithm> #include <algorithm>

View file

@ -18,7 +18,7 @@
#include "response.hpp" #include "response.hpp"
#include "incredis/incredis.hpp" #include "incredis/incredis.hpp"
#include "settings_bag.hpp" #include "settings_bag.hpp"
#include "tawashiConfig.h" #include "tawashi_config.h"
#include "duckhandy/stringize.h" #include "duckhandy/stringize.h"
#include "duckhandy/lexical_cast.hpp" #include "duckhandy/lexical_cast.hpp"
#include "pathname/pathname.hpp" #include "pathname/pathname.hpp"

View file

@ -21,26 +21,26 @@
#include <cassert> #include <cassert>
#include <cstdint> #include <cstdint>
#include <sstream> #include <sstream>
#include <spdlog/spdlog.h> #include <iostream>
namespace tawashi { namespace tawashi {
namespace { namespace {
const IniFile::KeyValueMapType* get_tawashi_node (const IniFile& parIni) { const IniFile::KeyValueMapType* get_tawashi_node (const IniFile& parIni, boost::string_ref parSectionName) {
auto it_found = parIni.parsed().find("tawashi"); auto it_found = parIni.parsed().find(parSectionName);
if (parIni.parsed().end() != it_found) { if (parIni.parsed().end() != it_found) {
return &it_found->second; return &it_found->second;
} }
else { else {
spdlog::get("statuslog")->warn("Couldn't find section [tawashi] in the settings file"); std::cerr << "Couldn't find section [" << parSectionName << "] in the settings file\n";
static const IniFile::KeyValueMapType empty_key_values; static const IniFile::KeyValueMapType empty_key_values;
return &empty_key_values; return &empty_key_values;
} }
} }
} //unnamed namespace } //unnamed namespace
SettingsBag::SettingsBag (const Kakoune::SafePtr<IniFile>& parIni) : SettingsBag::SettingsBag (const Kakoune::SafePtr<IniFile>& parIni, boost::string_ref parSectionName) :
m_ini(parIni), m_ini(parIni),
m_values(get_tawashi_node(*parIni)) m_values(get_tawashi_node(*parIni, parSectionName))
{ {
assert(m_values); assert(m_values);
} }

View file

@ -31,7 +31,7 @@ namespace tawashi {
class SettingsBag : public Kakoune::SafeCountable { class SettingsBag : public Kakoune::SafeCountable {
typedef std::map<boost::string_ref, boost::string_ref> MapType; typedef std::map<boost::string_ref, boost::string_ref> MapType;
public: public:
explicit SettingsBag (const Kakoune::SafePtr<IniFile>& parIni); SettingsBag (const Kakoune::SafePtr<IniFile>& parIni, boost::string_ref parSectionName);
~SettingsBag() noexcept; ~SettingsBag() noexcept;
const boost::string_ref& operator[] (boost::string_ref parIndex) const; const boost::string_ref& operator[] (boost::string_ref parIndex) const;

View file

@ -17,9 +17,6 @@
#pragma once #pragma once
#define TAWASHI_CONFIG_PATH "@TAWASHI_CONFIG_PATH@"
#define TAWASHI_CONFIG_FILE "@TAWASHI_CONFIG_FILE@"
#define TAWASHI_PATH_PREFIX "@CMAKE_INSTALL_PREFIX@"
#define VERSION_MAJOR @PROJECT_VERSION_MAJOR@ #define VERSION_MAJOR @PROJECT_VERSION_MAJOR@
#define VERSION_MINOR @PROJECT_VERSION_MINOR@ #define VERSION_MINOR @PROJECT_VERSION_MINOR@
#define VERSION_PATCH @PROJECT_VERSION_PATCH@ #define VERSION_PATCH @PROJECT_VERSION_PATCH@

View file

@ -1,63 +0,0 @@
project(tawashi_implem LANGUAGES CXX C)
find_package(Boost 1.53.0 REQUIRED COMPONENTS program_options filesystem system)
find_package(SourceHighlight REQUIRED)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_library(${PROJECT_NAME} STATIC
split_get_vars.cpp
response.cpp
submit_paste_response.cpp
cgi_environment_vars.cpp
cgi_env.cpp
num_to_token.cpp
cgi_post.cpp
escapist.cpp
index_response.cpp
pastie_response.cpp
ini_file.cpp
pathname/pathname.cpp
response_factory.cpp
list_highlight_langs.cpp
settings_bag.cpp
sanitized_utf8.cpp
tiger.c
error_response.cpp
tawashi_exception.cpp
http_header.cpp
quick_submit_paste_response.cpp
ip_utils.cpp
mime_split.cpp
)
target_include_directories(${PROJECT_NAME}
PRIVATE ${TAWASHI_GEN_INCLUDE_DIR}
PUBLIC ${TAWASHI_SOURCE_ROOT}/lib/kakoune
PUBLIC ${TAWASHI_SOURCE_ROOT}/lib/mstch/include
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
)
target_include_directories(${PROJECT_NAME} SYSTEM
PUBLIC ${Boost_INCLUDE_DIRS}
PUBLIC ${TAWASHI_SOURCE_ROOT}/lib/better-enums
PRIVATE ${SourceHighlight_INCLUDE_DIR}
PRIVATE ${TAWASHI_SOURCE_ROOT}/lib/utf8_v2_3_4/source
PUBLIC ${TAWASHI_SOURCE_ROOT}/lib/spdlog/include
)
target_link_libraries(${PROJECT_NAME}
PRIVATE ${Boost_LIBRARIES}
PRIVATE incredis
PRIVATE ${SourceHighlight_LIBRARIES}
PUBLIC mstch
PRIVATE houdini
PRIVATE pthread
)
target_compile_definitions(${PROJECT_NAME}
PRIVATE BOOST_SPIRIT_USE_PHOENIX_V3=1
PUBLIC $<$<CONFIG:Debug>:SPDLOG_DEBUG_ON>
PUBLIC $<$<CONFIG:Debug>:SPDLOG_TRACE_ON>
)
target_compile_options(${PROJECT_NAME}
PRIVATE -fdiagnostics-color=always
)