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/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_configuration.e b/draft/application/cms/src/cms_configuration.e
index 2292c362..fb38305c 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]
@@ -114,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
@@ -242,4 +254,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/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/kernel/api/cms_common_api.e b/draft/application/cms/src/kernel/api/cms_common_api.e
index f925745b..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,18 +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
- Result := based_path (Result)
- if Result.substring_index ("://", 1) = 0 then
- Result.prepend (service.site_url)
- end
- end
end
checked_url (a_url: STRING): STRING
diff --git a/draft/application/cms/src/kernel/form/cms_form.e b/draft/application/cms/src/kernel/form/cms_form.e
index a40c9a15..988c522d 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)
@@ -167,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")
+ 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 e10aee74..65dec274 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]
@@ -55,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
')
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 ("