diff --git a/draft/application/cms/cms-safe.ecf b/draft/application/cms/cms-safe.ecf index d225d9dd..51accbb1 100644 --- a/draft/application/cms/cms-safe.ecf +++ b/draft/application/cms/cms-safe.ecf @@ -14,7 +14,7 @@ - + diff --git a/draft/application/cms/cms.ecf b/draft/application/cms/cms.ecf index 7d3f886d..0eb505c1 100644 --- a/draft/application/cms/cms.ecf +++ b/draft/application/cms/cms.ecf @@ -15,7 +15,7 @@ - + diff --git a/draft/application/cms/example/cms_demo-safe.ecf b/draft/application/cms/example/cms_demo-safe.ecf index cac6d8f4..ffe42c05 100644 --- a/draft/application/cms/example/cms_demo-safe.ecf +++ b/draft/application/cms/example/cms_demo-safe.ecf @@ -16,6 +16,7 @@ + diff --git a/draft/application/cms/example/src/module/demo/demo_widget_cms_execution.e b/draft/application/cms/example/src/module/demo/demo_widget_cms_execution.e index f68d136c..58083ee5 100644 --- a/draft/application/cms/example/src/module/demo/demo_widget_cms_execution.e +++ b/draft/application/cms/example/src/module/demo/demo_widget_cms_execution.e @@ -35,9 +35,9 @@ feature -- Execution set_main_content (s) end - new_table: CMS_WIDGET_AGENT_TABLE [READABLE_STRING_8] + new_table: WSF_WIDGET_AGENT_TABLE [READABLE_STRING_8] local - l_table: CMS_WIDGET_AGENT_TABLE [READABLE_STRING_8] + l_table: WSF_WIDGET_AGENT_TABLE [READABLE_STRING_8] do create l_table.make l_table.add_css_style ("width: 85%%; border: solid 1px #999; padding: 2px;") @@ -53,10 +53,10 @@ feature -- Execution l_table.set_data (<<"foo", "bar", "foobar">>) l_table.set_foot_data (<<"abc", "def">>) - l_table.set_compute_item_function (agent (d: READABLE_STRING_8): CMS_WIDGET_TABLE_ROW + l_table.set_compute_item_function (agent (d: READABLE_STRING_8): WSF_WIDGET_TABLE_ROW local i: INTEGER - w: CMS_WIDGET_TABLE_ITEM + w: WSF_WIDGET_TABLE_ITEM do create Result.make (d.count) if d.is_case_insensitive_equal ("bar") then diff --git a/draft/application/cms/src/cms_execution.e b/draft/application/cms/src/cms_execution.e index 8cbcdd42..06e1f8db 100644 --- a/draft/application/cms/src/cms_execution.e +++ b/draft/application/cms/src/cms_execution.e @@ -264,7 +264,7 @@ feature -- Message add_message (a_msg, "success") end - report_form_errors (fd: CMS_FORM_DATA) + report_form_errors (fd: WSF_FORM_DATA) require has_error: not fd.is_valid do diff --git a/draft/application/cms/src/cms_service.e b/draft/application/cms/src/cms_service.e index 00003f80..d47e5b0b 100644 --- a/draft/application/cms/src/cms_service.e +++ b/draft/application/cms/src/cms_service.e @@ -203,7 +203,7 @@ feature -- Hook: form_alter form_alter_hooks: detachable ARRAYED_LIST [CMS_HOOK_FORM_ALTER] - call_form_alter_hooks (f: CMS_FORM; a_form_data: detachable CMS_FORM_DATA; a_execution: CMS_EXECUTION) + call_form_alter_hooks (f: CMS_FORM; a_form_data: detachable WSF_FORM_DATA; a_execution: CMS_EXECUTION) do if attached form_alter_hooks as lst then across @@ -438,11 +438,12 @@ feature -- Core Execution -- Default request handler if no other are relevant local e: CMS_EXECUTION + sess: WSF_ROUTER_SESSION do initialize_urls (req) - if attached router.dispatch_and_return_handler (req, res) as p then - -- ok - else + create sess + router.dispatch (req, res, sess) + if not sess.dispatched then create {NOT_FOUND_CMS_EXECUTION} e.make (req, res, Current) e.execute end diff --git a/draft/application/cms/src/form/cms_form.e b/draft/application/cms/src/form/cms_form.e new file mode 100644 index 00000000..b0746d51 --- /dev/null +++ b/draft/application/cms/src/form/cms_form.e @@ -0,0 +1,43 @@ +note + description: "Summary description for {CMS_FORM}." + author: "" + date: "$Date$" + revision: "$Revision$" + +class + CMS_FORM + +inherit + WSF_FORM + rename + process as process_form + end + +create + make + +feature -- Basic operation + + prepare (a_execution: CMS_EXECUTION) + do + a_execution.service.call_form_alter_hooks (Current, Void, a_execution) + end + + process (a_execution: CMS_EXECUTION) + do + process_form (a_execution.request, agent on_prepared (a_execution, ?), agent on_processed (a_execution, ?)) + end + + on_prepared (a_execution: CMS_EXECUTION; fd: WSF_FORM_DATA) + do + a_execution.service.call_form_alter_hooks (Current, fd, a_execution) + end + + on_processed (a_execution: CMS_EXECUTION; fd: WSF_FORM_DATA) + do + if not fd.is_valid or fd.has_error then + a_execution.report_form_errors (fd) + end + end + +end diff --git a/draft/application/cms/src/hooks/cms_hook_form_alter.e b/draft/application/cms/src/hooks/cms_hook_form_alter.e index 83499bd1..afc45305 100644 --- a/draft/application/cms/src/hooks/cms_hook_form_alter.e +++ b/draft/application/cms/src/hooks/cms_hook_form_alter.e @@ -12,7 +12,7 @@ inherit feature -- Hook - form_alter (a_form: CMS_FORM; a_form_data: detachable CMS_FORM_DATA; a_execution: CMS_EXECUTION) + form_alter (a_form: CMS_FORM; a_form_data: detachable WSF_FORM_DATA; a_execution: CMS_EXECUTION) deferred end diff --git a/draft/application/cms/src/kernel/api/cms_api_options.e b/draft/application/cms/src/kernel/api/cms_api_options.e index 0195f193..1fbfa52c 100644 --- a/draft/application/cms/src/kernel/api/cms_api_options.e +++ b/draft/application/cms/src/kernel/api/cms_api_options.e @@ -8,7 +8,7 @@ class CMS_API_OPTIONS inherit - TABLE_ITERABLE [detachable ANY, STRING] + WSF_API_OPTIONS create make, @@ -22,77 +22,5 @@ convert feature {NONE} -- Initialization - make (n: INTEGER) - do - create table.make (n) - end - - make_from_manifest (lst: ARRAY [TUPLE [key: STRING; value: detachable ANY]]) - do - make (lst.count) - across - lst as c - loop - force (c.item.value, c.item.key) - end - end - -feature -- Access - - item (k: STRING): detachable ANY - do - Result := table.item (k) - end - - force (v: detachable ANY; k: STRING) - do - table.force (v, k) - end - - boolean_item (k: STRING; dft: BOOLEAN): BOOLEAN - do - if attached {BOOLEAN} item (k) as b then - Result := b - else - Result := dft - end - end - - string_general_item (k: STRING): detachable READABLE_STRING_GENERAL - do - if attached {READABLE_STRING_GENERAL} item (k) as s then - Result := s - end - end - - string_item, string_8_item (k: STRING): detachable READABLE_STRING_8 - do - if attached {READABLE_STRING_8} item (k) as s then - Result := s - end - end - - table: HASH_TABLE [detachable ANY, STRING] - -feature -- Change - - import (a_opts: CMS_API_OPTIONS) - do - across - a_opts as c - loop - force (c.item, c.key) - end - end - -feature -- Access - - new_cursor: TABLE_ITERATION_CURSOR [detachable ANY, STRING] - -- Fresh cursor associated with current structure - do - Result := table.new_cursor - end - -invariant 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 e6422cde..c8a7fc0c 100644 --- a/draft/application/cms/src/kernel/api/cms_common_api.e +++ b/draft/application/cms/src/kernel/api/cms_common_api.e @@ -7,104 +7,28 @@ note deferred class CMS_COMMON_API +inherit + WSF_API_UTILITIES + feature {NONE} -- Access service: CMS_SERVICE deferred end + site_url: READABLE_STRING_8 + do + Result := service.site_url + end + base_url: detachable READABLE_STRING_8 -- Base url if any. do Result := service.script_url end - based_path (p: STRING): STRING - -- Path `p' in the context of the `base_url' - do - if attached base_url as l_base_url then - create Result.make_from_string (l_base_url) - if p.is_empty then - else - if p[1] = '/' then - Result.append (p.substring (2, p.count)) - else - Result.append (p) - end - end - else - Result := p - end - end - feature -- Access - url_encoded (s: detachable READABLE_STRING_GENERAL): STRING_8 - local - enc: URL_ENCODER - do - create enc - if s /= Void then - Result := enc.general_encoded_string (s) - else - create Result.make_empty - end - end - - html_encoded (s: detachable READABLE_STRING_GENERAL): STRING_8 - local - enc: HTML_ENCODER - do - create enc - if s /= Void then - Result := enc.general_encoded_string (s) - else - create Result.make_empty - end - end - - link (a_text: detachable READABLE_STRING_GENERAL; a_path: STRING; opts: detachable CMS_API_OPTIONS): STRING - local - l_html: BOOLEAN - t: READABLE_STRING_GENERAL - do - l_html := True - if opts /= Void then - l_html := opts.boolean_item ("html", l_html) - end - Result := "" - if a_text = Void then - t := a_path - else - t := a_text - end - if l_html then - Result.append (html_encoded (t)) - else - Result.append (checked_plain (t)) - end - Result.append ("") - end - - link_with_raw_text (a_text: detachable READABLE_STRING_8; a_path: STRING; opts: detachable CMS_API_OPTIONS): STRING - local - l_html: BOOLEAN - t: READABLE_STRING_8 - do - l_html := True - if opts /= Void then - l_html := opts.boolean_item ("html", l_html) - end - Result := "" - if a_text = Void then - t := a_path - else - t := a_text - end - Result.append (t) - Result.append ("") - end - user_link (u: CMS_USER): like link do Result := link (u.name, "/user/" + u.id.out, Void) @@ -125,91 +49,6 @@ 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 - l_abs: BOOLEAN - do - l_abs := False - - if opts /= Void then - l_abs := opts.boolean_item ("absolute", l_abs) - if attached opts.item ("query") as l_query then - if attached {READABLE_STRING_8} l_query as s_value then - q := s_value - elseif attached {ITERABLE [TUPLE [key, value: READABLE_STRING_GENERAL]]} l_query as lst then - create q.make_empty - across - lst as c - loop - if q.is_empty then - else - q.append_character ('&') - end - q.append (url_encoded (c.item.key)) - q.append_character ('=') - q.append (url_encoded (c.item.value)) - end - end - end - if attached opts.string_item ("fragment") as s_frag then - 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 - end - - checked_url (a_url: STRING): STRING - do - Result := a_url - end - - checked_plain (a_text: READABLE_STRING_GENERAL): STRING_8 - do - Result := html_encoder.general_encoded_string (a_text) - end - feature -- Helper is_empty (s: detachable READABLE_STRING_GENERAL): BOOLEAN @@ -255,9 +94,9 @@ feature {NONE} -- Implementation end end - html_encoder: HTML_ENCODER - once ("thread") - create Result - end +-- html_encoder: HTML_ENCODER +-- once ("thread") +-- create Result +-- end end diff --git a/draft/application/cms/src/kernel/content/cms_content_type.e b/draft/application/cms/src/kernel/content/cms_content_type.e index 64438267..ebddfea9 100644 --- a/draft/application/cms/src/kernel/content/cms_content_type.e +++ b/draft/application/cms/src/kernel/content/cms_content_type.e @@ -34,14 +34,14 @@ feature -- Factory deferred end - change_node (a_execution: CMS_EXECUTION; a_form_data: CMS_FORM_DATA; a_node: like new_node) + change_node (a_execution: CMS_EXECUTION; a_form_data: WSF_FORM_DATA; a_node: like new_node) -- Apply data from `a_form_data' to a_node require a_node.has_id deferred end - new_node (a_execution: CMS_EXECUTION; a_form_data: CMS_FORM_DATA; a_node: detachable like new_node): CMS_NODE + new_node (a_execution: CMS_EXECUTION; a_form_data: WSF_FORM_DATA; a_node: detachable like new_node): CMS_NODE -- New content created with `a_form_data' deferred ensure diff --git a/draft/application/cms/src/kernel/form/cms_form_item.e b/draft/application/cms/src/kernel/form/cms_form_item.e deleted file mode 100644 index 344fef10..00000000 --- a/draft/application/cms/src/kernel/form/cms_form_item.e +++ /dev/null @@ -1,17 +0,0 @@ -note - description: "Summary description for {CMS_FORM_ITEM}." - author: "" - date: "$Date$" - revision: "$Revision$" - -deferred class - CMS_FORM_ITEM - -inherit - CMS_WIDGET - - WITH_CSS_CLASS - - WITH_CSS_STYLE - -end diff --git a/draft/application/cms/src/kernel/link/cms_pager.e b/draft/application/cms/src/kernel/link/cms_pager.e index 6de95864..7cafd9a0 100644 --- a/draft/application/cms/src/kernel/link/cms_pager.e +++ b/draft/application/cms/src/kernel/link/cms_pager.e @@ -7,147 +7,11 @@ note class CMS_PAGER +inherit + WSF_WIDGET_PAGER + create make -feature {NONE} -- Initialization - - make (tpl: READABLE_STRING_8; a_lower, a_upper: NATURAL_64; a_step: NATURAL_64) - do - create template.make (tpl) - lower := a_lower - upper := a_upper - step := a_step - end - -feature -- Change - - set_active_range (a_lower, a_upper: NATURAL_64) - do - if a_upper = 0 then - active_range := [{NATURAL_64} 1, {NATURAL_64} 0] - elseif a_lower > 0 and a_lower <= a_upper then - active_range := [a_lower, a_upper] - else - active_range := Void - end - ensure - valid_range: attached active_range as rg implies (rg.upper = 0 or else rg.lower <= rg.upper) - end - -feature -- Access - - template: URI_TEMPLATE - - lower: NATURAL_64 - - upper: NATURAL_64 - - step: NATURAL_64 - - active_range: detachable TUPLE [lower_index, upper_index: NATURAL_64] - -feature -- Conversion - - to_html (a_theme: CMS_THEME): STRING_8 - local - l_step: INTEGER - nb: INTEGER - curr: INTEGER - n, i: INTEGER - tb: HASH_TABLE [detachable ANY, STRING_8] - do - create Result.make (32) - Result.append ("') - nb := ((upper - lower) // step).to_integer_32 + 1 - if nb > 1 then - if attached active_range as rg then - if rg.upper_index = 0 then - -- all - else - curr := ((rg.lower_index - lower) // step).to_integer_32 - if step * curr.to_natural_64 < rg.lower_index then - curr := curr + 1 - end - end - end - - l_step := step.to_integer_32 - create tb.make (2) - tb.force (1, "lower") - tb.force (step, "upper") - if curr > 1 then - if curr > 2 then - tb.force (1, "lower") - tb.force (l_step, "upper") - - Result.append_character (' ') - Result.append (a_theme.link ("<<", template.expanded_string (tb), Void)) - Result.append_character (' ') - end - - tb.force ((curr - 1) * l_step + 1, "lower") - tb.force ((curr ) * l_step , "upper") - - Result.append_character (' ') - Result.append (a_theme.link ("<", template.expanded_string (tb), Void)) - Result.append_character (' ') - end - - from - i := (curr - 1).max (1) - n := 5 - until - n = 0 or i > nb - loop - Result.append_character (' ') - - tb.force ((i - 1) * l_step + 1, "lower") - tb.force ((i ) * l_step , "upper") - - if i = curr then - Result.append ("") - end - Result.append (a_theme.link (i.out, template.expanded_string (tb), Void)) - if i = curr then - Result.append ("") - end - - Result.append_character (' ') - - i := i + 1 - n := n - 1 - end - - if curr < nb then - Result.append_character (' ') - tb.force ((curr ) * l_step + 1, "lower") - tb.force ((curr + 1) * l_step , "upper") - - Result.append (a_theme.link (">", template.expanded_string (tb), Void)) - Result.append_character (' ') - - if curr + 1 < nb then - tb.force ((nb - 1) * l_step + 1, "lower") - tb.force ( upper , "upper") - - Result.append_character (' ') - Result.append (a_theme.link (">>", template.expanded_string (tb), Void)) - Result.append_character (' ') - end - end - Result.append_character (' ') - tb.force (1, "lower") - tb.force (upper , "upper") - Result.append (a_theme.link ("all", template.expanded_string (tb), Void)) - Result.append_character (' ') - end - - Result.append ("") - debug - Result.append ("curr=" + curr.out +" step=" + step.out + " nb=" + nb.out) - end - end end diff --git a/draft/application/cms/src/kernel/log/cms_log.e b/draft/application/cms/src/kernel/log/cms_log.e index 7f71460c..d5b02f43 100644 --- a/draft/application/cms/src/kernel/log/cms_log.e +++ b/draft/application/cms/src/kernel/log/cms_log.e @@ -91,7 +91,7 @@ feature -- Change feature -- Conversion - to_html (a_theme: CMS_THEME): STRING_8 + to_html (a_theme: WSF_THEME): STRING_8 do Result := "
" Result.append ("
") diff --git a/draft/application/cms/src/modules/admin/admin_user_roles_cms_execution.e b/draft/application/cms/src/modules/admin/admin_user_roles_cms_execution.e index 84ea97c0..5fe6fb6b 100644 --- a/draft/application/cms/src/modules/admin/admin_user_roles_cms_execution.e +++ b/draft/application/cms/src/modules/admin/admin_user_roles_cms_execution.e @@ -81,7 +81,7 @@ feature -- Execution feature -- Forms - edit_form_submit (fd: CMS_FORM_DATA; a_roles: LIST [CMS_USER_ROLE]) + edit_form_submit (fd: WSF_FORM_DATA; a_roles: LIST [CMS_USER_ROLE]) local l_role: CMS_USER_ROLE do @@ -120,9 +120,9 @@ feature -- Forms new_edit_form (a_action: READABLE_STRING_8; a_roles: LIST [CMS_USER_ROLE]; a_use_data: BOOLEAN): CMS_FORM local perms: ARRAYED_SET [READABLE_STRING_8] - tb: CMS_WIDGET_AGENT_TABLE [READABLE_STRING_8] + tb: WSF_WIDGET_AGENT_TABLE [READABLE_STRING_8] i: INTEGER - tf: CMS_FORM_TEXT_INPUT + tf: WSF_FORM_TEXT_INPUT do create perms.make (10) perms.compare_objects @@ -158,10 +158,10 @@ feature -- Forms tb.add_css_style ("border: solid 1px #999;") tb.set_data (perms) - tb.set_compute_item_function (agent (p: READABLE_STRING_8; ia_roles: LIST [CMS_USER_ROLE]; ia_use_data: BOOLEAN): CMS_WIDGET_TABLE_ROW + tb.set_compute_item_function (agent (p: READABLE_STRING_8; ia_roles: LIST [CMS_USER_ROLE]; ia_use_data: BOOLEAN): WSF_WIDGET_TABLE_ROW local - it: CMS_WIDGET_TABLE_ITEM - cb: CMS_FORM_CHECKBOX_INPUT + it: WSF_WIDGET_TABLE_ITEM + cb: WSF_FORM_CHECKBOX_INPUT do create Result.make (1 + ia_roles.count) create it.make_with_text (p) @@ -188,21 +188,21 @@ feature -- Forms create Result.make (a_action, "edit-user-roles") Result.set_method_post Result.extend (tb.to_computed_table) - Result.extend (create {CMS_FORM_SUBMIT_INPUT}.make_with_text ("op", "Apply")) + Result.extend (create {WSF_FORM_SUBMIT_INPUT}.make_with_text ("op", "Apply")) create tf.make ("new-role") tf.add_css_class ("horizontal") tf.set_size (24) tf.set_label ("New user role") Result.extend (tf) - Result.extend (create {CMS_FORM_SUBMIT_INPUT}.make_with_text ("op", "Add role")) + Result.extend (create {WSF_FORM_SUBMIT_INPUT}.make_with_text ("op", "Add role")) create tf.make ("new-permission") tf.add_css_class ("horizontal") tf.set_size (24) tf.set_label ("New permission") Result.extend (tf) - Result.extend (create {CMS_FORM_SUBMIT_INPUT}.make_with_text ("op", "Add permission")) + Result.extend (create {WSF_FORM_SUBMIT_INPUT}.make_with_text ("op", "Add permission")) diff --git a/draft/application/cms/src/modules/node/cms_page_content_type.e b/draft/application/cms/src/modules/node/cms_page_content_type.e index 74e4f787..948d8e4d 100644 --- a/draft/application/cms/src/modules/node/cms_page_content_type.e +++ b/draft/application/cms/src/modules/node/cms_page_content_type.e @@ -41,11 +41,11 @@ feature -- Factory fill_edit_form (f: CMS_FORM; a_node: detachable CMS_NODE) local - ti: CMS_FORM_TEXT_INPUT - fset: CMS_FORM_FIELD_SET - ta: CMS_FORM_TEXTAREA - tselect: CMS_FORM_SELECT - opt: CMS_FORM_SELECT_OPTION + ti: WSF_FORM_TEXT_INPUT + fset: WSF_FORM_FIELD_SET + ta: WSF_FORM_TEXTAREA + tselect: WSF_FORM_SELECT + opt: WSF_FORM_SELECT_OPTION do create ti.make ("title") ti.set_label ("Title") @@ -96,7 +96,7 @@ feature -- Factory end - change_node (a_execution: CMS_EXECUTION; fd: CMS_FORM_DATA; a_node: like new_node) + change_node (a_execution: CMS_EXECUTION; fd: WSF_FORM_DATA; a_node: like new_node) local b: detachable READABLE_STRING_8 f: detachable CMS_FORMAT @@ -123,7 +123,7 @@ feature -- Factory end end - new_node (a_execution: CMS_EXECUTION; fd: CMS_FORM_DATA; a_node: detachable like new_node): CMS_PAGE + new_node (a_execution: CMS_EXECUTION; fd: WSF_FORM_DATA; a_node: detachable like new_node): CMS_PAGE -- local b: detachable READABLE_STRING_8 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 e79252b9..6b3357e3 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 @@ -18,7 +18,7 @@ feature -- Execution local b: STRING_8 f: like edit_form - fd: detachable CMS_FORM_DATA + fd: detachable WSF_FORM_DATA do create b.make_empty if attached non_empty_string_path_parameter ("type") as s_type then diff --git a/draft/application/cms/src/modules/node/node_cms_execution.e b/draft/application/cms/src/modules/node/node_cms_execution.e index 339b7fa4..075649b9 100644 --- a/draft/application/cms/src/modules/node/node_cms_execution.e +++ b/draft/application/cms/src/modules/node/node_cms_execution.e @@ -12,7 +12,7 @@ inherit feature -- Form - edit_form_validate (fd: CMS_FORM_DATA; b: STRING) + edit_form_validate (fd: WSF_FORM_DATA; b: STRING) local l_preview: BOOLEAN l_format: detachable CMS_FORMAT @@ -39,7 +39,7 @@ feature -- Form end end - edit_form_submit (fd: CMS_FORM_DATA; a_node: detachable CMS_NODE; a_type: CMS_CONTENT_TYPE; b: STRING) + edit_form_submit (fd: WSF_FORM_DATA; a_node: detachable CMS_NODE; a_type: CMS_CONTENT_TYPE; b: STRING) local l_preview: BOOLEAN l_node: detachable CMS_NODE @@ -77,7 +77,7 @@ feature -- Form end end --- edit_form_submit (fd: CMS_FORM_DATA; a_type: CMS_CONTENT_TYPE; b: STRING) +-- edit_form_submit (fd: WSF_FORM_DATA; a_type: CMS_CONTENT_TYPE; b: STRING) -- local -- l_preview: BOOLEAN -- do @@ -110,8 +110,8 @@ feature -- Form edit_form (a_node: detachable CMS_NODE; a_url: READABLE_STRING_8; a_name: STRING; a_type: CMS_CONTENT_TYPE): CMS_FORM local f: CMS_FORM - ts: CMS_FORM_SUBMIT_INPUT - th: CMS_FORM_HIDDEN_INPUT + ts: WSF_FORM_SUBMIT_INPUT + th: WSF_FORM_HIDDEN_INPUT do create f.make (a_url, a_name) 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 0ab65038..ebe46173 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 @@ -18,7 +18,7 @@ feature -- Execution local b: STRING_8 f: like edit_form - fd: detachable CMS_FORM_DATA + fd: detachable WSF_FORM_DATA do create b.make_empty if diff --git a/draft/application/cms/src/modules/openid/openid_cms_execution.e b/draft/application/cms/src/modules/openid/openid_cms_execution.e index e1b805cb..53bbdbf9 100644 --- a/draft/application/cms/src/modules/openid/openid_cms_execution.e +++ b/draft/application/cms/src/modules/openid/openid_cms_execution.e @@ -18,8 +18,8 @@ feature -- Execution local b: STRING f: CMS_FORM - tf: CMS_FORM_TEXT_INPUT - ts: CMS_FORM_SUBMIT_INPUT + tf: WSF_FORM_TEXT_INPUT + ts: WSF_FORM_SUBMIT_INPUT o: OPENID_CONSUMER v: OPENID_CONSUMER_VALIDATION tb: HASH_TABLE [READABLE_STRING_8, STRING_8] diff --git a/draft/application/cms/src/modules/openid/openid_module.e b/draft/application/cms/src/modules/openid/openid_module.e index 302b1b78..2f3a073f 100644 --- a/draft/application/cms/src/modules/openid/openid_module.e +++ b/draft/application/cms/src/modules/openid/openid_module.e @@ -60,10 +60,10 @@ feature -- Hooks end end - form_alter (a_form: CMS_FORM; a_form_data: detachable CMS_FORM_DATA; a_execution: CMS_EXECUTION) + form_alter (a_form: CMS_FORM; a_form_data: detachable WSF_FORM_DATA; a_execution: CMS_EXECUTION) local - i: CMS_FORM_DIV - fh: CMS_FORM_HIDDEN_INPUT + i: WSF_FORM_DIV + fh: WSF_FORM_HIDDEN_INPUT do if a_form.id.same_string ("openid-login") then create i.make_with_text_and_css_id ( @@ -82,7 +82,7 @@ feature -- Hooks , "openid" ) - if attached a_form.items_by_type ({CMS_WIDGET_TEXT}) as lst and then not lst.is_empty then + if attached a_form.items_by_type ({WSF_WIDGET_TEXT}) as lst and then not lst.is_empty then a_form.insert_before (i, lst.last) else a_form.extend (i) @@ -98,7 +98,7 @@ feature -- Hooks across f_lst as c loop - if attached {CMS_FORM_TEXT_INPUT} c.item as txt then + if attached {WSF_FORM_TEXT_INPUT} c.item as txt then txt.set_text_value (l_openid_nickname.to_string_32) end end @@ -110,7 +110,7 @@ feature -- Hooks across f_lst as c loop - if attached {CMS_FORM_TEXT_INPUT} c.item as txt then + if attached {WSF_FORM_TEXT_INPUT} c.item as txt then txt.set_text_value (l_openid_email.to_string_32) end end @@ -122,7 +122,7 @@ feature -- Hooks end end - openid_user_register_submitted (a_form_data: CMS_FORM_DATA) + openid_user_register_submitted (a_form_data: WSF_FORM_DATA) do end 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 76a2a39b..89e0762f 100644 --- a/draft/application/cms/src/modules/user/user_cms_execution.e +++ b/draft/application/cms/src/modules/user/user_cms_execution.e @@ -94,7 +94,7 @@ feature -- Execution l_url: detachable READABLE_STRING_8 b: STRING_8 f: CMS_FORM - fd: detachable CMS_FORM_DATA + fd: detachable WSF_FORM_DATA do if attached {WSF_STRING} request.item ("destination") as s_dest @@ -134,7 +134,7 @@ feature -- Execution end end - on_form_submitted (fd: CMS_FORM_DATA) + on_form_submitted (fd: WSF_FORM_DATA) local u: detachable CMS_USER do @@ -159,12 +159,12 @@ feature -- Execution login_form (a_action: READABLE_STRING_8; a_form_name: READABLE_STRING_8; a_destination: READABLE_STRING_8): CMS_FORM local - th: CMS_FORM_HIDDEN_INPUT - ti: CMS_FORM_TEXT_INPUT - tp: CMS_FORM_PASSWORD_INPUT - ts: CMS_FORM_SUBMIT_INPUT - l_logo: CMS_FORM_RAW_TEXT - d: CMS_FORM_DIV + th: WSF_FORM_HIDDEN_INPUT + ti: WSF_FORM_TEXT_INPUT + tp: WSF_FORM_PASSWORD_INPUT + ts: WSF_FORM_SUBMIT_INPUT + l_logo: WSF_FORM_RAW_TEXT + d: WSF_FORM_DIV do create Result.make (a_action, a_form_name) 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 37afd19a..bc076fb6 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 @@ -20,7 +20,7 @@ feature -- Execution local b: STRING_8 f: CMS_FORM - fd: detachable CMS_FORM_DATA + fd: detachable WSF_FORM_DATA u: detachable CMS_USER l_is_editing_current_user: BOOLEAN do @@ -63,7 +63,7 @@ feature -- Execution set_main_content (b) end - edit_form_validate (fd: CMS_FORM_DATA; u: CMS_USER) + edit_form_validate (fd: WSF_FORM_DATA; u: CMS_USER) local fu: detachable CMS_USER do @@ -81,7 +81,7 @@ feature -- Execution end end - edit_form_submit (fd: CMS_FORM_DATA; u: CMS_USER; a_is_editing_current_user: BOOLEAN; b: STRING) + edit_form_submit (fd: WSF_FORM_DATA; u: CMS_USER; a_is_editing_current_user: BOOLEAN; b: STRING) local up: detachable CMS_USER_PROFILE l_roles: like {CMS_USER}.roles @@ -138,12 +138,12 @@ feature -- Execution edit_form (u: CMS_USER; a_url: READABLE_STRING_8; a_name: STRING): CMS_FORM local f: CMS_FORM - ti: CMS_FORM_TEXT_INPUT - tp: CMS_FORM_PASSWORD_INPUT - ta: CMS_FORM_TEXTAREA - ts: CMS_FORM_SUBMIT_INPUT - tset: CMS_FORM_FIELD_SET - cb: CMS_FORM_CHECKBOX_INPUT + ti: WSF_FORM_TEXT_INPUT + tp: WSF_FORM_PASSWORD_INPUT + ta: WSF_FORM_TEXTAREA + ts: WSF_FORM_SUBMIT_INPUT + tset: WSF_FORM_FIELD_SET + cb: WSF_FORM_CHECKBOX_INPUT do create f.make (a_url, a_name) 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 25438ecf..70b60710 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 @@ -21,7 +21,7 @@ feature -- Execution b: STRING_8 f: CMS_FORM u: detachable CMS_USER - fd: detachable CMS_FORM_DATA + fd: detachable WSF_FORM_DATA do set_title ("Request new password") create b.make_empty @@ -56,7 +56,7 @@ feature -- Execution set_main_content (b) end - password_form_validate (fd: CMS_FORM_DATA) + password_form_validate (fd: WSF_FORM_DATA) local u: detachable CMS_USER do @@ -73,7 +73,7 @@ feature -- Execution initialize_primary_tabs (u) end - password_form_submit (fd: CMS_FORM_DATA; b: STRING) + password_form_submit (fd: WSF_FORM_DATA; b: STRING) local e: detachable CMS_EMAIL l_uuid: UUID @@ -113,9 +113,9 @@ feature -- Execution local u: like user f: CMS_FORM - ti: CMS_FORM_TEXT_INPUT - th: CMS_FORM_HIDDEN_INPUT - ts: CMS_FORM_SUBMIT_INPUT + ti: WSF_FORM_TEXT_INPUT + th: WSF_FORM_HIDDEN_INPUT + ts: WSF_FORM_SUBMIT_INPUT err: BOOLEAN do create f.make (a_url, a_name) 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 b82f64ca..95369dc9 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 @@ -20,7 +20,7 @@ feature -- Execution local b: STRING_8 f: CMS_FORM - fd: detachable CMS_FORM_DATA + fd: detachable WSF_FORM_DATA do set_title ("Create new account") create b.make_empty @@ -50,7 +50,7 @@ feature -- Execution set_main_content (b) end - registration_form_validate (fd: CMS_FORM_DATA) + registration_form_validate (fd: WSF_FORM_DATA) local u: detachable CMS_USER do @@ -68,7 +68,7 @@ feature -- Execution end end - registration_form_submitted (fd: CMS_FORM_DATA; buf: STRING) + registration_form_submitted (fd: WSF_FORM_DATA; buf: STRING) local b: STRING u: detachable CMS_USER @@ -124,17 +124,17 @@ feature -- Execution registration_form (a_url: READABLE_STRING_8; a_name: STRING): CMS_FORM local f: CMS_FORM - ti: CMS_FORM_TEXT_INPUT - tp: CMS_FORM_PASSWORD_INPUT - ta: CMS_FORM_TEXTAREA - ts: CMS_FORM_SUBMIT_INPUT + ti: WSF_FORM_TEXT_INPUT + tp: WSF_FORM_PASSWORD_INPUT + ta: WSF_FORM_TEXTAREA + ts: WSF_FORM_SUBMIT_INPUT do create f.make (a_url, a_name) create ti.make ("username") ti.set_label ("Username") ti.set_is_required (True) - ti.set_validation_action (agent (fd: CMS_FORM_DATA) + ti.set_validation_action (agent (fd: WSF_FORM_DATA) do if attached {WSF_STRING} fd.item ("username") as f_username and then f_username.value.count >= 5 then else diff --git a/draft/application/cms/src/theme/cms_theme.e b/draft/application/cms/src/theme/cms_theme.e index 5942c413..bec379ae 100644 --- a/draft/application/cms/src/theme/cms_theme.e +++ b/draft/application/cms/src/theme/cms_theme.e @@ -8,6 +8,12 @@ deferred class CMS_THEME inherit + WSF_THEME + undefine + url_encoded, + html_encoded + end + CMS_COMMON_API feature {NONE} -- Access diff --git a/library/network/protocol/http/src/http_header.e b/library/network/protocol/http/src/http_header.e index aa1f89c0..b1eee52d 100644 --- a/library/network/protocol/http/src/http_header.e +++ b/library/network/protocol/http/src/http_header.e @@ -250,6 +250,85 @@ feature -- Header: merging end end +feature -- Status report + + has, has_header_named (a_name: READABLE_STRING_8): BOOLEAN + -- Has header item for `n'? + do + Result := across headers as c some has_same_header_name (c.item, a_name) end + end + + has_content_length: BOOLEAN + -- Has header "Content-Length" + do + Result := has_header_named ({HTTP_HEADER_NAMES}.header_content_length) + end + + has_content_type: BOOLEAN + -- Has header "Content-Type" + do + Result := has_header_named ({HTTP_HEADER_NAMES}.header_content_type) + end + + has_transfer_encoding_chunked: BOOLEAN + -- Has "Transfer-Encoding: chunked" header + do + if has_header_named ({HTTP_HEADER_NAMES}.header_transfer_encoding) then + Result := attached header_named_value ({HTTP_HEADER_NAMES}.header_transfer_encoding) as v and then v.same_string (str_chunked) + end + end + +feature -- Access + + header_named_value (a_name: READABLE_STRING_8): detachable STRING_8 + -- First header item found for `a_name' if any + require + has_header: has_header_named (a_name) + local + c: like headers.new_cursor + n: INTEGER + l_line: READABLE_STRING_8 + do + from + n := a_name.count + c := headers.new_cursor + until + c.after or Result /= Void + loop + l_line := c.item + if has_same_header_name (l_line, a_name) then + Result := l_line.substring (n + 2, l_line.count) + Result.left_adjust + Result.right_adjust + end + c.forth + end + end + +feature -- Removal + + remove_header_named (a_name: READABLE_STRING_8) + -- Remove any header line related to name `a_name'. + local + lst: like headers + do + from + lst := headers + lst.start + until + lst.after + loop + if has_same_header_name (lst.item, a_name) then + -- remove + lst.remove + else + lst.forth + end + end + ensure + removed: not has_header_named (a_name) + end + feature -- Header change: general add_header (h: READABLE_STRING_8) @@ -280,6 +359,8 @@ feature -- Header change: general s.append (colon_space) s.append (v) add_header (s) + ensure + added: has_header_named (k) end put_header_key_value (k,v: READABLE_STRING_8) @@ -292,6 +373,8 @@ feature -- Header change: general s.append (colon_space) s.append (v) put_header (s) + ensure + added: has_header_named (k) end put_header_key_values (k: READABLE_STRING_8; a_values: ITERABLE [READABLE_STRING_8]; a_separator: detachable READABLE_STRING_8) @@ -318,6 +401,8 @@ feature -- Header change: general if not s.is_empty then put_header_key_value (k, s) end + ensure + added: has_header_named (k) end feature -- Content related header @@ -607,6 +692,12 @@ feature -- Others feature -- Redirection + remove_location + -- Remove any location header line. + do + remove_header_named ({HTTP_HEADER_NAMES}.header_location) + end + put_location (a_location: READABLE_STRING_8) -- Tell the client the new location `a_location' require @@ -669,83 +760,18 @@ feature -- Cookie put_cookie (key, value, date_to_rfc1123_http_date_format (expiration), path, domain, secure, http_only) end -feature -- Status report - - header_named_value (a_name: READABLE_STRING_8): detachable STRING_8 - -- Has header item for `n'? - require - has_header: has_header_named (a_name) - local - c: like headers.new_cursor - n: INTEGER - l_line: READABLE_STRING_8 - do - from - n := a_name.count - c := headers.new_cursor - until - c.after or Result /= Void - loop - l_line := c.item - if l_line.starts_with (a_name) then - if l_line.valid_index (n + 1) then - if l_line [n + 1] = ':' then - Result := l_line.substring (n + 2, l_line.count) - Result.left_adjust - Result.right_adjust - end - end - end - c.forth - end - end - - has_header_named (a_name: READABLE_STRING_8): BOOLEAN - -- Has header item for `n'? - local - c: like headers.new_cursor - n: INTEGER - l_line: READABLE_STRING_8 - do - from - n := a_name.count - c := headers.new_cursor - until - c.after or Result - loop - l_line := c.item - if l_line.starts_with (a_name) then - if l_line.valid_index (n + 1) then - Result := l_line [n + 1] = ':' - end - end - c.forth - end - end - - has_content_length: BOOLEAN - -- Has header "Content-Length" - do - Result := has_header_named ({HTTP_HEADER_NAMES}.header_content_length) - end - - has_content_type: BOOLEAN - -- Has header "Content-Type" - do - Result := has_header_named ({HTTP_HEADER_NAMES}.header_content_type) - end - - has_transfer_encoding_chunked: BOOLEAN - -- Has "Transfer-Encoding: chunked" header - do - if has_header_named ({HTTP_HEADER_NAMES}.header_transfer_encoding) then - Result := attached header_named_value ({HTTP_HEADER_NAMES}.header_transfer_encoding) as v and then v.same_string (str_chunked) - end - end - - feature {NONE} -- Implementation: Header + has_same_header_name (h: READABLE_STRING_8; a_name: READABLE_STRING_8): BOOLEAN + -- Header line `h' has same name as `a_name' ? + do + if h.starts_with (a_name) then + if h.valid_index (a_name.count + 1) then + Result := h[a_name.count + 1] = ':' + end + end + end + force_header_by_name (n: detachable READABLE_STRING_8; h: READABLE_STRING_8) -- Add header `h' or replace existing header of same header name `n' require diff --git a/library/server/ewsgi/connectors/nino/src/wgi_nino_input_stream.e b/library/server/ewsgi/connectors/nino/src/wgi_nino_input_stream.e index 585d7e9f..6cddecdd 100644 --- a/library/server/ewsgi/connectors/nino/src/wgi_nino_input_stream.e +++ b/library/server/ewsgi/connectors/nino/src/wgi_nino_input_stream.e @@ -54,7 +54,7 @@ feature -- Input do src := source last_string.wipe_out - if src.socket_ok then + if src.readable then src.read_stream_thread_aware (nb) last_string.append_string (src.last_string) end diff --git a/library/server/ewsgi/specification/response/wgi_response.e b/library/server/ewsgi/specification/response/wgi_response.e index 11db233e..8d8f9de5 100644 --- a/library/server/ewsgi/specification/response/wgi_response.e +++ b/library/server/ewsgi/specification/response/wgi_response.e @@ -11,10 +11,10 @@ feature {WGI_CONNECTOR, WGI_SERVICE} -- Commit push -- Commit and push response do - commit if attached post_commit_action as act then act.call (Void) end + commit end commit @@ -22,6 +22,7 @@ feature {WGI_CONNECTOR, WGI_SERVICE} -- Commit deferred ensure status_is_set: status_is_set + status_committed: status_committed header_committed: header_committed message_committed: message_committed end diff --git a/library/server/wsf/router/documentation/wsf_router_mapping_documentation.e b/library/server/wsf/router/documentation/wsf_router_mapping_documentation.e index ea334357..5f755f35 100644 --- a/library/server/wsf/router/documentation/wsf_router_mapping_documentation.e +++ b/library/server/wsf/router/documentation/wsf_router_mapping_documentation.e @@ -14,7 +14,7 @@ feature {NONE} -- Initialization make (m: like mapping) do mapping := m - create {STRING_32} description.make_empty + create descriptions.make (0) end feature -- Status report @@ -27,7 +27,7 @@ feature -- Status report -- Is Current empty? -- i.e: does not carry any information. do - Result := description.is_empty + Result := descriptions.is_empty end feature -- Access @@ -35,7 +35,18 @@ feature -- Access mapping: WSF_ROUTER_MAPPING -- Associated mapping + descriptions: ARRAYED_LIST [READABLE_STRING_GENERAL] + description: STRING_32 + do + create Result.make_empty + across + descriptions as c + loop + Result.append_string_general (c.item) + Result.append ("%N") + end + end feature -- Change @@ -46,7 +57,17 @@ feature -- Change add_description (d: READABLE_STRING_GENERAL) do - description.append_string_general (d) + descriptions.force (d) end +note + copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" end diff --git a/library/server/wsf/router/documentation/wsf_router_self_documentation_message.e b/library/server/wsf/router/documentation/wsf_router_self_documentation_message.e index 6aea58be..21d4bfc4 100644 --- a/library/server/wsf/router/documentation/wsf_router_self_documentation_message.e +++ b/library/server/wsf/router/documentation/wsf_router_self_documentation_message.e @@ -204,6 +204,7 @@ feature {WSF_RESPONSE} -- Output l_url: detachable STRING_8 l_base_url: detachable READABLE_STRING_8 l_doc: detachable WSF_ROUTER_MAPPING_DOCUMENTATION + l_first: BOOLEAN do if attached {WSF_SELF_DOCUMENTED_ROUTER_MAPPING} m as l_doc_mapping then l_doc := l_doc_mapping.documentation (meths) @@ -256,7 +257,17 @@ feature {WSF_RESPONSE} -- Output if l_doc /= Void and then not l_doc.is_empty then s.append ("%N
    ") - s.append (html_encoder.encoded_string (l_doc.description)) + l_first := True + across + l_doc.descriptions as c + loop + if not l_first then + s.append ("
    ") + else + l_first := False + end + s.append (html_encoder.general_encoded_string (c.item)) + end s.append ("%N
%N") else debug diff --git a/library/server/wsf/router/support/starts_with/helpers/wsf_starts_with_agent_handler.e b/library/server/wsf/router/support/starts_with/helpers/wsf_starts_with_agent_handler.e new file mode 100644 index 00000000..6ab61154 --- /dev/null +++ b/library/server/wsf/router/support/starts_with/helpers/wsf_starts_with_agent_handler.e @@ -0,0 +1,44 @@ +note + description: "Summary description for {WSF_STARTS_WITH_AGENT_HANDLER}." + author: "" + date: "$Date$" + revision: "$Revision$" + +class + WSF_STARTS_WITH_AGENT_HANDLER + +inherit + WSF_STARTS_WITH_HANDLER + +create + make + +feature {NONE} -- Initialization + + make (a_action: like action) + do + action := a_action + end + +feature -- Access + + action: PROCEDURE [ANY, TUPLE [start_path: READABLE_STRING_8; request: WSF_REQUEST; response: WSF_RESPONSE]] + +feature -- Execution + + execute (a_start_path: READABLE_STRING_8; req: WSF_REQUEST; res: WSF_RESPONSE) + do + action.call ([a_start_path, req, res]) + end + +note + copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" +end diff --git a/library/server/wsf/router/wsf_file_system_handler.e b/library/server/wsf/router/wsf_file_system_handler.e index 628115bf..9e54a43e 100644 --- a/library/server/wsf/router/wsf_file_system_handler.e +++ b/library/server/wsf/router/wsf_file_system_handler.e @@ -13,8 +13,11 @@ inherit execute as execute_starts_with end + WSF_SELF_DOCUMENTED_HANDLER + create - make + make, + make_hidden feature {NONE} -- Initialization @@ -34,6 +37,29 @@ feature {NONE} -- Initialization not document_root.is_empty and then not document_root.ends_with (operating_environment.directory_separator.out) end + make_hidden (d: like document_root) + require + valid_d: (d /= Void and then not d.is_empty) implies not d.ends_with (operating_environment.directory_separator.out) + do + make (d) + is_hidden := True + ensure + hidden: is_hidden + end + + is_hidden: BOOLEAN + -- Current mapped handler should be hidden from self documentation + +feature -- Documentation + + mapping_documentation (m: WSF_ROUTER_MAPPING; a_request_methods: detachable WSF_REQUEST_METHODS): WSF_ROUTER_MAPPING_DOCUMENTATION + -- + do + create Result.make (m) + Result.set_is_hidden (is_hidden) + Result.add_description ("File service") + end + feature -- Access document_root: STRING diff --git a/library/server/wsf/src/implementation/wsf_wgi_delayed_header_response.e b/library/server/wsf/src/implementation/wsf_wgi_delayed_header_response.e index 006b67ff..9b685893 100644 --- a/library/server/wsf/src/implementation/wsf_wgi_delayed_header_response.e +++ b/library/server/wsf/src/implementation/wsf_wgi_delayed_header_response.e @@ -14,7 +14,8 @@ inherit put_string, put_substring, flush, - message_writable + message_writable, + message_committed end WSF_RESPONSE_EXPORTER @@ -36,10 +37,10 @@ feature {NONE} -- Implementation commit do - Precursor if not header_committed then process_header end + Precursor end process_header @@ -65,6 +66,12 @@ feature -- Status report message_writable: BOOLEAN = True -- Can message be written? + message_committed: BOOLEAN + -- + do + Result := header_committed + end + feature -- Output operation put_character (c: CHARACTER_8) diff --git a/library/server/wsf/src/response/wsf_html_delayed_redirection_response.e b/library/server/wsf/src/response/wsf_html_delayed_redirection_response.e index e92ded3b..a0f1f218 100644 --- a/library/server/wsf/src/response/wsf_html_delayed_redirection_response.e +++ b/library/server/wsf/src/response/wsf_html_delayed_redirection_response.e @@ -26,7 +26,7 @@ feature {NONE} -- Initialization url_location := a_url_location delay := a_delay_in_seconds make_html - set_status_code ({HTTP_STATUS_CODE}.found) + status_code := {HTTP_STATUS_CODE}.found end feature -- Header @@ -65,7 +65,7 @@ feature {NONE} -- Output end note - copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others" + copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/library/server/wsf/src/response/wsf_html_page_response.e b/library/server/wsf/src/response/wsf_html_page_response.e index 5a829fca..874d1e06 100644 --- a/library/server/wsf/src/response/wsf_html_page_response.e +++ b/library/server/wsf/src/response/wsf_html_page_response.e @@ -197,7 +197,7 @@ feature {NONE} -- HTML Generation end note - copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others" + copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/library/server/wsf/src/response/wsf_redirection_response.e b/library/server/wsf/src/response/wsf_redirection_response.e index 3a4145b0..90496c95 100644 --- a/library/server/wsf/src/response/wsf_redirection_response.e +++ b/library/server/wsf/src/response/wsf_redirection_response.e @@ -18,7 +18,7 @@ feature {NONE} -- Initialization make (a_url_location: like url_location) do - status_code := {HTTP_STATUS_CODE}.ok + status_code := {HTTP_STATUS_CODE}.found url_location := a_url_location create header.make end @@ -100,7 +100,7 @@ feature {WSF_RESPONSE} -- Output end note - copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others" + copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/library/server/wsf/src/wsf_response.e b/library/server/wsf/src/wsf_response.e index c70c1da3..cc2b6b5f 100644 --- a/library/server/wsf/src/wsf_response.e +++ b/library/server/wsf/src/wsf_response.e @@ -252,23 +252,23 @@ feature -- Header output operation: helpers message_writable: message_writable end - put_header_lines (a_lines: ITERABLE [TUPLE [name: READABLE_STRING_8; value: READABLE_STRING_8]]) + put_header_lines (a_lines: ITERABLE [READABLE_STRING_8]) -- Put headers from `a_lines' require header_not_committed: not header_committed do across a_lines as c loop - put_header_line (c.item.name + ": " + c.item.value) + put_header_line (c.item) end end - add_header_lines (a_lines: ITERABLE [TUPLE [name: READABLE_STRING_8; value: READABLE_STRING_8]]) + add_header_lines (a_lines: ITERABLE [READABLE_STRING_8]) -- Add headers from `a_lines' require header_not_committed: not header_committed do across a_lines as c loop - add_header_line (c.item.name + ": " + c.item.value) + add_header_line (c.item) end end @@ -409,8 +409,7 @@ feature -- Response object do a_message.send_to (Current) ensure - status_committed: status_committed - header_committed: header_committed + status_committed: status_is_set end feature -- Redirect diff --git a/library/server/wsf/src/wsf_response_message.e b/library/server/wsf/src/wsf_response_message.e index 904dd425..70dfa8e2 100644 --- a/library/server/wsf/src/wsf_response_message.e +++ b/library/server/wsf/src/wsf_response_message.e @@ -26,11 +26,10 @@ feature {WSF_RESPONSE} -- Output deferred ensure res_status_set: res.status_is_set - res_header_committed: res.header_committed end note - copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others" + copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/library/server/wsf/wsf-safe.ecf b/library/server/wsf/wsf-safe.ecf deleted file mode 100644 index dbb91df7..00000000 --- a/library/server/wsf/wsf-safe.ecf +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - /.git$ - /EIFGENs$ - /.svn$ - - - - - - - - - - - - - - - diff --git a/library/server/wsf_html/api/wsf_api_options.e b/library/server/wsf_html/api/wsf_api_options.e new file mode 100644 index 00000000..eb9396c8 --- /dev/null +++ b/library/server/wsf_html/api/wsf_api_options.e @@ -0,0 +1,98 @@ +note + description: "Summary description for {WSF_API_OPTIONS}." + author: "" + date: "$Date$" + revision: "$Revision$" + +class + WSF_API_OPTIONS + +inherit + TABLE_ITERABLE [detachable ANY, STRING] + +create + make, + make_from_manifest + +convert + make_from_manifest ({ ARRAY [TUPLE [key: STRING; value: detachable ANY]], + ARRAY [TUPLE [STRING_8, ARRAY [TUPLE [STRING_8, STRING_32]]]], + ARRAY [TUPLE [STRING_8, ARRAY [TUPLE [STRING_8, STRING_8]]]] + }) + +feature {NONE} -- Initialization + + make (n: INTEGER) + do + create table.make (n) + end + + make_from_manifest (lst: ARRAY [TUPLE [key: STRING; value: detachable ANY]]) + do + make (lst.count) + across + lst as c + loop + force (c.item.value, c.item.key) + end + end + +feature -- Access + + item (k: STRING): detachable ANY + do + Result := table.item (k) + end + + force (v: detachable ANY; k: STRING) + do + table.force (v, k) + end + + boolean_item (k: STRING; dft: BOOLEAN): BOOLEAN + do + if attached {BOOLEAN} item (k) as b then + Result := b + else + Result := dft + end + end + + string_general_item (k: STRING): detachable READABLE_STRING_GENERAL + do + if attached {READABLE_STRING_GENERAL} item (k) as s then + Result := s + end + end + + string_item, string_8_item (k: STRING): detachable READABLE_STRING_8 + do + if attached {READABLE_STRING_8} item (k) as s then + Result := s + end + end + + table: HASH_TABLE [detachable ANY, STRING] + +feature -- Change + + import (a_opts: WSF_API_OPTIONS) + do + across + a_opts as c + loop + force (c.item, c.key) + end + end + +feature -- Access + + new_cursor: TABLE_ITERATION_CURSOR [detachable ANY, STRING] + -- Fresh cursor associated with current structure + do + Result := table.new_cursor + end + +invariant + +end diff --git a/library/server/wsf_html/api/wsf_api_utilities.e b/library/server/wsf_html/api/wsf_api_utilities.e new file mode 100644 index 00000000..a45b299b --- /dev/null +++ b/library/server/wsf_html/api/wsf_api_utilities.e @@ -0,0 +1,208 @@ +note + description: "Summary description for {WSF_API_UTILITIES}." + author: "" + date: "$Date$" + revision: "$Revision$" + +deferred class + WSF_API_UTILITIES + +feature -- Core + + site_url: READABLE_STRING_8 + deferred + end + + base_url: detachable READABLE_STRING_8 + -- Base url if any. + deferred + end + + based_path (p: STRING): STRING + -- Path `p' in the context of the `base_url' + do + if attached base_url as l_base_url then + create Result.make_from_string (l_base_url) + if p.is_empty then + else + if p[1] = '/' then + Result.append (p.substring (2, p.count)) + else + Result.append (p) + end + end + else + Result := p + end + end + +feature -- Conversion + + link (a_text: detachable READABLE_STRING_GENERAL; a_path: READABLE_STRING_8; opts: detachable WSF_API_OPTIONS): STRING + do + create Result.make (32) + append_link_to_html (a_text, a_path, opts, Result) + end + + link_with_raw_text (a_raw_text: detachable READABLE_STRING_8; a_path: READABLE_STRING_8; opts: detachable WSF_API_OPTIONS): STRING + do + create Result.make (32) + append_link_with_raw_text_to_html (a_raw_text, a_path, opts, Result) + end + + append_link_to_html (a_text: detachable READABLE_STRING_GENERAL; a_path: READABLE_STRING_8; opts: detachable WSF_API_OPTIONS; a_html: STRING_8) + local + l_html: BOOLEAN + t: READABLE_STRING_GENERAL + do + l_html := True + if opts /= Void then + l_html := opts.boolean_item ("html", l_html) + end + a_html.append ("") + if a_text = Void then + t := a_path + else + t := a_text + end + if l_html then + a_html.append (html_encoded (t)) + else + a_html.append (checked_plain (t)) + end + a_html.append ("") + end + + append_link_with_raw_text_to_html (a_raw_text: detachable READABLE_STRING_8; a_path: READABLE_STRING_8; opts: detachable WSF_API_OPTIONS; a_html: STRING_8) + local + l_html: BOOLEAN + t: READABLE_STRING_8 + do + l_html := True + if opts /= Void then + l_html := opts.boolean_item ("html", l_html) + end + a_html.append ("") + if a_raw_text = Void then + t := a_path + else + t := a_raw_text + end + a_html.append (t) + a_html.append ("") + end + + absolute_url (a_path: STRING; opts: detachable WSF_API_OPTIONS): STRING + local + l_opts: detachable WSF_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: READABLE_STRING_8; opts: detachable WSF_API_OPTIONS): STRING + local + q,f: detachable STRING_8 + l_abs: BOOLEAN + do + l_abs := False + + if opts /= Void then + l_abs := opts.boolean_item ("absolute", l_abs) + if attached opts.item ("query") as l_query then + if attached {READABLE_STRING_8} l_query as s_value then + q := s_value + elseif attached {ITERABLE [TUPLE [key, value: READABLE_STRING_GENERAL]]} l_query as lst then + create q.make_empty + across + lst as c + loop + if q.is_empty then + else + q.append_character ('&') + end + q.append (url_encoded (c.item.key)) + q.append_character ('=') + q.append (url_encoded (c.item.value)) + end + end + end + if attached opts.string_item ("fragment") as s_frag then + f := s_frag + end + end + if l_abs then + if a_path.substring_index ("://", 1) = 0 then + create Result.make_from_string (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 + end + + checked_url (a_url: READABLE_STRING_8): READABLE_STRING_8 + do + Result := a_url + end + + checked_plain (a_text: READABLE_STRING_GENERAL): STRING_8 + do + Result := html_encoded (a_text) + end + +feature -- Encoding + + url_encoded (s: detachable READABLE_STRING_GENERAL): STRING_8 + local + enc: URL_ENCODER + do + create enc + if s /= Void then + Result := enc.general_encoded_string (s) + else + create Result.make_empty + end + end + + html_encoded (s: detachable READABLE_STRING_GENERAL): STRING_8 + local + enc: HTML_ENCODER + do + create enc + if s /= Void then + Result := enc.general_encoded_string (s) + else + create Result.make_empty + end + end + + + +end diff --git a/library/server/wsf_html/api/wsf_request_theme.e b/library/server/wsf_html/api/wsf_request_theme.e new file mode 100644 index 00000000..8d72f61d --- /dev/null +++ b/library/server/wsf_html/api/wsf_request_theme.e @@ -0,0 +1,40 @@ +note + description: "[ + WF_THEME associated with a request + ]" + date: "$Date$" + revision: "$Revision$" + +class + WSF_REQUEST_THEME + +inherit + WSF_THEME + +create + make_with_request + +feature {NONE} -- Initialization + + make_with_request (req: WSF_REQUEST) + do + request := req + end + + request: WSF_REQUEST + -- Associated request + +feature -- Core + + site_url: READABLE_STRING_8 + do + Result := request.absolute_script_url ("") + end + + base_url: detachable READABLE_STRING_8 + -- Base url if any. + do + Result := request.script_url ("") + end + +end diff --git a/library/server/wsf_html/api/wsf_theme.e b/library/server/wsf_html/api/wsf_theme.e new file mode 100644 index 00000000..4af56be2 --- /dev/null +++ b/library/server/wsf_html/api/wsf_theme.e @@ -0,0 +1,14 @@ +note + description: "Summary description for {WSF_THEME}." + author: "" + date: "$Date$" + revision: "$Revision$" + +deferred class + WSF_THEME + +inherit + WSF_API_UTILITIES + + +end diff --git a/library/server/wsf_html/api/wsf_url_api_options.e b/library/server/wsf_html/api/wsf_url_api_options.e new file mode 100644 index 00000000..b7d1412c --- /dev/null +++ b/library/server/wsf_html/api/wsf_url_api_options.e @@ -0,0 +1,25 @@ +note + description: "Summary description for {WSF_URL_API_OPTIONS}." + author: "" + date: "$Date$" + revision: "$Revision$" + +class + WSF_URL_API_OPTIONS + +inherit + WSF_API_OPTIONS + +create + make, + make_absolute + +feature {NONE} -- Initialization + + make_absolute + do + make (1) + force (True, "absolute") + end + +end diff --git a/draft/library/text/css/src/css_selector.e b/library/server/wsf_html/css/css_selector.e similarity index 100% rename from draft/library/text/css/src/css_selector.e rename to library/server/wsf_html/css/css_selector.e diff --git a/draft/library/text/css/src/css_style.e b/library/server/wsf_html/css/css_style.e similarity index 100% rename from draft/library/text/css/src/css_style.e rename to library/server/wsf_html/css/css_style.e diff --git a/draft/library/text/css/src/css_text.e b/library/server/wsf_html/css/css_text.e similarity index 100% rename from draft/library/text/css/src/css_text.e rename to library/server/wsf_html/css/css_text.e diff --git a/draft/application/cms/src/kernel/form/cms_form.e b/library/server/wsf_html/form/wsf_form.e similarity index 59% rename from draft/application/cms/src/kernel/form/cms_form.e rename to library/server/wsf_html/form/wsf_form.e index 2e5e5195..091e6720 100644 --- a/draft/application/cms/src/kernel/form/cms_form.e +++ b/library/server/wsf_html/form/wsf_form.e @@ -1,14 +1,16 @@ note - description: "Summary description for {CMS_FORM}." + description: "Summary description for {WSF_FORM}." author: "" date: "$Date$" revision: "$Revision$" class - CMS_FORM + WSF_FORM inherit - CMS_FORM_COMPOSITE + WSF_FORM_COMPOSITE + + WSF_WITH_HTML_ATTRIBUTE create make @@ -48,41 +50,42 @@ feature -- Access -- Form's method --| GET or POST + encoding_type: detachable READABLE_STRING_8 + -- Encoding type + feature -- Basic operation - prepare (a_execution: CMS_EXECUTION) - do - a_execution.service.call_form_alter_hooks (Current, Void, a_execution) - end - - process (a_execution: CMS_EXECUTION) + process (req: WSF_REQUEST; a_before_callback, a_after_callback: detachable PROCEDURE [ANY, TUPLE [WSF_FORM_DATA]]) + -- Process Current form with request `req' + -- agent `a_before_callback' is called before the validation + -- agent `a_after_callback' is called after the validation local - fd: CMS_FORM_DATA + fd: WSF_FORM_DATA do - create fd.make (a_execution.request, Current) + create fd.make (req, Current) last_data := fd - a_execution.service.call_form_alter_hooks (Current, fd, a_execution) + if a_before_callback /= Void then + a_before_callback.call ([fd]) + end fd.validate fd.apply_to_associated_form -- Maybe only when has error? if fd.is_valid then fd.submit - if fd.has_error then - a_execution.report_form_errors (fd) - end - else - a_execution.report_form_errors (fd) + end + if a_after_callback /= Void then + a_after_callback.call ([fd]) end end - last_data: detachable CMS_FORM_DATA + last_data: detachable WSF_FORM_DATA feature -- Validation - validation_actions: ACTION_SEQUENCE [TUPLE [CMS_FORM_DATA]] + validation_actions: ACTION_SEQUENCE [TUPLE [WSF_FORM_DATA]] -- Procedure to validate the data -- report error if not valid - submit_actions: ACTION_SEQUENCE [TUPLE [CMS_FORM_DATA]] + submit_actions: ACTION_SEQUENCE [TUPLE [WSF_FORM_DATA]] -- Submit actions feature -- Element change @@ -97,17 +100,30 @@ feature -- Element change method := "POST" end + set_encoding_type (s: like encoding_type) + do + encoding_type := s + end + + set_multipart_form_data_encoding_type + do + encoding_type := "multipart/form-data" + end + feature -- Optional html_classes: ARRAYED_LIST [STRING_8] feature -- Conversion - append_to_html (a_theme: CMS_THEME; a_html: STRING_8) + append_to_html (a_theme: WSF_THEME; a_html: STRING_8) local s: STRING_8 do - a_html.append ("
%N") end - to_html (a_theme: CMS_THEME): STRING_8 + to_html (a_theme: WSF_THEME): STRING_8 do create Result.make_empty append_to_html (a_theme, Result) diff --git a/draft/application/cms/src/kernel/form/cms_form_button_input.e b/library/server/wsf_html/form/wsf_form_button_input.e similarity index 58% rename from draft/application/cms/src/kernel/form/cms_form_button_input.e rename to library/server/wsf_html/form/wsf_form_button_input.e index e7937122..b0d3e5e4 100644 --- a/draft/application/cms/src/kernel/form/cms_form_button_input.e +++ b/library/server/wsf_html/form/wsf_form_button_input.e @@ -1,14 +1,14 @@ note - description: "Summary description for {CMS_FORM_BUTTON_INPUT}." + description: "Summary description for {WSF_FORM_BUTTON_INPUT}." author: "" date: "$Date$" revision: "$Revision$" class - CMS_FORM_BUTTON_INPUT + WSF_FORM_BUTTON_INPUT inherit - CMS_FORM_INPUT + WSF_FORM_INPUT create make diff --git a/draft/application/cms/src/kernel/form/cms_form_checkbox_input.e b/library/server/wsf_html/form/wsf_form_checkbox_input.e similarity index 60% rename from draft/application/cms/src/kernel/form/cms_form_checkbox_input.e rename to library/server/wsf_html/form/wsf_form_checkbox_input.e index d0860bf1..aefc92fd 100644 --- a/draft/application/cms/src/kernel/form/cms_form_checkbox_input.e +++ b/library/server/wsf_html/form/wsf_form_checkbox_input.e @@ -1,14 +1,14 @@ note - description: "Summary description for {CMS_FORM_CHECKBOX_INPUT}." + description: "Summary description for {WSF_FORM_CHECKBOX_INPUT}." author: "" date: "$Date$" revision: "$Revision$" class - CMS_FORM_CHECKBOX_INPUT + WSF_FORM_CHECKBOX_INPUT inherit - CMS_FORM_SELECTABLE_INPUT + WSF_FORM_SELECTABLE_INPUT create make, diff --git a/draft/application/cms/src/kernel/form/cms_form_composite.e b/library/server/wsf_html/form/wsf_form_composite.e similarity index 67% rename from draft/application/cms/src/kernel/form/cms_form_composite.e rename to library/server/wsf_html/form/wsf_form_composite.e index 55971d07..b3b9ca4b 100644 --- a/draft/application/cms/src/kernel/form/cms_form_composite.e +++ b/library/server/wsf_html/form/wsf_form_composite.e @@ -5,10 +5,10 @@ note revision : "$Revision$" deferred class - CMS_FORM_COMPOSITE + WSF_FORM_COMPOSITE inherit - CMS_WIDGET_COMPOSITE + WSF_WIDGET_COMPOSITE redefine extend end @@ -22,18 +22,18 @@ feature -- Status feature -- Access - fields_by_name (a_name: READABLE_STRING_GENERAL): detachable LIST [CMS_FORM_FIELD] + fields_by_name (a_name: READABLE_STRING_GENERAL): detachable LIST [WSF_FORM_FIELD] do Result := fields_by_name_from (Current, a_name) end feature -- Change - extend (i: CMS_WIDGET) + extend (i: WSF_WIDGET) local n: READABLE_STRING_8 do - if attached {CMS_FORM_FIELD} i as l_field then + if attached {WSF_FORM_FIELD} i as l_field then n := l_field.name if n.is_empty then n := (items.count + 1).out @@ -45,34 +45,34 @@ feature -- Change feature {NONE} -- Implementation: Items - container_has_field (a_container: ITERABLE [CMS_WIDGET]; a_name: READABLE_STRING_GENERAL): BOOLEAN + container_has_field (a_container: ITERABLE [WSF_WIDGET]; a_name: READABLE_STRING_GENERAL): BOOLEAN do across a_container as i until Result loop - if attached {CMS_FORM_FIELD} i.item as l_field and then l_field.name.same_string_general (a_name) then + if attached {WSF_FORM_FIELD} i.item as l_field and then l_field.name.same_string_general (a_name) then Result := True - elseif attached {ITERABLE [CMS_WIDGET]} i.item as l_cont then + elseif attached {ITERABLE [WSF_WIDGET]} i.item as l_cont then Result := container_has_field (l_cont, a_name) end end end - fields_by_name_from (a_container: ITERABLE [CMS_WIDGET]; a_name: READABLE_STRING_GENERAL): detachable ARRAYED_LIST [CMS_FORM_FIELD] + fields_by_name_from (a_container: ITERABLE [WSF_WIDGET]; a_name: READABLE_STRING_GENERAL): detachable ARRAYED_LIST [WSF_FORM_FIELD] local - res: detachable ARRAYED_LIST [CMS_FORM_FIELD] + res: detachable ARRAYED_LIST [WSF_FORM_FIELD] do across a_container as i loop - if attached {CMS_FORM_FIELD} i.item as l_field and then l_field.name.same_string_general (a_name) then + if attached {WSF_FORM_FIELD} i.item as l_field and then l_field.name.same_string_general (a_name) then if res = Void then create res.make (1) end res.force (l_field) - elseif attached {ITERABLE [CMS_WIDGET]} i.item as l_cont then + elseif attached {ITERABLE [WSF_WIDGET]} i.item as l_cont then if attached fields_by_name_from (l_cont, a_name) as lst then if res = Void then res := lst diff --git a/draft/application/cms/src/kernel/form/cms_form_data.e b/library/server/wsf_html/form/wsf_form_data.e similarity index 80% rename from draft/application/cms/src/kernel/form/cms_form_data.e rename to library/server/wsf_html/form/wsf_form_data.e index e02a368a..dce571af 100644 --- a/draft/application/cms/src/kernel/form/cms_form_data.e +++ b/library/server/wsf_html/form/wsf_form_data.e @@ -1,21 +1,20 @@ note - description : "Objects that ..." - author : "$Author$" + description : "Objects that represent a form filled with data from request." date : "$Date$" revision : "$Revision$" class - CMS_FORM_DATA + WSF_FORM_DATA inherit TABLE_ITERABLE [detachable WSF_VALUE, READABLE_STRING_8] -create {CMS_FORM} +create {WSF_FORM} make feature {NONE} -- Initialization - make (req: WSF_REQUEST; a_form: CMS_FORM) + make (req: WSF_REQUEST; a_form: WSF_FORM) -- Initialize `Current'. do form := a_form @@ -25,7 +24,7 @@ feature {NONE} -- Initialization feature -- Access - form: CMS_FORM + form: WSF_FORM feature -- Status @@ -34,6 +33,9 @@ feature -- Status Result := errors = Void end + is_applied_to_associated_form: BOOLEAN + -- Data already applied to `form'? + feature -- Access item_same_string (a_name: READABLE_STRING_GENERAL; s: READABLE_STRING_GENERAL): BOOLEAN @@ -132,11 +134,11 @@ feature -- Basic operation form.validation_actions.call ([Current]) end - validate_item (w: CMS_WIDGET) + validate_item (w: WSF_WIDGET) do - if attached {CMS_FORM_FIELD} w as l_field then + if attached {WSF_FORM_FIELD} w as l_field then l_field.validate (Current) - elseif attached {ITERABLE [CMS_WIDGET]} w as lst then + elseif attached {ITERABLE [WSF_WIDGET]} w as lst then across lst as c loop @@ -158,40 +160,43 @@ feature -- Basic operation apply_to_associated_form do - if attached errors as errs then - across - errs as e - loop - if attached e.item as err then - if attached err.field as e_field then - set_fields_invalid (True, e_field.name) + if not is_applied_to_associated_form then + if attached errors as errs then + across + errs as e + loop + if attached e.item as err then + if attached err.field as e_field then + set_fields_invalid (True, e_field.name) + end end end end - end - across - items as c - loop across - form as i + items as c loop - apply_to_associated_form_item (c.key, c.item, i.item) + across + form as i + loop + apply_to_associated_form_item (c.key, c.item, i.item) + end end + is_applied_to_associated_form := True end end feature {NONE} -- Implementation: apply - apply_to_associated_form_item (a_name: READABLE_STRING_8; a_value: detachable WSF_VALUE; i: CMS_WIDGET) + apply_to_associated_form_item (a_name: READABLE_STRING_8; a_value: detachable WSF_VALUE; i: WSF_WIDGET) local do - if attached {CMS_FORM_FIELD} i as l_field then - if not attached {CMS_FORM_SUBMIT_INPUT} l_field then + if attached {WSF_FORM_FIELD} i as l_field then + if not attached {WSF_FORM_SUBMIT_INPUT} l_field then if l_field.name.same_string (a_name) then l_field.set_value (a_value) end end - elseif attached {ITERABLE [CMS_WIDGET]} i as l_set then + elseif attached {ITERABLE [WSF_WIDGET]} i as l_set then across l_set as c loop @@ -231,20 +236,20 @@ feature {NONE} -- Implementation get_form_items (req, form) end - get_form_items (req: WSF_REQUEST; lst: ITERABLE [CMS_WIDGET]) + get_form_items (req: WSF_REQUEST; lst: ITERABLE [WSF_WIDGET]) do across lst as c loop - if attached {CMS_FORM_FIELD} c.item as l_field then + if attached {WSF_FORM_FIELD} c.item as l_field then get_form_field_item (req, l_field, l_field.name) - elseif attached {ITERABLE [CMS_WIDGET]} c.item as l_set then + elseif attached {ITERABLE [WSF_WIDGET]} c.item as l_set then get_form_items (req, l_set) end end end - get_form_field_item (req: WSF_REQUEST; i: CMS_FORM_FIELD; n: READABLE_STRING_8) + get_form_field_item (req: WSF_REQUEST; i: WSF_FORM_FIELD; n: READABLE_STRING_8) local v: detachable WSF_VALUE do @@ -269,7 +274,7 @@ feature {NONE} -- Implementation end end - add_error (a_field: detachable CMS_FORM_FIELD; a_msg: detachable READABLE_STRING_8) + add_error (a_field: detachable WSF_FORM_FIELD; a_msg: detachable READABLE_STRING_8) local err: like errors do @@ -322,7 +327,7 @@ feature -- Reports Result := attached errors as err and then not err.is_empty end - errors: detachable ARRAYED_LIST [TUPLE [field: detachable CMS_FORM_FIELD; message: detachable READABLE_STRING_8]] + errors: detachable ARRAYED_LIST [TUPLE [field: detachable WSF_FORM_FIELD; message: detachable READABLE_STRING_8]] invariant diff --git a/draft/application/cms/src/kernel/form/cms_form_div.e b/library/server/wsf_html/form/wsf_form_div.e similarity index 77% rename from draft/application/cms/src/kernel/form/cms_form_div.e rename to library/server/wsf_html/form/wsf_form_div.e index 7b2c6dd6..e3205162 100644 --- a/draft/application/cms/src/kernel/form/cms_form_div.e +++ b/library/server/wsf_html/form/wsf_form_div.e @@ -5,14 +5,14 @@ note revision : "$Revision$" class - CMS_FORM_DIV + WSF_FORM_DIV inherit - CMS_FORM_ITEM + WSF_FORM_ITEM - CMS_FORM_COMPOSITE + WSF_FORM_COMPOSITE - WITH_CSS_ID + WSF_WITH_CSS_ID create make, @@ -32,16 +32,16 @@ feature {NONE} -- Initialization make_with_text (s: READABLE_STRING_8) do - make_with_item (create {CMS_FORM_RAW_TEXT}.make (s)) + make_with_item (create {WSF_FORM_RAW_TEXT}.make (s)) end - make_with_item (i: CMS_WIDGET) + make_with_item (i: WSF_WIDGET) do initialize_with_count (1) extend (i) end - make_with_items (it: ITERABLE [CMS_WIDGET]) + make_with_items (it: ITERABLE [WSF_WIDGET]) do initialize_with_count (2) across @@ -51,7 +51,7 @@ feature {NONE} -- Initialization end end - make_with_item_and_css_id (i: CMS_WIDGET; a_css_id: READABLE_STRING_8) + make_with_item_and_css_id (i: WSF_WIDGET; a_css_id: READABLE_STRING_8) do make_with_item (i) set_css_id (a_css_id) @@ -65,7 +65,7 @@ feature {NONE} -- Initialization feature -- Conversion - append_to_html (a_theme: CMS_THEME; a_html: STRING_8) + append_to_html (a_theme: WSF_THEME; a_html: STRING_8) do a_html.append ("") end - append_item_to_html (a_theme: CMS_THEME; a_html: STRING_8) + append_item_to_html (a_theme: WSF_THEME; a_html: STRING_8) deferred end diff --git a/draft/application/cms/src/kernel/form/cms_form_field_set.e b/library/server/wsf_html/form/wsf_form_field_set.e similarity index 89% rename from draft/application/cms/src/kernel/form/cms_form_field_set.e rename to library/server/wsf_html/form/wsf_form_field_set.e index 893f39fa..da3de611 100644 --- a/draft/application/cms/src/kernel/form/cms_form_field_set.e +++ b/library/server/wsf_html/form/wsf_form_field_set.e @@ -5,14 +5,14 @@ note revision : "$Revision$" class - CMS_FORM_FIELD_SET + WSF_FORM_FIELD_SET inherit - CMS_FORM_ITEM + WSF_FORM_ITEM - CMS_FORM_COMPOSITE + WSF_FORM_COMPOSITE - WITH_CSS_ID + WSF_WITH_CSS_ID create make @@ -59,7 +59,7 @@ feature -- Change feature -- Conversion - append_to_html (a_theme: CMS_THEME; a_html: STRING_8) + append_to_html (a_theme: WSF_THEME; a_html: STRING_8) do a_html.append ("") Precursor (a_theme, a_html) diff --git a/draft/application/cms/src/kernel/form/cms_form_image_input.e b/library/server/wsf_html/form/wsf_form_image_input.e similarity index 89% rename from draft/application/cms/src/kernel/form/cms_form_image_input.e rename to library/server/wsf_html/form/wsf_form_image_input.e index f3d1860d..60022600 100644 --- a/draft/application/cms/src/kernel/form/cms_form_image_input.e +++ b/library/server/wsf_html/form/wsf_form_image_input.e @@ -1,14 +1,14 @@ note - description: "Summary description for {CMS_FORM_IMAGE_INPUT}." + description: "Summary description for {WSF_FORM_IMAGE_INPUT}." author: "" date: "$Date$" revision: "$Revision$" class - CMS_FORM_IMAGE_INPUT + WSF_FORM_IMAGE_INPUT inherit - CMS_FORM_INPUT + WSF_FORM_INPUT redefine specific_input_attributes_string end diff --git a/draft/application/cms/src/kernel/form/cms_form_input.e b/library/server/wsf_html/form/wsf_form_input.e similarity index 92% rename from draft/application/cms/src/kernel/form/cms_form_input.e rename to library/server/wsf_html/form/wsf_form_input.e index ae74f5c1..494e8f9d 100644 --- a/draft/application/cms/src/kernel/form/cms_form_input.e +++ b/library/server/wsf_html/form/wsf_form_input.e @@ -1,14 +1,14 @@ note - description: "Summary description for {CMS_FORM_INPUT}." + description: "Summary description for {WSF_FORM_INPUT}." author: "" date: "$Date$" revision: "$Revision$" deferred class - CMS_FORM_INPUT + WSF_FORM_INPUT inherit - CMS_FORM_FIELD + WSF_FORM_FIELD feature {NONE} -- Initialization @@ -78,7 +78,7 @@ feature -- Element change feature -- Conversion - append_item_to_html (a_theme: CMS_THEME; a_html: STRING_8) + append_item_to_html (a_theme: WSF_THEME; a_html: STRING_8) local old_count: INTEGER do @@ -121,7 +121,7 @@ feature -- Conversion feature {NONE} -- Implementation - append_child_to_html (a_theme: CMS_THEME; a_html: STRING_8) + append_child_to_html (a_theme: WSF_THEME; a_html: STRING_8) -- Specific child element if any. --| To redefine if needed do diff --git a/library/server/wsf_html/form/wsf_form_item.e b/library/server/wsf_html/form/wsf_form_item.e new file mode 100644 index 00000000..d8573ddf --- /dev/null +++ b/library/server/wsf_html/form/wsf_form_item.e @@ -0,0 +1,17 @@ +note + description: "Summary description for {WSF_FORM_ITEM}." + author: "" + date: "$Date$" + revision: "$Revision$" + +deferred class + WSF_FORM_ITEM + +inherit + WSF_WIDGET + + WSF_WITH_CSS_CLASS + + WSF_WITH_CSS_STYLE + +end diff --git a/draft/application/cms/src/kernel/form/cms_form_password_input.e b/library/server/wsf_html/form/wsf_form_password_input.e similarity index 67% rename from draft/application/cms/src/kernel/form/cms_form_password_input.e rename to library/server/wsf_html/form/wsf_form_password_input.e index 118b4788..004c45be 100644 --- a/draft/application/cms/src/kernel/form/cms_form_password_input.e +++ b/library/server/wsf_html/form/wsf_form_password_input.e @@ -1,14 +1,14 @@ note - description: "Summary description for {CMS_FORM_PASSWORD_INPUT}." + description: "Summary description for {WSF_FORM_PASSWORD_INPUT}." author: "" date: "$Date$" revision: "$Revision$" class - CMS_FORM_PASSWORD_INPUT + WSF_FORM_PASSWORD_INPUT inherit - CMS_FORM_INPUT + WSF_FORM_INPUT redefine input_type end diff --git a/draft/application/cms/src/kernel/form/cms_form_radio_input.e b/library/server/wsf_html/form/wsf_form_radio_input.e similarity index 60% rename from draft/application/cms/src/kernel/form/cms_form_radio_input.e rename to library/server/wsf_html/form/wsf_form_radio_input.e index 78288dca..fb321435 100644 --- a/draft/application/cms/src/kernel/form/cms_form_radio_input.e +++ b/library/server/wsf_html/form/wsf_form_radio_input.e @@ -1,14 +1,14 @@ note - description: "Summary description for {CMS_FORM_RADIO_INPUT}." + description: "Summary description for {WSF_FORM_RADIO_INPUT}." author: "" date: "$Date$" revision: "$Revision$" class - CMS_FORM_RADIO_INPUT + WSF_FORM_RADIO_INPUT inherit - CMS_FORM_SELECTABLE_INPUT + WSF_FORM_SELECTABLE_INPUT create make, diff --git a/draft/application/cms/src/kernel/form/cms_form_raw_text.e b/library/server/wsf_html/form/wsf_form_raw_text.e similarity index 58% rename from draft/application/cms/src/kernel/form/cms_form_raw_text.e rename to library/server/wsf_html/form/wsf_form_raw_text.e index 90fa8fdc..cdca2d24 100644 --- a/draft/application/cms/src/kernel/form/cms_form_raw_text.e +++ b/library/server/wsf_html/form/wsf_form_raw_text.e @@ -1,14 +1,14 @@ note - description: "Summary description for {CMS_FORM_RAW_TEXT}." + description: "Summary description for {WSF_FORM_RAW_TEXT}." author: "" date: "$Date$" revision: "$Revision$" class - CMS_FORM_RAW_TEXT + WSF_FORM_RAW_TEXT inherit - CMS_WIDGET_TEXT + WSF_WIDGET_TEXT rename set_text as set_value, make_with_text as make @@ -21,12 +21,12 @@ create feature -- Conversion - append_to_html (a_theme: CMS_THEME; a_html: STRING_8) + append_to_html (a_theme: WSF_THEME; a_html: STRING_8) do append_item_html_to (a_theme, a_html) end - append_item_html_to (a_theme: CMS_THEME; a_html: STRING_8) + append_item_html_to (a_theme: WSF_THEME; a_html: STRING_8) do a_html.append (text) end diff --git a/draft/application/cms/src/kernel/form/cms_form_reset_input.e b/library/server/wsf_html/form/wsf_form_reset_input.e similarity index 58% rename from draft/application/cms/src/kernel/form/cms_form_reset_input.e rename to library/server/wsf_html/form/wsf_form_reset_input.e index d652d66b..ffe80d62 100644 --- a/draft/application/cms/src/kernel/form/cms_form_reset_input.e +++ b/library/server/wsf_html/form/wsf_form_reset_input.e @@ -1,14 +1,14 @@ note - description: "Summary description for {CMS_FORM_RESET_INPUT}." + description: "Summary description for {WSF_FORM_RESET_INPUT}." author: "" date: "$Date$" revision: "$Revision$" class - CMS_FORM_RESET_INPUT + WSF_FORM_RESET_INPUT inherit - CMS_FORM_INPUT + WSF_FORM_INPUT create make diff --git a/draft/application/cms/src/kernel/form/cms_form_select.e b/library/server/wsf_html/form/wsf_form_select.e similarity index 88% rename from draft/application/cms/src/kernel/form/cms_form_select.e rename to library/server/wsf_html/form/wsf_form_select.e index acdd6db6..d48bacbb 100644 --- a/draft/application/cms/src/kernel/form/cms_form_select.e +++ b/library/server/wsf_html/form/wsf_form_select.e @@ -1,16 +1,18 @@ note - description: "Summary description for {CMS_FORM_SELECT}." + description: "Summary description for {WSF_FORM_SELECT}." author: "" date: "$Date$" revision: "$Revision$" class - CMS_FORM_SELECT + WSF_FORM_SELECT inherit - CMS_FORM_FIELD + WSF_FORM_FIELD - CMS_FORM_UTILITY + WSF_FORM_UTILITY + + WSF_WITH_HTML_ATTRIBUTE create make @@ -25,13 +27,13 @@ feature {NONE} -- Initialization feature -- Access - options: ARRAYED_LIST [CMS_FORM_SELECT_OPTION] + options: ARRAYED_LIST [WSF_FORM_SELECT_OPTION] feature -- Element change set_text_by_value (a_text: detachable READABLE_STRING_GENERAL) local - opt: CMS_FORM_SELECT_OPTION + opt: WSF_FORM_SELECT_OPTION l_found: BOOLEAN v: READABLE_STRING_8 do @@ -96,14 +98,14 @@ feature -- Element change end end - add_option (opt: CMS_FORM_SELECT_OPTION) + add_option (opt: WSF_FORM_SELECT_OPTION) do options.force (opt) end feature -- Conversion - append_item_to_html (a_theme: CMS_THEME; a_html: STRING_8) + append_item_to_html (a_theme: WSF_THEME; a_html: STRING_8) local l_is_already_selected: BOOLEAN h: detachable STRING_8 @@ -115,6 +117,7 @@ feature -- Conversion append_css_class_to (a_html, Void) append_css_id_to (a_html) append_css_style_to (a_html) + append_html_attributes_to (a_html) if is_readonly then a_html.append (" readonly=%"readonly%" />") diff --git a/draft/application/cms/src/kernel/form/cms_form_select_option.e b/library/server/wsf_html/form/wsf_form_select_option.e similarity index 94% rename from draft/application/cms/src/kernel/form/cms_form_select_option.e rename to library/server/wsf_html/form/wsf_form_select_option.e index 3a18067d..7da513bd 100644 --- a/draft/application/cms/src/kernel/form/cms_form_select_option.e +++ b/library/server/wsf_html/form/wsf_form_select_option.e @@ -5,10 +5,10 @@ note revision : "$Revision$" class - CMS_FORM_SELECT_OPTION + WSF_FORM_SELECT_OPTION inherit - CMS_FORM_SELECTABLE_ITEM + WSF_FORM_SELECTABLE_ITEM create make diff --git a/draft/application/cms/src/kernel/form/cms_form_selectable_input.e b/library/server/wsf_html/form/wsf_form_selectable_input.e similarity index 91% rename from draft/application/cms/src/kernel/form/cms_form_selectable_input.e rename to library/server/wsf_html/form/wsf_form_selectable_input.e index 07a711ca..37c58366 100644 --- a/draft/application/cms/src/kernel/form/cms_form_selectable_input.e +++ b/library/server/wsf_html/form/wsf_form_selectable_input.e @@ -1,14 +1,14 @@ note - description: "Summary description for {CMS_FORM_SELECTABLE_INPUT}." + description: "Summary description for {WSF_FORM_SELECTABLE_INPUT}." author: "" date: "$Date$" revision: "$Revision$" deferred class - CMS_FORM_SELECTABLE_INPUT + WSF_FORM_SELECTABLE_INPUT inherit - CMS_FORM_INPUT + WSF_FORM_INPUT rename default_value as value, make_with_text as make_with_value @@ -18,7 +18,7 @@ inherit append_child_to_html end - CMS_FORM_SELECTABLE_ITEM + WSF_FORM_SELECTABLE_ITEM rename is_selected as checked, set_is_selected as set_checked @@ -87,7 +87,7 @@ feature -- Change feature {NONE} -- Implementation - append_child_to_html (a_theme: CMS_THEME; a_html: STRING_8) + append_child_to_html (a_theme: WSF_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_selectable_item.e b/library/server/wsf_html/form/wsf_form_selectable_item.e similarity index 75% rename from draft/application/cms/src/kernel/form/cms_form_selectable_item.e rename to library/server/wsf_html/form/wsf_form_selectable_item.e index 216cee0d..6788125a 100644 --- a/draft/application/cms/src/kernel/form/cms_form_selectable_item.e +++ b/library/server/wsf_html/form/wsf_form_selectable_item.e @@ -1,10 +1,10 @@ note - description: "Summary description for {CMS_FORM_SELECTABLE_ITEM}." + description: "Summary description for {WSF_FORM_SELECTABLE_ITEM}." date: "$Date$" revision: "$Revision$" deferred class - CMS_FORM_SELECTABLE_ITEM + WSF_FORM_SELECTABLE_ITEM feature -- Status report diff --git a/draft/application/cms/src/kernel/form/cms_form_submit_input.e b/library/server/wsf_html/form/wsf_form_submit_input.e similarity index 62% rename from draft/application/cms/src/kernel/form/cms_form_submit_input.e rename to library/server/wsf_html/form/wsf_form_submit_input.e index 6ead4705..32f0fab3 100644 --- a/draft/application/cms/src/kernel/form/cms_form_submit_input.e +++ b/library/server/wsf_html/form/wsf_form_submit_input.e @@ -1,14 +1,14 @@ note - description: "Summary description for {CMS_FORM_INPUT}." + description: "Summary description for {WSF_FORM_INPUT}." author: "" date: "$Date$" revision: "$Revision$" class - CMS_FORM_SUBMIT_INPUT + WSF_FORM_SUBMIT_INPUT inherit - CMS_FORM_INPUT + WSF_FORM_INPUT create make, diff --git a/draft/application/cms/src/kernel/form/cms_form_text_input.e b/library/server/wsf_html/form/wsf_form_text_input.e similarity index 61% rename from draft/application/cms/src/kernel/form/cms_form_text_input.e rename to library/server/wsf_html/form/wsf_form_text_input.e index a1bc7b81..4ddbdf38 100644 --- a/draft/application/cms/src/kernel/form/cms_form_text_input.e +++ b/library/server/wsf_html/form/wsf_form_text_input.e @@ -1,14 +1,14 @@ note - description: "Summary description for {CMS_FORM_TEXT_INPUT}." + description: "Summary description for {WSF_FORM_TEXT_INPUT}." author: "" date: "$Date$" revision: "$Revision$" class - CMS_FORM_TEXT_INPUT + WSF_FORM_TEXT_INPUT inherit - CMS_FORM_INPUT + WSF_FORM_INPUT create make, diff --git a/draft/application/cms/src/kernel/form/cms_form_textarea.e b/library/server/wsf_html/form/wsf_form_textarea.e similarity index 89% rename from draft/application/cms/src/kernel/form/cms_form_textarea.e rename to library/server/wsf_html/form/wsf_form_textarea.e index b71bb5ba..78073a11 100644 --- a/draft/application/cms/src/kernel/form/cms_form_textarea.e +++ b/library/server/wsf_html/form/wsf_form_textarea.e @@ -1,14 +1,14 @@ note - description: "Summary description for {CMS_FORM_INPUT}." + description: "Summary description for {WSF_FORM_INPUT}." author: "" date: "$Date$" revision: "$Revision$" class - CMS_FORM_TEXTAREA + WSF_FORM_TEXTAREA inherit - CMS_FORM_FIELD + WSF_FORM_FIELD create make @@ -61,7 +61,7 @@ feature -- Element change feature -- Conversion - append_item_to_html (a_theme: CMS_THEME; a_html: STRING_8) + append_item_to_html (a_theme: WSF_THEME; a_html: STRING_8) do a_html.append ("