From d9e8ff9065a2ab0d019de4632ee1a52387d92641 Mon Sep 17 00:00:00 2001 From: totoro Date: Sat, 17 Aug 2019 10:46:45 +0900 Subject: [PATCH] add alternative "empty" for HTML_Row add helper for HTML "a" with list of (HTML_Off_Form) --- web/CXM_making_a_web_site.anubis | 85 +++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------ web/types/making_a_web_site.anubis | 17 +++++++++-------- 2 files changed, 58 insertions(+), 44 deletions(-) diff --git a/web/CXM_making_a_web_site.anubis b/web/CXM_making_a_web_site.anubis index 242dc7f..c2bb577 100644 --- a/web/CXM_making_a_web_site.anubis +++ b/web/CXM_making_a_web_site.anubis @@ -488,7 +488,7 @@ define WEB_Session -> String // the function constructed returns the name of session_name = s_var.session_id, //println("make_save_state_function " + state_directory+"/s"+state_name); if save(to_be_saved,state_directory+"/"+session_name) is ok then - logger(logInfo, "----- session ["+session_name+"] saved"+dump_WEB_Session_Fields(*s_var.fields)); + //logger(logInfo, "----- session ["+session_name+"] saved"+dump_WEB_Session_Fields(*s_var.fields)); session_name else logger(logError, ("Cannot create session file in '"+state_directory+"'.\n")); @@ -1556,6 +1556,7 @@ public define HTML_Off_Form a(List(CoreAttrs) attrs, A_href _href, A_target _tar public define HTML_Off_Form a(CoreAttrs attr, A_href _href, A_target _target, HTML_Off_Form content) = a([attr], _href, _target, [content]). public define HTML_Off_Form a(A_href _href, A_target _target, HTML_Off_Form content) = a([], _href, _target, [content]). public define HTML_Off_Form a(A_href _href, A_target _target, List(HTML_Off_Form) content) = a([], _href, _target, content). +public define HTML_Off_Form a(CoreAttrs attr, A_href _href, A_target _target, List(HTML_Off_Form) content) = a([attr], _href, _target, content). //
public define HTML_Off_Form article(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("article", attrs, content). @@ -3295,10 +3296,10 @@ define WEB_Page_Renderer default_page_renderer, [h . t] then if h.name = renderer_name then - println("renderer_name ["+renderer_name+"] found"); + //println("renderer_name ["+renderer_name+"] found"); h else - println("renderer_name "+renderer_name+" not matching"); + //println("renderer_name "+renderer_name+" not matching"); get_page_renderer(renderer_name, t, logger) } . @@ -3363,7 +3364,7 @@ define (Maybe(WEB_Session), HTTP_Answer) success(new_controller) then apply_controller_action(new_controller, plugins, controllers, _current_page_renderer, page_renderers, cinfo, new_session, failure, initial_session, logger), }, success(action_name) then - logger(logInfo, "ACTION_NAME ["+action_name+"] from IP "+get_String(_session.fields, "IP", "")); + //logger(logInfo, "ACTION_NAME ["+action_name+"] from IP "+get_String(_session.fields, "IP", "")); if apply_action(_session, action_name, *controller.controller_actions) is { http_answer(session, answer) then @@ -3503,7 +3504,7 @@ public define Web_Site Bool is_https) |-> //(Printable_tree) logger(logTrace,"host_name "+host_name); - logger(logTrace,dump_http_info(http_info)); + logger(logTrace, dump_http_info(http_info)); logger(logTrace, dump_web_arg_values(_lwa)); with cinfo = info(host_name, http_port, https_port, site_directory, secret), @@ -3518,12 +3519,12 @@ public define Web_Site logger(logInfo, "previous out_of_date"); //expired_session(previous_session, http_info, var(_lwa), is_https), since previous_session is web_session(id, lang, entries, previous, _, draw), - replace_String(entries, "IP", get_String(_lwa, "x-forwarded-for", ip_addr_to_string(http_info.ip_address))); + replace_String(entries, "IP", http_header_value(http_info.http_headers, "x-forwarded-for", ip_addr_to_string(http_info.ip_address))); web_session(id, lang, entries, web_request(http_info, var(_lwa), is_https), previous, draw) still_valid(previous_session) then since previous_session is web_session(id, lang, entries, previous, _, draw), - replace_String(entries, "IP", get_String(_lwa, "x-forwarded-for", ip_addr_to_string(http_info.ip_address))); + replace_String(entries, "IP", http_header_value(http_info.http_headers, "x-forwarded-for", ip_addr_to_string(http_info.ip_address))); web_session(id, lang, entries, web_request(http_info, var(_lwa), is_https), previous, draw) }, @@ -4818,20 +4819,24 @@ define Printable_tree Formating the rows in a table. define Printable_tree - format - ( - List(HTML_Row($T)) rows, - $T -> Printable_tree format_element, - ) = - if rows is - { - [ ] then [ ], - [h . t] then if h is row(options,cells) then - ["", - format(cells,format_element), - "\n" - . format(t,format_element)] - }. + format + ( + List(HTML_Row($T)) rows, + $T -> Printable_tree format_element, + )= + if rows is + { + [ ] then [ ], + [h . t] then + if h is + { + empty then format(t, format_element), + row(options, cells) then + ["", format(cells, format_element), "\n" + . format(t, format_element)] + } + } +. define Printable_tree format @@ -4883,13 +4888,15 @@ define Printable_tree }. define Printable_tree - format - ( - List(TextAreaOption) l - ) = - if member(l,wrap_lines) - then format1(l) - else [" wrap=\"off\" " . format1(l)]. + format + ( + List(TextAreaOption) l + )= + if member(l, wrap_lines) then + format1(l) + else + [" wrap=\"off\" " . format1(l)] +. *** [5.7] Formating elements which may be put anywhere. @@ -5544,18 +5551,24 @@ define Bool ( HTML_Row(HTML_In_Form) row ) = - mapor(contains_an_upload, - map(content,cells(row))). + if row is + { + empty then false, + row(_, cells) then + mapor(contains_an_upload, + map(content, cells)) + } +. define Bool - contains_an_upload - ( - HTML_Footer_Row(HTML_In_Form) row - ) = + contains_an_upload + ( + HTML_Footer_Row(HTML_In_Form) row + )= if row is { - empty then false, - footer_row(_, cells) then + empty then false, + footer_row(_, cells) then mapor(contains_an_upload, map(content,cells)) }. diff --git a/web/types/making_a_web_site.anubis b/web/types/making_a_web_site.anubis index 0358c83..c92bc9f 100644 --- a/web/types/making_a_web_site.anubis +++ b/web/types/making_a_web_site.anubis @@ -110,15 +110,15 @@ public type HtmlEvents: oncut, //HTML5 Fires when the user cuts the content of an element onpaste, //HTML5 Fires when the user pastes some content in an element //Media Events - onabort, //HTML5 Script to be run on abort - oncanplay, //HTML5 Script to be run when a file is ready to start playing (when it has buffered enough to begin) + onabort, //HTML5 Script to be run on abort + oncanplay, //HTML5 Script to be run when a file is ready to start playing (when it has buffered enough to begin) oncanplaythrough, //HTML5 Script to be run when a file can be played all the way to the end without pausing for buffering - oncuechange, //HTML5 Script to be run when the cue changes in a element + oncuechange, //HTML5 Script to be run when the cue changes in a element ondurationchange, //HTML5 Script to be run when the length of the media changes - onemptied, //HTML5 Script to be run when something bad happens and the file is suddenly unavailable (like unexpectedly disconnects) - onended, //HTML5 Script to be run when the media has reach the end (a useful event for messages like "thanks for listening") - onerror, //HTML5 Script to be run when an error occurs when the file is being loaded - onloadeddata, //HTML5 Script to be run when media data is loaded + onemptied, //HTML5 Script to be run when something bad happens and the file is suddenly unavailable (like unexpectedly disconnects) + onended, //HTML5 Script to be run when the media has reach the end (a useful event for messages like "thanks for listening") + onerror, //HTML5 Script to be run when an error occurs when the file is being loaded + onloadeddata, //HTML5 Script to be run when media data is loaded onloadedmetadata, //HTML5 Script to be run when meta data (like dimensions and duration) are loaded onloadstart, //HTML5 Script to be run just as the file begins to load before anything is actually loaded onpause, //HTML5 Script to be run when the media is paused either by the user or programmatically @@ -320,7 +320,8 @@ public type HTML_Footer_Row($T): footer_row(List(Cell_Option) options, List(HTML_Cell($T)) cells). public type HTML_Row($T): - row(List(Cell_Option) options, List(HTML_Cell($T)) cells). + empty, + row(List(Cell_Option) options, List(HTML_Cell($T)) cells). public type HTML_Header_Cell($T): header_cell(List(Cell_Option) options, $T content). -- libgit2 0.21.4