From a97235c7b7314af5a95d29961d957612e0ccfa6c Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Fri, 15 Feb 2013 19:00:05 +0100 Subject: [PATCH] Now the cms.ini resolves variable ${abc} ... and key is case insensitive --- draft/application/cms/example/cms.ini | 4 +- draft/application/cms/src/cms_configuration.e | 52 ++++++++++++++++++- .../cms/www/themes/default/res/style.css | 11 ++-- 3 files changed, 59 insertions(+), 8 deletions(-) diff --git a/draft/application/cms/example/cms.ini b/draft/application/cms/example/cms.ini index cf723b06..7de4d96e 100644 --- a/draft/application/cms/example/cms.ini +++ b/draft/application/cms/example/cms.ini @@ -4,5 +4,5 @@ site.email=your@email.com root-dir=../www var-dir=var files-dir=files -themes-dir=../www/themes -theme=test +themes-dir=${root-dir}/themes +#theme=test diff --git a/draft/application/cms/src/cms_configuration.e b/draft/application/cms/src/cms_configuration.e index 2292c362..28f5f20c 100644 --- a/draft/application/cms/src/cms_configuration.e +++ b/draft/application/cms/src/cms_configuration.e @@ -25,9 +25,20 @@ feature {NONE} -- Initialization make configuration_location := a_filename import (a_filename) + resolve analyze end + resolve + -- Resolve options related to variable ${..} + do + across + options as c + loop + options.replace (resolved_string (c.item), c.key) + end + end + analyze do get_root_location @@ -42,7 +53,7 @@ feature -- Access option (a_name: READABLE_STRING_GENERAL): detachable ANY do - Result := options.item (a_name.as_string_8) + Result := options.item (a_name.as_string_8.as_lower) end options: HASH_TABLE [STRING, STRING] @@ -242,4 +253,43 @@ feature {NONE} -- Environment create Result end + resolved_string (s: READABLE_STRING_8): STRING + -- Resolved `s' using `options' or else environment variables. + local + i,n,b,e: INTEGER + k: detachable READABLE_STRING_8 + do + from + i := 1 + n := s.count + create Result.make (s.count) + until + i > n + loop + if i + 1 < n and then s[i] = '$' and then s[i+1] = '{' then + b := i + 2 + e := s.index_of ('}', b) - 1 + if e > 0 then + k := s.substring (b, e) + if attached option (k) as v then + Result.append (v.out) + i := e + 1 + elseif attached execution_environment.get (k) as v then + Result.append (v) + i := e + 1 + else + Result.extend (s[i]) + end + else + Result.extend (s[i]) + end + else + Result.extend (s[i]) + end + i := i + 1 + end + end + + + end diff --git a/draft/application/cms/www/themes/default/res/style.css b/draft/application/cms/www/themes/default/res/style.css index 330b3446..8905e92e 100644 --- a/draft/application/cms/www/themes/default/res/style.css +++ b/draft/application/cms/www/themes/default/res/style.css @@ -70,9 +70,10 @@ div#main-wrapper { } div#main { margin: 0; padding: 0; clear: both; height:0; display: block; } -div#content { padding: 5px 3px 5px 20px; +div#content { + padding: 5px 3px 5px 20px; margin-top: 10px; - min-width: 80%; + min-width: 60%; display: inline; float: left; position: relative; @@ -81,7 +82,7 @@ div#content { padding: 5px 3px 5px 20px; } div#first_sidebar { - width: 200px; + width: 20%; margin: 5px; padding: 5px; display: inline; @@ -89,11 +90,11 @@ div#first_sidebar { position: relative; } div#second_sidebar { - width: 100px; + width: 20%; margin: 5px; padding: 5px; display: inline; - float: right; + float: left; position: relative; background-color: #eee; }