changed the way how the request's answer is created,
now winix can return json, xml, csv from out_main_stream or from frames and json from models removed from Request: bool send_bin_stream bool return_json bool return_info_only pt::Space info bool page_generated bool out_main_stream_use_html_filter bool out_streams_use_html_filter added to Request: enum AnswerSource enum AnswerContainer AnswerSource answer_source AnswerContainer answer_container bool use_ezc_engine std::wstring frame bool send_all_frames bool use_html_filter added to Config: // the name of the url parameter for returning all frames, e.g. https://domain.tld/mydir/myfunction/allframes // default: allframes std::wstring request_all_frames_parameter; // the name of the root element when serializing request answer to xml // default: winix std::wstring xml_root; algorithm (the whole algorithm is described in core/request.h): at the beginning of a request winix sets answer_source to models answer_container to text use_ezc_engine to true next answer_container and use_ezc_engine can be changed in the following way: 1. winix will look for 'Accept' http header and depending on the header winix will set: (not implemented yet) Accept | answer_container | use_ezc_engine ------------------------------------|----------------- application/json | json | false application/xml | xml | false text/csv | csv | false 2. next answer_container is set depending on 'container' url parameter container | answer_container --------------------------------------------------------- not present | don't change the value text | text json | json xml | xml csv | csv use_ezc_engine is set depending on 'answer' url parameter: answer | use_ezc_engine --------------------------------- not present | don't change the value html | true data | false if 'answer' is html then we take into account two more parameters: frame: frame_name (empty default) - if set then winix returns this specific frame allframes: (if present then winix returns all frames)
This commit is contained in:
@@ -1637,9 +1637,6 @@ functionparser.o: ../../../winix/winixd/core/config.h
|
||||
functionparser.o: ../../../pikotools/src/space/spaceparser.h
|
||||
functionparser.o: ../../../pikotools/src/space/space.h
|
||||
functionparser.o: ../../../pikotools/src/convert/baseparser.h
|
||||
functionparser.o: ../../../winix/winixd/core/log.h
|
||||
functionparser.o: ../../../winix/winixd/core/logmanipulators.h
|
||||
functionparser.o: ../../../pikotools/src/log/log.h
|
||||
functionparser.o: ../../../pikotools/src/textstream/textstream.h
|
||||
functionparser.o: ../../../pikotools/src/textstream/stream.h
|
||||
functionparser.o: ../../../pikotools/src/space/space.h
|
||||
@@ -1652,6 +1649,9 @@ functionparser.o: ../../../pikotools/src/utf8/utf8_private.h
|
||||
functionparser.o: ../../../pikotools/src/date/date.h
|
||||
functionparser.o: ../../../pikotools/src/membuffer/membuffer.h
|
||||
functionparser.o: ../../../pikotools/src/textstream/types.h
|
||||
functionparser.o: ../../../winix/winixd/core/log.h
|
||||
functionparser.o: ../../../winix/winixd/core/logmanipulators.h
|
||||
functionparser.o: ../../../pikotools/src/log/log.h
|
||||
functionparser.o: ../../../pikotools/src/log/filelog.h
|
||||
functionparser.o: ../../../morm/src/morm.h ../../../morm/src/morm_types.h
|
||||
functionparser.o: ../../../morm/src/model.h
|
||||
@@ -4177,9 +4177,6 @@ privchanger.o: ../../../winix/winixd/core/config.h
|
||||
privchanger.o: ../../../pikotools/src/space/spaceparser.h
|
||||
privchanger.o: ../../../pikotools/src/space/space.h
|
||||
privchanger.o: ../../../pikotools/src/convert/baseparser.h
|
||||
privchanger.o: ../../../winix/winixd/core/log.h
|
||||
privchanger.o: ../../../winix/winixd/core/logmanipulators.h
|
||||
privchanger.o: ../../../pikotools/src/log/log.h
|
||||
privchanger.o: ../../../pikotools/src/textstream/textstream.h
|
||||
privchanger.o: ../../../pikotools/src/textstream/stream.h
|
||||
privchanger.o: ../../../pikotools/src/space/space.h
|
||||
@@ -4192,6 +4189,9 @@ privchanger.o: ../../../pikotools/src/utf8/utf8_private.h
|
||||
privchanger.o: ../../../pikotools/src/date/date.h
|
||||
privchanger.o: ../../../pikotools/src/membuffer/membuffer.h
|
||||
privchanger.o: ../../../pikotools/src/textstream/types.h
|
||||
privchanger.o: ../../../winix/winixd/core/log.h
|
||||
privchanger.o: ../../../winix/winixd/core/logmanipulators.h
|
||||
privchanger.o: ../../../pikotools/src/log/log.h
|
||||
privchanger.o: ../../../pikotools/src/log/filelog.h ../../../morm/src/morm.h
|
||||
privchanger.o: ../../../morm/src/morm_types.h ../../../morm/src/model.h
|
||||
privchanger.o: ../../../morm/src/modelconnector.h ../../../morm/src/clearer.h
|
||||
|
||||
@@ -66,6 +66,11 @@ void Cat::MakeGet()
|
||||
return;
|
||||
}
|
||||
|
||||
if( !cur->request->item.item_content.file_mime_type.empty() )
|
||||
{
|
||||
cur->request->out_headers.add(Header::content_type, cur->request->item.item_content.file_mime_type);
|
||||
}
|
||||
|
||||
cur->request->send_as_attachment = cur->request->IsParam(L"attachment");
|
||||
}
|
||||
|
||||
|
||||
@@ -311,7 +311,11 @@ long Cp::CopyDirTree(const Item & dir, long dst_dir_id)
|
||||
temp.item_content.link_redirect = 0;
|
||||
}
|
||||
|
||||
cur->request->status = system->dirs.AddDirectory(temp);
|
||||
bool status = system->dirs.AddDirectory(temp);
|
||||
|
||||
if( !status )
|
||||
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
|
||||
loop_checker.push_back(temp.id);
|
||||
|
||||
// remember the new dir_id because temp can be changed
|
||||
|
||||
@@ -91,7 +91,7 @@ void Download::MakeGet()
|
||||
}
|
||||
|
||||
cur->request->x_sendfile.clear();
|
||||
cur->request->send_bin_stream = true;
|
||||
cur->request->answer_source = Request::AnswerSource::answer_bin_stream;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -128,10 +128,12 @@ return WINIX_NOTIFY_CODE_ADD;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// IMPROVEME
|
||||
// make some kind of utils and put this method there
|
||||
// because this method is used from ckeditor and other editors too
|
||||
void Emacs::MakePost()
|
||||
{
|
||||
bool status = false;
|
||||
bool adding = !cur->request->is_item;
|
||||
|
||||
if( !adding )
|
||||
@@ -147,36 +149,46 @@ void Emacs::MakePost()
|
||||
|
||||
if( adding )
|
||||
{
|
||||
cur->request->is_item = true; // !! moze lepiej nie ustawiac is_item? (bo jak wystapi blad np dodania do bazy danych
|
||||
// to formularz edycji zmieni sie z 'dodaj' na 'edytuj'
|
||||
cur->request->item.item_content.privileges = system->NewFilePrivileges();
|
||||
cur->request->status = system->AddFile(cur->request->item, NotifyCodeAdd()) ? WINIX_ERR_OK : WINIX_ERR_PERMISSION_DENIED;
|
||||
cur->request->item.item_content.privileges = system->NewFilePrivileges();
|
||||
status = system->AddFile(cur->request->item, NotifyCodeAdd());
|
||||
|
||||
if( status )
|
||||
{
|
||||
cur->request->is_item = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( system->EditFile(cur->request->item, cur->request->item.url != old_url, NotifyCodeEdit()) )
|
||||
cur->request->status = WINIX_ERR_OK;
|
||||
else
|
||||
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
status = system->EditFile(cur->request->item, cur->request->item.url != old_url, NotifyCodeEdit());
|
||||
}
|
||||
|
||||
if( cur->request->status == WINIX_ERR_OK )
|
||||
cur->request->status = status ? WINIX_ERR_OK : WINIX_ERR_PERMISSION_DENIED;
|
||||
answer.add(L"status", status);
|
||||
|
||||
if( status )
|
||||
{
|
||||
if( adding )
|
||||
{
|
||||
system->RedirectToLastFunction(nullptr, false);
|
||||
answer.add(L"redirect_to", cur->request->redirect_to);
|
||||
|
||||
if( cur->request->answer_container != Request::AnswerContainer::answer_text )
|
||||
{
|
||||
cur->request->redirect_to.clear();
|
||||
}
|
||||
}
|
||||
|
||||
functions->CheckSpecialFile(cur->request->item);
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Emacs: error: " << cur->request->status << logend;
|
||||
}
|
||||
|
||||
cur->request->models.Add(L"answer", answer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Emacs::Clear()
|
||||
{
|
||||
answer.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -56,10 +56,14 @@ public:
|
||||
private:
|
||||
|
||||
bool HasAccess(const Item & item); // !! takie funkcje to nie powinny byc skladowe modelu?
|
||||
void Clear();
|
||||
|
||||
int NotifyCodeEdit();
|
||||
int NotifyCodeAdd();
|
||||
|
||||
std::wstring old_url;
|
||||
pt::Space answer;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -624,7 +624,7 @@ void Functions::ReadItemFilterHtml(Item & item)
|
||||
html_filter.ClearOrphans();
|
||||
// SetNoFilterTag doesn't have to be called (default empty tag)
|
||||
|
||||
html_filter.Filter(cur->request->PostVar(L"itemcontent"), item.item_content.content_raw);
|
||||
html_filter.filter(cur->request->PostVar(L"itemcontent"), item.item_content.content_raw);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -96,9 +96,7 @@ void Mkdir::PostFunMkdir(bool add_to_dir_tab, int privileges)
|
||||
cur->request->item.item_content.privileges = privileges;
|
||||
Item * pdir;
|
||||
|
||||
cur->request->status = system->dirs.AddDirectory(cur->request->item, add_to_dir_tab, &pdir);
|
||||
|
||||
if( cur->request->status == WINIX_ERR_OK )
|
||||
if( system->dirs.AddDirectory(cur->request->item, add_to_dir_tab, &pdir) )
|
||||
{
|
||||
if( pdir )
|
||||
plugin->Call(WINIX_DIR_ADDED, pdir);
|
||||
@@ -107,7 +105,7 @@ void Mkdir::PostFunMkdir(bool add_to_dir_tab, int privileges)
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Content: PostFunMkdir: Error: " << cur->request->status << logend;
|
||||
log << log1 << "Mkdir: PostFunMkdir: cannot create directory " << logend;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -514,32 +514,20 @@ void Rm::RemoveDir()
|
||||
void Rm::Clear()
|
||||
{
|
||||
content_item_tab.clear();
|
||||
files.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* !! IMPROVE ME what about a Content-Type header for javascript?
|
||||
*
|
||||
*/
|
||||
void Rm::CreateJSON(bool status)
|
||||
{
|
||||
using TemplatesFunctions::R;
|
||||
pt::WTextStream buf;
|
||||
pt::Space & file = files.add_empty_space();
|
||||
file.add(cur->request->item.url, status);
|
||||
|
||||
JSONescape(cur->request->item.url, buf);
|
||||
|
||||
auto & out = cur->request->out_main_stream;
|
||||
out << R("{\"files\": [{\"") << R(buf) << R("\": ");
|
||||
|
||||
if( status )
|
||||
out << R("true");
|
||||
else
|
||||
out << R("false");
|
||||
|
||||
out << R("}]}");
|
||||
|
||||
cur->request->page_generated = true;
|
||||
cur->request->out_main_stream_use_html_filter = false;
|
||||
cur->request->models.Add(L"files", files);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -88,6 +88,8 @@ private:
|
||||
std::vector<Item*> rm_path_dir_tab;
|
||||
Item rm_path_item;
|
||||
|
||||
pt::Space files;
|
||||
|
||||
bool HasAccessToDir(const Item & dir, bool only_content);
|
||||
void Prepare();
|
||||
void Clear();
|
||||
|
||||
@@ -75,6 +75,11 @@ void Run::MakeGet()
|
||||
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
return;
|
||||
}
|
||||
|
||||
if( !cur->request->item.item_content.file_mime_type.empty() )
|
||||
{
|
||||
cur->request->out_headers.add(Header::content_type, cur->request->item.item_content.file_mime_type);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* Copyright (c) 2008-2021, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -51,7 +51,7 @@ Tinymce::Tinymce()
|
||||
|
||||
void Tinymce::Init()
|
||||
{
|
||||
system->AddCommonFileToVar(L"winix/tinymce.js", L"tinymce.js");
|
||||
system->AddCommonFileToVar(L"winix/tinymce.js", L"tinymce.js", Header::text_javascript_utf8);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -394,7 +394,6 @@ void Upload::MakePost()
|
||||
void Upload::CreateAnswer()
|
||||
{
|
||||
Request & req = *cur->request;
|
||||
pt::Space & files = req.info.add_empty_space(L"files");
|
||||
|
||||
for(size_t i=0 ; i<req.item_tab.size() ; ++i)
|
||||
{
|
||||
@@ -408,7 +407,7 @@ void Upload::CreateAnswer()
|
||||
file.add(L"url", link);
|
||||
|
||||
std::wstring delete_url = link;
|
||||
delete_url += L"/rm/jquery_upload";
|
||||
delete_url += L"/rm/jquery_upload/container:json/answer:data";
|
||||
file.add(L"deleteUrl", delete_url);
|
||||
|
||||
file.add(L"deleteType", L"POST");
|
||||
@@ -429,8 +428,7 @@ void Upload::CreateAnswer()
|
||||
*/
|
||||
}
|
||||
|
||||
cur->request->return_json = true;
|
||||
cur->request->return_info_only = true;
|
||||
cur->request->models.Add(L"files", files);
|
||||
}
|
||||
|
||||
|
||||
@@ -460,6 +458,12 @@ void Upload::MakeGet()
|
||||
}
|
||||
|
||||
|
||||
void Upload::Clear()
|
||||
{
|
||||
files.clear();
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
|
||||
@@ -63,9 +63,11 @@ private:
|
||||
//DbItemQuery query;
|
||||
bool is_jquery_upload;
|
||||
magic_t magic_cookie;
|
||||
pt::Space files;
|
||||
|
||||
void Init();
|
||||
void Finish();
|
||||
void Clear();
|
||||
|
||||
bool HasAccess(const Item & item);
|
||||
bool UploadSaveStaticFile(const Item & item, const std::wstring & tmp_filename);
|
||||
|
||||
Reference in New Issue
Block a user