From a2608ea07af21af40cf5c09eaa14f4c6bc7e6e61 Mon Sep 17 00:00:00 2001 From: totoro Date: Sun, 15 Apr 2018 23:20:21 +0200 Subject: [PATCH] add helper for cell when there is only one Cell_option and one content fix the retrieving session from disk and change the method to determine the saving filename. Now the filename is determined by the session id. --- web/CXM_making_a_web_site.anubis | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------- 1 file changed, 68 insertions(+), 58 deletions(-) diff --git a/web/CXM_making_a_web_site.anubis b/web/CXM_making_a_web_site.anubis index da2a750..8297531 100644 --- a/web/CXM_making_a_web_site.anubis +++ b/web/CXM_making_a_web_site.anubis @@ -558,13 +558,15 @@ define WEB_Session -> String // the function constructed returns the name of ) = (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), + 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)), + //session_name = to_ascii(sha1(s)), + 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 + println("----- session ["+session_name+"] saved"+dump_WEB_Session_Fields(*s_var.fields)); session_name else println("Cannot create session file in '"+state_directory+"'.\n"); @@ -625,15 +627,24 @@ define (List(String) file_names) -> One { [ ] then unique, [h . t] then + if h = "." | h = ".." then + df(t) + else with file_path = state_directory+"/"+h, - if (RetrieveResult((Int, WEB_Session)))retrieve(file_path) is ok(d) - then ( - if d is (time_stamp,data) then - if time_stamp < now - then (forget(remove(file_path)); df(t)) - else df(t) - ) - else (forget(remove(file_path)); df(t)) + if (RetrieveResult((Int, WEB_Session_No_Var)))retrieve(file_path) is ok(d) then + ( + if d is (time_stamp, data) then + if time_stamp < now then + //println("session "+h+" out date will be deleted timestamp ["+time_stamp+"] now ["+now+"]"); + (forget(remove(file_path)); + df(t)) + else + //println("Session "+h+" still valid ["+time_stamp+"] now ["+now+"]"); + df(t) + ) + else + println("Can't retreive session "+h+", hence will be deleted"); + (forget(remove(file_path)); df(t)) }. define One @@ -1296,12 +1307,22 @@ public type HTML_Header_Cell($T): convenience, we define the following particular case: public define HTML_Cell($T) - cell - ( - $T content - ) = - cell([],content). - + cell + ( + $T content + )= + cell([],content) +. + +public define HTML_Cell($T) + cell + ( + Cell_Option option, + $T content + ) = + cell([option],content) +. + public define HTML_Header_Cell($T) header_cell ( @@ -2026,9 +2047,10 @@ public type HTML_Off_Form: 'HTML_Off_Form' defines all the elements you may put outside any form. -public define HTML_Off_Form text(List(CoreAttrs) lto, Int i) = text(lto, to_decimal(i)). +public define HTML_Off_Form text(List(CoreAttrs) lto, Int i) = text(lto, to_decimal(i)). public define HTML_Off_Form text(Int i) = text([], i). public define HTML_Off_Form text(String s) = text([], s). +public define HTML_Off_Form text(CoreAttrs attr, String s) = text([attr], s). public define HTML_Off_Form a(A_href _href) = a([], _href, _self, []). public define HTML_Off_Form a(List(CoreAttrs) attrs, A_href _href) = a(attrs, _href, _self, []). @@ -2056,12 +2078,13 @@ public define HTML_Off_Form br public define HTML_Off_Form br(List(CoreAttrs) attrs) = html_void_tag("br", attrs). //