Added CMS_STRING_EXPANDER.
For now with basic implementation. It will be improved later Added SEO related attribute in CMS_RESPONSE. Added improved Contact module. Added basic SEO module.
This commit is contained in:
@@ -209,6 +209,38 @@ feature -- Access: Site
|
||||
Result := utf.utf_32_string_to_utf_8_string_8 (site_name)
|
||||
end
|
||||
|
||||
site_properties: detachable STRING_TABLE [READABLE_STRING_32]
|
||||
-- Optional site properties.
|
||||
do
|
||||
Result := text_table_item ("site.property")
|
||||
end
|
||||
|
||||
site_property (a_name: READABLE_STRING_GENERAL): detachable READABLE_STRING_32
|
||||
do
|
||||
Result := text_item ({STRING_32} "site." + a_name.as_string_32)
|
||||
if Result = Void and then attached site_properties as props then
|
||||
Result := props.item (a_name)
|
||||
end
|
||||
end
|
||||
|
||||
site_description: detachable READABLE_STRING_32
|
||||
-- Optional site description.
|
||||
do
|
||||
Result := site_property ("description")
|
||||
end
|
||||
|
||||
site_headline: detachable READABLE_STRING_32
|
||||
-- Optional site headline.
|
||||
do
|
||||
Result := site_property ("headline")
|
||||
end
|
||||
|
||||
site_keywords: detachable READABLE_STRING_32
|
||||
-- Optional site comma separated keywords.
|
||||
do
|
||||
Result := site_property ("keywords")
|
||||
end
|
||||
|
||||
site_email: READABLE_STRING_8
|
||||
-- Website email address.
|
||||
-- Used as "From:" address when the site is sending emails
|
||||
|
||||
@@ -27,6 +27,6 @@ feature -- Factory
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
||||
copyright: "2011-2016, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
end
|
||||
|
||||
119
src/service/misc/cms_string_expander.e
Normal file
119
src/service/misc/cms_string_expander.e
Normal file
@@ -0,0 +1,119 @@
|
||||
note
|
||||
description: "[
|
||||
String expander facility for the CMS.
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CMS_STRING_EXPANDER [G -> STRING_GENERAL]
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
do
|
||||
create values.make (3)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
values: STRING_TABLE [G]
|
||||
|
||||
has_error: BOOLEAN
|
||||
do
|
||||
Result := attached error_handler as h and then h.has_error
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
force, put (new: G; key: READABLE_STRING_GENERAL)
|
||||
do
|
||||
values.force (new, key)
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
expand_string (a_text: STRING_GENERAL)
|
||||
do
|
||||
if attached {STRING_32} a_text as t32 then
|
||||
expand_string_32 (t32)
|
||||
elseif attached {STRING_8} a_text as t8 then
|
||||
expand_string_8 (t8)
|
||||
else
|
||||
check known_string: False end
|
||||
end
|
||||
end
|
||||
|
||||
expand_string_8 (a_text: STRING)
|
||||
local
|
||||
k, s: STRING_8
|
||||
utf: UTF_CONVERTER
|
||||
do
|
||||
--| FIXME: implement better string expander.
|
||||
across
|
||||
values as ic
|
||||
loop
|
||||
if attached {READABLE_STRING_8} ic.item as v then
|
||||
s := v.to_string_8
|
||||
elseif attached ic.item as v then
|
||||
s := utf.utf_32_string_to_utf_8_string_8 (v)
|
||||
else
|
||||
create s.make_empty
|
||||
end
|
||||
if attached {READABLE_STRING_8} ic.key as v then
|
||||
k := v
|
||||
else
|
||||
k := utf.utf_32_string_to_utf_8_string_8 (ic.key)
|
||||
end
|
||||
a_text.replace_substring_all ({STRING_8} "$" + k, s)
|
||||
end
|
||||
end
|
||||
|
||||
expand_string_32 (a_text: STRING_32)
|
||||
local
|
||||
k, s: STRING_32
|
||||
do
|
||||
--| FIXME: implement better string expander.
|
||||
across
|
||||
values as ic
|
||||
loop
|
||||
if attached ic.item as v then
|
||||
s := v.to_string_32
|
||||
else
|
||||
create s.make_empty
|
||||
end
|
||||
k := ic.key.to_string_32
|
||||
a_text.replace_substring_all ({STRING_32} "$" + k, s)
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
reset_error
|
||||
do
|
||||
if attached error_handler as h then
|
||||
h.reset
|
||||
end
|
||||
end
|
||||
|
||||
error_handler: detachable ERROR_HANDLER
|
||||
|
||||
report_error (m: detachable READABLE_STRING_GENERAL)
|
||||
local
|
||||
h: like error_handler
|
||||
do
|
||||
h := error_handler
|
||||
if h = Void then
|
||||
create h.make
|
||||
error_handler := h
|
||||
end
|
||||
h.add_custom_error (-1, "string expander error", m)
|
||||
end
|
||||
|
||||
;note
|
||||
copyright: "2011-2016, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
end
|
||||
@@ -91,12 +91,24 @@ feature -- Access
|
||||
|
||||
header: WSF_HEADER
|
||||
|
||||
main_content: detachable STRING_8
|
||||
|
||||
feature -- Access: metadata
|
||||
|
||||
title: detachable READABLE_STRING_32
|
||||
|
||||
page_title: detachable READABLE_STRING_32
|
||||
-- Page title
|
||||
|
||||
main_content: detachable STRING_8
|
||||
description: detachable READABLE_STRING_32
|
||||
|
||||
keywords: detachable READABLE_STRING_32
|
||||
|
||||
publication_date: detachable DATE_TIME
|
||||
-- Optional publication date.
|
||||
|
||||
modification_date: detachable DATE_TIME
|
||||
-- Optional modification date.
|
||||
|
||||
additional_page_head_lines: detachable LIST [READABLE_STRING_8]
|
||||
-- HTML>head>...extra lines
|
||||
@@ -104,6 +116,8 @@ feature -- Access
|
||||
redirection: detachable READABLE_STRING_8
|
||||
-- Location for eventual redirection.
|
||||
|
||||
feature -- Access: query
|
||||
|
||||
location: STRING_8
|
||||
-- Associated cms local location.
|
||||
do
|
||||
@@ -113,6 +127,7 @@ feature -- Access
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
feature -- API
|
||||
|
||||
api: CMS_API
|
||||
@@ -286,6 +301,32 @@ feature -- Element change
|
||||
page_title := t
|
||||
end
|
||||
|
||||
set_description (d: like description)
|
||||
do
|
||||
description := d
|
||||
end
|
||||
|
||||
set_keywords (s: like keywords)
|
||||
do
|
||||
keywords := s
|
||||
end
|
||||
|
||||
set_publication_date (dt: like publication_date)
|
||||
do
|
||||
publication_date := dt
|
||||
if dt /= Void and modification_date = Void then
|
||||
modification_date := dt
|
||||
end
|
||||
end
|
||||
|
||||
set_modification_date (dt: like modification_date)
|
||||
do
|
||||
modification_date := dt
|
||||
if dt /= Void and publication_date = Void then
|
||||
publication_date := dt
|
||||
end
|
||||
end
|
||||
|
||||
set_main_content (s: like main_content)
|
||||
do
|
||||
main_content := s
|
||||
@@ -1358,6 +1399,6 @@ feature {NONE} -- Execution
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
||||
copyright: "2011-2016, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user