Moved library/src to src
This commit is contained in:
193
src/theme/cms_html_page.e
Normal file
193
src/theme/cms_html_page.e
Normal file
@@ -0,0 +1,193 @@
|
||||
note
|
||||
description: "Summary description for {CMS_HTML_PAGE}."
|
||||
author: ""
|
||||
date: "$Date: 2014-11-13 19:34:00 +0100 (jeu., 13 nov. 2014) $"
|
||||
revision: "$Revision: 96086 $"
|
||||
|
||||
class
|
||||
CMS_HTML_PAGE
|
||||
|
||||
create
|
||||
make,
|
||||
make_typed
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_typed (a_type: attached like type)
|
||||
-- Make current page with optional page type `a_type'.
|
||||
do
|
||||
make
|
||||
type := a_type
|
||||
end
|
||||
|
||||
make
|
||||
do
|
||||
create regions.make (5)
|
||||
language := "en"
|
||||
|
||||
status_code := {HTTP_STATUS_CODE}.ok
|
||||
create header.make
|
||||
create {ARRAYED_LIST [STRING]} head_lines.make (5)
|
||||
header.put_content_type_text_html
|
||||
create variables.make (0)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
type: detachable READABLE_STRING_8
|
||||
-- Optional page type.
|
||||
-- such as "front", "about", ... that could be customized by themes.
|
||||
|
||||
is_front: BOOLEAN
|
||||
|
||||
title: detachable READABLE_STRING_32
|
||||
|
||||
language: STRING
|
||||
|
||||
head_lines: LIST [STRING]
|
||||
|
||||
head_lines_to_string: STRING
|
||||
do
|
||||
create Result.make_empty
|
||||
across
|
||||
head_lines as h
|
||||
loop
|
||||
Result.append (h.item)
|
||||
Result.append_character ('%N')
|
||||
end
|
||||
end
|
||||
|
||||
variables: STRING_TABLE [detachable ANY]
|
||||
|
||||
feature -- Status
|
||||
|
||||
|
||||
status_code: INTEGER
|
||||
|
||||
feature -- Header
|
||||
|
||||
header: HTTP_HEADER
|
||||
|
||||
feature -- Region
|
||||
|
||||
regions: STRING_TABLE [STRING_8]
|
||||
-- header
|
||||
-- content
|
||||
-- footer
|
||||
-- could have sidebar first, sidebar second, ...
|
||||
|
||||
region (n: STRING_8): STRING_8
|
||||
do
|
||||
if attached regions.item (n) as r then
|
||||
Result := r
|
||||
else
|
||||
Result := ""
|
||||
debug
|
||||
Result := "{{" + n + "}}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_is_front (b: BOOLEAN)
|
||||
-- Set `is_front' to `b'.
|
||||
do
|
||||
is_front := b
|
||||
end
|
||||
|
||||
register_variable (a_value: detachable ANY; k: READABLE_STRING_GENERAL)
|
||||
do
|
||||
variables.force (a_value, k)
|
||||
end
|
||||
|
||||
add_to_region (s: STRING; k: STRING)
|
||||
local
|
||||
r: detachable STRING
|
||||
do
|
||||
r := regions.item (k)
|
||||
if r = Void then
|
||||
create r.make_from_string (s)
|
||||
set_region (r, k)
|
||||
else
|
||||
r.append (s)
|
||||
end
|
||||
end
|
||||
|
||||
set_region (s: STRING; k: STRING)
|
||||
do
|
||||
regions.force (s, k)
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_status_code (c: like status_code)
|
||||
do
|
||||
status_code := c
|
||||
end
|
||||
|
||||
set_language (s: like language)
|
||||
do
|
||||
language := s
|
||||
end
|
||||
|
||||
set_title (s: like title)
|
||||
do
|
||||
title := s
|
||||
end
|
||||
|
||||
add_meta_name_content (a_name: STRING; a_content: STRING)
|
||||
local
|
||||
s: STRING_8
|
||||
do
|
||||
s := "<meta name=%"" + a_name + "%" content=%"" + a_content + "%" />"
|
||||
head_lines.extend (s)
|
||||
end
|
||||
|
||||
add_meta_http_equiv (a_http_equiv: STRING; a_content: STRING)
|
||||
local
|
||||
s: STRING_8
|
||||
do
|
||||
s := "<meta http-equiv=%"" + a_http_equiv + "%" content=%"" + a_content + "%" />"
|
||||
head_lines.extend (s)
|
||||
end
|
||||
|
||||
add_style (a_href: STRING; a_media: detachable STRING)
|
||||
local
|
||||
s: STRING_8
|
||||
do
|
||||
s := "<link rel=%"stylesheet%" href=%""+ a_href + "%" type=%"text/css%""
|
||||
if a_media /= Void then
|
||||
s.append (" media=%""+ a_media + "%"")
|
||||
end
|
||||
s.append ("/>")
|
||||
head_lines.extend (s)
|
||||
end
|
||||
|
||||
add_javascript_url (a_src: STRING)
|
||||
local
|
||||
s: STRING_8
|
||||
do
|
||||
s := "<script type=%"text/javascript%" src=%"" + a_src + "%"></script>"
|
||||
head_lines.extend (s)
|
||||
end
|
||||
|
||||
add_javascript_content (a_script: STRING)
|
||||
local
|
||||
s: STRING_8
|
||||
do
|
||||
s := "<script type=%"text/javascript%">%N" + a_script + "%N</script>"
|
||||
head_lines.extend (s)
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2014, Jocelyn Fiat, 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
|
||||
77
src/theme/cms_html_page_response.e
Normal file
77
src/theme/cms_html_page_response.e
Normal file
@@ -0,0 +1,77 @@
|
||||
note
|
||||
description: "Summary description for {CMS_HTML_PAGE_RESPONSE}."
|
||||
author: ""
|
||||
date: "$Date: 2014-11-13 16:23:47 +0100 (jeu., 13 nov. 2014) $"
|
||||
revision: "$Revision: 96085 $"
|
||||
|
||||
class
|
||||
CMS_HTML_PAGE_RESPONSE
|
||||
|
||||
inherit
|
||||
WSF_RESPONSE_MESSAGE
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_html: like html)
|
||||
do
|
||||
html := a_html
|
||||
status_code := {HTTP_STATUS_CODE}.ok
|
||||
create header.make
|
||||
header.put_content_type_text_html
|
||||
end
|
||||
|
||||
feature -- Status
|
||||
|
||||
status_code: INTEGER
|
||||
|
||||
feature -- Header
|
||||
|
||||
header: HTTP_HEADER
|
||||
|
||||
feature -- Html access
|
||||
|
||||
html: STRING
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_status_code (c: like status_code)
|
||||
do
|
||||
status_code := c
|
||||
end
|
||||
|
||||
feature {WSF_RESPONSE} -- Output
|
||||
|
||||
send_to (res: WSF_RESPONSE)
|
||||
local
|
||||
h: like header
|
||||
s: STRING_8
|
||||
do
|
||||
h := header
|
||||
res.set_status_code (status_code)
|
||||
s := html
|
||||
|
||||
if not h.has_content_length then
|
||||
h.put_content_length (s.count)
|
||||
end
|
||||
if not h.has_content_type then
|
||||
h.put_content_type_text_html
|
||||
end
|
||||
res.put_header_text (h.string)
|
||||
res.put_string (s)
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, 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
|
||||
|
||||
13
src/theme/cms_html_template.e
Normal file
13
src/theme/cms_html_template.e
Normal file
@@ -0,0 +1,13 @@
|
||||
note
|
||||
description: "Summary description for {WSF_CMS_HTML_TEMPLATE}."
|
||||
author: ""
|
||||
date: "$Date: 2014-11-13 16:23:47 +0100 (jeu., 13 nov. 2014) $"
|
||||
revision: "$Revision: 96085 $"
|
||||
|
||||
deferred class
|
||||
CMS_HTML_TEMPLATE
|
||||
|
||||
inherit
|
||||
CMS_TEMPLATE
|
||||
|
||||
end
|
||||
12
src/theme/cms_page_template.e
Normal file
12
src/theme/cms_page_template.e
Normal file
@@ -0,0 +1,12 @@
|
||||
note
|
||||
description: "Summary description for {CMS_PAGE_TEMPLATE}."
|
||||
author: ""
|
||||
date: "$Date: 2014-11-13 16:23:47 +0100 (jeu., 13 nov. 2014) $"
|
||||
revision: "$Revision: 96085 $"
|
||||
|
||||
deferred class
|
||||
CMS_PAGE_TEMPLATE
|
||||
|
||||
inherit
|
||||
CMS_TEMPLATE
|
||||
end
|
||||
43
src/theme/cms_template.e
Normal file
43
src/theme/cms_template.e
Normal file
@@ -0,0 +1,43 @@
|
||||
note
|
||||
description: "[
|
||||
Abstract interface for a CMS Template, as part of the theme design.
|
||||
]"
|
||||
date: "$Date: 2014-11-20 15:03:29 +0100 (jeu., 20 nov. 2014) $"
|
||||
revision: "$Revision: 96138 $"
|
||||
|
||||
deferred class
|
||||
CMS_TEMPLATE
|
||||
|
||||
feature -- Access
|
||||
|
||||
theme: CMS_THEME
|
||||
-- Associated theme.
|
||||
deferred
|
||||
end
|
||||
|
||||
variables: STRING_TABLE [detachable ANY]
|
||||
-- Variables used for Current template rendering.
|
||||
deferred
|
||||
end
|
||||
|
||||
prepare (page: CMS_HTML_PAGE)
|
||||
-- Prepare `page' with current template.
|
||||
deferred
|
||||
end
|
||||
|
||||
to_html (page: CMS_HTML_PAGE): STRING
|
||||
-- HTML rendering for page `page'.
|
||||
deferred
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2014, Jocelyn Fiat, 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
|
||||
139
src/theme/cms_theme.e
Normal file
139
src/theme/cms_theme.e
Normal file
@@ -0,0 +1,139 @@
|
||||
note
|
||||
description: "Abstract class describing a generic theme"
|
||||
date: "$Date: 2014-11-18 02:49:56 +0100 (mar., 18 nov. 2014) $"
|
||||
revision: "$Revision: 96108 $"
|
||||
|
||||
deferred class
|
||||
CMS_THEME
|
||||
|
||||
inherit
|
||||
CMS_ENCODERS
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
|
||||
feature {NONE} -- Access
|
||||
|
||||
setup: CMS_SETUP
|
||||
|
||||
feature -- Access
|
||||
|
||||
name: STRING
|
||||
-- theme name.
|
||||
deferred
|
||||
end
|
||||
|
||||
regions: ARRAY [STRING]
|
||||
-- theme's regions.
|
||||
deferred
|
||||
end
|
||||
|
||||
page_template: CMS_TEMPLATE
|
||||
-- theme template page.
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
menu_html (a_menu: CMS_MENU; is_horizontal: BOOLEAN): STRING_8
|
||||
do
|
||||
debug ("refactor_fixme")
|
||||
fixme ("Refactor HTML code to use the new Bootstrap theme template")
|
||||
end
|
||||
create Result.make_from_string ("<div id=%""+ a_menu.name +"%" class=%"menu%">")
|
||||
if is_horizontal then
|
||||
Result.append ("<ul class=%"horizontal%" >%N")
|
||||
else
|
||||
Result.append ("<ul class=%"vertical%" >%N")
|
||||
end
|
||||
across
|
||||
a_menu as c
|
||||
loop
|
||||
append_cms_link_to (c.item, Result)
|
||||
end
|
||||
Result.append ("</ul>%N")
|
||||
Result.append ("</div>")
|
||||
end
|
||||
|
||||
block_html (a_block: CMS_BLOCK): STRING_8
|
||||
local
|
||||
s: STRING
|
||||
do
|
||||
debug ("refactor_fixme")
|
||||
fixme ("Refactor HTML code to use the new Bootstrap theme template")
|
||||
end
|
||||
if attached a_block.is_raw then
|
||||
create s.make_empty
|
||||
if attached a_block.title as l_title then
|
||||
s.append ("<div class=%"title%">" + html_encoded (l_title) + "</div>")
|
||||
end
|
||||
s.append (a_block.to_html (Current))
|
||||
else
|
||||
create s.make_from_string ("<div class=%"block%" id=%"" + a_block.name + "%">")
|
||||
if attached a_block.title as l_title then
|
||||
s.append ("<div class=%"title%">" + html_encoded (l_title) + "</div>")
|
||||
end
|
||||
s.append ("<div class=%"inside%">")
|
||||
s.append (a_block.to_html (Current))
|
||||
s.append ("</div>")
|
||||
s.append ("</div>")
|
||||
end
|
||||
Result := s
|
||||
end
|
||||
|
||||
page_html (page: CMS_HTML_PAGE): STRING_8
|
||||
-- Render `page' as html.
|
||||
deferred
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
append_cms_link_to (lnk: CMS_LINK; s: STRING_8)
|
||||
local
|
||||
cl: STRING
|
||||
do
|
||||
debug ("refactor_fixme")
|
||||
fixme ("Remove HTML from Eiffel")
|
||||
end
|
||||
create cl.make_empty
|
||||
if lnk.is_active then
|
||||
cl.append ("active ")
|
||||
end
|
||||
if lnk.is_expandable then
|
||||
cl.append ("expandable ")
|
||||
end
|
||||
if lnk.is_expanded then
|
||||
cl.append ("expanded ")
|
||||
end
|
||||
if cl.is_empty then
|
||||
s.append ("<li>")
|
||||
else
|
||||
s.append ("<li class=%""+ cl + "%">")
|
||||
end
|
||||
s.append ("<a href=%"" + (lnk.location) + "%">" + html_encoded (lnk.title) + "</a>")
|
||||
if
|
||||
(lnk.is_expanded or lnk.is_collapsed) and then
|
||||
attached lnk.children as l_children
|
||||
then
|
||||
s.append ("<ul>%N")
|
||||
across
|
||||
l_children as c
|
||||
loop
|
||||
append_cms_link_to (c.item, s)
|
||||
end
|
||||
s.append ("</ul>")
|
||||
end
|
||||
s.append ("</li>")
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2014, Jocelyn Fiat, 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
|
||||
135
src/theme/cms_theme_information.e
Normal file
135
src/theme/cms_theme_information.e
Normal file
@@ -0,0 +1,135 @@
|
||||
note
|
||||
description: "Summary description for {CMS_THEME_INFORMATION}."
|
||||
date: "$Date: 2014-11-13 16:23:47 +0100 (jeu., 13 nov. 2014) $"
|
||||
revision: "$Revision: 96085 $"
|
||||
|
||||
class
|
||||
CMS_THEME_INFORMATION
|
||||
|
||||
create
|
||||
make,
|
||||
make_default
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_default
|
||||
do
|
||||
engine := {STRING_32} "default"
|
||||
create items.make_caseless (1)
|
||||
create regions.make (5)
|
||||
across
|
||||
(<<"top","header", "highlighted","help", "content", "footer", "first_sidebar", "second_sidebar", "bottom">>) as ic
|
||||
loop
|
||||
regions.force (ic.item, ic.item)
|
||||
end
|
||||
end
|
||||
|
||||
make (fn: PATH)
|
||||
local
|
||||
f: PLAIN_TEXT_FILE
|
||||
s: STRING_8
|
||||
h,k: STRING_8
|
||||
v: STRING_32
|
||||
i: INTEGER
|
||||
utf: UTF_CONVERTER
|
||||
l_engine: detachable READABLE_STRING_32
|
||||
done: BOOLEAN
|
||||
do
|
||||
make_default
|
||||
create f.make_with_path (fn)
|
||||
if f.exists and then f.is_access_readable then
|
||||
f.open_read
|
||||
from
|
||||
until
|
||||
done or f.exhausted or f.end_of_file
|
||||
loop
|
||||
f.read_line_thread_aware
|
||||
s := f.last_string
|
||||
s.left_adjust
|
||||
if
|
||||
s.is_empty
|
||||
or else s.starts_with_general (";")
|
||||
or else s.starts_with_general ("#")
|
||||
or else s.starts_with_general ("--")
|
||||
then
|
||||
-- Ignore
|
||||
else
|
||||
i := s.index_of ('=', 1)
|
||||
if i > 0 then
|
||||
h := s.substring (1, i - 1)
|
||||
h.left_adjust
|
||||
h.right_adjust
|
||||
if h.is_case_insensitive_equal_general ("engine") then
|
||||
s.remove_head (i)
|
||||
s.right_adjust
|
||||
v := utf.utf_8_string_8_to_string_32 (s)
|
||||
l_engine := v
|
||||
elseif h.starts_with_general ("regions[") and h[h.count] = ']' then
|
||||
s.remove_head (i)
|
||||
s.right_adjust
|
||||
v := utf.utf_8_string_8_to_string_32 (s)
|
||||
i := h.index_of ('[', 1)
|
||||
k := h.substring (i + 1, h.count - 1)
|
||||
k.left_adjust
|
||||
k.right_adjust
|
||||
if k.starts_with_general ("-") then
|
||||
--| If name is prefixed by "-"
|
||||
--| remove the related region
|
||||
--| If name is "-*", clear all regions.
|
||||
if k.is_case_insensitive_equal_general ("-*") then
|
||||
regions.wipe_out
|
||||
else
|
||||
k.remove_head (1)
|
||||
regions.remove (k)
|
||||
end
|
||||
else
|
||||
regions.force (v, k)
|
||||
end
|
||||
else
|
||||
s.remove_head (i)
|
||||
s.right_adjust
|
||||
v := utf.utf_8_string_8_to_string_32 (s)
|
||||
end
|
||||
items.force (v, h)
|
||||
end
|
||||
end
|
||||
end
|
||||
f.close
|
||||
end
|
||||
if l_engine /= Void and then not l_engine.is_empty then
|
||||
engine := l_engine
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
engine: STRING_32
|
||||
-- Template engine.
|
||||
--| Could be: default, smarty, ...
|
||||
|
||||
regions: STRING_TABLE [READABLE_STRING_GENERAL]
|
||||
-- Regions available in this theme
|
||||
|
||||
item (k: READABLE_STRING_GENERAL): detachable STRING_32
|
||||
-- Item associated with name `k' if any.
|
||||
do
|
||||
Result := items[k]
|
||||
end
|
||||
|
||||
items: STRING_TABLE [STRING_32]
|
||||
-- Items indexed by key name.
|
||||
|
||||
invariant
|
||||
engine_set: not engine.is_empty
|
||||
|
||||
note
|
||||
copyright: "2011-2014, Jocelyn Fiat, 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
|
||||
75
src/theme/default_cms_template.e
Normal file
75
src/theme/default_cms_template.e
Normal file
@@ -0,0 +1,75 @@
|
||||
note
|
||||
description: "Summary description for {DEFAULT_CMS_TEMPLATE}."
|
||||
date: "$Date: 2014-11-13 16:23:47 +0100 (jeu., 13 nov. 2014) $"
|
||||
revision: "$Revision: 96085 $"
|
||||
|
||||
deferred class
|
||||
DEFAULT_CMS_TEMPLATE
|
||||
|
||||
inherit
|
||||
CMS_TEMPLATE
|
||||
|
||||
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
|
||||
|
||||
note
|
||||
copyright: "2011-2014, Jocelyn Fiat, 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
|
||||
48
src/theme/missing_theme/missing_cms_template.e
Normal file
48
src/theme/missing_theme/missing_cms_template.e
Normal file
@@ -0,0 +1,48 @@
|
||||
note
|
||||
description: "[
|
||||
Template to be used with missing theme.
|
||||
]"
|
||||
date: "$Date: 2014-11-19 20:00:19 +0100 (mer., 19 nov. 2014) $"
|
||||
revision: "$Revision: 96123 $"
|
||||
|
||||
class
|
||||
MISSING_CMS_TEMPLATE
|
||||
|
||||
inherit
|
||||
|
||||
CMS_TEMPLATE
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
make (a_theme: MISSING_CMS_THEME)
|
||||
-- Instantiate Current template based on theme `a_theme'.
|
||||
do
|
||||
theme := a_theme
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
theme: MISSING_CMS_THEME
|
||||
-- <Precursor>
|
||||
|
||||
variables: STRING_TABLE [detachable ANY]
|
||||
-- <Precursor>
|
||||
do
|
||||
create Result.make (0)
|
||||
end
|
||||
|
||||
prepare (page: CMS_HTML_PAGE)
|
||||
-- <Precursor>
|
||||
do
|
||||
end
|
||||
|
||||
to_html (page: CMS_HTML_PAGE): STRING
|
||||
-- <Precursor>
|
||||
do
|
||||
Result := " "
|
||||
end
|
||||
|
||||
end
|
||||
48
src/theme/missing_theme/missing_cms_theme.e
Normal file
48
src/theme/missing_theme/missing_cms_theme.e
Normal file
@@ -0,0 +1,48 @@
|
||||
note
|
||||
description: "[
|
||||
Theme used when expected theme is missing.
|
||||
It is mainly used to report missing theme error.
|
||||
]"
|
||||
date: "$Date: 2014-11-19 20:00:19 +0100 (mer., 19 nov. 2014) $"
|
||||
revision: "$Revision: 96123 $"
|
||||
|
||||
class
|
||||
MISSING_CMS_THEME
|
||||
|
||||
inherit
|
||||
|
||||
CMS_THEME
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_setup: like setup)
|
||||
do
|
||||
setup := a_setup
|
||||
ensure
|
||||
setup_set: setup = a_setup
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
name: STRING = "missing theme"
|
||||
|
||||
regions: ARRAY [STRING]
|
||||
do
|
||||
create Result.make_empty
|
||||
end
|
||||
|
||||
page_template: CMS_TEMPLATE
|
||||
-- theme template page.
|
||||
do
|
||||
create {MISSING_CMS_TEMPLATE} Result.make (Current)
|
||||
end
|
||||
|
||||
page_html (page: CMS_HTML_PAGE): STRING_8
|
||||
do
|
||||
to_implement ("Add a better response message, maybe using smarty template")
|
||||
Result := "Service Unavailable"
|
||||
end
|
||||
end
|
||||
60
src/theme/smarty_theme/smarty_cms_html_page_inspector.e
Normal file
60
src/theme/smarty_theme/smarty_cms_html_page_inspector.e
Normal file
@@ -0,0 +1,60 @@
|
||||
note
|
||||
description: "Summary description for {SMARTY_CMS_HTML_PAGE_INSPECTOR}."
|
||||
author: ""
|
||||
date: "$Date: 2014-11-13 16:23:47 +0100 (jeu., 13 nov. 2014) $"
|
||||
revision: "$Revision: 96085 $"
|
||||
|
||||
class
|
||||
SMARTY_CMS_HTML_PAGE_INSPECTOR
|
||||
|
||||
inherit
|
||||
TEMPLATE_INSPECTOR
|
||||
redefine
|
||||
internal_data
|
||||
end
|
||||
|
||||
CMS_ENCODERS
|
||||
|
||||
create
|
||||
register
|
||||
|
||||
feature {TEMPLATE_ROUTINES}
|
||||
|
||||
internal_data (field_name: STRING; obj: detachable ANY): detachable CELL [detachable ANY]
|
||||
-- Return object in a cell
|
||||
-- If not handled by this inspector, return Void
|
||||
local
|
||||
l_fn: STRING
|
||||
do
|
||||
if attached {CMS_HTML_PAGE} obj as l_page then
|
||||
l_fn := field_name.as_lower
|
||||
if attached l_page.variables.item (l_fn) as v then
|
||||
Result := cell_of (v)
|
||||
elseif l_fn.is_case_insensitive_equal ("title") then
|
||||
if attached l_page.title as l_title then
|
||||
Result := cell_of (html_encoded (l_title))
|
||||
else
|
||||
Result := cell_of (Void)
|
||||
end
|
||||
elseif l_fn.is_case_insensitive_equal ("is_front") then
|
||||
Result := cell_of (l_page.is_front)
|
||||
elseif l_fn.starts_with_general ("region_") then
|
||||
l_fn.remove_head (7) -- remove "region_"
|
||||
Result := cell_of (l_page.region (l_fn))
|
||||
elseif l_fn.is_case_insensitive_equal ("regions") then
|
||||
Result := cell_of (l_page.regions)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2014, Jocelyn Fiat, 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
|
||||
140
src/theme/smarty_theme/smarty_cms_page_template.e
Normal file
140
src/theme/smarty_theme/smarty_cms_page_template.e
Normal file
@@ -0,0 +1,140 @@
|
||||
note
|
||||
description: "Summary description for {CMS_PAGE_TEMPLATE}."
|
||||
date: "$Date: 2015-01-14 16:13:47 +0100 (mer., 14 janv. 2015) $"
|
||||
revision: "$Revision: 96454 $"
|
||||
|
||||
class
|
||||
SMARTY_CMS_PAGE_TEMPLATE
|
||||
|
||||
inherit
|
||||
CMS_PAGE_TEMPLATE
|
||||
|
||||
CMS_ENCODERS
|
||||
|
||||
SHARED_TEMPLATE_CONTEXT
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (tpl: READABLE_STRING_GENERAL; t: SMARTY_CMS_THEME)
|
||||
do
|
||||
theme := t
|
||||
create variables.make (0)
|
||||
template_name := tpl
|
||||
end
|
||||
|
||||
variables: STRING_TABLE [detachable ANY]
|
||||
|
||||
feature -- Access
|
||||
|
||||
template_name: READABLE_STRING_GENERAL
|
||||
|
||||
theme: SMARTY_CMS_THEME
|
||||
|
||||
prepare (page: CMS_HTML_PAGE)
|
||||
do
|
||||
variables.make (10)
|
||||
|
||||
across
|
||||
page.variables as ic
|
||||
loop
|
||||
variables.force (ic.item, ic.key)
|
||||
end
|
||||
|
||||
-- FIXME: review variables !
|
||||
if attached page.title as l_title then
|
||||
variables.force (html_encoded (l_title), "head_title")
|
||||
variables.force (html_encoded (l_title), "page_title")
|
||||
else
|
||||
variables.force ("CMS", "head_title")
|
||||
variables.force ("", "page_title")
|
||||
end
|
||||
|
||||
variables.force (page.language, "language")
|
||||
variables.force (page.head_lines_to_string, "head_lines")
|
||||
|
||||
across
|
||||
theme.regions as r
|
||||
loop
|
||||
variables.force (page.region (r.item), "region_" + r.item)
|
||||
end
|
||||
end
|
||||
|
||||
to_html (page: CMS_HTML_PAGE): STRING
|
||||
local
|
||||
tpl: detachable TEMPLATE_FILE
|
||||
ut: FILE_UTILITIES
|
||||
p: detachable PATH
|
||||
n: STRING_32
|
||||
do
|
||||
-- Process html generation
|
||||
template_context.set_template_folder (theme.templates_directory)
|
||||
template_context.disable_verbose
|
||||
debug ("smarty")
|
||||
template_context.enable_verbose
|
||||
end
|
||||
|
||||
if attached page.type as l_page_type then
|
||||
create n.make_from_string_general (l_page_type)
|
||||
n.append_character ('-')
|
||||
n.append_string_general (template_name)
|
||||
n.append_string_general (".tpl")
|
||||
|
||||
p := template_context.template_file (n)
|
||||
|
||||
if ut.file_path_exists (p) then
|
||||
create tpl.make_from_file (n)
|
||||
end
|
||||
end
|
||||
if tpl = Void then
|
||||
create n.make_from_string_general (template_name)
|
||||
n.append_string_general (".tpl")
|
||||
|
||||
p := template_context.template_file (n)
|
||||
if ut.file_path_exists (p) then
|
||||
create tpl.make_from_file (n)
|
||||
end
|
||||
end
|
||||
|
||||
if tpl /= Void then
|
||||
across
|
||||
variables as ic
|
||||
loop
|
||||
tpl.add_value (ic.item, ic.key)
|
||||
end
|
||||
|
||||
debug ("cms")
|
||||
template_context.enable_verbose
|
||||
end
|
||||
tpl.analyze
|
||||
tpl.get_output
|
||||
if attached tpl.output as l_output then
|
||||
Result := l_output
|
||||
else
|
||||
create Result.make_from_string ("ERROR: template issue.")
|
||||
end
|
||||
else
|
||||
create Result.make_from_string ("ERROR: template issue.")
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Registration
|
||||
|
||||
register (v: STRING_8; k: STRING_8)
|
||||
do
|
||||
variables.force (v, k)
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2014, Jocelyn Fiat, 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
|
||||
47
src/theme/smarty_theme/smarty_cms_regions_inspector.e
Normal file
47
src/theme/smarty_theme/smarty_cms_regions_inspector.e
Normal file
@@ -0,0 +1,47 @@
|
||||
note
|
||||
description: "Summary description for {SMARTY_CMS_REGIONS_INSPECTOR}."
|
||||
author: ""
|
||||
date: "$Date: 2014-11-13 16:23:47 +0100 (jeu., 13 nov. 2014) $"
|
||||
revision: "$Revision: 96085 $"
|
||||
|
||||
class
|
||||
SMARTY_CMS_REGIONS_INSPECTOR
|
||||
|
||||
inherit
|
||||
TEMPLATE_INSPECTOR
|
||||
redefine
|
||||
internal_data
|
||||
end
|
||||
|
||||
create
|
||||
register
|
||||
|
||||
feature {TEMPLATE_ROUTINES}
|
||||
|
||||
internal_data (field_name: STRING; obj: detachable ANY): detachable CELL [detachable ANY]
|
||||
-- Return object in a cell
|
||||
-- If not handled by this inspector, return Void
|
||||
local
|
||||
l_fn: STRING
|
||||
do
|
||||
if attached {like {CMS_RESPONSE}.regions} obj as l_regions then
|
||||
l_fn := field_name.as_lower
|
||||
if l_fn.is_case_insensitive_equal ("count") then
|
||||
Result := cell_of (l_regions.count)
|
||||
elseif l_regions.has (l_fn) then
|
||||
Result := cell_of (l_regions.item (l_fn))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2014, Jocelyn Fiat, 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
|
||||
140
src/theme/smarty_theme/smarty_cms_theme.e
Normal file
140
src/theme/smarty_theme/smarty_cms_theme.e
Normal file
@@ -0,0 +1,140 @@
|
||||
note
|
||||
description: "Smarty template CMS theme."
|
||||
date: "$Date: 2014-12-05 22:39:27 +0100 (ven., 05 déc. 2014) $"
|
||||
revision: "$Revision: 96260 $"
|
||||
|
||||
class
|
||||
SMARTY_CMS_THEME
|
||||
|
||||
inherit
|
||||
CMS_THEME
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_setup: like setup; a_info: like information;)
|
||||
do
|
||||
setup := a_setup
|
||||
information := a_info
|
||||
if attached a_info.item ("template_dir") as s then
|
||||
templates_directory := a_setup.theme_location.extended (s)
|
||||
else
|
||||
templates_directory := a_setup.theme_location
|
||||
end
|
||||
ensure
|
||||
setup_set: setup = a_setup
|
||||
information_set: information = a_info
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
name: STRING = "smarty-CMS"
|
||||
|
||||
templates_directory: PATH
|
||||
|
||||
information: CMS_THEME_INFORMATION
|
||||
|
||||
regions: ARRAY [STRING]
|
||||
local
|
||||
i: INTEGER
|
||||
utf: UTF_CONVERTER
|
||||
l_regions: like internal_regions
|
||||
do
|
||||
l_regions := internal_regions
|
||||
if l_regions = Void then
|
||||
if attached information.regions as tb and then not tb.is_empty then
|
||||
i := 1
|
||||
create l_regions.make_filled ("", i, i + tb.count - 1)
|
||||
across
|
||||
tb as ic
|
||||
loop
|
||||
l_regions.force (utf.utf_32_string_to_utf_8_string_8 (ic.key), i) -- NOTE: UTF-8 encoded !
|
||||
i := i + 1
|
||||
end
|
||||
else
|
||||
l_regions := <<"top","header", "highlighted","help", "content", "footer", "first_sidebar", "second_sidebar", "bottom">>
|
||||
end
|
||||
internaL_regions := l_regions
|
||||
end
|
||||
Result := l_regions
|
||||
end
|
||||
|
||||
page_template: SMARTY_CMS_PAGE_TEMPLATE
|
||||
local
|
||||
tpl: like internal_page_template
|
||||
do
|
||||
tpl := internal_page_template
|
||||
if tpl = Void then
|
||||
create tpl.make ("page", Current)
|
||||
internal_page_template := tpl
|
||||
end
|
||||
Result := tpl
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
prepare (page: CMS_HTML_PAGE)
|
||||
do
|
||||
page.register_variable (page, "page")
|
||||
page.register_variable (page.regions, "regions")
|
||||
across
|
||||
page.regions as ic
|
||||
loop
|
||||
page.register_variable (ic.item, "region_" + ic.key)
|
||||
end
|
||||
end
|
||||
|
||||
page_html (page: CMS_HTML_PAGE): STRING_8
|
||||
local
|
||||
l_page_inspector: detachable SMARTY_CMS_HTML_PAGE_INSPECTOR
|
||||
l_regions_inspector: detachable SMARTY_CMS_REGIONS_INSPECTOR
|
||||
l_table_inspector: detachable STRING_TABLE_OF_STRING_INSPECTOR
|
||||
do
|
||||
prepare (page)
|
||||
create l_page_inspector.register (page.generating_type)
|
||||
|
||||
if attached {CMS_RESPONSE} page.variables.item ("cms") as l_cms then
|
||||
if attached l_cms.regions as l_regions then
|
||||
create l_regions_inspector.register (l_regions.generating_type)
|
||||
end
|
||||
end
|
||||
|
||||
create l_table_inspector.register (({detachable STRING_TABLE [STRING_8]}).name)
|
||||
create l_table_inspector.register (({detachable STRING_TABLE [STRING_32]}).name)
|
||||
create l_table_inspector.register (({detachable STRING_TABLE [READABLE_STRING_8]}).name)
|
||||
create l_table_inspector.register (({detachable STRING_TABLE [READABLE_STRING_32]}).name)
|
||||
|
||||
page_template.prepare (page)
|
||||
Result := page_template.to_html (page)
|
||||
|
||||
-- Clean template inspector.
|
||||
if l_regions_inspector /= Void then
|
||||
l_regions_inspector.unregister
|
||||
end
|
||||
if l_page_inspector /= Void then
|
||||
l_page_inspector.unregister
|
||||
end
|
||||
l_table_inspector.unregister
|
||||
end
|
||||
|
||||
feature {NONE} -- Internal
|
||||
|
||||
internal_regions: detachable like regions
|
||||
|
||||
internal_page_template: detachable like page_template
|
||||
|
||||
invariant
|
||||
attached internal_page_template as inv_p implies inv_p.theme = Current
|
||||
note
|
||||
copyright: "2011-2014, Jocelyn Fiat, 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
|
||||
56
src/theme/smarty_theme/string_table_of_string_inspector.e
Normal file
56
src/theme/smarty_theme/string_table_of_string_inspector.e
Normal file
@@ -0,0 +1,56 @@
|
||||
note
|
||||
description: "Summary description for {STRING_TABLE_OF_STRING_INSPECTOR}."
|
||||
author: ""
|
||||
date: "$Date: 2014-12-05 22:39:27 +0100 (ven., 05 déc. 2014) $"
|
||||
revision: "$Revision: 96260 $"
|
||||
|
||||
class
|
||||
STRING_TABLE_OF_STRING_INSPECTOR
|
||||
|
||||
inherit
|
||||
TEMPLATE_INSPECTOR
|
||||
redefine
|
||||
internal_data
|
||||
end
|
||||
|
||||
create
|
||||
register
|
||||
|
||||
feature {TEMPLATE_ROUTINES}
|
||||
|
||||
internal_data (field_name: STRING; obj: detachable ANY): detachable CELL [detachable ANY]
|
||||
-- Return object in a cell
|
||||
-- If not handled by this inspector, return Void
|
||||
local
|
||||
l_fn: STRING
|
||||
utf: UTF_CONVERTER
|
||||
do
|
||||
if attached {STRING_TABLE [detachable READABLE_STRING_GENERAL]} obj as l_regions then
|
||||
l_fn := field_name.as_lower
|
||||
if l_fn.is_case_insensitive_equal ("count") then
|
||||
Result := cell_of (l_regions.count)
|
||||
elseif attached l_regions.item (l_fn) as v then
|
||||
if attached {READABLE_STRING_32} v as v32 then
|
||||
if attached v32.is_valid_as_string_8 then
|
||||
Result := cell_of (v.to_string_8)
|
||||
else
|
||||
Result := cell_of (utf.escaped_utf_32_string_to_utf_8_string_8 (v32))
|
||||
end
|
||||
else
|
||||
Result := cell_of (v.to_string_8)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2014, Jocelyn Fiat, 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
|
||||
Reference in New Issue
Block a user