Moved library/src to src

This commit is contained in:
2015-01-27 19:58:13 +01:00
parent d97c4b1a4a
commit 5ddc2006e2
83 changed files with 255 additions and 92 deletions

View 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

View 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

View 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

View 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

View 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