mirror of
https://github.com/KingDuckZ/kamokan.git
synced 2025-02-17 09:35:49 +00:00
Implement EditResponse.
I can't really test this yet, but it might just work.
This commit is contained in:
parent
b325af980f
commit
3a9a9611ac
4 changed files with 83 additions and 0 deletions
|
@ -21,6 +21,7 @@
|
||||||
#include "pastie_response.hpp"
|
#include "pastie_response.hpp"
|
||||||
#include "index_response.hpp"
|
#include "index_response.hpp"
|
||||||
#include "error_response.hpp"
|
#include "error_response.hpp"
|
||||||
|
#include "edit_response.hpp"
|
||||||
#include "response_factory.hpp"
|
#include "response_factory.hpp"
|
||||||
#include "cgi_env.hpp"
|
#include "cgi_env.hpp"
|
||||||
#include "ini_file.hpp"
|
#include "ini_file.hpp"
|
||||||
|
@ -140,6 +141,7 @@ int main (int parArgc, char* parArgv[], char* parEnvp[]) {
|
||||||
using kamokan::QuickSubmitPasteResponse;
|
using kamokan::QuickSubmitPasteResponse;
|
||||||
using kamokan::PastieResponse;
|
using kamokan::PastieResponse;
|
||||||
using kamokan::ErrorResponse;
|
using kamokan::ErrorResponse;
|
||||||
|
using kamokan::EditResponse;
|
||||||
using kamokan::Response;
|
using kamokan::Response;
|
||||||
using tawashi::RequestMethodType;
|
using tawashi::RequestMethodType;
|
||||||
|
|
||||||
|
@ -168,6 +170,7 @@ int main (int parArgc, char* parArgv[], char* parEnvp[]) {
|
||||||
resp_factory.register_maker("", RequestMethodType::POST, &make_response<QuickSubmitPasteResponse>);
|
resp_factory.register_maker("", RequestMethodType::POST, &make_response<QuickSubmitPasteResponse>);
|
||||||
resp_factory.register_maker("paste.cgi", RequestMethodType::POST, &make_response<SubmitPasteResponse>);
|
resp_factory.register_maker("paste.cgi", RequestMethodType::POST, &make_response<SubmitPasteResponse>);
|
||||||
resp_factory.register_maker("error.cgi", RequestMethodType::GET, &make_response<ErrorResponse>);
|
resp_factory.register_maker("error.cgi", RequestMethodType::GET, &make_response<ErrorResponse>);
|
||||||
|
resp_factory.register_maker("edit.cgi", RequestMethodType::GET, &make_response<EditResponse>);
|
||||||
resp_factory.register_jolly_maker(&make_response<PastieResponse>, RequestMethodType::GET);
|
resp_factory.register_jolly_maker(&make_response<PastieResponse>, RequestMethodType::GET);
|
||||||
resp_factory.set_app_start_time(app_start_time);
|
resp_factory.set_app_start_time(app_start_time);
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ add_library(${PROJECT_NAME} STATIC
|
||||||
quick_submit_paste_response.cpp
|
quick_submit_paste_response.cpp
|
||||||
storage.cpp
|
storage.cpp
|
||||||
string_conv.cpp
|
string_conv.cpp
|
||||||
|
edit_response.cpp
|
||||||
pastie_retrieving_response.cpp
|
pastie_retrieving_response.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
39
src/kamokan_impl/edit_response.cpp
Normal file
39
src/kamokan_impl/edit_response.cpp
Normal file
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "edit_response.hpp"
|
||||||
|
#include "escapist.hpp"
|
||||||
|
|
||||||
|
namespace kamokan {
|
||||||
|
EditResponse::EditResponse (
|
||||||
|
const Kakoune::SafePtr<SettingsBag>& parSettings,
|
||||||
|
std::ostream* parStreamOut,
|
||||||
|
const Kakoune::SafePtr<cgi::Env>& 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
|
40
src/kamokan_impl/edit_response.hpp
Normal file
40
src/kamokan_impl/edit_response.hpp
Normal file
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "pastie_retrieving_response.hpp"
|
||||||
|
|
||||||
|
namespace kamokan {
|
||||||
|
class EditResponse : public PastieRetrievingResponse {
|
||||||
|
public:
|
||||||
|
EditResponse (
|
||||||
|
const Kakoune::SafePtr<SettingsBag>& parSettings,
|
||||||
|
std::ostream* parStreamOut,
|
||||||
|
const Kakoune::SafePtr<cgi::Env>& 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
|
Loading…
Add table
Reference in a new issue