Commit Graph
100 Commits
Author SHA1 Message Date
tomasz.sowa da2dec447b allow to specify how many times we can try to connect to the database at startup
add config options:
db_startup_connection_max_attempts - default 0 (infinite)
db_startup_connection_attempt_delay - delay in seconds between attempts (default 5)

BREAKING CHANGE: WINIX_PLUGIN_INIT plugin message requires to set result status,
you have to set the result status to true (env.res) if your
plugin was initialized correctly, otherwise winix will not start
2022-04-29 06:17:16 +02:00
tomasz.sowa c6c50a5d23 allow to use host database connection parameter
Add config option:
db_host (default empty) - name of host to connect to
2022-04-28 06:12:44 +02:00
tomasz.sowa 98c1e8daad allow to not change fast cgi socket permissions
New config options:
fcgi_set_socket_chmod (bool) - default true
fcgi_set_socket_owner (bool) - default true
2022-04-27 23:31:50 +02:00
tomasz.sowa f99191aa6f make depend 2022-04-26 23:46:57 +02:00
tomasz.sowa df04075f1c add methods to Request for adding and removing parameters
Added methods:
void AddParam(const std::wstring & param_name, const std::wstring & param_value);
void AddParam(const wchar_t * param_name, const wchar_t * param_value);
void RemoveParam(const wchar_t * param_name);
void RemoveParam(const std::wstring & param_name);

This is only temporarily, we will be using the pt::Space structure in the future.
2022-04-26 23:41:56 +02:00
tomasz.sowa 3d2a635e34 fix: use TextStreamBase::to_str() instead of to_string() 2022-04-25 22:05:34 +02:00
tomasz.sowa aad5db9a6a let Functions::Add() returns info whether the functions/controller has been added 2022-04-25 16:35:14 +02:00
tomasz.sowa 43ebbdaa33 add WINIX_PLUGIN_QUIT and WINIX_QUIT plugins messages
While here:
- rename WINIX_CLOSE to WINIX_PREPARE_TO_CLOSE
2022-04-25 16:34:26 +02:00
tomasz.sowa 92c7f90b95 fix: correctly propagate a migration status when the migration failed 2022-04-25 15:19:02 +02:00
tomasz.sowa aae93d018b allow to use db_hostaddr, db_port or db_conn_string config parameters to connect to PostgreSQL 2022-04-20 18:37:52 +02:00
tomasz.sowa 7a115a3970 fix(Log): treat pt::Log::Manipulators as enum and not as int 2022-04-16 21:52:53 +02:00
tomasz.sowa 64e5114947 allow to read environment variables as config parameters
Environment variables must be prefixed with winix_ to be loaded by winix.
The winix_ prefix is then removed and the key value converted to lowercase.

Sample:
evn WINIX_MY_OPTION=TEST123test winix -c config_file

This will add my_option to the config with value TEST123test.
Environment variables are read last so they will overwrite the values
from the configuration files.
2022-04-16 21:50:23 +02:00
tomasz.sowa 4f8b5e649a recognize startup parameters
Usage: winix [options]
  -c             : a path to the config file
  --config       : a path to the config file
  -h             : print usage information
  --help         : print usage information
  -?             : print usage information

While here:
- let it be possible to parse multiple configs,
- fix: some error messages were not printed at startup.
2022-04-16 18:38:30 +02:00
tomasz.sowa e0d9989d74 fix(Item): id should be of type serial 2022-04-11 23:27:49 +02:00
tomasz.sowa 0fe680ef4a fix: migration to version 2 in User model 2022-04-11 23:19:30 +02:00
tomasz.sowa e182c0a21b fix: create core schema before making a first select request
Migration uses Finder to get the current table version.
2022-04-11 23:11:00 +02:00
tomasz.sowa c8edd241d5 create core schema as a first migration 2022-04-11 20:57:49 +02:00
tomasz.sowa a544ccd1a7 fix: User model initial column name: aenv 2022-04-11 20:44:58 +02:00
tomasz.sowa 7df2205b40 update flatpickr to 4.6.11 2022-04-05 17:37:24 +02:00
tomasz.sowa 265e843d02 update uikit to 3.13.7 2022-04-05 16:59:57 +02:00
tomasz.sowa 22a8a97389 update htmx to 1.7.0 2022-04-05 16:53:46 +02:00
tomasz.sowa bb74f2a423 update uikit to 3.11.1 2022-02-08 14:13:33 +01:00
tomasz.sowa 2033168db2 Merge branch 'cli' into ajax 2022-02-08 14:01:50 +01:00
tomasz.sowa e377f144fd fix: do not send headers again after binary content 2022-02-04 18:46:46 +01:00
tomasz.sowa 234ebf8ce8 change HtmlTextStream iterators type to pt::WTextStream::iterator 2022-02-03 20:57:38 +01:00
tomasz.sowa 09cf3c9fa9 add some comments in AcceptBaseParser 2022-02-02 18:34:56 +01:00
tomasz.sowa df32899581 move AcceptEncodingParser to utils 2022-02-02 18:34:22 +01:00
tomasz.sowa 33e8df11c5 parse Accept-Language header to Request::accept_languages table 2022-02-02 18:20:32 +01:00
tomasz.sowa 75daf37bbd improve AcceptBaseParser parsing algorithm
remove AcceptParser - not needed now, AcceptBaseParser can prepare a table now
2022-02-02 17:58:27 +01:00
tomasz.sowa d0d2cfb22c move AcceptBaseParser to utils directory 2022-02-02 17:11:46 +01:00
tomasz.sowa 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
tomasz.sowa 227dd923d6 fix: correctly escape ezc stream to json/xml/csv 2022-01-28 15:54:11 +01:00
tomasz.sowa f6cb9a8aed set correct timetable dst for 'Sarajevo, Skopje, Warsaw, Zagreb'
year: 2022 and 2023
2022-01-26 22:34:13 +01:00
tomasz.sowa b615dc7e6e add cmp ezc function 2022-01-22 04:35:42 +01:00
tomasz.sowa 944560dd2b update uikit to 3.10.1 2022-01-19 15:47:11 +01:00
tomasz.sowa 1d6d29e24d add winixcli/src/winix to .gitignore 2022-01-18 19:46:12 +01:00
tomasz.sowa ff8e9e6b32 start working on winixcli
winixcli can now read a PGModeler file
and is able to generate a template through ezc

winixcli parameters:
--input-mode pgmodeler (only one parameter at the moment)
--input-file file (pgmodeler file)
--templates-dir dir_path (a path to templates directory)
--template file (template file)
2022-01-18 19:40:57 +01:00
tomasz.sowa 557555c4b3 htmx updated to 1.6.1 2021-12-08 15:19:35 +01:00
tomasz.sowa f8e1037476 uikit updated to 3.9.4 2021-11-26 21:51:01 +01:00
tomasz.sowa 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
tomasz.sowa 119497bb01 added winix_frame_is ezc winix function 2021-10-24 22:27:52 +02:00
tomasz.sowa dfd6475a81 uikit updated to 3.7.6 2021-10-24 22:27:35 +02:00
tomasz.sowa d6d5236a03 added fil_json_escape filter 2021-10-21 13:42:41 +02:00
tomasz.sowa a327a26bd5 added winix_uikit_version parameter to index_head_adder.html 2021-10-13 23:48:30 +02:00
tomasz.sowa 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
tomasz.sowa 3e46c5674c htmx updated to 1.6.0 2021-10-08 17:44:34 +02:00
tomasz.sowa c4b5565995 don't check for request->is_htmx_request for sending frames, check only "frame" url paremeter
added config parameter: request_frame_parameter, default: "frame"
2021-10-08 03:08:11 +02:00
tomasz.sowa 3f5eabeaa1 uikit updated to 3.7.5 2021-10-07 05:02:24 +02:00
tomasz.sowa 9b8e48e7b2 added static libraries: clocklet (timepicker), flatpickr and litepicker (data pickers) 2021-10-07 04:42:46 +02:00
tomasz.sowa c3122fb82f added [lang] ezc function for returning a localized string 2021-10-07 04:41:06 +02:00
tomasz.sowa 1741597d52 uikit updated to 3.7.4 2021-09-27 02:53:16 +02:00
tomasz.sowa 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
tomasz.sowa 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
tomasz.sowa 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
tomasz.sowa 7673264fe1 make depend 2021-08-12 21:57:03 +02:00
tomasz.sowa 42dc43b036 added WINIX_MAKE_DATABASE_MIGRATION plugin message for making migrations from plugins 2021-08-11 22:18:14 +02:00
tomasz.sowa ef22d951a0 fixed: base class of System should be derived as public 2021-08-10 22:06:53 +02:00
tomasz.sowa e95dc834a3 uikit updated to 3.7.2 2021-08-07 21:23:47 +02:00
tomasz.sowa 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
tomasz.sowa 22134b6cc0 commented some method calls to html_filter 2021-07-26 03:54:02 +02:00
tomasz.sowa f861c0761e make depend 2021-07-17 13:57:39 +02:00
tomasz.sowa 1899d5ee17 BBCODEParser has been moved to pikotools library 2021-07-17 13:56:37 +02:00
tomasz.sowa 17bd48ece3 HTMLFilter has been moved to pikotools library 2021-07-17 13:42:04 +02:00
tomasz.sowa 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
tomasz.sowa ba6159964b htmx updated to 1.5.0 2021-07-16 13:16:02 +02:00
tomasz.sowa b834971f5e uikit updated to 3.7.1 2021-07-16 12:28:38 +02:00
tomasz.sowa 9dc15d536c Makefile: removed macros: EZC_GENERATOR_HAS_PT_STREAM and EZC_GENERATOR_HAS_WINIX_STREAM 2021-07-13 01:49:58 +02:00
tomasz.sowa 2e45cb6ac9 updated to the new ezc api (Generator has three additional parameters now) 2021-07-13 01:46:07 +02:00
tomasz.sowa 2dcfeaa688 fixed: in Item do_migration_to_3(...) admin meta was called admin_meta (not meta_admin) 2021-07-07 01:04:48 +02:00
tomasz.sowa 9d65d931d0 moved some ezc functions from templates/item.cpp to Item and ItemContent
removed: templates/item.cpp
updated: some html templates which use [item] or [item_tab]
removed some old html templates: item_info.html and itam_tab_info.html
2021-07-06 21:52:29 +02:00
tomasz.sowa 746aa41111 renamed: ItemContent::meta_admin -> ItemContent::admin_meta 2021-07-03 01:18:28 +02:00
tomasz.sowa 175dd17416 added request.last_item ezc function 2021-07-03 01:14:53 +02:00
tomasz.sowa 619936c12e make depend 2021-07-01 23:35:08 +02:00
tomasz.sowa 732144df01 updated to the new morm api - models methods which take 'morm::ModelWrapper ** model_wrapper' now take 'morm::Wrapper & wrapper' 2021-07-01 23:34:49 +02:00
tomasz.sowa df3f04a951 added to misc: timespec_to_stream_with_unit() for printing times either is seconds or miliseconds 2021-06-30 16:30:11 +02:00
tomasz.sowa 0f78968579 updated ticket plugin to the new ezc api (child spaces were removed) 2021-06-29 23:42:57 +02:00
tomasz.sowa 66173c7a31 removed old meta ezc functions from gallery plugin 2021-06-28 21:34:41 +02:00
tomasz.sowa 3f934d9aec removed old meta ezc functions from menu plugin 2021-06-28 21:34:22 +02:00
tomasz.sowa df0cc131fe fixed in thread winix function: answers were not sorted correctly 2021-06-28 21:33:33 +02:00
tomasz.sowa ba60f9da8a updated group plugin to the new pikotools api (child spaces were removed) 2021-06-28 20:58:39 +02:00
tomasz.sowa 4569198b9d fixed in index_head_adder.html: winix_function_is "emacs" should be in parentheses 2021-06-27 23:43:01 +02:00
tomasz.sowa ccbbb59af7 make depend 2021-06-27 23:34:06 +02:00
tomasz.sowa 3a5af25eaf updated some html templates 2021-06-27 23:33:10 +02:00
tomasz.sowa 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
tomasz.sowa 472490c239 make depend 2021-06-24 21:17:11 +02:00
tomasz.sowa b6340a30d2 updated to the new pikotools api (changes in Log) 2021-06-24 21:17:03 +02:00
tomasz.sowa bf1f0954b9 fixed: changed "%g" to "%f" when printing request/ezc times
SetNonZeroDigitsAfterComma() incorrectly terminated the string if the format was "%g" (in the case where it was used as %e)
2021-06-24 16:11:02 +02:00
tomasz.sowa 2f1cdcf379 added printing info how much time winix spent in the ezc engine
added to Request:
timespec timespec_req_stop;
timespec timespec_req_diff;
timespec timespec_ezc_engine_start;
timespec timespec_ezc_engine_stop;
2021-06-24 15:33:44 +02:00
tomasz.sowa 443c2023d9 make depend 2021-06-23 17:04:21 +02:00
tomasz.sowa 2c5062ba22 UrlEncode() methods from core/misc.h are now thread safe 2021-06-23 17:04:07 +02:00
tomasz.sowa 8ab07d11b1 fixed: cur.request->function->fun didn't have a model connector set when a request started 2021-06-21 16:51:35 +02:00
tomasz.sowa a1c0f6f7f0 added config option: add_header_cache_no_store_in_htmx_request
send "Cache-Control: no-store, max-age=0" http header if a request is made by htmx library (ajax)
if a webbrowser get a page from the cache then it will render just the last request without the whole html page (css, js, etc)
https://github.com/bigskysoftware/htmx/issues/497
2021-06-21 11:43:59 +02:00
tomasz.sowa 672737a0d8 added a comment in ItemContent 2021-06-20 22:27:06 +02:00
tomasz.sowa ade96bf6d3 some methods from templates/item.cpp moved to ItemContent 2021-06-20 21:22:08 +02:00
tomasz.sowa 801fc062ef added FunctionBase::Clear() which is called at the end of a request 2021-06-20 20:47:59 +02:00
tomasz.sowa f35840e7de some work in html templates: changed some functions from item_* to item.* 2021-06-20 18:12:43 +02:00
tomasz.sowa 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
tomasz.sowa e7c7324058 ItemContent::user_name(EzcEnv & env) changed to ItemContent::user(morm::ModelWrapper ** model_wrapper) and we return a User class
ItemContent::group_name(EzcEnv & env) changed to ItemContent::group(morm::ModelWrapper ** model_wrapper) and we return a Group class
added ItemContent::display_user_name(EzcEnv & env)
some functions in templates/item.cpp moved to Item
2021-06-19 23:48:12 +02:00
tomasz.sowa d8c1a81bcb removed config options: ezc_error_prefix and ezc_error_postfix
Ezc::PatternParser and Ezc::Generator use only pt::Log as a logger now
2021-06-19 20:33:35 +02:00
tomasz.sowa 94f96c11cb make depend 2021-06-18 19:18:46 +02:00