diff --git a/src/kamokan/main.cpp b/src/kamokan/main.cpp index cead51f..bc18543 100644 --- a/src/kamokan/main.cpp +++ b/src/kamokan/main.cpp @@ -21,6 +21,7 @@ #include "pastie_response.hpp" #include "index_response.hpp" #include "error_response.hpp" +#include "edit_response.hpp" #include "response_factory.hpp" #include "cgi_env.hpp" #include "ini_file.hpp" @@ -140,6 +141,7 @@ int main (int parArgc, char* parArgv[], char* parEnvp[]) { using kamokan::QuickSubmitPasteResponse; using kamokan::PastieResponse; using kamokan::ErrorResponse; + using kamokan::EditResponse; using kamokan::Response; using tawashi::RequestMethodType; @@ -168,6 +170,7 @@ int main (int parArgc, char* parArgv[], char* parEnvp[]) { resp_factory.register_maker("", RequestMethodType::POST, &make_response); resp_factory.register_maker("paste.cgi", RequestMethodType::POST, &make_response); resp_factory.register_maker("error.cgi", RequestMethodType::GET, &make_response); + resp_factory.register_maker("edit.cgi", RequestMethodType::GET, &make_response); resp_factory.register_jolly_maker(&make_response, RequestMethodType::GET); resp_factory.set_app_start_time(app_start_time); diff --git a/src/kamokan_impl/CMakeLists.txt b/src/kamokan_impl/CMakeLists.txt index edc2c0b..a1f4a8e 100644 --- a/src/kamokan_impl/CMakeLists.txt +++ b/src/kamokan_impl/CMakeLists.txt @@ -20,6 +20,7 @@ add_library(${PROJECT_NAME} STATIC quick_submit_paste_response.cpp storage.cpp string_conv.cpp + edit_response.cpp pastie_retrieving_response.cpp ) diff --git a/src/kamokan_impl/edit_response.cpp b/src/kamokan_impl/edit_response.cpp new file mode 100644 index 0000000..f221fa8 --- /dev/null +++ b/src/kamokan_impl/edit_response.cpp @@ -0,0 +1,39 @@ +/* Copyright 2017, Michele Santullo + * This file is part of "kamokan". + * + * "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. + * + * "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 "kamokan". If not, see . + */ + +#include "edit_response.hpp" +#include "escapist.hpp" + +namespace kamokan { + EditResponse::EditResponse ( + const Kakoune::SafePtr& parSettings, + std::ostream* parStreamOut, + const Kakoune::SafePtr& parCgiEnv + ) : + PastieRetrievingResponse(parSettings, parStreamOut, parCgiEnv) + { + } + + tawashi::HttpHeader EditResponse::on_retrieving_process() { + return tawashi::make_header_type_html(); + } + + std::string EditResponse::on_pastie_prepare (std::string&& parPastie) { + tawashi::Escapist houdini; + return houdini.escape_html(parPastie); + } +} //namespace kamokan diff --git a/src/kamokan_impl/edit_response.hpp b/src/kamokan_impl/edit_response.hpp new file mode 100644 index 0000000..094c425 --- /dev/null +++ b/src/kamokan_impl/edit_response.hpp @@ -0,0 +1,40 @@ +/* Copyright 2017, Michele Santullo + * This file is part of "kamokan". + * + * "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. + * + * "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 "kamokan". If not, see . + */ + +#pragma once + +#include "pastie_retrieving_response.hpp" + +namespace kamokan { + class EditResponse : public PastieRetrievingResponse { + public: + EditResponse ( + const Kakoune::SafePtr& parSettings, + std::ostream* parStreamOut, + const Kakoune::SafePtr& parCgiEnv + ); + + protected: + virtual boost::string_view page_basename() const override { + return boost::string_view("edit"); + } + + private: + virtual std::string on_pastie_prepare (std::string&& parPastie) override; + virtual tawashi::HttpHeader on_retrieving_process() override; + }; +} //namespace kamokan