remove Request::post_tab and add Request::http_status

Instead of Reqest::post_tab we use now Request::post_in (pt::Space).

Request::http_status will be used instead Request::status,
but at the moment is not changed in all places.
Request::status has been marked as depracated.

While here:
- Check for root dir in App and not in FunctionParser,
let FunctionParser only log the root dir.
- Read post variables after parsing url parameters,
this allows winix functions to set limits
for post input.
- Set limits when parsing input json format, new
options added to config: post_max_object_items, post_max_table_items,
post_max_all_items, post_max_nested_objects.
There are similar options in each winix function (they are in
FunctionBase).
- Some refactoring in App.
- Add config option: log_whole_http_post if true
then the whole parsed post input is logged.
- Add config option: post_json_max - max length of input stream
for parsing json.
- Add config option: templates_request_status, default request_status.html
this is an ezc template used as [content] when the request status
is not 200_ok.
- Fix: Sort winix function didn't show items to sort (fix and do some
refactoring as well)
- Properly sort items in: ImgCrop, Ls, Sort, Upload
- Remove ezc templates: err_404.html, err_per_denied.html - now
request_status.html is used.
This commit is contained in:
2022-05-30 01:29:18 +02:00
parent 9e222f5b80
commit 7d1fb3c04e
46 changed files with 1224 additions and 835 deletions

View File

@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2008-2021, Tomasz Sowa
* Copyright (c) 2008-2022, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -41,15 +41,14 @@
namespace Winix
{
// !! IMPROVE ME moze zamienic na EzcFunctions
// !! IMPROVE ME may change to EzcFunctions?
namespace TemplatesFunctions
{
size_t pat_index; // main index pattern
size_t pat_index_generic; // generic index pattern, without any css-site styles, only main css (uikit)
size_t pat_index_raw; // pattern for a raw content (raw content without html, body markup)
size_t pat_err_404; // 404 error
size_t pat_err_per_denied; // permission denied error
size_t pat_request_status; // error.html
Patterns patterns; // all html patterns
IndexPatterns index_patterns; // patterns for main index templates (those from mountpoint)
@@ -106,7 +105,7 @@ Ezc::Pattern * p;
if( !cur->request->function )
{
log << log1 << "Templates: cannot get a template for a function (there is not a function)" << logend;
log << log1 << "Templates: cannot get a template for a function (there is no a function)" << logend;
return 0;
}
@@ -134,60 +133,30 @@ return p;
void content(Info & i)
void content(EzcEnv & env)
{
Ezc::Pattern * p = 0;
Ezc::Pattern * pattern = 0;
switch( cur->request->status )
switch( cur->request->http_status )
{
//case WINIX_ERR_NO_ITEM: !! we need something like 'error::item_required'
//p = &pat_err_item_required;
//break;
case WINIX_ERR_INCORRECT_URI: // !!temporarily
case WINIX_ERR_INTERNAL_ERROR: // !! temprarily
case WINIX_ERR_PERMISSION_DENIED:
case WINIX_ERR_CANT_CHANGE_USER:
case WINIX_ERR_CANT_CHANGE_GROUP:
case WINIX_ERR_CANT_CHANGE_PRIVILEGES:
// !! locale.GetLang() bedzie brane indywidualnie dla kazdego uzytkownika
p = patterns.Get(pat_err_per_denied, locale.GetCurLang());
case Header::status_200_ok:
pattern = GetPatternForFunction();
break;
if( p )
log << log3 << "Templates: error pattern taken from: " << patterns.GetFileName(pat_err_per_denied) << logend;
break;
case WINIX_ERR_NO_ITEM:
case WINIX_ERR_NO_FUNCTION:
case WINIX_ERR_UNKNOWN_PARAM:
// !! locale.GetLang() bedzie brane indywidualnie dla kazdego uzytkownika
p = patterns.Get(pat_err_404, locale.GetCurLang());
if( p )
log << log3 << "Templates: error pattern taken from: " << patterns.GetFileName(pat_err_404) << logend;
break;
//default:
// !! locale.GetLang() bedzie brane indywidualnie dla kazdego uzytkownika
//p = &patterns[locale.GetLang()][pat_err_others];
//break;
//case WINIX_ERR_OK:
//case WINIX_ERR_SPAM:
//case WINIX_ERR_INCORRECT_REBUS:
default:
p = GetPatternForFunction();
break;
}
pattern = patterns.Get(pat_request_status, locale.GetCurLang());
if( pattern )
log << log3 << "Templates: error pattern taken from: " << patterns.GetFileName(pat_request_status) << logend;
break;
}
if( p )
if( pattern )
{
InitGenerator(content_gen, cur->request->models);
content_gen.SetPattern(*p);
content_gen.Generate(i.out, cur->request->out_streams);
content_gen.SetPattern(*pattern);
content_gen.Generate(env.out, cur->request->out_streams);
}
else
{
@@ -853,8 +822,7 @@ using namespace TemplatesFunctions;
pat_index = patterns.Add(config->templates_index);
pat_index_generic = patterns.Add(config->templates_index_generic);
pat_index_raw = patterns.Add(config->templates_index_raw);
pat_err_404 = patterns.Add(L"err_404.html"); // !! IMPROVE ME name to the config
pat_err_per_denied = patterns.Add(L"err_per_denied.html"); // !! IMPROVE ME name to the config
pat_request_status = patterns.Add(config->templates_request_status);
ReadTemplatesForFunctions();
ReadIndexTemplates();