diff --git a/web/CXM_jquery.anubis b/web/CXM_jquery.anubis index e78d0ce..dd94524 100644 --- a/web/CXM_jquery.anubis +++ b/web/CXM_jquery.anubis @@ -12,14 +12,15 @@ read tools/basis.anubis /* jQuery Actioner type */ public type JQuery_Actioner_type: - jqform, - jqlink, - jqflink, - jqscript. + jqform ( String form), + jqlink ( WEB_Action_Name name), + jqflink ( String link), + jqscript( String script) +. /* jQuery Actioner */ public type JQuery_Actioner: - jQuery_actioner(Actioner_Target target, JQuery_Actioner_type type, String url_or_form_id_or_script). + jQuery_actioner(Actioner_Target target, JQuery_Actioner_type type). //, String url_or_form_id_or_script /* jQuery Selector - http://api.jquery.com/category/selectors/ */ public type JQuerySelector: @@ -64,32 +65,54 @@ public define String JQuery_Actioner actioner ) = - if actioner is jQuery_actioner(target, act_type, str) then + if actioner is jQuery_actioner(target, act_type) then if target is { same then if act_type is { - jqform then "$('#"+str+"').submit();", - jqlink then "document.location='/?a="+str+"';", - jqflink then "document.location='"+str+"';", - jqscript then str + jqform(form) then "$('#"+form+"').submit();", + jqlink(control_action) then + if control_action is + { + controller_action(ctrl, action) then "document.location='/?aws_controller="+ctrl+"&aws_action="+action+"';", + action_name(action) then "document.location='/?aws_action="+action+"';", + url(url) then "document.location='"+url+"';", + } + jqflink(link) then "document.location='"+link+"';", + jqscript(script) then script }, same(label) then if act_type is { - jqform then "$('#"+str+"').submit();", - jqlink then "document.location='/?a="+str+"';", - jqflink then "document.location='"+str+"';", - jqscript then str + jqform(form) then "$('#"+form+"').submit();", + jqlink(control_action) then + if control_action is + { + controller_action(ctrl, action) then "document.location='/?aws_controller="+ctrl+"&aws_action="+action+"';", + action_name(action) then "document.location='/?aws_action="+action+"';", + url(url) then "document.location='"+url+"';", + } + jqflink(link) then "document.location='"+link+"';", + jqscript(script) then script }, other(window_name, window_options) then if act_type is { - jqform then "$('#"+str+"').submit();", //il s'agit d'une soumision d'un formulaire => cela se fait uniquement dans la même fenêtre ! - jqlink then "window.open('"+str+"', '"+window_name+"', '"+jquery_button_get_onclick_action_window_options(window_options, "")+"');", - jqflink then "document.location='"+str+"';", - jqscript then str + jqform(form) then "$('#"+form+"').submit();",//il s'agit d'une soumision d'un formulaire => cela se fait uniquement dans la même fenêtre ! + jqlink(control_action) then + if control_action is + { + controller_action(ctrl, action) then + "window.open('aws_controller="+ctrl+"&aws_action="+action+"', '"+window_name+"', '"+jquery_button_get_onclick_action_window_options(window_options, "")+"');", + //"document.location='/?aws_controller="+ctrl+"&aws_action="+action+"';", + action_name(action) then + "window.open('"+action+"', '"+window_name+"', '"+jquery_button_get_onclick_action_window_options(window_options, "")+"');", + url(url) then "document.location='"+url+"';", + } + jqflink(link) then "document.location='"+link+"';", + jqscript(script) then script + } }. diff --git a/web/CXM_making_a_web_site.anubis b/web/CXM_making_a_web_site.anubis index f304692..ed6e497 100644 --- a/web/CXM_making_a_web_site.anubis +++ b/web/CXM_making_a_web_site.anubis @@ -62,6 +62,7 @@ read CXM_cookies.anubis read CXM_json.anubis transmit CXM_web_dump.anubis transmit CXM_web_arg_utils.anubis +transmit CXM_web_session.anubis //read CXM_html_tooltip.anubis @@ -303,31 +304,15 @@ public type WEB_Action_Name: String action_name ), action_name( - String name + String action_name + ), + //url is raw action, hence we will onlu copy that url in final link + url( + String url_name ) . -public type WEB_Session_Entry: - session_entry( - String field, - String value - ). -public type WEB_Request: - web_request( - HTTP_Info http_info, - List(Web_arg) lwa, - Bool is_https, - ) -. - -public type WEB_Session: - web_session( - String language, - List(WEB_Session_Entry) entries, - WEB_Request web_request, - WEB_Request previous_request - ). @@ -342,6 +327,11 @@ public type WEB_Controller_Result: redirect( //internal redirection, session is modified to call the right controller and action WEB_Session session ), + redirect( //internal redirection, session is modified to call the right controller and action + WEB_Session session, + String controller, + String action_name + ), redirect_to_previous, ajax( HTTP_Answer http_answer @@ -389,9 +379,10 @@ define WEB_Session -> String // the function constructed returns the name of Int timeout, String state_directory ) = - (WEB_Session s) |-> + (WEB_Session s_var) |-> //Set the new timeout with time_stamp = now+timeout, + s = to_WEB_Session_No_Var(s_var), to_be_saved = (time_stamp,s), //generate new session name session_name = to_ascii(sha1(s)), @@ -428,9 +419,12 @@ define Previous_Session with session_name = value(cookie), with file_path = session_directory+"/"+session_name, //unserialize the stored session and his timeout value - if (RetrieveResult((Int, WEB_Session)))retrieve(file_path) is ok(d) then + println("retrieve session ["+session_name+"]"); + if (RetrieveResult((Int, WEB_Session_No_Var)))retrieve(file_path) is ok(d) then ( - since d is (time_stamp, s), + println("retrieve session OK ["+session_name+"]"); + since d is (time_stamp, s_no_var), + with s = to_WEB_Session(s_no_var), if time_stamp < now then ( forget(remove(file_path)); @@ -2849,7 +2843,9 @@ public define Web_Site define HTTP_Answer error_page ( - HTTP_Status http_status + HTTP_Status http_status, + String message, + WEB_Session _session, ) = html_page @@ -2867,7 +2863,11 @@ define HTTP_Answer sequence([ text([size(16)], "Anubis Web Server 1.14"), br, - text([size(16)],"Error "+to_String(http_status)) + text([size(16)],"Error "+to_String(http_status)), + br, + text([], "Internal message :"+message), + br,br, + in_form(html_Id(""),text_area(wan(""), init(dump(_session)), 120, 60)) ]) ) ) @@ -2880,14 +2880,16 @@ define WEB_Controller_Result String requested_action_name, List(WEB_Action) actions_list ) = + //println("apply_action "); if actions_list is { - [] then http_answer(error_page(http_not_found)), + [] then http_answer(error_page(http_not_found, "No action found", _session)), [h . t] then with action_name = if h.name is { controller_action(_, name) then name, - action_name(name) then name + action_name(name) then name, + url(url) then url, }, if requested_action_name = action_name then if h.allowed_proto is @@ -2895,13 +2897,13 @@ define WEB_Controller_Result //Action only in HTTP http then if _session.web_request.is_https then - http_answer(error_page(http_forbidden)) + http_answer(error_page(http_forbidden, "Only HTTP authorized", _session)) else //ask to the server the authorization to execute that action if h.allow(_session) then h.do_it(_session) else - http_answer(error_page(http_unauthorized)) + http_answer(error_page(http_unauthorized, "you are not authorized for this action", _session)) //Action only in HTTPS https then @@ -2910,16 +2912,17 @@ define WEB_Controller_Result if h.allow(_session) then h.do_it(_session) else - http_answer(error_page(http_unauthorized)) + http_answer(error_page(http_unauthorized, "you are not authorized for this action", _session)) else - http_answer(error_page(http_forbidden)) + http_answer(error_page(http_forbidden, "Only HTTPS authorized", _session)) //Action in both HTTP / HTTPS http_https then //ask to the server the authorization to execute that action if h.allow(_session) then + //println("do_it "+action_name); h.do_it(_session) else - http_answer(error_page(http_unauthorized)) + http_answer(error_page(http_unauthorized, "you are not authorized for this action", _session)) } else @@ -2938,6 +2941,7 @@ define Maybe(WEB_Controller) [] then failure, [h . t] then if h.name = controller_name then + success(h) else get_controller(controller_name, t) @@ -2949,14 +2953,32 @@ define (Maybe(WEB_Session), HTTP_Answer) ( WEB_Controller controller, List(WEB_Controller) controllers, - WEB_Session _session + WEB_Session _session, + Maybe(String) _mb_action_name, + (HTTP_Info, + List(Web_arg), + Bool is_https) -> WEB_Session initial_session, )= //get the action name - if get_String(_session.web_request.lwa, "aws_action") is + with mb_action_name = + if _mb_action_name is + { + failure then get_String(_session.web_request.lwa, "aws_action"), + success(_an) then success(_an) + }, + + if mb_action_name is { - failure then (failure, error_page(http_not_found)), + failure then + //(failure, error_page(http_not_found, "Action name failure", _session)), + with new_session = initial_session(_session.web_request.http_info, _session.web_request.lwa, _session.web_request.is_https), + if get_controller(get_String(new_session.web_request.lwa, "aws_controller", "root"), controllers) is + { + failure then (failure, error_page(http_not_found, "Initial Session Controller not found", new_session)), + success(new_controller) then apply_controller_action(new_controller, controllers, new_session, failure, initial_session), + }, success(action_name) then - + println("ACTION_NAME ["+action_name+"]"); if apply_action(_session, action_name, *controller.controller_actions) is { http_answer(session, answer) then (success(session), answer), @@ -2964,19 +2986,26 @@ define (Maybe(WEB_Session), HTTP_Answer) redirect(new_session) then if get_controller(get_String(new_session.web_request.lwa, "aws_controller", "root"), controllers) is { - failure then (failure, error_page(http_not_found)), - success(new_controller) then apply_controller_action(new_controller, controllers, new_session), - } + failure then (failure, error_page(http_not_found, "Redirect Controller not found", new_session)), + success(new_controller) then apply_controller_action(new_controller, controllers, new_session, failure, initial_session), + }, + + redirect(new_session, r_controller_name, r_action_name) then + if get_controller(r_controller_name, controllers) is + { + failure then (failure, error_page(http_not_found, "Redirect Controller "+r_controller_name+" not found", new_session)), + success(new_controller) then + apply_controller_action(new_controller, controllers, new_session, success(r_action_name), initial_session), + }, - redirect_to_previous then - if get_controller(get_String(_session.previous_request.lwa, "aws_controller", "root"), controllers) is + redirect_to_previous then + if get_controller(get_String(_session.previous_web_request.lwa, "aws_controller", "root"), controllers) is { - failure then (failure, error_page(http_not_found)), + failure then (failure, error_page(http_not_found, "Redirect to previous Controller not found", _session)), success(new_controller) then since _session is web_session(lang, entries, _, previous), - apply_controller_action(new_controller, controllers, web_session(lang, entries, previous, previous)), - } - + apply_controller_action(new_controller, controllers, web_session(lang, entries, previous, previous), failure, initial_session), + }, ajax(answer) then (failure, answer), } } @@ -3063,8 +3092,11 @@ public define Web_Site //since apply_controller_action(get_controller(get_String(lwa, "aws_controller", "root"), *web_controllers), *web_controllers, current_session) since if get_controller(get_String(current_session.web_request.lwa, "aws_controller", "root"), *web_controllers) is { - failure then (failure, error_page(http_not_found)), - success(new_controller) then apply_controller_action(new_controller, *web_controllers, current_session), + failure then + (failure, error_page(http_not_found, "Controller not found", current_session)), + + success(new_controller) then + apply_controller_action(new_controller, *web_controllers, current_session, failure, initial_session), } is (mb_new_session, http_answer), @@ -3503,6 +3535,19 @@ define Int The next function composes the URL. It is a JavaScript URL when the target is another window. +public define String + format_web_action_name + ( + WEB_Action_Name action + )= + if action is + { + controller_action(controller, action_name) then "?aws_controller="+controller+"&aws_action="+action_name, + action_name(action_name) then "?aws_action="+action_name, + url(url) then url + } +. + define String make_actioner_url ( @@ -3530,12 +3575,7 @@ define String "https://"+common_name+":"+https_port+"/", } + //with action_string = - if action is - { - controller_action(controller, action_name) then "?aws_controller="+controller+"&aws_action="+action_name, - action_name(action_name) then "?aws_action="+action_name - } - //"?a=" + action_name + + format_web_action_name(action) + format_extra_operands(extra_ops), if target is @@ -4042,7 +4082,8 @@ define Printable_tree //if action name is empty, format options on image because maybe there onclick action with action_name = if action is { controller_action(_, an) then an, - action_name(an) then an + action_name(an) then an, + url(_) then "" }, if action_name ="" then [ @@ -4062,12 +4103,13 @@ define Printable_tree text, "" ], javascript(s,h) then - with action_name = - if action is - { - controller_action(_, an) then an, - action_name(an) then an - }, + with action_name = + if action is + { + controller_action(_, an) then an, + action_name(an) then an, + url(_) then "" + }, if action_name = "" then [""] else @@ -4110,7 +4152,8 @@ define Printable_tree javascript(s,h) then with action_name = if action is { controller_action(_, an) then an, - action_name(an) then an + action_name(an) then an, + url(_) then "" }, if action_name = "" then // special case where URL (so the action_name) is provided by the form itself // so javascript isn't needed. This is the standard HMTL way. diff --git a/web/CXM_multihost_http_server.anubis b/web/CXM_multihost_http_server.anubis index af98276..f7bd3cc 100644 --- a/web/CXM_multihost_http_server.anubis +++ b/web/CXM_multihost_http_server.anubis @@ -1579,7 +1579,9 @@ define List(Web_arg) then with second1 = read_name_or_value(s,i+1,i+1), // print("\""+second1+"\"\n"); with second = web_to_ascii(second1,0,[]), - [web_arg(first,second) . read_www_url_encoded_web_args(s,i+length(second1)+2)] + //println("first ["+first+"] second ["+second+"]"); + with _first = if substr(first,0,4) = "amp;" then substr(first, 4, length(first) - 4) else first, + [web_arg(_first,second) . read_www_url_encoded_web_args(s,i+length(second1)+2)] else print("**** ALERT **** badly formatted argument [" + s + "]!!!\n"); [] }. diff --git a/web/CXM_web_session.anubis b/web/CXM_web_session.anubis new file mode 100644 index 0000000..69284dc --- /dev/null +++ b/web/CXM_web_session.anubis @@ -0,0 +1,1067 @@ +/* + * Created by PyramIDE. + * User: フランスのトトロ aka (David RENÉ) + * Date: 17/02/2017 + * Time: 17:18 + * © Calexium + */ + +read system/convert.anubis +read system/muscle.anubis +read CXM_common.anubis +read CXM_web_dump.anubis + + +public type WEB_Session_Field_Datum: + string(String), //fully implented + bool(Bool), //fully implented + int(Int), //fully implented + message(Message), //fully implented + byte_array(ByteArray), + float(Float), + word128(Word128), + word64(Word64), + word32(Word32), + word16(Word16), + word8(Word8), + word4(Word4) +. + +public type WEB_Session_Field_Type: + string_t, + bool_t, + int_t, + message_t, + byte_array_t, + float_t, + word128_t, + word64_t, + word32_t, + word16_t, + word8_t, + word4_t +. + +public type WEB_Session_Field: + session_field( + String field_name, + WEB_Session_Field_Type field_type, + Var(WEB_Session_Field_Datum) field_datum //Var because it can be replaced + ). + +public type WEB_Session_Field_No_Var: + session_field( + String field_name, + WEB_Session_Field_Type field_type, + WEB_Session_Field_Datum field_datum //Var because it can be replaced + ). + +public type WEB_Request: + web_request( + HTTP_Info http_info, + List(Web_arg) lwa, + Bool is_https, + ) +. + +public type WEB_Session: + web_session( + String language, + Var(List(WEB_Session_Field)) fields, + WEB_Request web_request, + WEB_Request previous_web_request + ). + +public type WEB_Session_No_Var: + web_session( + String language, + List(WEB_Session_Field_No_Var) fields, + WEB_Request web_request, + WEB_Request previous_web_request + ). + +public define Var(List(WEB_Session_Field)) + empty_fields_list = + var([]). + +public define WEB_Session_Field + session_field + ( + String _field_name, + String _string + )= + session_field(_field_name, string_t, var(string(_string))) +. + + *----------------------------------------------------------------* + +define Var(List(WEB_Session_Field)) + to_WEB_Session_Field + ( + List(WEB_Session_Field_No_Var) fields + )= + var(map((WEB_Session_Field_No_Var field) |-> session_field(field.field_name, field.field_type, var(field.field_datum)), fields)) +. + +define List(WEB_Session_Field_No_Var) + to_WEB_Session_Field_No_Var + ( + List(WEB_Session_Field) fields + )= + map((WEB_Session_Field field) |-> session_field(field.field_name, field.field_type, *field.field_datum), fields) +. + +public define WEB_Session + to_WEB_Session + ( + WEB_Session_No_Var _session + )= + since _session is web_session(language, fields, web_request, previous_web_request), + web_session(language, to_WEB_Session_Field(fields), web_request, previous_web_request) +. + +public define WEB_Session_No_Var + to_WEB_Session_No_Var + ( + WEB_Session _session + )= + since _session is web_session(language, fields, web_request, previous_web_request), + web_session(language, to_WEB_Session_Field_No_Var(*fields), web_request, previous_web_request) +. + +public define Maybe(WEB_Session_Field_Datum) + get_field + ( + List(WEB_Session_Field) fields, + WEB_Session_Field_Type _field_type, + String _field_name + ) = + if fields is + { + [] then failure, + [h . t] then + if h.field_name = _field_name & h.field_type = _field_type then + success(*h.field_datum) + else + get_field(t, _field_type, _field_name) + } +. + /******** ANY functions ***************/ + + +define List(WEB_Session_Field) + _remove_any + ( + List(WEB_Session_Field) fields, + WEB_Session_Field_Type _field_type, + String _field_name + )= + if fields is + { + [] then [], + [h . t] then + if h.field_name = _field_name & h.field_type = _field_type then + _remove_any(t, _field_type, _field_name) + else + [ h. _remove_any(t, _field_type, _field_name) ] + } +. + +define One + remove_any + ( + Var(List(WEB_Session_Field)) fields, + WEB_Session_Field_Type _field_type, + String _field_name + )= + fields <- _remove_any(*fields, _field_type, _field_name) +. + +define One + replace_any + ( + List(WEB_Session_Field) fields, + WEB_Session_Field_Type _field_type, + String _field_name, + WEB_Session_Field_Datum _field_value, + Var(List(WEB_Session_Field)) fields_org, + )= + if fields is + { + [] then fields_org <- [session_field(_field_name, _field_type, var(_field_value)) . *fields_org], + [h . t] then + if h.field_name = _field_name & h.field_type = _field_type then + h.field_datum <- _field_value + else + replace_any(t, _field_type, _field_name, _field_value, fields_org) + } +. + + +define One + replace_any + ( + Var(List(WEB_Session_Field)) fields, + WEB_Session_Field_Type _field_type, + String _field_name, + WEB_Session_Field_Datum _field_value + )= + replace_any(*fields, _field_type, _field_name, _field_value, fields) +. + + /*************** String *****************/ + + Maybe(String) get_String(fields, _field_name) + String get_String(fiels, _field_name, default_value) + +public define Maybe(String) + get_String + ( + Var(List(WEB_Session_Field)) fields, + String _field_name + ) = + if get_field(*fields, string_t, _field_name) is + { + failure then failure, + success(datum) then + if datum is string(value) then + success(value) + else + failure + } +. + +public define String + get_String + ( + Var(List(WEB_Session_Field)) fields, + String _field_name, + String default_value + ) = + if get_String(fields, _field_name) is + { + failure then default_value + success(value) then value + }. + +public define One + put_String + ( + Var(List(WEB_Session_Field)) fields, + String _field_name, + String _field_value + )= + fields <- [session_field(_field_name, string_t, var(string(_field_value))) . *fields] +. + +public define One + replace_String + ( + Var(List(WEB_Session_Field)) fields, + String _field_name, + String _field_value + )= + replace_any(fields, string_t, _field_name, string(_field_value)) +. + + +public define One + remove_String + ( + Var(List(WEB_Session_Field)) fields, + String _field_name + )= + remove_any(fields, string_t, _field_name) +. + + /*************** Bool *****************/ + + Maybe(Bool) get_Bool(fields, _field_name) + Bool get_Bool(fiels, _field_name, default_value) + +public define Maybe(Bool) + get_Bool + ( + List(WEB_Session_Field) fields, + String _field_name + ) = + if get_field(fields, bool_t, _field_name) is + { + failure then failure, + success(datum) then + if datum is bool(value) then + success(value) + else + failure + } +. + +public define Bool + get_Bool + ( + List(WEB_Session_Field) fields, + String _field_name, + Bool default_value + ) = + if get_Bool(fields, _field_name) is + { + failure then default_value + success(value) then value + }. + +public define One + put_Bool + ( + Var(List(WEB_Session_Field)) fields, + String _field_name, + Bool _field_value + )= + fields <- [session_field(_field_name, bool_t, var(bool(_field_value))) . *fields] +. + +public define One + replace_Bool + ( + Var(List(WEB_Session_Field)) fields, + String _field_name, + Bool _field_value + )= + replace_any(fields, bool_t, _field_name, bool(_field_value)) +. + + +public define One + remove_Bool + ( + Var(List(WEB_Session_Field)) fields, + String _field_name + )= + remove_any(fields, bool_t, _field_name) +. + + /*************** Int *****************/ + + Maybe(String) get_Int(fields, _field_name) + String get_Int(fiels, _field_name, default_value) + +public define Maybe(Int) + get_Int + ( + List(WEB_Session_Field) fields, + String _field_name + ) = + if get_field(fields, int_t, _field_name) is + { + failure then failure, + success(datum) then + if datum is int(value) then + success(value) + else + failure + } +. + +public define Int + get_Int + ( + List(WEB_Session_Field) fields, + String _field_name, + Int default_value + ) = + if get_Int(fields, _field_name) is + { + failure then default_value + success(value) then value + }. + +public define One + put_Int + ( + Var(List(WEB_Session_Field)) fields, + String _field_name, + Int _field_value + )= + fields <- [session_field(_field_name, int_t, var(int(_field_value))) . *fields] +. + +public define One + replace_Int + ( + Var(List(WEB_Session_Field)) fields, + String _field_name, + Int _field_value + )= + replace_any(fields, int_t, _field_name, int(_field_value)) +. + + +public define One + remove_Int + ( + Var(List(WEB_Session_Field)) fields, + String _field_name + )= + remove_any(fields, int_t, _field_name) +. + + /*************** Message *****************/ + + Maybe(String) get_Message(fields, _field_name) + String get_Message(fiels, _field_name, default_value) + +public define Maybe(Message) + get_Message + ( + Var(List(WEB_Session_Field)) fields, + String _field_name + ) = + if get_field(*fields, message_t, _field_name) is + { + failure then failure, + success(datum) then + if datum is message(value) then + success(value) + else + failure + } +. + +public define Message + get_Message + ( + Var(List(WEB_Session_Field)) fields, + String _field_name, + Message default_value + ) = + if get_Message(fields, _field_name) is + { + failure then default_value + success(value) then value + }. + +public define One + put_Message + ( + Var(List(WEB_Session_Field)) fields, + String _field_name, + Message _field_value + )= + fields <- [session_field(_field_name, message_t, var(message(_field_value))) . *fields] +. + +public define One + replace_Message + ( + Var(List(WEB_Session_Field)) fields, + String _field_name, + Message _field_value + )= + replace_any(fields, message_t, _field_name, message(_field_value)) +. + +public define One + remove_Message + ( + Var(List(WEB_Session_Field)) fields, + String _field_name + )= + remove_any(fields, message_t, _field_name) +. + + /*************** ByteArray *****************/ + + Maybe(ByteArray) get_ByteArray(fields, _field_name) + ByteArray get_ByteArray(fiels, _field_name, default_value) + +public define Maybe(ByteArray) + get_ByteArray + ( + List(WEB_Session_Field) fields, + String _field_name + ) = + if get_field(fields, byte_array_t, _field_name) is + { + failure then failure, + success(datum) then + if datum is byte_array(value) then + success(value) + else + failure + } +. + +public define ByteArray + get_ByteArray + ( + List(WEB_Session_Field) fields, + String _field_name, + ByteArray default_value + ) = + if get_ByteArray(fields, _field_name) is + { + failure then default_value + success(value) then value + }. + +public define One + put_ByteArray + ( + Var(List(WEB_Session_Field)) fields, + String _field_name, + ByteArray _field_value + )= + fields <- [session_field(_field_name, byte_array_t, var(byte_array(_field_value))) . *fields] +. + +public define One + replace_ByteArray + ( + Var(List(WEB_Session_Field)) fields, + String _field_name, + ByteArray _field_value + )= + replace_any(fields, byte_array_t, _field_name, byte_array(_field_value)) +. + +public define One + remove_ByteArray + ( + Var(List(WEB_Session_Field)) fields, + String _field_name + )= + remove_any(fields, byte_array_t, _field_name) +. + + /*************** Float *****************/ + + Maybe(Float) get_Float(fields, _field_name) + Float get_Float(fiels, _field_name, default_value) + +public define Maybe(Float) + get_Float + ( + List(WEB_Session_Field) fields, + String _field_name + ) = + if get_field(fields, float_t, _field_name) is + { + failure then failure, + success(datum) then + if datum is float(value) then + success(value) + else + failure + } +. + +public define Float + get_Float + ( + List(WEB_Session_Field) fields, + String _field_name, + Float default_value + ) = + if get_Float(fields, _field_name) is + { + failure then default_value + success(value) then value + }. + +public define One + put_Float + ( + Var(List(WEB_Session_Field)) fields, + String _field_name, + Float _field_value + )= + fields <- [session_field(_field_name, float_t, var(float(_field_value))) . *fields] +. + +public define One + replace_Float + ( + Var(List(WEB_Session_Field)) fields, + String _field_name, + Float _field_value + )= + replace_any(fields, float_t, _field_name, float(_field_value)) +. + +public define One + remove_Float + ( + Var(List(WEB_Session_Field)) fields, + String _field_name + )= + remove_any(fields, float_t, _field_name) +. + + /*************** Word128 *****************/ + + Maybe(Word128) get_Word128t(fields, _field_name) + Word128 get_Word128(fields, _field_name, default_value) + +public define Maybe(Word128) + get_Word128 + ( + List(WEB_Session_Field) fields, + String _field_name + ) = + if get_field(fields, word128_t, _field_name) is + { + failure then failure, + success(datum) then + if datum is word128(value) then + success(value) + else + failure + } +. + +public define Word128 + get_Word128 + ( + List(WEB_Session_Field) fields, + String _field_name, + Word128 default_value + ) = + if get_Word128(fields, _field_name) is + { + failure then default_value + success(value) then value + }. + +public define One + put_Word128 + ( + Var(List(WEB_Session_Field)) fields, + String _field_name, + Word128 _field_value + )= + fields <- [session_field(_field_name, word128_t, var(word128(_field_value))) . *fields] +. + +public define One + replace_Word128 + ( + Var(List(WEB_Session_Field)) fields, + String _field_name, + Word128 _field_value + )= + replace_any(fields, word128_t, _field_name, word128(_field_value)) +. + +public define One + remove_Word128 + ( + Var(List(WEB_Session_Field)) fields, + String _field_name + )= + remove_any(fields, word128_t, _field_name) +. + + /*************** Word64 *****************/ + + Maybe(Word64) get_Word64(fields, _field_name) + Word64 get_Word64(fields, _field_name, default_value) + +public define Maybe(Word64) + get_Word64 + ( + List(WEB_Session_Field) fields, + String _field_name + ) = + if get_field(fields, word64_t, _field_name) is + { + failure then failure, + success(datum) then + if datum is word64(value) then + success(value) + else + failure + } +. + +public define Word64 + get_Word64 + ( + List(WEB_Session_Field) fields, + String _field_name, + Word64 default_value + ) = + if get_Word64(fields, _field_name) is + { + failure then default_value + success(value) then value + }. + +public define One + put_Word64 + ( + Var(List(WEB_Session_Field)) fields, + String _field_name, + Word64 _field_value + )= + fields <- [session_field(_field_name, word64_t, var(word64(_field_value))) . *fields] +. + +public define One + replace_Word64 + ( + Var(List(WEB_Session_Field)) fields, + String _field_name, + Word64 _field_value + )= + replace_any(fields, word64_t, _field_name, word64(_field_value)) +. + +public define One + remove_Word64 + ( + Var(List(WEB_Session_Field)) fields, + String _field_name + )= + remove_any(fields, word64_t, _field_name) +. + + /*************** Word32 *****************/ + + Maybe(Word32) get_Word32(fields, _field_name) + Word32 get_Word32(fields, _field_name, default_value) + +public define Maybe(Word32) + get_Word32 + ( + List(WEB_Session_Field) fields, + String _field_name + ) = + if get_field(fields, word32_t, _field_name) is + { + failure then failure, + success(datum) then + if datum is word32(value) then + success(value) + else + failure + } +. + +public define Word32 + get_Word32 + ( + List(WEB_Session_Field) fields, + String _field_name, + Word32 default_value + ) = + if get_Word32(fields, _field_name) is + { + failure then default_value + success(value) then value + }. + +public define One + put_Word32 + ( + Var(List(WEB_Session_Field)) fields, + String _field_name, + Word32 _field_value + )= + fields <- [session_field(_field_name, word32_t, var(word32(_field_value))) . *fields] +. + +public define One + replace_Word32 + ( + Var(List(WEB_Session_Field)) fields, + String _field_name, + Word32 _field_value + )= + replace_any(fields, word32_t, _field_name, word32(_field_value)) +. + +public define One + remove_Word32 + ( + Var(List(WEB_Session_Field)) fields, + String _field_name + )= + remove_any(fields, word32_t, _field_name) +. + + /*************** Word16 *****************/ + + Maybe(Word16) get_Word16(fields, _field_name) + Word16 get_Word16(fields, _field_name, default_value) + +public define Maybe(Word16) + get_Word16 + ( + List(WEB_Session_Field) fields, + String _field_name + ) = + if get_field(fields, word16_t, _field_name) is + { + failure then failure, + success(datum) then + if datum is word16(value) then + success(value) + else + failure + } +. + +public define Word16 + get_Word16 + ( + List(WEB_Session_Field) fields, + String _field_name, + Word16 default_value + ) = + if get_Word16(fields, _field_name) is + { + failure then default_value + success(value) then value + }. + +public define One + put_Word16 + ( + Var(List(WEB_Session_Field)) fields, + String _field_name, + Word16 _field_value + )= + fields <- [session_field(_field_name, word16_t, var(word16(_field_value))) . *fields] +. + +public define One + replace_Word16 + ( + Var(List(WEB_Session_Field)) fields, + String _field_name, + Word16 _field_value + )= + replace_any(fields, word16_t, _field_name, word16(_field_value)) +. + +public define One + remove_Word16 + ( + Var(List(WEB_Session_Field)) fields, + String _field_name + )= + remove_any(fields, word16_t, _field_name) +. + + /*************** Word8 *****************/ + + Maybe(Word8) get_Word8(fields, _field_name) + Word8 get_Word8(fields, _field_name, default_value) + +public define Maybe(Word8) + get_Word8 + ( + List(WEB_Session_Field) fields, + String _field_name + ) = + if get_field(fields, word8_t, _field_name) is + { + failure then failure, + success(datum) then + if datum is word8(value) then + success(value) + else + failure + } +. + +public define Word8 + get_Word8 + ( + List(WEB_Session_Field) fields, + String _field_name, + Word8 default_value + ) = + if get_Word8(fields, _field_name) is + { + failure then default_value + success(value) then value + }. + +public define One + put_Word8 + ( + Var(List(WEB_Session_Field)) fields, + String _field_name, + Word8 _field_value + )= + fields <- [session_field(_field_name, word8_t, var(word8(_field_value))) . *fields] +. + +public define One + replace_Word8 + ( + Var(List(WEB_Session_Field)) fields, + String _field_name, + Word8 _field_value + )= + replace_any(fields, word8_t, _field_name, word8(_field_value)) +. + +public define One + remove_Word8 + ( + Var(List(WEB_Session_Field)) fields, + String _field_name + )= + remove_any(fields, word8_t, _field_name) +. + + /*************** Word4 *****************/ + + Maybe(Word4) get_Word4(fields, _field_name) + Word4 get_Word4(fields, _field_name, default_value) + +public define Maybe(Word4) + get_Word4 + ( + List(WEB_Session_Field) fields, + String _field_name + ) = + if get_field(fields, word4_t, _field_name) is + { + failure then failure, + success(datum) then + if datum is word4(value) then + success(value) + else + failure + } +. + +public define Word4 + get_Word4 + ( + List(WEB_Session_Field) fields, + String _field_name, + Word4 default_value + ) = + if get_Word4(fields, _field_name) is + { + failure then default_value + success(value) then value + }. + +public define One + put_Word4 + ( + Var(List(WEB_Session_Field)) fields, + String _field_name, + Word4 _field_value + )= + fields <- [session_field(_field_name, word4_t, var(word4(_field_value))) . *fields] +. + +public define One + replace_Word4 + ( + Var(List(WEB_Session_Field)) fields, + String _field_name, + Word4 _field_value + )= + replace_any(fields, word4_t, _field_name, word4(_field_value)) +. + +public define One + remove_Word4 + ( + Var(List(WEB_Session_Field)) fields, + String _field_name + )= + remove_any(fields, word4_t, _field_name) +. + +public define String + dump_WEB_Session_Field + ( + WEB_Session_Field _field + )= + with name = "Name = ["+_field.field_name+"]", + if *_field.field_datum is + { + string(_string) then name+", Type = String, Value = ["+_string+"]", + bool(_bool) then name+", Type = Bool, Value = ["+to_String(_bool)+"]", + int(_int) then name+", Type = Int, Value = ["+_int+"]", + message(_message) then name+", Type = Message, Value = ["+dump(_message)+"]", + byte_array(_byte_array) then name+", Type = ByteArray", + float(_float) then name+", Type = Float, Value = ["+float_to_string(_float, 10)+"]", + word128(_word128) then name+", Type = Word128, Value = ["+to_decimal(_word128)+"]", + word64(_word64) then name+", Type = Word64, Value = ["+to_decimal(_word64)+"]", + word32(_word32) then name+", Type = Word32, Value = ["+to_decimal(_word32)+"]", + word16(_word16) then name+", Type = Word16, Value = ["+to_decimal(_word16)+"]", + word8(_word8) then name+", Type = Word8, Value = ["+to_decimal(_word8)+"]", + word4(_word4) then name+", Type = Word4, Value = ["+to_decimal(_word4)+"]", + } +. + +public define String + dump_WEB_Session_Field_list + ( + List(WEB_Session_Field) _fields + )= + join("\n", map((WEB_Session_Field _field) |-> dump_WEB_Session_Field(_field), _fields)) +. + + +public define String + dump_WEB_Session_Fields + ( + List(WEB_Session_Field) _fields + )= + "\n"+ + "-- BEGIN Fields of Session:---------------- \n"+ + join("\n", map((WEB_Session_Field _field) |-> dump_WEB_Session_Field(_field), _fields))+ + "\n-- END Fields of Session:---------------- \n" +. + +public define String + dump_WEB_Session_Fields + ( + Var(List(WEB_Session_Field)) _fields + )= + dump_WEB_Session_Fields(*_fields) +. + + *---------------------- DUMP ------------------* + + String language, + List(WEB_Session_Field) fields, + WEB_Request web_request, + WEB_Request previous_web_request + +public define String + dump + ( + WEB_Session _session + )= + since _session is web_session(language, fields, web_request, previous_web_request), + "WEB Session Dump: \n"+ + "----------------- \n"+ + "Language : ["+language+"]\n\n"+ + dump_WEB_Session_Fields(*fields)+ + "-----------------------------------------------------------------------------\n"+ + "Current WEB REQUEST:\n"+ + "-----------------------------------------------------------------------------\n"+ + "http_info:\n"+ + dump_http_info(web_request.http_info)+"\n"+ + "web arguments:"+ + dump_web_arg_values(web_request.lwa)+"\n\n"+ + "-----------------------------------------------------------------------------\n"+ + "Previous WEB REQUEST:\n"+ + "-----------------------------------------------------------------------------\n"+ + "is https "+to_String(previous_web_request.is_https)+"\n"+ + "http_info:\n"+ + dump_http_info(previous_web_request.http_info)+"\n"+ + "web arguments:"+ + dump_web_arg_values(previous_web_request.lwa)+"\n" + +. diff --git a/web/jQuery/CXM_jquery_button.anubis b/web/jQuery/CXM_jquery_button.anubis index 118379b..db5c545 100644 --- a/web/jQuery/CXM_jquery_button.anubis +++ b/web/jQuery/CXM_jquery_button.anubis @@ -287,7 +287,7 @@ public define HTML_Partial_Content cancel: " + to_JS_String(dlg_cancel) + "};", button_name = uid, - _actioner = jQuery_actioner(same, jqscript, "CalexiumToolBox.make_confirm_dialog(this, " /*+ to_js_string("/?a=" + url + format_extra_operands(extra_ops))+*/ + to_JS_String(jquery_button_get_onclick_action(actioner)) + ");"), + _actioner = jQuery_actioner(same, jqscript("CalexiumToolBox.make_confirm_dialog(this, " /*+ to_js_string("/?a=" + url + format_extra_operands(extra_ops))+*/ + to_JS_String(jquery_button_get_onclick_action(actioner)) + ");")), partial_content([js(js_file("js/cxm/cxm.js")), js_inline(jquery_ready(js_data))],sequence([ partial(jquery_button(jQuery_button(button, uid, button_name, button_label, _actioner, jq_icon_none, jq_icon_none))) @@ -316,7 +316,7 @@ public define HTML_Partial_Content cancel: " + to_JS_String(dlg_cancel) + "};", _button_name = uid, - _actioner = jQuery_actioner(same, jqscript, "CalexiumToolBox.make_confirm_dialog(this, " + to_JS_String(jquery_button_get_onclick_action(actioner)) +");"), + _actioner = jQuery_actioner(same, jqscript("CalexiumToolBox.make_confirm_dialog(this, " + to_JS_String(jquery_button_get_onclick_action(actioner)) +");")), partial_content([js(js_file("js/cxm/cxm.js")), js_inline(jquery_ready(js_data))],sequence([ partial(jquery_button(jquery_img_button(img_url, button_label, _button_name, _actioner, orientation))) @@ -328,13 +328,13 @@ public define HTML_Partial_Content String label, //translated label of the button String form_id // )= - jquery_button(jquery_img_button(icn16_check, label, "", jQuery_actioner(same, jqform, form_id), left)). + jquery_button(jquery_img_button(icn16_check, label, "", jQuery_actioner(same, jqform(form_id)), left)). public define HTML_Partial_Content img_button ( String icon, String label, //translated label of the button - String action + WEB_Action_Name action )= - jquery_button(jquery_img_button(icon, label, "", jQuery_actioner(same, jqlink, action), left)). + jquery_button(jquery_img_button(icon, label, "", jQuery_actioner(same, jqlink(action)), left)). diff --git a/web/jQuery/CXM_jquery_dialog.anubis b/web/jQuery/CXM_jquery_dialog.anubis index c1e97df..90e23df 100644 --- a/web/jQuery/CXM_jquery_dialog.anubis +++ b/web/jQuery/CXM_jquery_dialog.anubis @@ -16,7 +16,7 @@ public type JQuery_dialog_id: public type JQuery_dialog: p_content(HTML_Partial_Content content), off_form(HTML_Off_Form o_form), - ajax(String url). + ajax(WEB_Action_Name url). public define HTML_Partial_Content @@ -43,12 +43,13 @@ public define HTML_Partial_Content if content is { - p_content(pc) then + p_content(pc) then if pc is partial_content(tags, html) then partial_content( [js . tags ], html), //html code of the dialog off_form(html) then partial_content( [js], html), //html code of the dialog - ajax(url) then + ajax(_url) then + with url = format_web_action_name(_url), partial_content( [js], div_empty([id(dlg_id), attr("ajax_url",url)])) }. diff --git a/web/widgets/left_menu.anubis b/web/widgets/left_menu.anubis index 5155c1a..4831615 100644 --- a/web/widgets/left_menu.anubis +++ b/web/widgets/left_menu.anubis @@ -12,10 +12,10 @@ read system/string.anubis public type Left_Menu_Entry: left_menu_entry( //MENU entry hence no selectable - String entry_id, //it's also use as icon prefix - List(String) classes, //additional classes if need (for disabling entry, change background color, etc.) - String action, //action (url to apply when click - String text, //text to show + String entry_id, //it's also use as icon prefix + List(String) classes, //additional classes if need (for disabling entry, change background color, etc.) + WEB_Action_Name action, //action (url to apply when click + String text, //text to show List((String, String)) extra //extra web arguments to send when click ), title( //TITLE entry hence no selectable @@ -33,9 +33,9 @@ public type Left_Menu: public define Left_Menu_Entry left_menu_entry ( - String entry_id, - String action, - String text + String entry_id, + WEB_Action_Name action, + String text )= left_menu_entry(entry_id, [], action, text, []) . @@ -43,9 +43,9 @@ public define Left_Menu_Entry public define Left_Menu_Entry left_menu_entry ( - String entry_id, //it's also use as icon prefix - String action, //action (url to apply when click - String text, //text to show + String entry_id, //it's also use as icon prefix + WEB_Action_Name action, //action (url to apply when click + String text, //text to show List((String, String)) extra //extra web arguments to send when click )= left_menu_entry(entry_id, [], action, text, extra) -- libgit2 0.21.4