diff --git a/database/db_types.anubis b/database/db_types.anubis
index e2722c1..0bb1f9f 100644
--- a/database/db_types.anubis
+++ b/database/db_types.anubis
@@ -186,7 +186,16 @@ public define DB_datetime
now
=
db_datetime(_Int_to_ISO_8601_datetime(now)).
-
+
+public define DB_date
+ now
+ =
+ db_date(_Int_to_ISO_8601_date(now)).
+
+public define DB_time
+ now
+ =
+ db_time(_Int_to_ISO_8601_time(now)).
public define DB_time
get_dummy_DB_time
diff --git a/database/db_utils.anubis b/database/db_utils.anubis
index b1e919c..ffa9664 100644
--- a/database/db_utils.anubis
+++ b/database/db_utils.anubis
@@ -268,7 +268,14 @@ public define List(Int)
with s = (Int)db_integer(explorer)(0),
db_get_integer_list(table_cursor, [s . so_far])
}.
-
+
+public define List(Int)
+ db_get_integer_list
+ (
+ One -> SQLite3Row table_cursor
+ ) =
+ db_get_integer_list(table_cursor, []).
+
public define List(Int)
db_get_integer_list
(
@@ -284,7 +291,14 @@ public define List(Int)
db_get_integer_list(table_cursor, [s . so_far])
}.
-
+public define List(Int)
+ db_get_integer_list
+ (
+ One -> DbRow table_cursor,
+ ) =
+ db_get_integer_list(table_cursor, []).
+
+
Help to construct clause and a list of bind according to list of SQLite3_update_field.
This is useful when we want to construct a SQL query with only needs fields.
diff --git a/web/CXM_making_a_web_site.anubis b/web/CXM_making_a_web_site.anubis
index 5bdc102..cd6dfb6 100644
--- a/web/CXM_making_a_web_site.anubis
+++ b/web/CXM_making_a_web_site.anubis
@@ -302,7 +302,7 @@ public type HTTP_Answer:...
taken from the data bases.
-
+public type HTML_Partial_Content:...
@@ -332,9 +332,57 @@ public type WEB_Controller_Result:
ajax(
WEB_Session session, //modified session
HTTP_Answer http_answer //http answer
- )
+ ),
+ ajax(
+ HTML_Partial_Content content,
+ String additional_script
+ ),
+ ajax(
+ WEB_Session session, //modified session
+ HTML_Partial_Content content,
+ String additional_script
+ ),
+ ajax(
+ Printable_tree content,
+ String additional_script
+ ),
+ ajax(
+ WEB_Session session, //modified session
+ Printable_tree content,
+ String additional_script
+ )
.
+public define WEB_Controller_Result
+ ajax
+ (
+ HTML_Partial_Content content
+ )=
+ ajax(content, "").
+
+public define WEB_Controller_Result
+ ajax
+ (
+ WEB_Session session, //modified session
+ HTML_Partial_Content content
+ )=
+ ajax(session, content, "").
+
+public define WEB_Controller_Result
+ ajax
+ (
+ Printable_tree content
+ )=
+ ajax(content, "").
+
+public define WEB_Controller_Result
+ ajax
+ (
+ WEB_Session session, //modified session
+ Printable_tree content
+ )=
+ ajax(session, content, "").
+
public type WEB_Action_Allowed_Protocol:
http,
https,
@@ -1669,7 +1717,7 @@ public type HTML_Off_Form:
List(HTML_In_Form) content),
in_form (HTML_Id form_id, HTML_In_Form content),
div (List(CoreAttrs), List(HTML_Off_Form) content),
- div (List(CoreAttrs), HTML_Partial_Content p_content),
+ div (List(CoreAttrs), List(HTML_Partial_Content) p_content),
div_empty (List(CoreAttrs)),
iframe (List(CoreAttrs),
List(CSS_Style) /*styles*/,
@@ -1977,6 +2025,30 @@ public define HTML_Off_Form
div([], elements)
.
+public define HTML_Off_Form
+ div
+ (
+ HTML_Partial_Content element
+ )=
+ div([], [element])
+.
+
+public define HTML_Off_Form
+ div
+ (
+ List(CoreAttrs) attrs,
+ HTML_Partial_Content element
+ )=
+ div(attrs, [element])
+.
+
+public define HTML_Off_Form
+ div
+ (
+ List(HTML_Partial_Content) elements
+ )=
+ div([], elements)
+.
public define HTML_Off_Form
li
@@ -3354,18 +3426,22 @@ define Maybe(WEB_Controller)
failure,
[h . t] then
if h.name = controller_name then
- println("Controller ["+controller_name+"] found");
+ //println("Controller ["+controller_name+"] found");
success(h)
else
get_controller(controller_name, t)
}
.
+public define JsonValue to_html_ajax_content(Printable_tree content_HTML, String additional_script).
+public define JsonValue to_html_ajax_content(HTML_Partial_Content content_HTML, CommonInfo cinfo, String additional_script).
+
define (Maybe(WEB_Session), HTTP_Answer)
apply_controller_action
(
WEB_Controller controller,
List(WEB_Controller) controllers,
+ CommonInfo cinfo,
WEB_Session _session,
Maybe(String) _mb_action_name,
(HTTP_Info,
@@ -3388,7 +3464,7 @@ define (Maybe(WEB_Session), HTTP_Answer)
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(new_controller) then apply_controller_action(new_controller, controllers, cinfo, new_session, failure, initial_session),
},
success(action_name) then
println("ACTION_NAME ["+action_name+"]");
@@ -3400,7 +3476,7 @@ define (Maybe(WEB_Session), HTTP_Answer)
if get_controller(get_String(new_session.web_request.lwa, "aws_controller", "root"), controllers) is
{
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),
+ success(new_controller) then apply_controller_action(new_controller, controllers, cinfo, new_session, failure, initial_session),
},
redirect(new_session, r_controller_name, r_action_name) then
@@ -3408,7 +3484,7 @@ define (Maybe(WEB_Session), HTTP_Answer)
{
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),
+ apply_controller_action(new_controller, controllers, cinfo, new_session, success(r_action_name), initial_session),
},
redirect_to_previous then
@@ -3417,7 +3493,7 @@ define (Maybe(WEB_Session), HTTP_Answer)
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), failure, initial_session),
+ apply_controller_action(new_controller, controllers, cinfo, web_session(lang, entries, previous, previous), failure, initial_session),
},
redirect_to_previous(entries) then
if get_controller(get_String(_session.previous_web_request.lwa, "aws_controller", "root"), controllers) is
@@ -3425,11 +3501,17 @@ define (Maybe(WEB_Session), HTTP_Answer)
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, _, _, previous),
- apply_controller_action(new_controller, controllers, web_session(lang, entries, previous, previous), failure, initial_session),
+ apply_controller_action(new_controller, controllers, cinfo, web_session(lang, entries, previous, previous), failure, initial_session),
},
- ajax(answer) then (failure, answer),
+ ajax(answer) then (failure, answer),
//ajax with modified session that must be saved
- ajax(session, answer) then (success(session), answer),
+ ajax(session, answer) then (success(session), answer),
+
+ ajax(content, additional_script) then (failure, json(http_ok, to_html_ajax_content(content, cinfo, additional_script))),
+ ajax(session, content, additional_script) then (success(session), json(http_ok, to_html_ajax_content(content, cinfo, additional_script))),
+ ajax(content, additional_script) then (failure, json(http_ok, to_html_ajax_content(content, additional_script))),
+ ajax(session, content, additional_script) then (success(session), json(http_ok, to_html_ajax_content(content, additional_script))),
+
}
}
.
@@ -3463,7 +3545,7 @@ public define Web_Site
)=
//call the initialization function
init(unique);
-
+
//
// make required directories (if needed)
@@ -3471,7 +3553,8 @@ public define Web_Site
with //web_sites_directory = (String) make_directory(my_anubis_directory+"/web_sites"),
base_directory = (String) make_directory(site_directory),
// state_directory = make_directory(site_directory+"/states"),
- forget((String)make_directory(site_directory+"/public"));
+ forget((String)make_directory(site_directory+"/public"));
+
//
// construct tool functions
// TODO 'make_separate_web_args_function' must retrieve state_cookies before parsing web_args if using_state_cookies is true
@@ -3492,7 +3575,7 @@ public define Web_Site
//println("host_name "+host_name);
//println(dump_http_info(http_info));
println(dump_web_arg_values(_lwa));
-
+ with cinfo = info(host_name, http_port, https_port, site_directory, secret),
//retrieve the previous session and determine the new one
with current_session = if retrieve_session(http_info, state_directory, website_name) is
@@ -3519,7 +3602,7 @@ public define Web_Site
(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),
+ apply_controller_action(new_controller, *web_controllers, cinfo, current_session, failure, initial_session),
}
is (mb_new_session, http_answer),
@@ -3534,7 +3617,7 @@ public define Web_Site
},
//formatting and send http answer because this is the last function
- format(info(host_name, http_port, https_port, site_directory, secret),
+ format(cinfo,
//state_name,
additional_headers(mb_new_session) + cookie_headers,
http_answer,
@@ -5428,9 +5511,9 @@ define Printable_tree
format_label(label, id)],
check_box(options, label, id, n, v, c) then
[ format_label(label, id),
- ""]
+ ""]
check_box_r(options, label, id, n, v, c) then
- [ "",
+ [ "",
format_label(label, id)]
div(options, e) then
format(cinfo,ic_v,any_div(options, e),format_element,is_https, action_count, head_tags),
@@ -5659,9 +5742,9 @@ define Printable_tree
div(options, e) then
format(cinfo, ic_v, any_div(options, e), format_element, is_https, action_count, head_tags),
div(options, p_content) then
- if p_content is partial_content(tags, html_elements) then
- head_tags <- *head_tags +tags;
- format(cinfo, ic_v, any_div(options, [html_elements]), format_element, is_https, action_count, head_tags),
+ with html_elements = map((HTML_Partial_Content pc) |-> since pc is partial_content(tags, html_elem), head_tags <- *head_tags +tags; html_elem, p_content),
+
+ format(cinfo, ic_v, any_div(options, html_elements), format_element, is_https, action_count, head_tags),
div_empty(options) then
format(cinfo, ic_v, any_div_empty(options), format_element, is_https, action_count, head_tags),
iframe(options, css_styles, css_files, js_files, body) then
@@ -5898,13 +5981,6 @@ public define HTML_ajax_content
html_ajax_content(to_String(content), script, js_file, css_file).
-public define HTML_ajax_content
- to_html_ajax_content
- (
- HTML_Partial_Content content_HTML,
- CommonInfo cinfo
- )= to_html_ajax_content(partial(content_HTML), cinfo).
-
public define JsonValue
to_html_ajax_content
(
@@ -5924,6 +6000,13 @@ public define JsonValue
public define JsonValue
to_html_ajax_content
(
+ HTML_Partial_Content content_HTML,
+ CommonInfo cinfo
+ )= to_html_ajax_content(content_HTML, cinfo, "").
+
+public define JsonValue
+ to_html_ajax_content
+ (
Printable_tree content_HTML,
String additional_script
)=
diff --git a/web/CXM_web_arg_utils.anubis b/web/CXM_web_arg_utils.anubis
index 2346816..af3dd34 100644
--- a/web/CXM_web_arg_utils.anubis
+++ b/web/CXM_web_arg_utils.anubis
@@ -157,8 +157,13 @@ public define Maybe(Bool)
) =
if web_arg_value(lwa, arg_name) is
{
- not_found then failure,
- found(value) then success(to_Bool(value))
+ not_found then
+ if web_arg_value(lwa, "~"+arg_name) is
+ {
+ not_found then failure,
+ found(_) then success(false)
+ },
+ found(_) then success(true)
}.
public define Bool
diff --git a/web/widgets/specialized_elements.anubis b/web/widgets/specialized_elements.anubis
index 8733820..d640b70 100644
--- a/web/widgets/specialized_elements.anubis
+++ b/web/widgets/specialized_elements.anubis
@@ -12,20 +12,29 @@ public define HTML_Off_Form
phone
(
List(CoreAttrs) attrs,
- String phone_number
+ String phone_number,
+ Bool image_only
)=
if phone_number = "" then empty
else
with _attrs = [data("phone-number", phone_number), event(onclick, "hk_phone_call(this)"), class("phone_click") . attrs],
div([
image(_attrs, "/icons/16x16/phone.png"),
- text(_attrs, phone_number)
+ if image_only then empty else
+ text(_attrs, phone_number)
])
.
public define HTML_Off_Form
phone
(
+ List(CoreAttrs) attrs,
+ String phone_number
+ )= phone(attrs, phone_number, false).
+
+public define HTML_Off_Form
+ phone
+ (
String phone_number
)=
phone([], phone_number)
--
libgit2 0.21.4