Updated CMS code.

Separated code to have a lib and an example.
Improved design, fixed a few issues related to folder location.

This is still experimental and require more work to be really friendly to use.
This commit is contained in:
Jocelyn Fiat
2013-01-31 15:33:24 +01:00
parent 40ea982293
commit ce469b6ede
136 changed files with 1841 additions and 299 deletions

View File

@@ -0,0 +1,13 @@
note
description: "Summary description for {WSF_CMS_HTML_TEMPLATE}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
CMS_HTML_TEMPLATE
inherit
CMS_TEMPLATE
end

View File

@@ -0,0 +1,12 @@
note
description: "Summary description for {CMS_PAGE_TEMPLATE}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
CMS_PAGE_TEMPLATE
inherit
CMS_TEMPLATE
end

View File

@@ -0,0 +1,81 @@
note
description: "Summary description for {WSF_CMS_PAGE_TEMPLATE}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
CMS_TEMPLATE
feature -- Access
theme: CMS_THEME
deferred
end
variables: HASH_TABLE [detachable ANY, STRING]
deferred
end
prepare (page: CMS_HTML_PAGE)
deferred
end
to_html (page: CMS_HTML_PAGE): STRING
deferred
end
feature {NONE} -- Implementation
apply_template_engine (s: STRING_8)
local
p,n: INTEGER
k: STRING
sv: detachable STRING
do
from
n := s.count
p := 1
until
p = 0
loop
p := s.index_of ('$', p)
if p > 0 then
k := next_identifier (s, p + 1)
s.remove_substring (p, p + k.count)
sv := Void
if attached variables.item (k) as l_value then
if attached {STRING_8} l_value as s8 then
sv := s8
elseif attached {STRING_32} l_value as s32 then
sv := s32.as_string_8 -- FIXME: use html encoder
else
sv := l_value.out
end
s.insert_string (sv, p)
p := p + sv.count
else
debug
s.insert_string ("$" + k, p)
end
end
end
end
end
next_identifier (s: STRING; a_index: INTEGER): STRING
local
i: INTEGER
do
from
i := a_index
until
not (s[i].is_alpha_numeric or s[i] = '_' or s[i] = '.')
loop
i := i + 1
end
Result := s.substring (a_index, i - 1)
end
end

View File

@@ -0,0 +1,69 @@
note
description: "Summary description for {WSF_CMS_THEME}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
CMS_THEME
inherit
CMS_COMMON_API
feature {NONE} -- Access
service: CMS_SERVICE
deferred
end
base_url: detachable READABLE_STRING_8
-- Base url if any.
do
Result := service.server_base_url
end
feature -- Access
name: STRING
deferred
end
regions: ARRAY [STRING]
deferred
-- Result := <<"header", "content", "footer">>
end
page_template: CMS_TEMPLATE
deferred
end
feature -- Conversion
menu_html (a_menu: CMS_MENU; is_horizontal: BOOLEAN): STRING_8
do
create Result.make_from_string ("<div id=%""+ a_menu.name +"%">")
if is_horizontal then
Result.append ("<ul class=%"horizontal%" >%N")
else
Result.append ("<ul class=%"vertical%" >%N")
end
across
a_menu as c
loop
if c.item.is_active then
Result.append ("<li class=%"active%">")
else
Result.append ("<li>")
end
Result.append ("<a href=%"" + url (c.item.location, c.item.options) + "%">" + html_encoded (c.item.title) + "</a></li>")
end
Result.append ("</ul>%N")
Result.append ("</div>")
end
page_html (page: CMS_HTML_PAGE): STRING_8
deferred
end
end