105 Commits

Author SHA1 Message Date
5eed025419 add trigger_htmx_event(...) methods to FunctionBase 2024-11-08 13:35:54 +01:00
8634716aa7 add FunctionBase::push_url_to(...) methods 2024-09-08 02:05:05 +02:00
e63838faeb improve frontend of emacs, ckeditor, tinymce, nicedit, meta and env functions
Improves in emacs:
- use htmx to send content to the controller
- show txt and formatted_txt content in the second panel
- show two tabs if "tabs" winix parameter is used
- add an option to show either one or two panels
- correctly resize the editor window (F11) when two panels are shown

Improves in ckeditor:
- use htmx to send content to the controller
- do not check automatically for ckeditor update

Improves in tinymce/nicedit/meta/env:
- use htmx to send content to the controller

while here:
- change PascalCase to snake_case in meta/env controllers
- update CodeMirror editor to 5.65.16
- udpate Showdown (markdown to html converter) to 2.1.0
2024-07-20 15:13:27 +02:00
68e7f44a76 do not send content when there is a htmx redirect 2024-07-11 21:58:52 +02:00
7df78838aa add assign_methods(...) functionality to the FunctionBase
in make_*() methods you can assing your controller methods in such a way:
  assign_methods(this,
    by_param(L"paramoption",                     &MyController::MyMethod3),
    by_param(L"paramoption1", L"paramoption2",   &MyController::MyMethod2),
    by_param_post(L"paramoption", L"postoption", &MyController::MyMethod1)
  );
2024-06-29 17:23:03 +02:00
c30b7db041 add closing dialogs, redirecting and removing content functionality to the winix framework
add such new methods to FunctionBase:
- bool can_push_url_to_browser_history();
- void add_standard_models();
- void close_modal_dialogs();

- void prepare_doc_url(const wchar_t * local_url, pt::WTextStream & url);
- void prepare_doc_url(const wchar_t * local_url, std::wstring & url);
- std::wstring prepare_doc_url(const wchar_t * local_url = nullptr);
- std::wstring prepare_doc_url(const std::wstring & local_url);

- void redirect_to(const wchar_t * url, bool append_domain = true);
- void redirect_to(const std::wstring & url, bool append_domain = true);
- void redirect_to(const pt::WTextStream & url, bool append_domain = true);

- void redirect_to(const wchar_t * url, const wchar_t * frame_url, const wchar_t * dom_target);
- void redirect_to(const std::wstring & url, const std::wstring & frame_url, const std::wstring & dom_target);
- void redirect_to(pt::WTextStream & url, pt::WTextStream & frame_url, pt::WTextStream & dom_target);
- void redirect_to(pt::WTextStream & url, pt::WTextStream & frame_url, const wchar_t * dom_target);
- void redirect_to(const wchar_t * url, const wchar_t * frame_url, pt::WTextStream & dom_target);

- void retarged(const wchar_t * frame, const wchar_t * dom_target, const wchar_t * push_url = nullptr, const wchar_t * swap_algorithm = nullptr);
- void retarged(const std::wstring & frame, const std::wstring & dom_target, const std::wstring & push_url, const wchar_t * swap_algorithm = nullptr);
- void retarged(const wchar_t * frame, pt::WTextStream & dom_target, const wchar_t * push_url = nullptr, const wchar_t * swap_algorithm = nullptr);

- void remove_content(pt::WTextStream & dom_target, bool close_dialogs = false);
- void remove_content(const wchar_t * dom_target, bool has_postfix, long dom_target_postfix, bool close_dialogs = false);
- void remove_content(const wchar_t * dom_target, long dom_target_postfix, bool close_dialogs = false);
- void remove_content(const wchar_t * dom_target, bool close_dialogs = false);

- void update_content(const wchar_t * frame, pt::WTextStream & dom_target, bool close_dialogs = false);
- void update_content(const wchar_t * frame, const wchar_t * dom_target, bool has_postfix, long dom_target_postfix, bool close_dialogs = false);
- void update_content(const wchar_t * frame, const wchar_t * dom_target, long dom_target_postfix, bool close_dialogs = false);
- void update_content(const wchar_t * frame, const wchar_t * dom_target, bool close_dialogs = false);

while here:
- refactor PascalCase to snake_case in FunctionBase
- add start_request() and finish_request() methods to FunctionBase
- add has_*_access() methods to FunctionBase
- fix: FunctionBase::clear() method was not called if a request was assigned to a job
- add a WinixEzcHelper model
- allow to serialize a header if the header value is neither a string nor an integer
- refactor PascalCase to snake_case in functions: Emacs, Mkdir, Upload
2024-06-27 10:57:08 +02:00
6aa100f12c WIP: remove the old database abstraction layer
remove such classes:
- DbBase
- DbConn
- DbTextStream
- Db

while here:
- remove: TextStream, SLog, TexTextStream
2024-06-22 18:03:54 +02:00
d122917f83 fix: correctly activate a user account 2024-05-27 18:22:47 +02:00
79babc916a add a Request::raw_post buffer
This buffer is used when a Function::NeedToCopyRawPost() method returned true.

while here:
- remove WINIX_POST_PARAMS and WINIX_RAW_POST_STRING plugin messages
2023-11-02 05:14:48 +01:00
a49b10ed2d allow to upload files from the ckeditor
while here:
- update ckeditor to 4.21.0
- add a Sourcedialog plugin to the ckeditor
2023-04-09 14:10:21 +02:00
c2013ff47f do not use the ezc engine when sending a static file
while here:
- in send_file_mode=0 return a 404 if a static file was not correctly read
2022-11-14 00:54:50 +01:00
d5e6fb7c54 add Access-Control-Expose-Headers to normal cors requests too 2022-09-14 12:48:20 +02:00
6138497fe0 change how origin header is treated
Now check whether the origin is in allowed_origins table,
and if not check allow_all_origins config parameter.

While here:
- add are_cors_preflight_requests_available - if true then preflight
  requests are available (default false)
2022-09-09 01:01:39 +02:00
222a1c8a1f refactor the algorithm for testing the cors
while here:
- send cors headers even if the status is 404
- add: access_control_expose_headers config option - list of additional headers sent in Access-Control-Expose-Headers
- add: access_control_allow_credentials config option - if true return Access-Control-Allow-Credentials header equal "true"
2022-09-08 03:12:44 +02:00
9f64692ede set Access-Control-Allow-Credentials if available 2022-09-07 14:46:29 +02:00
a19158cb62 add config options for testing the Origin header in cors requests
- allow_all_cors_origins - whether or not to allow all origins
- allowed_cors_origins - a list of allowed origins (used if allow_all_cors_origins is false)
2022-08-31 20:42:42 +02:00
217f42b7c6 add support for preflight requ (cors) 2022-08-30 01:52:02 +02:00
a34db6505d move some methods from App to Request
methods moved: SetEnv(), ReadEnvVariables(), ReadEnvRemoteIP(), CheckSSL(), SetSubdomain()

while here:
- add the rest of http methods: put, connect, trace, patch
2022-08-29 19:20:41 +02:00
ceb5336ca1 add support for OPTIONS http method 2022-08-11 08:04:40 +02:00
968660e8ca fix: set correctly request->session
The session cookie was not created because request->session pointed at
a temporary session.

While here:
- do some cleaning in App
- set request->mount too
- add fcgi_cannot_create_request_delay to the config
- fix: in mailregister plugin get model_connector from env (and not from the request)
2022-07-30 18:37:50 +02:00
e5ed1d6ae8 fix: do not use cur if login winix function if config.use_internal_loggin_mechanism is false
In the login winix function cur pointer will be null if config.use_internal_loggin_mechanism
is false, in such a case those objects are not registered as winix functions
but we have a public api
(the public api should be moved somewhere e.g. make a service layer)
2022-07-27 01:25:49 +02:00
9e6a5b2d37 add use_internal_session_mechanism and use_internal_loggin_mechanism config options 2022-07-26 21:54:33 +02:00
979ef907fe allow a request to be processed in a job
Now we allow a request to be passed into a job queue,
and after the job finishes the request is passed into
a controller again. In order to achieve this we have
a requests queue in System, when we put a request
to the job this Request structure is preserved in the
queue and for a new request a new Request is added to
the queue.

while here:
- remove App::Lock()/Unlock(), use scoped locking
- fix: Plugin now has a Call method which takes ModelConnector
  and a logger (used in multithreaded environment)
- BaseThread has a main_model_connector pointer
  to the main (from the main thread) model connector
- the FastCGI structure fcgi_request moved from App to Request
- some methods for handling requests moved from App to Request
- small refactoring in main.cpp
- add Http class (a http client)
2022-07-25 14:21:21 +02:00
b484071818 print components versions in uname winix function 2022-07-03 12:17:14 +02:00
26226de865 global winixd/Makefile uses now 'find' for looking for *.cpp files
and we don't need Makefiles in subdirectories anymore (except plugins)
2022-06-26 06:22:27 +02:00
01c10bad0e add use_antispam_mechanism_for_not_logged_users config option 2022-05-30 05:35:05 +02:00
7d1fb3c04e 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.
2022-05-30 01:29:18 +02:00
5e89c4004a make depend 2022-05-26 00:35:24 +02:00
f99191aa6f make depend 2022-04-26 23:46:57 +02:00
aad5db9a6a let Functions::Add() returns info whether the functions/controller has been added 2022-04-25 16:35:14 +02:00
f7b5ac0dc8 change the way how winix answer is created
Now we can return ezc content and models serialized in the same json structure,
Xml and Csv are not implemented yet.
Ezc frames are returned in 'ezc_frames' field.
Main ezc stream is returned in 'main_stream' field.
Frame url parameter can take more than one frame (names separated by commas).
Honor Accept http header (AcceptParser).

Samples:
--------
http://domain.tld/dir/controller
returns html answer from the main ezc stream

http://domain.tld/dir/controller/container:raw
returns html answer from the main ezc stream (the same as above)

http://domain.tld/dir/controller/frame:abc
returns "abc" frame as html

http://domain.tld/dir/controller/container:json
returns all serialized models to json and no ezc streams

http://domain.tld/dir/controller/container:xml
returns all serialized models to xml and no ezc streams (not implemented yet)

http://domain.tld/dir/controller/container:json/frame:abc,xyz
returns all serialized models to json and two frames in 'ezc_frames' object

http://domain.tld/dir/controller/container:json/all_frames
returns all serialized models to json and all frames in 'ezc_frames' object

http://domain.tld/dir/controller/container:json/main_stream
returns all serialized models and the main ezc stream in 'main_stream' field

http://domain.tld/dir/controller/container:json/main_stream/all_frames
returns all serialized models to json, all frames and the main stream
2022-02-01 18:44:23 +01:00
35cb54324f added a new item content type: markdown
- emacs editor has an option to select markdown, now it has two planes: one for content editing and the other to show preview
- CodeMirror editor updated to 5.64.0
- to convert markdown to html we use showdown https://github.com/showdownjs/showdown (conversion is done on the client side)
2021-11-26 21:49:21 +01:00
d5ebb7ca12 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)
2021-10-13 01:27:14 +02:00
9c5c74ba84 added: setting a correct mime type for static files - using magic library
added: std::wstring file_mime_type to ItemContent - a mime type for static file
added: Header (core/header.h) - there will be header names defined, at the moment only content_type
added: FuncionsBase::Finish() - it is called at the end when the winix finishes
2021-09-22 00:23:25 +02:00
26ed7b80be changed values for send_file_mode config parameter:
0 - winix will read the content of the file and send it back to the webserver
  1 - winix will use send_file_header header with a full path to the file
  2 - winix will use send_file_header header with a relative path to the file
2021-09-17 03:35:56 +02:00
55ac9a61ed added possibility to send static files to nginx via X-Accel-Redirect header
added to config:
int send_file_mode;
    // 0 - full path to a file in send_file_header header
    // 1 - relative path to a file in send_file_header (need http_send_file_relative_prefix set) (used for nginx)
std::wstring send_file_header;
    // default: X-SENDFILE
    // for Apache set: X-SENDFILE
    // for Lighttpd set: X-LIGHTTPD-send-file
    // for Nginx set: X-Accel-Redirect
std::wstring send_file_relative_prefix;
    // relative prefix used for sending static files if send_file_mode is 1
    // default: "upload-files-internal"
2021-09-15 20:28:34 +02:00
b424988d1b updated to the new pikotools api (api2021): HTMLFilter renamed to HTMLParser
added to config: int html_filter_white_char_mode;
  how white characters between html tags are treated
  0 - WHITE_MODE_ORIGIN - they are copied from input to output
  1 - WHITE_MODE_SINGLE_LINE - new line characters are removed
  2 - WHITE_MODE_TREE - try to create a tree (some kind of pretty printing)
  default: 2
2021-08-07 02:16:48 +02:00
22134b6cc0 commented some method calls to html_filter 2021-07-26 03:54:02 +02:00
f861c0761e make depend 2021-07-17 13:57:39 +02:00
17bd48ece3 HTMLFilter has been moved to pikotools library 2021-07-17 13:42:04 +02:00
c5c02d7f44 HtmlTextStream has now pt::Stream as a based class and uses pt::WTextStream as a buffer 2021-07-16 18:17:57 +02:00
746aa41111 renamed: ItemContent::meta_admin -> ItemContent::admin_meta 2021-07-03 01:18:28 +02:00
619936c12e make depend 2021-07-01 23:35:08 +02:00
ccbbb59af7 make depend 2021-06-27 23:34:06 +02:00
1d18b7fa12 - updated to the new pikotools api (child spaces were removed)
some plugins need to be fixed yet: ticket, gallery, group, menu
- added current user to default models as "user"
- renamed in User: super_user -> is_super_user, env -> admin_env, pass_hash_salted -> is_pass_hash_salted
- now Users class has a WinixModel as a base class
  some plugin calls have to be fixed yet
- added UserWrapper model with a pointer to User class
- removed from ItemContent: methods for accessing 'meta' and 'admin_meta', now ezc can iterate through Space classes
- fixed in env winix function: if there is "changeuser" parameter then we should only switch the user (not save anything)
2021-06-27 23:31:50 +02:00
472490c239 make depend 2021-06-24 21:17:11 +02:00
443c2023d9 make depend 2021-06-23 17:04:21 +02:00
801fc062ef added FunctionBase::Clear() which is called at the end of a request 2021-06-20 20:47:59 +02:00
79eda7abb0 - added to FunctionBase: bool register_default_models (default true)
if true then winix will add default models for ezc templates such as "request", "item", etc.
- some methods from templates/item.cpp moved to Item
2021-06-20 18:04:50 +02:00
94f96c11cb make depend 2021-06-18 19:18:46 +02:00