From 5eb8baa0965b35e7b2c65096313af18e6cfd87f6 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Fri, 15 Feb 2013 15:08:53 +0100 Subject: [PATCH 01/11] keep compilable with EiffelStudio <= 7.1 --- draft/application/cms/src/kernel/link/cms_external_link.e | 2 ++ draft/application/cms/src/modules/debug/debug_module.e | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/draft/application/cms/src/kernel/link/cms_external_link.e b/draft/application/cms/src/kernel/link/cms_external_link.e index a73d9638..74e3ccee 100644 --- a/draft/application/cms/src/kernel/link/cms_external_link.e +++ b/draft/application/cms/src/kernel/link/cms_external_link.e @@ -29,6 +29,8 @@ feature -- Status report is_expandable: BOOLEAN = False + has_children: BOOLEAN = False + children: detachable LIST [CMS_LINK] do end diff --git a/draft/application/cms/src/modules/debug/debug_module.e b/draft/application/cms/src/modules/debug/debug_module.e index fa1c2de7..c586e3bf 100644 --- a/draft/application/cms/src/modules/debug/debug_module.e +++ b/draft/application/cms/src/modules/debug/debug_module.e @@ -86,7 +86,7 @@ feature -- Handler s.append ("
") - append_info_to ("Current dir", (create {EXECUTION_ENVIRONMENT}).current_working_path.name, e, s) + append_info_to ("Current dir", (create {EXECUTION_ENVIRONMENT}).current_working_directory, e, s) append_info_to ("Base url", cms.base_url, e, s) append_info_to ("Script url", cms.script_url, e, s) s.append ("
") From c62ad33ddc21707a81b2a4ffafa0fd0a66e012ca Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Fri, 15 Feb 2013 15:10:31 +0100 Subject: [PATCH 02/11] removed unused local variable --- draft/application/cms/src/kernel/form/cms_form_select.e | 1 - 1 file changed, 1 deletion(-) diff --git a/draft/application/cms/src/kernel/form/cms_form_select.e b/draft/application/cms/src/kernel/form/cms_form_select.e index fd49ad0a..b793df82 100644 --- a/draft/application/cms/src/kernel/form/cms_form_select.e +++ b/draft/application/cms/src/kernel/form/cms_form_select.e @@ -63,7 +63,6 @@ feature -- Element change select_value_by_text (a_text: detachable READABLE_STRING_GENERAL) local - opt: CMS_FORM_SELECT_OPTION l_found: BOOLEAN v: READABLE_STRING_8 do From a97235c7b7314af5a95d29961d957612e0ccfa6c Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Fri, 15 Feb 2013 19:00:05 +0100 Subject: [PATCH 03/11] Now the cms.ini resolves variable ${abc} ... and key is case insensitive --- draft/application/cms/example/cms.ini | 4 +- draft/application/cms/src/cms_configuration.e | 52 ++++++++++++++++++- .../cms/www/themes/default/res/style.css | 11 ++-- 3 files changed, 59 insertions(+), 8 deletions(-) diff --git a/draft/application/cms/example/cms.ini b/draft/application/cms/example/cms.ini index cf723b06..7de4d96e 100644 --- a/draft/application/cms/example/cms.ini +++ b/draft/application/cms/example/cms.ini @@ -4,5 +4,5 @@ site.email=your@email.com root-dir=../www var-dir=var files-dir=files -themes-dir=../www/themes -theme=test +themes-dir=${root-dir}/themes +#theme=test diff --git a/draft/application/cms/src/cms_configuration.e b/draft/application/cms/src/cms_configuration.e index 2292c362..28f5f20c 100644 --- a/draft/application/cms/src/cms_configuration.e +++ b/draft/application/cms/src/cms_configuration.e @@ -25,9 +25,20 @@ feature {NONE} -- Initialization make configuration_location := a_filename import (a_filename) + resolve analyze end + resolve + -- Resolve options related to variable ${..} + do + across + options as c + loop + options.replace (resolved_string (c.item), c.key) + end + end + analyze do get_root_location @@ -42,7 +53,7 @@ feature -- Access option (a_name: READABLE_STRING_GENERAL): detachable ANY do - Result := options.item (a_name.as_string_8) + Result := options.item (a_name.as_string_8.as_lower) end options: HASH_TABLE [STRING, STRING] @@ -242,4 +253,43 @@ feature {NONE} -- Environment create Result end + resolved_string (s: READABLE_STRING_8): STRING + -- Resolved `s' using `options' or else environment variables. + local + i,n,b,e: INTEGER + k: detachable READABLE_STRING_8 + do + from + i := 1 + n := s.count + create Result.make (s.count) + until + i > n + loop + if i + 1 < n and then s[i] = '$' and then s[i+1] = '{' then + b := i + 2 + e := s.index_of ('}', b) - 1 + if e > 0 then + k := s.substring (b, e) + if attached option (k) as v then + Result.append (v.out) + i := e + 1 + elseif attached execution_environment.get (k) as v then + Result.append (v) + i := e + 1 + else + Result.extend (s[i]) + end + else + Result.extend (s[i]) + end + else + Result.extend (s[i]) + end + i := i + 1 + end + end + + + end diff --git a/draft/application/cms/www/themes/default/res/style.css b/draft/application/cms/www/themes/default/res/style.css index 330b3446..8905e92e 100644 --- a/draft/application/cms/www/themes/default/res/style.css +++ b/draft/application/cms/www/themes/default/res/style.css @@ -70,9 +70,10 @@ div#main-wrapper { } div#main { margin: 0; padding: 0; clear: both; height:0; display: block; } -div#content { padding: 5px 3px 5px 20px; +div#content { + padding: 5px 3px 5px 20px; margin-top: 10px; - min-width: 80%; + min-width: 60%; display: inline; float: left; position: relative; @@ -81,7 +82,7 @@ div#content { padding: 5px 3px 5px 20px; } div#first_sidebar { - width: 200px; + width: 20%; margin: 5px; padding: 5px; display: inline; @@ -89,11 +90,11 @@ div#first_sidebar { position: relative; } div#second_sidebar { - width: 100px; + width: 20%; margin: 5px; padding: 5px; display: inline; - float: right; + float: left; position: relative; background-color: #eee; } From 0d51189324b39bd679a4683a91123500d07a85fc Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Tue, 19 Feb 2013 10:41:33 +0100 Subject: [PATCH 04/11] Code cleaning and use HTTP_DATE instead of duplicating code. --- draft/application/cms/example/src/web_cms.e | 5 ----- draft/application/cms/src/cms_setup.e | 7 ------- draft/application/cms/src/notification/cms_email.e | 5 ++++- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/draft/application/cms/example/src/web_cms.e b/draft/application/cms/example/src/web_cms.e index 3374cf65..c8a5f5e4 100644 --- a/draft/application/cms/example/src/web_cms.e +++ b/draft/application/cms/example/src/web_cms.e @@ -8,11 +8,6 @@ class WEB_CMS inherit --- CMS_SERVICE --- redefine --- modules --- end - WSF_DEFAULT_SERVICE redefine initialize diff --git a/draft/application/cms/src/cms_setup.e b/draft/application/cms/src/cms_setup.e index 09dff63b..2ed8c7e0 100644 --- a/draft/application/cms/src/cms_setup.e +++ b/draft/application/cms/src/cms_setup.e @@ -7,13 +7,6 @@ note deferred class CMS_SETUP -feature -- Initialization - - initialize_storage (a_cms: CMS_SERVICE) - do - - end - feature -- Access configuration: detachable CMS_CONFIGURATION diff --git a/draft/application/cms/src/notification/cms_email.e b/draft/application/cms/src/notification/cms_email.e index 90733493..13cfe771 100644 --- a/draft/application/cms/src/notification/cms_email.e +++ b/draft/application/cms/src/notification/cms_email.e @@ -84,8 +84,11 @@ feature {NONE} -- Implementation date_to_rfc1123_http_date_format (dt: DATE_TIME): STRING_8 -- String representation of `dt' using the RFC 1123 + local + d: HTTP_DATE do - Result := dt.formatted_out ("ddd,[0]dd mmm yyyy [0]hh:[0]mi:[0]ss.ff2") + " GMT" + create d.make_from_date_time (dt) + Result := d.rfc1123_string end invariant From fd0d771d432e84afa10fadb497afb9074e7801cc Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Tue, 19 Feb 2013 10:41:50 +0100 Subject: [PATCH 05/11] Fixed request new password --- .../cms/src/modules/user/user_new_password_cms_execution.e | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/draft/application/cms/src/modules/user/user_new_password_cms_execution.e b/draft/application/cms/src/modules/user/user_new_password_cms_execution.e index 97f372ff..550f0676 100644 --- a/draft/application/cms/src/modules/user/user_new_password_cms_execution.e +++ b/draft/application/cms/src/modules/user/user_new_password_cms_execution.e @@ -43,7 +43,7 @@ feature -- Execution b.append ("Unexpected issue") end else - f := new_password_form (request.path_info, "new-password") + f := new_password_form (url (request.path_info, Void), "new-password") if request.is_post_request_method then create fd.make (request, f) if attached {WSF_STRING} fd.item ("name") as s_name then From c9674b9e8e69c2d84993cb5dfc2384f9563f2e48 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Tue, 19 Feb 2013 13:25:12 +0100 Subject: [PATCH 06/11] Fixed computation of absolute url ... --- draft/application/cms/src/kernel/api/cms_common_api.e | 1 - 1 file changed, 1 deletion(-) diff --git a/draft/application/cms/src/kernel/api/cms_common_api.e b/draft/application/cms/src/kernel/api/cms_common_api.e index f925745b..f42d0027 100644 --- a/draft/application/cms/src/kernel/api/cms_common_api.e +++ b/draft/application/cms/src/kernel/api/cms_common_api.e @@ -164,7 +164,6 @@ feature -- Access Result.append ("#" + f) end if l_abs then - Result := based_path (Result) if Result.substring_index ("://", 1) = 0 then Result.prepend (service.site_url) end From 5d05f31d0354eae97f1c114c492b7ece5c5d0db1 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Tue, 19 Feb 2013 16:22:43 +0100 Subject: [PATCH 07/11] Fixed absolute url computing for CMS --- draft/application/cms/src/cms_configuration.e | 1 + .../cms/src/kernel/api/cms_common_api.e | 42 ++++++++++++++++--- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/draft/application/cms/src/cms_configuration.e b/draft/application/cms/src/cms_configuration.e index 28f5f20c..fb38305c 100644 --- a/draft/application/cms/src/cms_configuration.e +++ b/draft/application/cms/src/cms_configuration.e @@ -125,6 +125,7 @@ feature -- Access end if Result /= Void then if Result.is_empty then + -- ok elseif not Result.ends_with ("/") then Result := Result + "/" end diff --git a/draft/application/cms/src/kernel/api/cms_common_api.e b/draft/application/cms/src/kernel/api/cms_common_api.e index f42d0027..e6422cde 100644 --- a/draft/application/cms/src/kernel/api/cms_common_api.e +++ b/draft/application/cms/src/kernel/api/cms_common_api.e @@ -125,6 +125,18 @@ feature -- Access Result := url ("/node/" + n.id.out, Void) end + absolute_url (a_path: STRING; opts: detachable CMS_API_OPTIONS): STRING + local + l_opts: detachable CMS_API_OPTIONS + do + l_opts := opts + if l_opts = Void then + create l_opts.make (1) + end + l_opts.force (True, "absolute") + Result := url (a_path, l_opts) + end + url (a_path: STRING; opts: detachable CMS_API_OPTIONS): STRING local q,f: detachable STRING_8 @@ -132,7 +144,6 @@ feature -- Access do l_abs := False - Result := based_path (a_path) if opts /= Void then l_abs := opts.boolean_item ("absolute", l_abs) if attached opts.item ("query") as l_query then @@ -157,17 +168,36 @@ feature -- Access f := s_frag end end + if l_abs then + if a_path.substring_index ("://", 1) = 0 then + create Result.make_from_string (service.site_url) + if a_path.is_empty then + elseif Result.ends_with ("/") then + if a_path[1] = '/' then + Result.append_string (a_path.substring (2, a_path.count)) + else + Result.append_string (a_path) + end + else + if a_path[1] = '/' then + Result.append_string (a_path) + else + Result.append_character ('/') + Result.append_string (a_path) + end + end + else + Result := a_path + end + else + Result := based_path (a_path) + end if q /= Void then Result.append ("?" + q) end if f /= Void then Result.append ("#" + f) end - if l_abs then - if Result.substring_index ("://", 1) = 0 then - Result.prepend (service.site_url) - end - end end checked_url (a_url: STRING): STRING From a417cc1e16b294483fa3b4e38c6175cac1f1f218 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Wed, 20 Feb 2013 19:05:33 +0100 Subject: [PATCH 08/11] Fixing various form urls, that was not taking into account base url --- draft/application/cms/src/modules/node/node_add_cms_execution.e | 2 +- .../application/cms/src/modules/node/node_edit_cms_execution.e | 2 +- .../application/cms/src/modules/user/user_edit_cms_execution.e | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/draft/application/cms/src/modules/node/node_add_cms_execution.e b/draft/application/cms/src/modules/node/node_add_cms_execution.e index 3e4e58ab..0176576b 100644 --- a/draft/application/cms/src/modules/node/node_add_cms_execution.e +++ b/draft/application/cms/src/modules/node/node_add_cms_execution.e @@ -25,7 +25,7 @@ feature -- Execution create b.make_empty if attached non_empty_string_path_parameter ("type") as s_type then if attached service.content_type (s_type) as l_type then - f := edit_form (Void, request.path_info, "add-" + l_type.name, l_type) + f := edit_form (Void, url (request.path_info, Void), "add-" + l_type.name, l_type) if request.is_post_request_method then create fd.make (request, f) l_preview := attached {WSF_STRING} fd.item ("op") as l_op and then l_op.same_string ("Preview") diff --git a/draft/application/cms/src/modules/node/node_edit_cms_execution.e b/draft/application/cms/src/modules/node/node_edit_cms_execution.e index 511993e3..778c12d1 100644 --- a/draft/application/cms/src/modules/node/node_edit_cms_execution.e +++ b/draft/application/cms/src/modules/node/node_edit_cms_execution.e @@ -30,7 +30,7 @@ feature -- Execution then if attached service.content_type (l_node.content_type_name) as l_type then if has_permission ("edit " + l_type.name) then - f := edit_form (l_node, request.path_info, "edit-" + l_type.name, l_type) + f := edit_form (l_node, url (request.path_info, Void), "edit-" + l_type.name, l_type) if request.is_post_request_method then create fd.make (request, f) l_preview := attached {WSF_STRING} fd.item ("op") as l_op and then l_op.same_string ("Preview") diff --git a/draft/application/cms/src/modules/user/user_edit_cms_execution.e b/draft/application/cms/src/modules/user/user_edit_cms_execution.e index c39000fb..b0af2ec5 100644 --- a/draft/application/cms/src/modules/user/user_edit_cms_execution.e +++ b/draft/application/cms/src/modules/user/user_edit_cms_execution.e @@ -47,7 +47,7 @@ feature -- Execution set_redirection (url ("/user/register", Void)) else service.storage.fill_user_profile (u) - f := edit_form (u, request.path_info, "user-edit") + f := edit_form (u, url (request.path_info, Void), "user-edit") if request.is_post_request_method then create fd.make (request, f) From b543a6b6f23ddf2bcc89df8017c524e7b347fe80 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Thu, 21 Feb 2013 19:08:26 +0100 Subject: [PATCH 09/11] Added functionalities to CMS_FORM_.. classes --- .../cms/src/kernel/form/cms_form.e | 43 +++++++++++++++++++ .../cms/src/kernel/form/cms_form_div.e | 11 +++++ .../cms/src/kernel/form/cms_form_field_set.e | 5 +++ 3 files changed, 59 insertions(+) diff --git a/draft/application/cms/src/kernel/form/cms_form.e b/draft/application/cms/src/kernel/form/cms_form.e index a40c9a15..c6fb0354 100644 --- a/draft/application/cms/src/kernel/form/cms_form.e +++ b/draft/application/cms/src/kernel/form/cms_form.e @@ -102,6 +102,20 @@ feature -- Items Result := fields_by_name_from (Current, a_name) end + items_by_css_id (a_id: READABLE_STRING_GENERAL): detachable LIST [CMS_FORM_ITEM] + do + Result := items_by_css_id_from (Current, a_id) + end + + first_item_by_css_id (a_id: READABLE_STRING_GENERAL): detachable CMS_FORM_ITEM + do + if attached items_by_css_id_from (Current, a_id) as lst then + if not lst.is_empty then + Result := lst.first + end + end + end + feature {NONE} -- Implementation: Items container_has_field (a_container: ITERABLE [CMS_FORM_ITEM]; a_name: READABLE_STRING_GENERAL): BOOLEAN @@ -144,6 +158,35 @@ feature {NONE} -- Implementation: Items Result := res end + items_by_css_id_from (a_container: ITERABLE [CMS_FORM_ITEM]; a_id: READABLE_STRING_GENERAL): detachable ARRAYED_LIST [CMS_FORM_ITEM] + local + res: detachable ARRAYED_LIST [CMS_FORM_ITEM] + do + across + a_container as i + loop + if + attached {WITH_CSS_ID} i.item as l_with_css_id and then + attached l_with_css_id.css_id as l_css_id and then + l_css_id.same_string_general (a_id) + then + if res = Void then + create res.make (1) + end + res.force (i.item) + elseif attached {ITERABLE [CMS_FORM_ITEM]} i.item as l_cont then + if attached items_by_css_id_from (l_cont, a_id) as lst then + if res = Void then + res := lst + else + res.append (lst) + end + end + end + end + Result := res + end + feature -- Change extend (i: CMS_FORM_ITEM) diff --git a/draft/application/cms/src/kernel/form/cms_form_div.e b/draft/application/cms/src/kernel/form/cms_form_div.e index e10aee74..ead7d3aa 100644 --- a/draft/application/cms/src/kernel/form/cms_form_div.e +++ b/draft/application/cms/src/kernel/form/cms_form_div.e @@ -17,6 +17,7 @@ inherit create make, make_with_item, + make_with_items, make_with_text feature {NONE} -- Initialization @@ -38,6 +39,16 @@ feature {NONE} -- Initialization extend (i) end + make_with_items (it: ITERABLE [CMS_FORM_ITEM]) + do + create items.make (2) + across + it as c + loop + extend (c.item) + end + end + feature -- Access new_cursor: ITERATION_CURSOR [CMS_FORM_ITEM] diff --git a/draft/application/cms/src/kernel/form/cms_form_field_set.e b/draft/application/cms/src/kernel/form/cms_form_field_set.e index 78d2bee6..9e18693d 100644 --- a/draft/application/cms/src/kernel/form/cms_form_field_set.e +++ b/draft/application/cms/src/kernel/form/cms_form_field_set.e @@ -51,6 +51,11 @@ feature -- Change items.force (i) end + prepend (i: CMS_FORM_ITEM) + do + items.put_front (i) + end + extend_text (t: READABLE_STRING_8) do items.force (create {CMS_FORM_RAW_TEXT}.make (t)) From 0902eef91c6c8350c42cbf6ed92498ea31a72d10 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Tue, 26 Feb 2013 12:22:53 +0100 Subject: [PATCH 10/11] Use append_to_html rather than function to_html: STRING this is mainly to avoid creating useless intermediary strings. --- .../cms/src/kernel/form/cms_form.e | 20 +++++---- .../src/kernel/form/cms_form_checkbox_input.e | 10 ++--- .../cms/src/kernel/form/cms_form_div.e | 16 ++++---- .../cms/src/kernel/form/cms_form_field.e | 24 +++++------ .../cms/src/kernel/form/cms_form_field_set.e | 18 ++++---- .../src/kernel/form/cms_form_hidden_input.e | 10 ++--- .../cms/src/kernel/form/cms_form_input.e | 41 +++++++++++-------- .../cms/src/kernel/form/cms_form_item.e | 8 +++- .../cms/src/kernel/form/cms_form_raw_text.e | 10 ++--- .../cms/src/kernel/form/cms_form_select.e | 26 ++++++------ .../cms/src/kernel/form/cms_form_textarea.e | 23 +++++------ .../src/modules/node/node_add_cms_execution.e | 2 +- .../modules/node/node_edit_cms_execution.e | 2 +- .../cms/src/modules/user/user_cms_execution.e | 2 +- .../modules/user/user_edit_cms_execution.e | 2 +- .../user/user_new_password_cms_execution.e | 4 +- .../user/user_register_cms_execution.e | 2 +- 17 files changed, 118 insertions(+), 102 deletions(-) diff --git a/draft/application/cms/src/kernel/form/cms_form.e b/draft/application/cms/src/kernel/form/cms_form.e index c6fb0354..988c522d 100644 --- a/draft/application/cms/src/kernel/form/cms_form.e +++ b/draft/application/cms/src/kernel/form/cms_form.e @@ -210,11 +210,11 @@ feature -- Change feature -- Conversion - to_html (a_theme: CMS_THEME): STRING_8 + append_to_html (a_theme: CMS_THEME; a_html: STRING_8) local - s: STRING + s: STRING_8 do - Result := "
%N") + a_html.append (">%N") across items as c loop - Result.append (c.item.to_html (a_theme)) + c.item.append_to_html (a_theme, a_html) end - Result.append ("
%N") + a_html.append ("%N") + end + + to_html (a_theme: CMS_THEME): STRING_8 + do + create Result.make_empty + append_to_html (a_theme, Result) end feature {NONE} -- Implementation diff --git a/draft/application/cms/src/kernel/form/cms_form_checkbox_input.e b/draft/application/cms/src/kernel/form/cms_form_checkbox_input.e index 7bea1bcc..83ba26ea 100644 --- a/draft/application/cms/src/kernel/form/cms_form_checkbox_input.e +++ b/draft/application/cms/src/kernel/form/cms_form_checkbox_input.e @@ -14,7 +14,7 @@ inherit redefine set_value, specific_input_attributes_string, - child_to_html + append_child_to_html end CMS_FORM_SELECTABLE_ITEM @@ -83,16 +83,16 @@ feature -- Change feature {NONE} -- Implementation - child_to_html (a_theme: CMS_THEME): detachable READABLE_STRING_8 + append_child_to_html (a_theme: CMS_THEME; a_html: STRING_8) -- Specific child element if any. --| To redefine if needed do if attached raw_text as t then - Result := t + a_html.append (t) elseif attached text as t then - Result := a_theme.html_encoded (t) + a_html.append (a_theme.html_encoded (t)) elseif attached value as v then - Result := a_theme.html_encoded (v) + a_html.append (a_theme.html_encoded (v)) end end diff --git a/draft/application/cms/src/kernel/form/cms_form_div.e b/draft/application/cms/src/kernel/form/cms_form_div.e index ead7d3aa..65dec274 100644 --- a/draft/application/cms/src/kernel/form/cms_form_div.e +++ b/draft/application/cms/src/kernel/form/cms_form_div.e @@ -66,20 +66,20 @@ feature -- Change feature -- Conversion - to_html (a_theme: CMS_THEME): STRING_8 + append_to_html (a_theme: CMS_THEME; a_html: STRING_8) do - Result := "%N") + a_html.append (">%N") across items as c loop - Result.append (c.item.to_html (a_theme)) + c.item.append_to_html (a_theme, a_html) end - Result.append ("%N%N") + a_html.append ("%N%N") end feature {NONE} -- Implementation diff --git a/draft/application/cms/src/kernel/form/cms_form_field.e b/draft/application/cms/src/kernel/form/cms_form_field.e index d2b43d39..a1179905 100644 --- a/draft/application/cms/src/kernel/form/cms_form_field.e +++ b/draft/application/cms/src/kernel/form/cms_form_field.e @@ -102,7 +102,7 @@ feature -- Element change feature -- Conversion - to_html (a_theme: CMS_THEME): STRING_8 + append_to_html (a_theme: CMS_THEME; a_html: STRING_8) local l_class_items: detachable ARRAYED_LIST [READABLE_STRING_8] do @@ -117,28 +117,28 @@ feature -- Conversion l_class_items := Void end - create Result.make_from_string ("') + a_html.append ("') if attached label as lab then - Result.append ("") + a_html.append ("") if is_required then - Result.append (" (required)") + a_html.append (" (required)") end - Result.append ("
%N") + a_html.append ("
%N") end - Result.append (item_to_html (a_theme)) + append_item_to_html (a_theme, a_html) if attached description as desc then if is_description_collapsible then - Result.append ("
Description ...
" + desc + "
") + a_html.append ("
Description ...
" + desc + "
") else - Result.append ("
" + desc + "
") + a_html.append ("
" + desc + "
") end end - Result.append ("") + a_html.append ("") end - item_to_html (a_theme: CMS_THEME): STRING_8 + append_item_to_html (a_theme: CMS_THEME; a_html: STRING_8) deferred end diff --git a/draft/application/cms/src/kernel/form/cms_form_field_set.e b/draft/application/cms/src/kernel/form/cms_form_field_set.e index 9e18693d..2a9af0a5 100644 --- a/draft/application/cms/src/kernel/form/cms_form_field_set.e +++ b/draft/application/cms/src/kernel/form/cms_form_field_set.e @@ -82,23 +82,23 @@ feature -- Change feature -- Conversion - to_html (a_theme: CMS_THEME): STRING_8 + append_to_html (a_theme: CMS_THEME; a_html: STRING_8) do - Result := "%N") + a_html.append (">%N") if attached legend as leg then - Result.append ("" + leg + "%N") + a_html.append ("" + leg + "%N") end across items as c loop - Result.append (c.item.to_html (a_theme)) + c.item.append_to_html (a_theme, a_html) end - Result.append ("%N%N") + a_html.append ("%N%N") end feature {NONE} -- Implementation diff --git a/draft/application/cms/src/kernel/form/cms_form_hidden_input.e b/draft/application/cms/src/kernel/form/cms_form_hidden_input.e index 8422a9fe..7056cdc2 100644 --- a/draft/application/cms/src/kernel/form/cms_form_hidden_input.e +++ b/draft/application/cms/src/kernel/form/cms_form_hidden_input.e @@ -11,7 +11,7 @@ inherit CMS_FORM_INPUT redefine input_type, - item_to_html + append_item_to_html end create @@ -27,11 +27,11 @@ feature -- Access feature -- Conversion - item_to_html (a_theme: CMS_THEME): STRING_8 + append_item_to_html (a_theme: CMS_THEME; a_html: STRING_8) do - Result := "
" - Result.append (Precursor (a_theme)) - Result.append ("
") + a_html.append ("
") + Precursor (a_theme, a_html) + a_html.append ("
") end end diff --git a/draft/application/cms/src/kernel/form/cms_form_input.e b/draft/application/cms/src/kernel/form/cms_form_input.e index f1dfca1c..ae74f5c1 100644 --- a/draft/application/cms/src/kernel/form/cms_form_input.e +++ b/draft/application/cms/src/kernel/form/cms_form_input.e @@ -78,45 +78,50 @@ feature -- Element change feature -- Conversion - item_to_html (a_theme: CMS_THEME): STRING_8 + append_item_to_html (a_theme: CMS_THEME; a_html: STRING_8) + local + old_count: INTEGER do - Result := " 0 then - Result.append (" size=%"" + size.out + "%"") + a_html.append (" size=%"" + size.out + "%"") end if maxlength > 0 then - Result.append (" maxlength=%"" + maxlength.out + "%"") + a_html.append (" maxlength=%"" + maxlength.out + "%"") end if attached specific_input_attributes_string as s then - Result.append_character (' ') - Result.append (s) + a_html.append_character (' ') + a_html.append (s) end - if attached child_to_html (a_theme) as s then - Result.append (">") - Result.append (s) - Result.append ("") + a_html.append (">") + old_count := a_html.count + append_child_to_html (a_theme, a_html) + if a_html.count > old_count then + a_html.append ("") else - Result.append ("/>") + check a_html.item (a_html.count) = '>' end + a_html.put ('/', a_html.count) -- replace previous '>' + a_html.append (">") end end feature {NONE} -- Implementation - child_to_html (a_theme: CMS_THEME): detachable READABLE_STRING_8 + append_child_to_html (a_theme: CMS_THEME; a_html: STRING_8) -- Specific child element if any. --| To redefine if needed do diff --git a/draft/application/cms/src/kernel/form/cms_form_item.e b/draft/application/cms/src/kernel/form/cms_form_item.e index 2718568d..7b7f908f 100644 --- a/draft/application/cms/src/kernel/form/cms_form_item.e +++ b/draft/application/cms/src/kernel/form/cms_form_item.e @@ -14,8 +14,14 @@ inherit feature -- Conversion - to_html (a_theme: CMS_THEME): STRING_8 + append_to_html (a_theme: CMS_THEME; a_html: STRING_8) deferred end + to_html (a_theme: CMS_THEME): STRING_8 + do + create Result.make_empty + append_to_html (a_theme, Result) + end + end diff --git a/draft/application/cms/src/kernel/form/cms_form_raw_text.e b/draft/application/cms/src/kernel/form/cms_form_raw_text.e index bd5df16f..915dace7 100644 --- a/draft/application/cms/src/kernel/form/cms_form_raw_text.e +++ b/draft/application/cms/src/kernel/form/cms_form_raw_text.e @@ -10,7 +10,7 @@ class inherit CMS_FORM_ITEM redefine - to_html + append_to_html end create @@ -36,14 +36,14 @@ feature -- Element change feature -- Conversion - to_html (a_theme: CMS_THEME): STRING_8 + append_to_html (a_theme: CMS_THEME; a_html: STRING_8) do - Result := item_to_html (a_theme) + append_item_html_to (a_theme, a_html) end - item_to_html (a_theme: CMS_THEME): STRING_8 + append_item_html_to (a_theme: CMS_THEME; a_html: STRING_8) do - Result := text + a_html.append (text) end end diff --git a/draft/application/cms/src/kernel/form/cms_form_select.e b/draft/application/cms/src/kernel/form/cms_form_select.e index b793df82..acdd6db6 100644 --- a/draft/application/cms/src/kernel/form/cms_form_select.e +++ b/draft/application/cms/src/kernel/form/cms_form_select.e @@ -103,38 +103,38 @@ feature -- Element change feature -- Conversion - item_to_html (a_theme: CMS_THEME): STRING_8 + append_item_to_html (a_theme: CMS_THEME; a_html: STRING_8) local l_is_already_selected: BOOLEAN h: detachable STRING_8 do - Result := "%N") + a_html.append ("%N") if h /= Void then - Result.append ("
" + h + "
%N") + a_html.append ("
" + h + "
%N") end end diff --git a/draft/application/cms/src/kernel/form/cms_form_textarea.e b/draft/application/cms/src/kernel/form/cms_form_textarea.e index dd6f37fe..b71bb5ba 100644 --- a/draft/application/cms/src/kernel/form/cms_form_textarea.e +++ b/draft/application/cms/src/kernel/form/cms_form_textarea.e @@ -61,30 +61,29 @@ feature -- Element change feature -- Conversion - item_to_html (a_theme: CMS_THEME): STRING_8 + append_item_to_html (a_theme: CMS_THEME; a_html: STRING_8) do - Result := "") + a_html.append ("") end end diff --git a/draft/application/cms/src/modules/node/node_add_cms_execution.e b/draft/application/cms/src/modules/node/node_add_cms_execution.e index 0176576b..bfe43dba 100644 --- a/draft/application/cms/src/modules/node/node_add_cms_execution.e +++ b/draft/application/cms/src/modules/node/node_add_cms_execution.e @@ -82,7 +82,7 @@ feature -- Execution end fd.apply_to_associated_form end - b.append (f.to_html (theme)) + f.append_to_html (theme, b) end else set_title ("Access denied") diff --git a/draft/application/cms/src/modules/node/node_edit_cms_execution.e b/draft/application/cms/src/modules/node/node_edit_cms_execution.e index 778c12d1..3153c177 100644 --- a/draft/application/cms/src/modules/node/node_edit_cms_execution.e +++ b/draft/application/cms/src/modules/node/node_edit_cms_execution.e @@ -87,7 +87,7 @@ feature -- Execution end fd.apply_to_associated_form end - b.append (f.to_html (theme)) + f.append_to_html (theme, b) end else b.append ("

Access denied

") diff --git a/draft/application/cms/src/modules/user/user_cms_execution.e b/draft/application/cms/src/modules/user/user_cms_execution.e index 6061694d..6f063958 100644 --- a/draft/application/cms/src/modules/user/user_cms_execution.e +++ b/draft/application/cms/src/modules/user/user_cms_execution.e @@ -112,7 +112,7 @@ feature -- Execution end fd.apply_to_associated_form end - b.append (f.to_html (theme)) + f.append_to_html (theme, b) set_main_content (b) end end diff --git a/draft/application/cms/src/modules/user/user_edit_cms_execution.e b/draft/application/cms/src/modules/user/user_edit_cms_execution.e index b0af2ec5..d4930d69 100644 --- a/draft/application/cms/src/modules/user/user_edit_cms_execution.e +++ b/draft/application/cms/src/modules/user/user_edit_cms_execution.e @@ -105,7 +105,7 @@ feature -- Execution end fd.apply_to_associated_form end - b.append (f.to_html (theme)) + f.append_to_html (theme, b) end end set_main_content (b) diff --git a/draft/application/cms/src/modules/user/user_new_password_cms_execution.e b/draft/application/cms/src/modules/user/user_new_password_cms_execution.e index 550f0676..00b1af92 100644 --- a/draft/application/cms/src/modules/user/user_new_password_cms_execution.e +++ b/draft/application/cms/src/modules/user/user_new_password_cms_execution.e @@ -34,7 +34,7 @@ feature -- Execution if attached u.email as l_email then f := new_password_form (url (request.path_info, Void), "new-password") b.append ("Password reset instructions will be mailed to " + l_email + ". You must " + link ("log out", "/user/logout", Void) + " to use the password reset link in the e-mail.") - b.append (f.to_html (theme)) + f.append_to_html (theme, b) else b.append ("Your account does not have any email address set!") set_redirection (url ("/user/"+ u.id.out +"/edit", Void)) @@ -84,7 +84,7 @@ feature -- Execution end fd.apply_to_associated_form end - b.append (f.to_html (theme)) + f.append_to_html (theme, b) end end set_main_content (b) diff --git a/draft/application/cms/src/modules/user/user_register_cms_execution.e b/draft/application/cms/src/modules/user/user_register_cms_execution.e index 95395022..b1b4d819 100644 --- a/draft/application/cms/src/modules/user/user_register_cms_execution.e +++ b/draft/application/cms/src/modules/user/user_register_cms_execution.e @@ -103,7 +103,7 @@ feature -- Execution end fd.apply_to_associated_form end - b.append (f.to_html (theme)) + f.append_to_html (theme, b) end end set_main_content (b) From 9c0a2bd6a18ff01d363472981d8274d997e85735 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Tue, 26 Feb 2013 15:33:00 +0100 Subject: [PATCH 11/11] prefer 2 append call, rather than create a temp intermediary string object with + --- library/network/protocol/http/src/http_header.e | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/library/network/protocol/http/src/http_header.e b/library/network/protocol/http/src/http_header.e index 8e78fba6..91c8a201 100644 --- a/library/network/protocol/http/src/http_header.e +++ b/library/network/protocol/http/src/http_header.e @@ -559,13 +559,16 @@ feature -- Cookie if domain /= Void and then not domain.same_string ("localhost") then - s.append ("; Domain=" + domain) + s.append ("; Domain=") + s.append (domain) end if path /= Void then - s.append ("; Path=" + path) + s.append ("; Path=") + s.append (path) end if expiration /= Void then - s.append ("; Expires=" + expiration) + s.append ("; Expires=") + s.append (expiration) end if secure then s.append ("; Secure")