Updated CMS_SERVICE to make the cms library complete void-safe.

Reviewed configuration related feature.
Renamed JSON_CONFIGURATION as APPLICATION_JSON_CONFIGURATION_HELPER to avoid confusion.
Updated CMS_DEFAULT_SETUP to use configuration from cms configuration library.
Added {CMS_API}.module_configuration (a_module_name: READABLE_STRING_GENERAL; a_name: detachable READABLE_STRING_GENERAL): detachable CONFIG_READER  to help getting access to configuration of a module (for now, only json and ini are supported, but in the future, this could support database layer directly)
Added CMS_HOOK_BLOCK_HELPER to reuse the template_block (..): ... function.
Cosmetic
Removed CMS_SETUP.smtp_server since for now, there is no need for such general setting.
Add header line "X-ServerEWF-App: CMS" as a simple way to know if request is processed by the CMS.
This commit is contained in:
2015-01-14 18:25:26 +01:00
parent 792880aa7a
commit db9e40cec4
31 changed files with 234 additions and 93 deletions

View File

@@ -2,27 +2,26 @@
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-13-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-13-0 http://www.eiffel.com/developers/xml/configuration-1-13-0.xsd" name="cms" uuid="8CC0D052-57D1-4CAA-AFF1-448FA290734B" library_target="cms"> <system xmlns="http://www.eiffel.com/developers/xml/configuration-1-13-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-13-0 http://www.eiffel.com/developers/xml/configuration-1-13-0.xsd" name="cms" uuid="8CC0D052-57D1-4CAA-AFF1-448FA290734B" library_target="cms">
<target name="cms"> <target name="cms">
<root all_classes="true"/> <root all_classes="true"/>
<option warning="true" full_class_checking="false" is_attached_by_default="true" void_safety="transitional" syntax="transitional"> <option warning="true" full_class_checking="false" is_attached_by_default="true" void_safety="all" syntax="transitional">
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/> <assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
</option> </option>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/> <library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="crypto" location="$ISE_LIBRARY\unstable\library\text\encryption\crypto\crypto-safe.ecf"/>
<library name="http" location="$ISE_LIBRARY\contrib\library\network\protocol\http\http-safe.ecf"/>
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json-safe.ecf" readonly="false"/>
<library name="config" location=".\library\configuration\config-safe.ecf"/> <library name="config" location=".\library\configuration\config-safe.ecf"/>
<library name="crypto" location="$ISE_LIBRARY\unstable\library\text\encryption\crypto\crypto-safe.ecf"/>
<library name="encoder" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\text\encoder\encoder-safe.ecf" readonly="false"/>
<library name="error" location="$ISE_LIBRARY\contrib\library\utility\general\error\error-safe.ecf"/>
<library name="http" location="$ISE_LIBRARY\contrib\library\network\protocol\http\http-safe.ecf"/>
<library name="http_authorization" location="$ISE_LIBRARY\contrib\library\network\authentication\http_authorization\http_authorization-safe.ecf" readonly="false"/>
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json-safe.ecf" readonly="false"/>
<library name="layout" location=".\library\layout\layout-safe.ecf"/> <library name="layout" location=".\library\layout\layout-safe.ecf"/>
<library name="model" location=".\library\model\cms_model-safe.ecf" readonly="false"/> <library name="model" location=".\library\model\cms_model-safe.ecf" readonly="false"/>
<library name="encoder" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\text\encoder\encoder-safe.ecf" readonly="false"/>
<library name="text_filter" location="$ISE_LIBRARY\unstable\library\text\text_filter\text_filter-safe.ecf"/>
<library name="error" location="$ISE_LIBRARY\contrib\library\utility\general\error\error-safe.ecf"/>
<library name="http_authorization" location="$ISE_LIBRARY\contrib\library\network\authentication\http_authorization\http_authorization-safe.ecf" readonly="false"/>
<library name="persistence_mysql" location=".\library\persistence\implementation\mysql\persistence_mysql-safe.ecf" readonly="false"/> <library name="persistence_mysql" location=".\library\persistence\implementation\mysql\persistence_mysql-safe.ecf" readonly="false"/>
<library name="smarty" location="$ISE_LIBRARY\contrib\library\text\template\smarty\smarty-safe.ecf" readonly="false"/> <library name="smarty" location="$ISE_LIBRARY\contrib\library\text\template\smarty\smarty-safe.ecf" readonly="false"/>
<library name="text_filter" location="$ISE_LIBRARY\unstable\library\text\text_filter\text_filter-safe.ecf"/>
<library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/>
<library name="wsf" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf-safe.ecf"/> <library name="wsf" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf-safe.ecf"/>
<library name="wsf_extension" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf_extension-safe.ecf" readonly="false"/> <library name="wsf_extension" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf_extension-safe.ecf" readonly="false"/>
<library name="wsf_html" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf_html\wsf_html-safe.ecf" readonly="false"/> <library name="wsf_html" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf_html\wsf_html-safe.ecf" readonly="false"/>
<library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/>
<cluster name="src" location=".\library\src\" recursive="true"> <cluster name="src" location=".\library\src\" recursive="true">
<file_rule> <file_rule>
<exclude>/EIFGENs$</exclude> <exclude>/EIFGENs$</exclude>

View File

@@ -2,8 +2,8 @@ note
description: "[ description: "[
application service application service
]" ]"
date: "$Date$" date: "$Date: 2014-11-20 15:03:29 +0100 (jeu., 20 nov. 2014) $"
revision: "$Revision$" revision: "$Revision: 96138 $"
class class
EWF_ROC_SERVER EWF_ROC_SERVER

View File

@@ -1,7 +1,7 @@
note note
description: "Summary description for {CONFIG_READER}." description: "Summary description for {CONFIG_READER}."
author: "" author: ""
date: "$Date: 2014-12-18 12:37:11 -0300 (ju. 18 de dic. de 2014) $" date: "$Date: 2014-12-18 16:37:11 +0100 (jeu., 18 déc. 2014) $"
revision: "$Revision: 96383 $" revision: "$Revision: 96383 $"
deferred class deferred class

View File

@@ -44,7 +44,7 @@ note
@include=file-to-include @include=file-to-include
]" ]"
date: "$Date: 2014-12-18 12:37:11 -0300 (ju. 18 de dic. de 2014) $" date: "$Date: 2014-12-18 16:37:11 +0100 (jeu., 18 déc. 2014) $"
revision: "$Revision: 96383 $" revision: "$Revision: 96383 $"
class class

View File

@@ -1,6 +1,6 @@
note note
description: "Object parsing a JSON configuration file." description: "Object parsing a JSON configuration file."
date: "$Date: 2014-12-18 12:37:11 -0300 (ju. 18 de dic. de 2014) $" date: "$Date: 2014-12-18 16:37:11 +0100 (jeu., 18 déc. 2014) $"
revision: "$Revision: 96383 $" revision: "$Revision: 96383 $"
class class

View File

@@ -3,7 +3,7 @@ note
Testing suite for CONFIG_READER . Testing suite for CONFIG_READER .
]" ]"
author: "$Author: jfiat $" author: "$Author: jfiat $"
date: "$Date: 2014-12-18 12:37:11 -0300 (ju. 18 de dic. de 2014) $" date: "$Date: 2014-12-18 16:37:11 +0100 (jeu., 18 déc. 2014) $"
revision: "$Revision: 96383 $" revision: "$Revision: 96383 $"
class class

View File

@@ -1,10 +1,10 @@
note note
description: "Provide access to json configuration" description: "Provide access to json configuration"
date: "$Date: 2014-11-20 15:03:29 +0100 (jeu., 20 nov. 2014) $" date: "$Date: 2015-01-14 16:13:47 +0100 (mer., 14 janv. 2015) $"
revision: "$Revision: 96138 $" revision: "$Revision: 96454 $"
class class
JSON_CONFIGURATION APPLICATION_JSON_CONFIGURATION_HELPER
feature -- Application Configuration feature -- Application Configuration
@@ -113,7 +113,7 @@ feature {NONE} -- JSON
end end
note note
copyright: "2011-2014, Javier Velilla, Jocelyn Fiat, Eiffel Software and others" copyright: "2011-2015, Javier Velilla, Jocelyn Fiat, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end end

View File

@@ -1,7 +1,7 @@
note note
description: "Object that represent Database configuration settings" description: "Object that represent Database configuration settings"
date: "$Date: 2014-08-20 15:21:15 -0300 (mi., 20 ago. 2014) $" date: "$Date: 2015-01-14 16:13:47 +0100 (mer., 14 janv. 2015) $"
revision: "$Revision: 95678 $" revision: "$Revision: 96454 $"
class class
DATABASE_CONFIGURATION DATABASE_CONFIGURATION

View File

@@ -2,8 +2,8 @@ note
description: "[ description: "[
Default CMS_SETUP that can be reused easily, and/or redefined to match specific setup. Default CMS_SETUP that can be reused easily, and/or redefined to match specific setup.
]" ]"
date: "$Date: 2014-11-19 20:00:19 +0100 (mer., 19 nov. 2014) $" date: "$Date: 2015-01-14 16:13:47 +0100 (mer., 14 janv. 2015) $"
revision: "$Revision: 96123 $" revision: "$Revision: 96454 $"
class class
CMS_DEFAULT_SETUP CMS_DEFAULT_SETUP
@@ -22,7 +22,7 @@ feature {NONE} -- Initialization
-- Create a default setup with `a_layout'. -- Create a default setup with `a_layout'.
do do
layout := a_layout layout := a_layout
create configuration.make (layout) create {INI_CONFIG} configuration.make_from_file (layout.cms_config_ini_path)
initialize initialize
end end
@@ -37,13 +37,32 @@ feature {NONE} -- Initialization
configure configure
do do
site_id := configuration.site_id --| Site id, used to identified a site, this could be set to a uuid, or else
site_url := configuration.site_url (Void) site_id := text_item_or_default ("site.id", "_EWF_CMS_NO_ID_")
site_name := configuration.site_name ("EWF::CMS")
site_email := configuration.site_email ("webmaster") -- Site url: optional, but ending with a slash
themes_location := configuration.themes_location site_url := string_8_item ("site_url")
theme_name := configuration.theme_name ("default") if attached site_url as l_url and then not l_url.is_empty then
smtp := configuration.smtp if l_url[l_url.count] /= '/' then
site_url := l_url + "/"
end
end
-- Site name
site_name := text_item_or_default ("site.name", "EWF::CMS")
-- Site email for any internal notification
-- Can be also used to precise the "From:" value for email.
site_email := text_item_or_default ("site.email", "webmaster")
-- Location for theme folders.
if attached text_item ("themes-dir") as s then
create themes_location.make_from_string (s)
else
themes_location := layout.www_path.extended ("themes")
end
-- Selected theme's name
theme_name := text_item_or_default ("theme", "default")
debug ("refactor_fixme") debug ("refactor_fixme")
fixme ("Review export clause for configuration and layout") fixme ("Review export clause for configuration and layout")
@@ -72,11 +91,36 @@ feature {NONE} -- Initialization
register_module (m) register_module (m)
end end
feature {NONE} -- Configuration
configuration: CONFIG_READER
-- Association configuration file.
feature -- Access feature -- Access
modules: CMS_MODULE_COLLECTION modules: CMS_MODULE_COLLECTION
-- <Precursor> -- <Precursor>
text_item (a_name: READABLE_STRING_GENERAL): detachable READABLE_STRING_32
-- Configuration value associated with `a_name', if any.
do
Result := configuration.resolved_text_item (a_name)
end
string_8_item (a_name: READABLE_STRING_GENERAL): detachable READABLE_STRING_8
-- String 8 configuration value associated with `a_name', if any.
local
utf: UTF_CONVERTER
do
if attached text_item (a_name) as s then
if s.is_valid_as_string_8 then
Result := s.as_string_8
else
Result := utf.escaped_utf_32_string_to_utf_8_string_8 (s)
end
end
end
is_html: BOOLEAN is_html: BOOLEAN
-- <Precursor> -- <Precursor>
do do

View File

@@ -1,14 +1,14 @@
note note
description: "Summary description for {CMS_JSON_CONFIGURATION}." description: "Summary description for {CMS_JSON_CONFIGURATION}."
date: "$Date$" date: "$Date: 2015-01-14 16:13:47 +0100 (mer., 14 janv. 2015) $"
revision: "$Revision$" revision: "$Revision: 96454 $"
class class
CMS_JSON_CONFIGURATION CMS_JSON_CONFIGURATION
inherit inherit
JSON_CONFIGURATION APPLICATION_JSON_CONFIGURATION_HELPER
feature -- Access feature -- Access

View File

@@ -7,8 +7,8 @@ note
- documentation - documentation
- themes - themes
]" ]"
date: "$Date$" date: "$Date: 2014-12-18 16:37:11 +0100 (jeu., 18 déc. 2014) $"
revision: "$Revision$" revision: "$Revision: 96383 $"
class class
CMS_LAYOUT CMS_LAYOUT
@@ -38,7 +38,7 @@ feature -- Access
end end
cms_config_ini_path: PATH cms_config_ini_path: PATH
-- Database Configuration file path. -- CMS Configuration file path.
local local
p: detachable PATH p: detachable PATH
do do

View File

@@ -1,7 +1,7 @@
note note
description: "Class that enable to set basic configuration, application layout, core modules and themes." description: "Class that enable to set basic configuration, application layout, core modules and themes."
date: "$Date: 2014-12-18 12:47:20 -0300 (ju. 18 de dic. de 2014) $" date: "$Date: 2015-01-14 18:12:03 +0100 (mer., 14 janv. 2015) $"
revision: "$Revision: 96384 $" revision: "$Revision: 96456 $"
deferred class deferred class
CMS_SETUP CMS_SETUP
@@ -66,9 +66,6 @@ feature -- Access: Site
-- Optional path defining the front page. -- Optional path defining the front page.
-- By default "" or "/". -- By default "" or "/".
smtp: detachable READABLE_STRING_8
-- Smtp server
feature -- Query feature -- Query
text_item (a_name: READABLE_STRING_GENERAL): detachable READABLE_STRING_32 text_item (a_name: READABLE_STRING_GENERAL): detachable READABLE_STRING_32

View File

@@ -0,0 +1,29 @@
note
description: "Summary description for {CMS_HOOK_BLOCK_HELPER}."
author: ""
date: "$Date: 2015-01-14 16:13:47 +0100 (mer., 14 janv. 2015) $"
revision: "$Revision: 96454 $"
deferred class
CMS_HOOK_BLOCK_HELPER
feature -- Factory
template_block (a_module: CMS_MODULE; a_block_id: READABLE_STRING_8; a_response: CMS_RESPONSE): detachable CMS_SMARTY_TEMPLATE_BLOCK
-- Smarty content block for `a_block_id' in the context of `a_module' and `a_response'.
local
p: detachable PATH
do
create p.make_from_string ("templates")
p := p.extended ("block_").appended (a_block_id).appended_with_extension ("tpl")
p := a_response.module_resource_path (a_module, p)
if p /= Void then
if attached p.entry as e then
create Result.make (a_block_id, Void, p.parent, e)
else
create Result.make (a_block_id, Void, p.parent, p)
end
end
end
end

View File

@@ -2,8 +2,8 @@ note
description: "[ description: "[
CMS block with smarty template file content. CMS block with smarty template file content.
]" ]"
date: "$Date: 2014-11-14 16:11:17 -0300 (vi. 14 de nov. de 2014) $" date: "$Date: 2014-12-05 22:39:27 +0100 (ven., 05 déc. 2014) $"
revision: "$Revision: 96092 $" revision: "$Revision: 96260 $"
class class
CMS_SMARTY_TEMPLATE_BLOCK CMS_SMARTY_TEMPLATE_BLOCK
@@ -115,6 +115,7 @@ feature -- Conversion
tpl: detachable TEMPLATE_FILE tpl: detachable TEMPLATE_FILE
ut: FILE_UTILITIES ut: FILE_UTILITIES
n: STRING_32 n: STRING_32
l_table_inspector: detachable STRING_TABLE_OF_STRING_INSPECTOR
do do
-- Process html generation -- Process html generation
p := location p := location
@@ -134,8 +135,16 @@ feature -- Conversion
tpl.add_value (ic.item, ic.key) tpl.add_value (ic.item, ic.key)
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)
tpl.analyze tpl.analyze
tpl.get_output tpl.get_output
l_table_inspector.unregister
-- l_table32_inspector.unregister
if attached tpl.output as l_output then if attached tpl.output as l_output then
Result := l_output Result := l_output
else else

View File

@@ -1,6 +1,6 @@
note note
description: "Summary description for {CMS_DEBUG_MODULE}." description: "Summary description for {CMS_DEBUG_MODULE}."
date: "$Date: 2014-12-18 12:47:20 -0300 (ju. 18 de dic. de 2014) $" date: "$Date: 2014-12-18 16:47:20 +0100 (jeu., 18 déc. 2014) $"
revision: "$Revision: 96384 $" revision: "$Revision: 96384 $"
class class

View File

@@ -1,6 +1,6 @@
note note
description: "Summary description for {NEW_CONTENT_HANDLER}." description: "Summary description for {NEW_CONTENT_HANDLER}."
date: "$Date: 2014-12-19 10:17:32 -0300 (vi., 19 dic. 2014) $" date: "$Date: 2014-12-19 14:17:32 +0100 (ven., 19 déc. 2014) $"
revision: "$Revision: 96402 $" revision: "$Revision: 96402 $"
class class

View File

@@ -1,6 +1,6 @@
note note
description: "Summary description for {NODE_HANDLER}." description: "Summary description for {NODE_HANDLER}."
date: "$Date: 2014-12-19 10:17:32 -0300 (vi., 19 dic. 2014) $" date: "$Date: 2014-12-19 14:17:32 +0100 (ven., 19 déc. 2014) $"
revision: "$Revision: 96402 $" revision: "$Revision: 96402 $"
class class

View File

@@ -1,6 +1,6 @@
note note
description: "Summary description for {NODE_SUMMARY_HANDLER}." description: "Summary description for {NODE_SUMMARY_HANDLER}."
date: "$Date: 2014-12-19 10:17:32 -0300 (vi., 19 dic. 2014) $" date: "$Date: 2014-12-19 14:17:32 +0100 (ven., 19 déc. 2014) $"
revision: "$Revision: 96402 $" revision: "$Revision: 96402 $"
class class

View File

@@ -1,6 +1,6 @@
note note
description: "Summary description for {NODE_TITLE_HANDLER}." description: "Summary description for {NODE_TITLE_HANDLER}."
date: "$Date: 2014-12-19 10:17:32 -0300 (vi., 19 dic. 2014) $" date: "$Date: 2014-12-19 14:17:32 +0100 (ven., 19 déc. 2014) $"
revision: "$Revision: 96402 $" revision: "$Revision: 96402 $"
class class

View File

@@ -1,7 +1,7 @@
note note
description: "API for a CMS" description: "API for a CMS"
date: "$Date$" date: "$Date: 2015-01-14 16:13:47 +0100 (mer., 14 janv. 2015) $"
revision: "$Revision$" revision: "$Revision: 96454 $"
class class
CMS_API CMS_API
@@ -38,7 +38,7 @@ feature -- Initialize
do do
if not retried then if not retried then
to_implement ("Refactor database setup") to_implement ("Refactor database setup")
if attached (create {JSON_CONFIGURATION}).new_database_configuration (setup.layout.application_config_path) as l_database_config then if attached (create {APPLICATION_JSON_CONFIGURATION_HELPER}).new_database_configuration (setup.layout.application_config_path) as l_database_config then
create {DATABASE_CONNECTION_MYSQL} l_database.login_with_connection_string (l_database_config.connection_string) create {DATABASE_CONNECTION_MYSQL} l_database.login_with_connection_string (l_database_config.connection_string)
create {CMS_STORAGE_MYSQL} storage.make (l_database) create {CMS_STORAGE_MYSQL} storage.make (l_database)
else else
@@ -207,10 +207,41 @@ feature -- Change User
end end
end end
feature -- Layout
module_configuration (a_module_name: READABLE_STRING_GENERAL; a_name: detachable READABLE_STRING_GENERAL): detachable CONFIG_READER
-- Configuration reader for `a_module', and if `a_name' is set, using name `a_name'.
local
p, l_path: PATH
ut: FILE_UTILITIES
do
p := setup.layout.config_path.extended ("modules").extended (a_module_name)
if a_name = Void then
p := p.extended (a_module_name)
else
p := p.extended (a_name)
end
l_path := p.appended_with_extension ("json")
if ut.file_path_exists (l_path) then
create {JSON_CONFIG} Result.make_from_file (l_path)
else
l_path := p.appended_with_extension ("ini")
if ut.file_path_exists (l_path) then
create {INI_CONFIG} Result.make_from_file (l_path)
end
end
if Result = Void and a_name /= Void then
-- Use sub config from default?
if attached {CONFIG_READER} module_configuration (a_module_name, Void) as cfg then
Result := cfg.sub_config (a_name)
else
-- Maybe try to use the global cms.ini ?
end
end
end
feature {NONE} -- Implemenataion feature {NONE} -- Implemenataion
storage: CMS_STORAGE storage: CMS_STORAGE
-- Persistence storage. -- Persistence storage.

View File

@@ -57,8 +57,11 @@ feature {NONE} -- Initialization
initialize_users initialize_users
initialize_auth_engine initialize_auth_engine
initialize_mailer initialize_mailer
-- initialize_router
-- initialize_filter: expanded here, for void-safety concern.
create_filter
initialize_router initialize_router
initialize_filter setup_filter
end end
initialize_modules initialize_modules
@@ -155,6 +158,7 @@ feature -- Execute Filter
-- Execute the filter. -- Execute the filter.
do do
res.put_header_line ("Date: " + (create {HTTP_DATE}.make_now_utc).string) res.put_header_line ("Date: " + (create {HTTP_DATE}.make_now_utc).string)
res.put_header_line ("X-EWF-Server: CMS_v1.0")
execute_service (req, res) execute_service (req, res)
end end

View File

@@ -1,6 +1,6 @@
note note
description: "Summary description for {CMS_ERROR_FILTER}." description: "Summary description for {CMS_ERROR_FILTER}."
date: "$Date: 2014-12-19 10:17:32 -0300 (vi., 19 dic. 2014) $" date: "$Date: 2014-12-19 14:17:32 +0100 (ven., 19 déc. 2014) $"
revision: "$Revision: 96402 $" revision: "$Revision: 96402 $"
class class

View File

@@ -1,6 +1,6 @@
note note
description: "Summary description for {BAD_REQUEST_ERROR_CMS_RESPONSE}." description: "Summary description for {BAD_REQUEST_ERROR_CMS_RESPONSE}."
date: "$Date: 2014-12-19 10:17:32 -0300 (vi., 19 dic. 2014) $" date: "$Date: 2014-12-19 14:17:32 +0100 (ven., 19 déc. 2014) $"
revision: "$Revision: 96402 $" revision: "$Revision: 96402 $"
class class

View File

@@ -1,7 +1,7 @@
note note
description: "Generic CMS Response.It builds the content to get process to render the output" description: "Generic CMS Response.It builds the content to get process to render the output"
date: "$Date$" date: "$Date: 2014-12-15 21:43:38 +0100 (lun., 15 déc. 2014) $"
revision: "$Revision$" revision: "$Revision: 96346 $"
deferred class deferred class
CMS_RESPONSE CMS_RESPONSE
@@ -379,12 +379,6 @@ feature -- Blocks
add_block (header_block, "header") add_block (header_block, "header")
if attached message_block as m then if attached message_block as m then
add_block (m, "content") add_block (m, "content")
end
-- FIXME: avoid hardcoded html! should be only in theme.
add_block (create {CMS_CONTENT_BLOCK}.make_raw ("top_content_anchor", Void, "<a id=%"main-content%"></a>%N", formats.full_html), "content")
if attached page_title as l_page_title then
-- FIXME: avoid hardcoded html! should be only in theme.
add_block (create {CMS_CONTENT_BLOCK}.make_raw ("page_title", Void, "<h1 id=%"page-title%" class=%"title%">"+ l_page_title +"</h1>%N", formats.full_html), "content")
end end
if attached primary_tabs_block as m then if attached primary_tabs_block as m then
add_block (m, "content") add_block (m, "content")
@@ -447,7 +441,7 @@ feature -- Blocks
s: STRING s: STRING
do do
create s.make_empty create s.make_empty
create Result.make ("page_top", Void, s, formats.full_html) create Result.make ("page_top", Void, s, Void)
Result.set_is_raw (True) Result.set_is_raw (True)
end end
@@ -458,7 +452,7 @@ feature -- Blocks
do do
create s.make_from_string (theme.menu_html (primary_menu, True)) create s.make_from_string (theme.menu_html (primary_menu, True))
create l_hb.make_empty create l_hb.make_empty
create Result.make ("header", Void, l_hb, formats.full_html) create Result.make ("header", Void, l_hb, Void)
Result.set_is_raw (True) Result.set_is_raw (True)
end end
@@ -480,7 +474,7 @@ feature -- Blocks
message_block: detachable CMS_CONTENT_BLOCK message_block: detachable CMS_CONTENT_BLOCK
do do
if attached message as m and then not m.is_empty then if attached message as m and then not m.is_empty then
create Result.make ("message", Void, "<div id=%"message%">" + m + "</div>", formats.full_html) create Result.make ("message", Void, "<div id=%"message%">" + m + "</div>", Void)
Result.set_is_raw (True) Result.set_is_raw (True)
end end
end end
@@ -497,7 +491,7 @@ feature -- Blocks
s := "No Content" s := "No Content"
end end
end end
create Result.make ("content", Void, s, formats.full_html) create Result.make ("content", Void, s, Void)
Result.set_is_raw (True) Result.set_is_raw (True)
end end
@@ -862,6 +856,11 @@ feature -- Generation
-- Menu... -- Menu...
page.register_variable (horizontal_primary_menu_html, "primary_nav") page.register_variable (horizontal_primary_menu_html, "primary_nav")
-- Page related
if attached page_title as l_page_title then
page.register_variable (l_page_title, "page_title")
end
end end
custom_prepare (page: CMS_HTML_PAGE) custom_prepare (page: CMS_HTML_PAGE)
@@ -911,7 +910,11 @@ feature -- Generation
-- Update the active status recursively on `a_comp'. -- Update the active status recursively on `a_comp'.
local local
ln: CMS_LINK ln: CMS_LINK
l_comp_link: detachable CMS_LOCAL_LINK
do do
if attached {CMS_LOCAL_LINK} a_comp as lnk then
l_comp_link := lnk
end
if attached a_comp.items as l_items then if attached a_comp.items as l_items then
across across
l_items as ic l_items as ic
@@ -923,9 +926,17 @@ feature -- Generation
if (ln.is_expanded or ln.is_collapsed) and then attached {CMS_LINK_COMPOSITE} ln as l_comp then if (ln.is_expanded or ln.is_collapsed) and then attached {CMS_LINK_COMPOSITE} ln as l_comp then
recursive_get_active (l_comp, req) recursive_get_active (l_comp, req)
end end
if l_comp_link /= Void then
if ln.is_expanded or (not ln.is_expandable and ln.is_active) then
l_comp_link.set_expanded (True)
end end
end end
end end
end
if l_comp_link /= Void and then l_comp_link.is_active then
l_comp_link.set_expanded (True)
end
end
get_local_link_active_status (a_lnk: CMS_LOCAL_LINK) get_local_link_active_status (a_lnk: CMS_LOCAL_LINK)
-- Get `a_lnk.is_active' value according to `request' data. -- Get `a_lnk.is_active' value according to `request' data.

View File

@@ -1,7 +1,7 @@
note note
description: "Summary description for {HOME_CMS_RESPONSE}." description: "Summary description for {HOME_CMS_RESPONSE}."
date: "$Date$" date: "$Date: 2014-12-17 13:14:43 +0100 (mer., 17 déc. 2014) $"
revision: "$Revision$" revision: "$Revision: 96367 $"
class class
HOME_CMS_RESPONSE HOME_CMS_RESPONSE

View File

@@ -1,6 +1,6 @@
note note
description: "Summary description for {INTERNAL_SERVER_ERROR_CMS_RESPONSE}." description: "Summary description for {INTERNAL_SERVER_ERROR_CMS_RESPONSE}."
date: "$Date: 2014-12-19 10:17:32 -0300 (vi., 19 dic. 2014) $" date: "$Date: 2014-12-19 14:17:32 +0100 (ven., 19 déc. 2014) $"
revision: "$Revision: 96402 $" revision: "$Revision: 96402 $"
class class

View File

@@ -2,8 +2,8 @@ note
description: "[ description: "[
Abstract interface for a CMS Template, as part of the theme design. Abstract interface for a CMS Template, as part of the theme design.
]" ]"
date: "$Date$" date: "$Date: 2014-11-20 15:03:29 +0100 (jeu., 20 nov. 2014) $"
revision: "$Revision$" revision: "$Revision: 96138 $"
deferred class deferred class
CMS_TEMPLATE CMS_TEMPLATE

View File

@@ -9,6 +9,7 @@ class
MISSING_CMS_TEMPLATE MISSING_CMS_TEMPLATE
inherit inherit
CMS_TEMPLATE CMS_TEMPLATE
create create

View File

@@ -1,7 +1,7 @@
note note
description: "Summary description for {CMS_PAGE_TEMPLATE}." description: "Summary description for {CMS_PAGE_TEMPLATE}."
date: "$Date$" date: "$Date: 2015-01-14 16:13:47 +0100 (mer., 14 janv. 2015) $"
revision: "$Revision$" revision: "$Revision: 96454 $"
class class
SMARTY_CMS_PAGE_TEMPLATE SMARTY_CMS_PAGE_TEMPLATE
@@ -75,26 +75,29 @@ feature -- Access
debug ("smarty") debug ("smarty")
template_context.enable_verbose template_context.enable_verbose
end end
p := template_context.template_folder
if p = Void then
create p.make_current
end
if attached page.type as l_page_type then if attached page.type as l_page_type then
create n.make_from_string_general (l_page_type) create n.make_from_string_general (l_page_type)
n.append_character ('-') n.append_character ('-')
n.append_string_general (template_name) n.append_string_general (template_name)
n.append_string_general (".tpl") n.append_string_general (".tpl")
if ut.file_path_exists (p.extended (n)) then
p := template_context.template_file (n)
if ut.file_path_exists (p) then
create tpl.make_from_file (n) create tpl.make_from_file (n)
end end
end end
if tpl = Void then if tpl = Void then
create n.make_from_string_general (template_name) create n.make_from_string_general (template_name)
n.append_string_general (".tpl") n.append_string_general (".tpl")
if ut.file_path_exists (p.extended (n)) then
p := template_context.template_file (n)
if ut.file_path_exists (p) then
create tpl.make_from_file (n) create tpl.make_from_file (n)
end end
end end
if tpl /= Void then if tpl /= Void then
across across
variables as ic variables as ic

View File

@@ -1,7 +1,7 @@
note note
description: "Smarty template CMS theme." description: "Smarty template CMS theme."
date: "$Date$" date: "$Date: 2014-12-05 22:39:27 +0100 (ven., 05 déc. 2014) $"
revision: "$Revision$" revision: "$Revision: 96260 $"
class class
SMARTY_CMS_THEME SMARTY_CMS_THEME
@@ -101,7 +101,11 @@ feature -- Conversion
end end
end end
create l_table_inspector.register (({detachable STRING_TABLE [STRING]}).name) 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) page_template.prepare (page)
Result := page_template.to_html (page) Result := page_template.to_html (page)

View File

@@ -1,8 +1,8 @@
note note
description: "Summary description for {STRING_TABLE_OF_STRING_INSPECTOR}." description: "Summary description for {STRING_TABLE_OF_STRING_INSPECTOR}."
author: "" author: ""
date: "$Date: 2014-11-06 17:59:12 -0300 (ju. 06 de nov. de 2014) $" date: "$Date: 2014-12-05 22:39:27 +0100 (ven., 05 déc. 2014) $"
revision: "$Revision: 96040 $" revision: "$Revision: 96260 $"
class class
STRING_TABLE_OF_STRING_INSPECTOR STRING_TABLE_OF_STRING_INSPECTOR
@@ -23,13 +23,22 @@ feature {TEMPLATE_ROUTINES}
-- If not handled by this inspector, return Void -- If not handled by this inspector, return Void
local local
l_fn: STRING l_fn: STRING
utf: UTF_CONVERTER
do do
if attached {STRING_TABLE [STRING]} obj as l_regions then if attached {STRING_TABLE [detachable READABLE_STRING_GENERAL]} obj as l_regions then
l_fn := field_name.as_lower l_fn := field_name.as_lower
if l_fn.is_case_insensitive_equal ("count") then if l_fn.is_case_insensitive_equal ("count") then
Result := cell_of (l_regions.count) Result := cell_of (l_regions.count)
elseif attached l_regions.item (l_fn) as v then elseif attached l_regions.item (l_fn) as v then
Result := cell_of (v) 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 end
end end