From c0e3a41035b5feeaf9909333483e4c236ce0ec34 Mon Sep 17 00:00:00 2001 From: Cedric RICARD Date: Mon, 4 Aug 2008 22:22:27 +0000 Subject: [PATCH] State name is now provided to the 'compute_page' function. Improving Dojo API --- calexium_lib/web/CXM_dojo.anubis | 256 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------- calexium_lib/web/CXM_making_a_web_site.anubis | 10 +++++++--- 2 files changed, 206 insertions(+), 60 deletions(-) diff --git a/calexium_lib/web/CXM_dojo.anubis b/calexium_lib/web/CXM_dojo.anubis index 96ae705..d73188b 100644 --- a/calexium_lib/web/CXM_dojo.anubis +++ b/calexium_lib/web/CXM_dojo.anubis @@ -6,20 +6,21 @@ * */ -read calexium_lib/web/CXM_making_a_web_site.anubis +read tools/basis.anubis read tools/base64.anubis -read tools/basis.anubis // required for 'make_directory' read locale/L3LanguageInfo.anubis +read system/string.anubis -read mailfountain_constants.anubis -read mailfountain_types.anubis read calexium_lib/web/CXM_common.anubis read calexium_lib/web/CXM_making_a_web_site.anubis read calexium_lib/web/CXM_multihost_http_server.anubis +read calexium_lib/net_services_protocols/logger_service.anubis + +read mailfountain_constants.anubis +read mailfountain_types.anubis read common/language_management.anubis read tools/mf_loggers.anubis -read calexium_lib/net_services_protocols/logger_service.anubis read system/logger.anubis public type Dojo_Grid_Data : @@ -72,26 +73,132 @@ public define HTML_Off_Form //
") ] . +public type DojoGridEditor: + inputEditor, + boolEditor, + selectEditor(List(String) options), + alwaysOnEditor. + +public type DojoGridDefaultColumn: + dojo_grid_default_column( + String styles, + Maybe(String) width, + Maybe(DojoGridEditor) editor). + +public type DojoGridColumn: + dojo_grid_column( String label, + String field_name, + Maybe(String) width, + Maybe(DojoGridEditor) editor). + +public type DojoGridView: + dojo_grid_view( + Maybe(DojoGridDefaultColumn) default_column, + List(DojoGridColumn) columns). + +public type DojoGridLayout: + dojo_grid_layout( + Maybe(String) selectable_row_header_width, + List(DojoGridView) views). + +define String to_String(DojoGridEditor editor) = + "editor: " + + if editor is + { + inputEditor then "dojox.grid.editors.Input", + boolEditor then "dojox.grid.editors.Bool", + selectEditor(options) then "dojox.grid.editors.Select, options: [" + join(",", map((String o) |-> "\"" + o + "\"", options)) + "]", + alwaysOnEditor then "dojox.grid.editors.AlwaysOn" + }. + +define String to_String(DojoGridView view) = + "{ " + (if view.default_column is success(col) then + (if col is dojo_grid_default_column(styles, mb_width, mb_editor) then + "defaultCell: {" + + "styles: \"" + styles + "\"" + + (if mb_width is success(w) then ", width=\"" + w + "\"" else "") + + (if mb_editor is success(e) then ", " + to_String(e) else "") + + "}, ") + else "") + + "cells: [[" + join(",", map((DojoGridColumn col) |-> + if col is dojo_grid_column(label, field, mb_width, mb_editor) then + "{" + + "name: \"" + label + "\"" + + "field: \"" + field + "\"" + + (if mb_width is success(w) then ", width=\"" + w + "\"" else "") + + (if mb_editor is success(e) then ", " + to_String(e) else "") + + "}", + view.columns)) + "]]" + +"}". + + +public define String + dojo_make_grid_script + ( + HtmlId html_id, + DojoGridLayout layout, + String layout_name, + String store_name, + Bool can_edit + ) + = +"". + +public define HTML_Off_Form + dojo_make_grid_script + ( + HtmlId html_id, + List(String) columns, + Bool can_edit + ) + = + literal( +""). public define HTML_Off_Form dojo_grid ( - String id, + HtmlId html_id, + List(CoreAttrs) attributes, + ) + = + div_empty([id(html_id.id), attr("dojoType", "dojox.Grid") . attributes ]). + + +public define HTML_Off_Form + dojo_grid + ( + HtmlId html_id, + List(CoreAttrs) attributes, +// List(GridColumn) columns, String colum1, String colum2, String colum3, String colum4, - Bool can_edit + Bool can_edit ) = - literal(" -
") -. + sequence([ + literal( + +""), + div_empty([id(html_id.id) . attributes /*attr("dojoType", "dojox.Grid"), */]), + ]). +//
"). public define HTML_Off_Form @@ -123,83 +230,118 @@ public define HTML_Off_Form //actioner(same, same, push_button([id("dojo_tip_" + keyword), class("in"), event(onclick,"new_search(this)")], keyword), "", [], []). +public type BorderContainerRegion: + center, + top, + bottom, + leading, + trailing, + left, + right. + +define String + to_String + ( + BorderContainerRegion region + )= + if region is + { + center then "center", + top then "top", + bottom then "bottom", + leading then "leading", + trailing then "trailing", + left then "left", + right then "right" + }. + + public define HTML_Off_Form dojo_ContentPane ( - String id, - String region, - Bool splitter, - HTML_Off_Form content + List(CoreAttrs) attributes, + BorderContainerRegion region, + Bool splitter, + HTML_Off_Form content ) = - sequence([ - literal("
"), - content, - literal("
") - ]). + div([ attr("dojoType", "dijit.layout.ContentPane"), + attr("region", to_String(region)), + attr("splitter", if splitter then "true" else "false") . attributes ], + content). +// sequence([ +// literal("
"), +// content, +// literal("
") +// ]). public define HTML_Off_Form dojo_TabContainer ( - String id, - HTML_Off_Form content + List(CoreAttrs) attributes, + HTML_Off_Form content ) = - sequence([ - literal("
"), - content, - literal("
") - ]). + div([attr("dojoType", "dijit.layout.TabContainer") . attributes ], + content). +// sequence([ +// literal("
"), +// content, +// literal("
") +// ]). public define HTML_Off_Form dojo_BorderContainer ( - String id, - String title, - HTML_Off_Form content + List(CoreAttrs) attributes, + String the_title, + Bool live_splitter, + Bool persist, + HTML_Off_Form content ) = - sequence([ - literal("
"), - content, - literal("
") - ]). + div([attr("dojoType", "dijit.layout.BorderContainer"), title(the_title), + attr("design", "sidebar"), attr("liveSplitters", live_splitter), attr("persist", persist) . attributes ], + content). public define HTML_Off_Form dojo_tree ( - String id, + List(CoreAttrs) attributes, )= - literal("
"). + div_empty(attributes). +// literal("
"). public define HTML_Off_Form dojo_Toolbar ( - String id, + List(CoreAttrs) attributes, HTML_Off_Form content )= - sequence([ - literal("
"), - content, - literal("
") - ]). + div([attr("dojoType", "dijit.Toolbar") . attributes ], + content). +// sequence([ +// literal("
"), +// content, +// literal("
") +// ]). public define HTML_Off_Form dojo_button ( - String id, + HtmlId html_id, String name, String iconclass, String tip_msg, ) = literal(" - - " + tip_msg + ""). + + " + tip_msg + ""). diff --git a/calexium_lib/web/CXM_making_a_web_site.anubis b/calexium_lib/web/CXM_making_a_web_site.anubis index 3f80216..56a1088 100644 --- a/calexium_lib/web/CXM_making_a_web_site.anubis +++ b/calexium_lib/web/CXM_making_a_web_site.anubis @@ -439,7 +439,7 @@ public define Web_Site List(Web_arg), Bool is_https) -> (Maybe($SessionTicket), Maybe($State), List(HTTP_header)) ticket_lost_state, List(Web_Action($SessionTicket, $State)) actions, - (Maybe($SessionTicket), Maybe($State), List(Web_arg) lwa) -> HTTP_Answer compute_page, + (Maybe($SessionTicket), Maybe($State), String state_name, List(Web_arg) lwa) -> HTTP_Answer compute_page, Int timeout, // seconds (todo: minutes) List(Redirection) redirections, String charset, @@ -734,6 +734,8 @@ public type CoreAttrs: attr (String, String), event (HtmlEvents, String). +public define CoreAttrs attr(String name, Bool value) = attr(name, if value then "true" else "false"). + public type InputAttrs: class (String), style (String), @@ -745,6 +747,8 @@ public type InputAttrs: attr (String, String), event (HtmlEvents, String). +public define InputAttrs attr(String name, Bool value) = attr(name, if value then "true" else "false"). + public define CoreAttrs tooltip(String s) = title(s). public define InputAttrs @@ -2219,7 +2223,7 @@ public define Web_Site List(Web_arg), Bool is_https) -> (Maybe($SessionTicket), Maybe($State), List(HTTP_header)) ticket_lost_state, List(Web_Action($SessionTicket, $State)) actions, - (Maybe($SessionTicket), Maybe($State), List(Web_arg) lwa) -> HTTP_Answer compute_page, + (Maybe($SessionTicket), Maybe($State), String state_name, List(Web_arg) lwa) -> HTTP_Answer compute_page, Int timeout, Redirections redirections, String charset, @@ -2295,7 +2299,7 @@ public define Web_Site format(info(host_name, http_port, https_port, site_directory, secret), state_name, headers, - compute_page(session_ticket, mb_new_state, operands), + compute_page(session_ticket, mb_new_state, state_name, operands), is_https, charset) }), -- libgit2 0.21.4