Updated CMS_HOOK_BLOCK, to provide a better block_identifiers (CMS_RESPONSE): detachable ITERABLE [READABLE_STRING_8] query, to be implemented by CMS_HOOK_RESPONSE_BLOCK descendants.
Added CONFIG_READER.table_keys: detachable LIST [READABLE_STRING_32].
This commit is contained in:
@@ -25,6 +25,7 @@
|
|||||||
<library name="cms_basic_auth_module" location="..\..\modules\basic_auth\basic_auth-safe.ecf" readonly="false"/>
|
<library name="cms_basic_auth_module" location="..\..\modules\basic_auth\basic_auth-safe.ecf" readonly="false"/>
|
||||||
<library name="cms_blog_module" location="..\..\modules\blog\cms_blog_module-safe.ecf" readonly="false"/>
|
<library name="cms_blog_module" location="..\..\modules\blog\cms_blog_module-safe.ecf" readonly="false"/>
|
||||||
<library name="cms_contact_module" location="..\..\modules\contact\contact-safe.ecf" readonly="false"/>
|
<library name="cms_contact_module" location="..\..\modules\contact\contact-safe.ecf" readonly="false"/>
|
||||||
|
<library name="cms_custom_block_module" location="..\..\modules\custom_block\custom_block-safe.ecf" readonly="false"/>
|
||||||
<library name="cms_demo_module" location="modules\demo\cms_demo_module-safe.ecf" readonly="false"/>
|
<library name="cms_demo_module" location="modules\demo\cms_demo_module-safe.ecf" readonly="false"/>
|
||||||
<library name="cms_email_service" location="..\..\library\email\email-safe.ecf" readonly="false"/>
|
<library name="cms_email_service" location="..\..\library\email\email-safe.ecf" readonly="false"/>
|
||||||
<library name="cms_feed_aggregator_module" location="..\..\modules\feed_aggregator\feed_aggregator-safe.ecf" readonly="false"/>
|
<library name="cms_feed_aggregator_module" location="..\..\modules\feed_aggregator\feed_aggregator-safe.ecf" readonly="false"/>
|
||||||
|
|||||||
@@ -18,3 +18,4 @@ set ROC_CMS_DIR=%~dp0
|
|||||||
%ROC_CMD% install --module ..\..\modules\session_auth --dir %ROC_CMS_DIR%
|
%ROC_CMD% install --module ..\..\modules\session_auth --dir %ROC_CMS_DIR%
|
||||||
%ROC_CMD% install --module ..\..\modules\taxonomy --dir %ROC_CMS_DIR%
|
%ROC_CMD% install --module ..\..\modules\taxonomy --dir %ROC_CMS_DIR%
|
||||||
%ROC_CMD% install --module ..\..\modules\files --dir %ROC_CMS_DIR%
|
%ROC_CMD% install --module ..\..\modules\files --dir %ROC_CMS_DIR%
|
||||||
|
%ROC_CMD% install --module ..\..\modules\custom_block --dir %ROC_CMS_DIR%
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"blocks": {
|
||||||
|
"test": {
|
||||||
|
"title": "Custom block test",
|
||||||
|
"region": "footer",
|
||||||
|
"weight": 100,
|
||||||
|
"conditions": ["path:demo/*"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
<div>
|
||||||
|
This is a nice custom block test for site {$sitename/}.
|
||||||
|
</div>
|
||||||
@@ -77,6 +77,7 @@ feature -- CMS modules
|
|||||||
|
|
||||||
-- Miscellanious
|
-- Miscellanious
|
||||||
a_setup.register_module (create {GOOGLE_CUSTOM_SEARCH_MODULE}.make)
|
a_setup.register_module (create {GOOGLE_CUSTOM_SEARCH_MODULE}.make)
|
||||||
|
a_setup.register_module (create {CMS_CUSTOM_BLOCK_MODULE}.make)
|
||||||
a_setup.register_module (create {CMS_DEBUG_MODULE}.make)
|
a_setup.register_module (create {CMS_DEBUG_MODULE}.make)
|
||||||
a_setup.register_module (create {CMS_DEMO_MODULE}.make)
|
a_setup.register_module (create {CMS_DEMO_MODULE}.make)
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ feature -- Query
|
|||||||
end
|
end
|
||||||
|
|
||||||
resolved_text_list_item (k: READABLE_STRING_GENERAL): detachable LIST [READABLE_STRING_32]
|
resolved_text_list_item (k: READABLE_STRING_GENERAL): detachable LIST [READABLE_STRING_32]
|
||||||
-- List of String item associated with key `k',
|
-- List of String items associated with key `k',
|
||||||
-- and expanded values to resolved variables ${varname}.
|
-- and expanded values to resolved variables ${varname}.
|
||||||
do
|
do
|
||||||
if attached text_list_item (k) as lst then
|
if attached text_list_item (k) as lst then
|
||||||
@@ -50,7 +50,7 @@ feature -- Query
|
|||||||
end
|
end
|
||||||
|
|
||||||
resolved_text_table_item (k: READABLE_STRING_GENERAL): detachable STRING_TABLE [READABLE_STRING_32]
|
resolved_text_table_item (k: READABLE_STRING_GENERAL): detachable STRING_TABLE [READABLE_STRING_32]
|
||||||
-- Table of String item associated with key `k',
|
-- Table of String items associated with key `k',
|
||||||
-- and expanded values to resolved variables ${varname}.
|
-- and expanded values to resolved variables ${varname}.
|
||||||
do
|
do
|
||||||
if attached text_table_item (k) as tb then
|
if attached text_table_item (k) as tb then
|
||||||
@@ -71,12 +71,17 @@ feature -- Query
|
|||||||
end
|
end
|
||||||
|
|
||||||
text_list_item (k: READABLE_STRING_GENERAL): detachable LIST [READABLE_STRING_32]
|
text_list_item (k: READABLE_STRING_GENERAL): detachable LIST [READABLE_STRING_32]
|
||||||
-- List of String item associated with key `k'.
|
-- List of String items associated with key `k'.
|
||||||
deferred
|
deferred
|
||||||
end
|
end
|
||||||
|
|
||||||
text_table_item (k: READABLE_STRING_GENERAL): detachable STRING_TABLE [READABLE_STRING_32]
|
text_table_item (k: READABLE_STRING_GENERAL): detachable STRING_TABLE [READABLE_STRING_32]
|
||||||
-- Table of String item associated with key `k'.
|
-- Table of String items associated with key `k'.
|
||||||
|
deferred
|
||||||
|
end
|
||||||
|
|
||||||
|
table_keys (k: READABLE_STRING_GENERAL): detachable LIST [READABLE_STRING_32]
|
||||||
|
-- Keys of table associated with key `k'.
|
||||||
deferred
|
deferred
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -163,6 +163,20 @@ feature -- Access: Config Reader
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
table_keys (k: READABLE_STRING_GENERAL): detachable LIST [READABLE_STRING_32]
|
||||||
|
-- <Precursor>
|
||||||
|
do
|
||||||
|
if attached {STRING_TABLE [like item]} item (k) as l_list then
|
||||||
|
create {ARRAYED_LIST [READABLE_STRING_32]} Result.make (l_list.count)
|
||||||
|
Result.compare_objects
|
||||||
|
across
|
||||||
|
l_list as ic
|
||||||
|
loop
|
||||||
|
Result.force (ic.key.as_string_32)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
integer_item (k: READABLE_STRING_GENERAL): INTEGER
|
integer_item (k: READABLE_STRING_GENERAL): INTEGER
|
||||||
-- Integer item associated with key `k'.
|
-- Integer item associated with key `k'.
|
||||||
do
|
do
|
||||||
@@ -522,7 +536,7 @@ feature {NONE} -- Implementation
|
|||||||
invariant
|
invariant
|
||||||
|
|
||||||
note
|
note
|
||||||
copyright: "2011-2015, Jocelyn Fiat, Eiffel Software and others"
|
copyright: "2011-2016, 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)"
|
||||||
source: "[
|
source: "[
|
||||||
Eiffel Software
|
Eiffel Software
|
||||||
|
|||||||
@@ -106,6 +106,20 @@ feature -- Access: Config Reader
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
table_keys (k: READABLE_STRING_GENERAL): detachable LIST [READABLE_STRING_32]
|
||||||
|
-- <Precursor>
|
||||||
|
do
|
||||||
|
if attached {JSON_OBJECT} item (k) as obj then
|
||||||
|
create {ARRAYED_LIST [READABLE_STRING_32]} Result.make (obj.count)
|
||||||
|
Result.compare_objects
|
||||||
|
across
|
||||||
|
obj as ic
|
||||||
|
loop
|
||||||
|
Result.force (ic.key.item)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
integer_item (k: READABLE_STRING_GENERAL): INTEGER
|
integer_item (k: READABLE_STRING_GENERAL): INTEGER
|
||||||
-- Integer item associated with key `k'.
|
-- Integer item associated with key `k'.
|
||||||
do
|
do
|
||||||
|
|||||||
@@ -85,6 +85,14 @@ feature -- Test
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
assert ("keys of (table)", attached cfg.table_keys ("table") as tb and then (
|
||||||
|
tb.i_th (1) ~ {STRING_32} "a" and
|
||||||
|
tb.i_th (2) ~ {STRING_32} "b" and
|
||||||
|
tb.i_th (3) ~ {STRING_32} "c" and
|
||||||
|
tb.i_th (4) ~ {STRING_32} "d"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
if attached cfg.sub_config ("second") as cfg_second then
|
if attached cfg.sub_config ("second") as cfg_second then
|
||||||
assert ("has_item (is)", cfg_second.has_item ("is"))
|
assert ("has_item (is)", cfg_second.has_item ("is"))
|
||||||
assert ("item (is)", attached cfg_second.text_item ("is") as v and then v.same_string_general ("2"))
|
assert ("item (is)", attached cfg_second.text_item ("is") as v and then v.same_string_general ("2"))
|
||||||
@@ -208,6 +216,14 @@ feature -- Test
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
assert ("keys of (table)", attached cfg.table_keys ("table") as tb and then (
|
||||||
|
tb.i_th (1) ~ {STRING_32} "a" and
|
||||||
|
tb.i_th (2) ~ {STRING_32} "b" and
|
||||||
|
tb.i_th (3) ~ {STRING_32} "c" and
|
||||||
|
tb.i_th (4) ~ {STRING_32} "d"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
if attached cfg.sub_config ("second") as cfg_second then
|
if attached cfg.sub_config ("second") as cfg_second then
|
||||||
assert ("has_item (is)", cfg_second.has_item ("is"))
|
assert ("has_item (is)", cfg_second.has_item ("is"))
|
||||||
assert ("item (is)", attached cfg_second.text_item ("is") as v and then v.same_string_general ("2"))
|
assert ("item (is)", attached cfg_second.text_item ("is") as v and then v.same_string_general ("2"))
|
||||||
|
|||||||
165
modules/custom_block/cms_custom_block_module.e
Normal file
165
modules/custom_block/cms_custom_block_module.e
Normal file
@@ -0,0 +1,165 @@
|
|||||||
|
note
|
||||||
|
description: "[
|
||||||
|
Module that provide custom block factory.
|
||||||
|
]"
|
||||||
|
author: "$Author: jfiat $"
|
||||||
|
date: "$Date: 2016-01-08 22:43:12 +0100 (ven., 08 janv. 2016) $"
|
||||||
|
revision: "$Revision: 98369 $"
|
||||||
|
|
||||||
|
class
|
||||||
|
CMS_CUSTOM_BLOCK_MODULE
|
||||||
|
|
||||||
|
inherit
|
||||||
|
CMS_MODULE
|
||||||
|
rename
|
||||||
|
module_api as custom_block_api
|
||||||
|
redefine
|
||||||
|
initialize,
|
||||||
|
setup_hooks,
|
||||||
|
custom_block_api
|
||||||
|
end
|
||||||
|
|
||||||
|
CMS_HOOK_RESPONSE_BLOCK
|
||||||
|
|
||||||
|
CMS_HOOK_BLOCK_HELPER
|
||||||
|
|
||||||
|
CMS_HOOK_AUTO_REGISTER
|
||||||
|
|
||||||
|
SHARED_EXECUTION_ENVIRONMENT
|
||||||
|
export
|
||||||
|
{NONE} all
|
||||||
|
end
|
||||||
|
|
||||||
|
REFACTORING_HELPER
|
||||||
|
|
||||||
|
create
|
||||||
|
make
|
||||||
|
|
||||||
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
|
make
|
||||||
|
-- Create current module
|
||||||
|
do
|
||||||
|
version := "1.0"
|
||||||
|
description := "Custom Block"
|
||||||
|
package := "layout"
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Access
|
||||||
|
|
||||||
|
name: STRING = "custom_block"
|
||||||
|
-- <Precursor>
|
||||||
|
|
||||||
|
feature {CMS_API} -- Module Initialization
|
||||||
|
|
||||||
|
initialize (api: CMS_API)
|
||||||
|
-- Initialize Current module with `api'.
|
||||||
|
do
|
||||||
|
create custom_block_api.make (api)
|
||||||
|
Precursor (api)
|
||||||
|
end
|
||||||
|
|
||||||
|
custom_block_api: detachable CMS_MODULE_API
|
||||||
|
-- <Precursor>.
|
||||||
|
|
||||||
|
feature -- Router
|
||||||
|
|
||||||
|
setup_router (a_router: WSF_ROUTER; a_api: CMS_API)
|
||||||
|
-- Router configuration.
|
||||||
|
do
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Hooks configuration
|
||||||
|
|
||||||
|
setup_hooks (a_hooks: CMS_HOOK_CORE_MANAGER)
|
||||||
|
-- Module hooks configuration.
|
||||||
|
do
|
||||||
|
auto_subscribe_to_hooks (a_hooks)
|
||||||
|
a_hooks.subscribe_to_block_hook (Current)
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Hooks
|
||||||
|
|
||||||
|
block_identifiers (a_response: detachable CMS_RESPONSE): detachable ARRAYED_LIST [READABLE_STRING_8]
|
||||||
|
-- <Precursor>
|
||||||
|
local
|
||||||
|
api: CMS_API
|
||||||
|
l_name: READABLE_STRING_32
|
||||||
|
l_block_id: READABLE_STRING_8
|
||||||
|
l_conds: detachable ARRAYED_LIST [CMS_BLOCK_CONDITION]
|
||||||
|
do
|
||||||
|
if attached custom_block_api as l_mod_api then
|
||||||
|
api := l_mod_api.cms_api
|
||||||
|
if
|
||||||
|
attached api.module_configuration (Current, name) as cfg and then
|
||||||
|
attached cfg.table_keys ("blocks") as lst
|
||||||
|
then
|
||||||
|
create Result.make (0)
|
||||||
|
across
|
||||||
|
lst as ic
|
||||||
|
loop
|
||||||
|
l_name := ic.item
|
||||||
|
if l_name.is_valid_as_string_8 then
|
||||||
|
l_block_id := l_name.to_string_8
|
||||||
|
if a_response /= Void then
|
||||||
|
if attached cfg.text_list_item ("blocks." + l_block_id + ".conditions") as l_cond_expressions then
|
||||||
|
if l_conds = Void then
|
||||||
|
create l_conds.make (l_cond_expressions.count)
|
||||||
|
end
|
||||||
|
across
|
||||||
|
l_cond_expressions as exp_ic
|
||||||
|
loop
|
||||||
|
l_conds.force (create {CMS_BLOCK_EXPRESSION_CONDITION}.make (exp_ic.item))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if l_conds = Void or else l_conds.is_empty then
|
||||||
|
Result.force ("?" + l_block_id)
|
||||||
|
elseif are_conditions_satisfied (l_conds, a_response) then
|
||||||
|
Result.force (l_block_id)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
Result.force ("?" + l_block_id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
are_conditions_satisfied (a_conditions: LIST [CMS_BLOCK_CONDITION]; a_response: CMS_RESPONSE): BOOLEAN
|
||||||
|
-- Are `a_conditions' satisfied for `a_response'?
|
||||||
|
do
|
||||||
|
Result := across a_conditions as ic some ic.item.satisfied_for_response (a_response) end
|
||||||
|
end
|
||||||
|
|
||||||
|
get_block_view (a_block_id: READABLE_STRING_8; a_response: CMS_RESPONSE)
|
||||||
|
local
|
||||||
|
l_region: detachable READABLE_STRING_8
|
||||||
|
l_cond: CMS_BLOCK_EXPRESSION_CONDITION
|
||||||
|
do
|
||||||
|
if attached smarty_template_block (Current, a_block_id, a_response.api) as bk then
|
||||||
|
if attached a_response.api.module_configuration (Current, name) as cfg then
|
||||||
|
if
|
||||||
|
attached cfg.text_item ("blocks." + a_block_id + ".region") as s and then
|
||||||
|
s.is_valid_as_string_8
|
||||||
|
then
|
||||||
|
l_region := s.to_string_8
|
||||||
|
end
|
||||||
|
bk.set_weight (cfg.integer_item ("blocks." + a_block_id + ".weight"))
|
||||||
|
bk.set_title (cfg.text_item ("blocks." + a_block_id + ".title"))
|
||||||
|
if attached cfg.text_list_item ("blocks." + a_block_id + ".conditions") as l_cond_exp_list then
|
||||||
|
across
|
||||||
|
l_cond_exp_list as ic
|
||||||
|
loop
|
||||||
|
create l_cond.make (ic.item)
|
||||||
|
bk.add_condition (l_cond)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
a_response.add_block (bk, l_region)
|
||||||
|
else
|
||||||
|
a_response.add_debug_message ("Missing template for custom block %"" + a_block_id + "%"!")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
21
modules/custom_block/custom_block-safe.ecf
Normal file
21
modules/custom_block/custom_block-safe.ecf
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||||
|
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-15-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-15-0 http://www.eiffel.com/developers/xml/configuration-1-15-0.xsd" name="custom_block_module" uuid="F9B7C390-04F2-4E59-9040-00DD68A5BDBC" library_target="custom_block_module">
|
||||||
|
<target name="custom_block_module">
|
||||||
|
<root all_classes="true" />
|
||||||
|
<file_rule>
|
||||||
|
<exclude>/.svn$</exclude>
|
||||||
|
<exclude>/CVS$</exclude>
|
||||||
|
<exclude>/EIFGENs$</exclude>
|
||||||
|
</file_rule>
|
||||||
|
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all" syntax="standard"/>
|
||||||
|
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||||
|
<library name="cms" location="..\..\cms-safe.ecf"/>
|
||||||
|
<library name="cms_model" location="..\..\library\model\cms_model-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"/>
|
||||||
|
<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_encoder" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\text\encoder\encoder-safe.ecf"/>
|
||||||
|
<cluster name="src" location=".\" recursive="true"/>
|
||||||
|
</target>
|
||||||
|
</system>
|
||||||
22
modules/custom_block/custom_block.ecf
Normal file
22
modules/custom_block/custom_block.ecf
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||||
|
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-15-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-15-0 http://www.eiffel.com/developers/xml/configuration-1-15-0.xsd" name="custom_block_module" uuid="F9B7C390-04F2-4E59-9040-00DD68A5BDBC" library_target="custom_block_module">
|
||||||
|
<target name="custom_block_module">
|
||||||
|
<root all_classes="true"/>
|
||||||
|
<file_rule>
|
||||||
|
<exclude>/.svn$</exclude>
|
||||||
|
<exclude>/CVS$</exclude>
|
||||||
|
<exclude>/EIFGENs$</exclude>
|
||||||
|
</file_rule>
|
||||||
|
<option warning="true" full_class_checking="true" void_safety="none" syntax="standard">
|
||||||
|
</option>
|
||||||
|
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
|
||||||
|
<library name="cms" location="..\..\cms.ecf"/>
|
||||||
|
<library name="cms_model" location="..\..\library\model\cms_model.ecf"/>
|
||||||
|
<library name="http" location="$ISE_LIBRARY\contrib\library\network\protocol\http\http.ecf"/>
|
||||||
|
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json.ecf"/>
|
||||||
|
<library name="time" location="$ISE_LIBRARY\library\time\time.ecf"/>
|
||||||
|
<library name="wsf" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf.ecf"/>
|
||||||
|
<library name="wsf_encoder" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\text\encoder\encoder.ecf"/>
|
||||||
|
<cluster name="src" location=".\" recursive="true"/>
|
||||||
|
</target>
|
||||||
|
</system>
|
||||||
10
modules/custom_block/site/config/custom_block.json.example
Normal file
10
modules/custom_block/site/config/custom_block.json.example
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"blocks": {
|
||||||
|
"test": {
|
||||||
|
"title": "Custom block test",
|
||||||
|
"region": "footer",
|
||||||
|
"weight": 100,
|
||||||
|
"conditions": ["path:demo/*"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
<div>
|
||||||
|
This is a nice custom block test for site {$sitename/}.
|
||||||
|
</div>
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
note
|
note
|
||||||
description: "[
|
description: "[
|
||||||
Hook providing a way to alter a block.
|
Hook providing a way to provide blocks.
|
||||||
]"
|
]"
|
||||||
date: "$Date: 2014-11-19 20:00:19 +0100 (mer., 19 nov. 2014) $"
|
date: "$Date: 2014-11-19 20:00:19 +0100 (mer., 19 nov. 2014) $"
|
||||||
revision: "$Revision: 96123 $"
|
revision: "$Revision: 96123 $"
|
||||||
@@ -13,13 +13,21 @@ inherit
|
|||||||
|
|
||||||
feature -- Hook
|
feature -- Hook
|
||||||
|
|
||||||
block_list: ITERABLE [like {CMS_BLOCK}.name]
|
block_list: detachable ITERABLE [like {CMS_BLOCK}.name]
|
||||||
-- List of block names, managed by current object.
|
-- List of block names, managed by current object.
|
||||||
-- If prefixed by "?", condition will be check
|
-- If prefixed by "?", condition will be checked
|
||||||
-- to determine if it should be displayed (and computed) or not.
|
-- to determine if it should be displayed (and computed) or not.
|
||||||
deferred
|
deferred
|
||||||
end
|
end
|
||||||
|
|
||||||
|
block_identifiers (a_response: detachable CMS_RESPONSE): detachable ITERABLE [like {CMS_BLOCK}.name]
|
||||||
|
-- List of block names, managed by current object, in the context of `a_response' if set.
|
||||||
|
-- If prefixed by "?", condition will be checked
|
||||||
|
-- to determine if it should be displayed (and computed) or not.
|
||||||
|
do
|
||||||
|
Result := block_list
|
||||||
|
end
|
||||||
|
|
||||||
get_block_view (a_block_id: READABLE_STRING_8; a_response: CMS_RESPONSE)
|
get_block_view (a_block_id: READABLE_STRING_8; a_response: CMS_RESPONSE)
|
||||||
-- Get block object identified by `a_block_id' and associate with `a_response'.
|
-- Get block object identified by `a_block_id' and associate with `a_response'.
|
||||||
deferred
|
deferred
|
||||||
|
|||||||
@@ -150,9 +150,12 @@ feature -- Hook: block
|
|||||||
across
|
across
|
||||||
lst as c
|
lst as c
|
||||||
loop
|
loop
|
||||||
if attached {CMS_HOOK_BLOCK} c.item as h then
|
if
|
||||||
|
attached {CMS_HOOK_BLOCK} c.item as h and then
|
||||||
|
attached h.block_identifiers (a_response) as l_names
|
||||||
|
then
|
||||||
across
|
across
|
||||||
h.block_list as blst
|
l_names as blst
|
||||||
loop
|
loop
|
||||||
bl := blst.item
|
bl := blst.item
|
||||||
bl_optional := bl.count > 0 and bl[1] = '?'
|
bl_optional := bl.count > 0 and bl[1] = '?'
|
||||||
@@ -252,6 +255,6 @@ feature -- Hook: export
|
|||||||
end
|
end
|
||||||
|
|
||||||
note
|
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)"
|
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||||
end
|
end
|
||||||
|
|||||||
45
src/hooks/cms_hook_response_block.e
Normal file
45
src/hooks/cms_hook_response_block.e
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
note
|
||||||
|
description: "[
|
||||||
|
Hook providing a way to provide blocks,
|
||||||
|
within the context of a response.
|
||||||
|
]"
|
||||||
|
date: "$Date$"
|
||||||
|
revision: "$Revision$"
|
||||||
|
|
||||||
|
deferred class
|
||||||
|
CMS_HOOK_RESPONSE_BLOCK
|
||||||
|
|
||||||
|
inherit
|
||||||
|
CMS_HOOK_BLOCK
|
||||||
|
rename
|
||||||
|
block_identifiers as old_block_identifiers
|
||||||
|
redefine
|
||||||
|
old_block_identifiers
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Hook
|
||||||
|
|
||||||
|
frozen block_list: detachable ITERABLE [like {CMS_BLOCK}.name]
|
||||||
|
-- List of block names, managed by current object.
|
||||||
|
-- If prefixed by "?", condition will be checked
|
||||||
|
-- to determine if it should be displayed (and computed) or not.
|
||||||
|
do
|
||||||
|
Result := block_identifiers (Void)
|
||||||
|
end
|
||||||
|
|
||||||
|
frozen old_block_identifiers (a_response: detachable CMS_RESPONSE): detachable ITERABLE [like {CMS_BLOCK}.name]
|
||||||
|
do
|
||||||
|
Result := block_identifiers (a_response)
|
||||||
|
end
|
||||||
|
|
||||||
|
block_identifiers (a_response: detachable CMS_RESPONSE): detachable ITERABLE [like {CMS_BLOCK}.name]
|
||||||
|
-- List of block names, managed by current object, in the context of `a_response' if set.
|
||||||
|
-- If prefixed by "?", condition will be checked
|
||||||
|
-- to determine if it should be displayed (and computed) or not.
|
||||||
|
deferred
|
||||||
|
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
|
||||||
@@ -15,7 +15,7 @@ create
|
|||||||
|
|
||||||
feature {NONE} -- Initialization
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
make (a_exp: READABLE_STRING_8)
|
make (a_exp: READABLE_STRING_GENERAL)
|
||||||
do
|
do
|
||||||
expression := a_exp
|
expression := a_exp
|
||||||
end
|
end
|
||||||
@@ -30,18 +30,18 @@ feature -- Access
|
|||||||
description: STRING_32
|
description: STRING_32
|
||||||
do
|
do
|
||||||
create Result.make_from_string_general ("Expression: %"")
|
create Result.make_from_string_general ("Expression: %"")
|
||||||
Result.append_string_general (expression)
|
Result.append_string_general (expression.as_string_32)
|
||||||
Result.append_character ('%"')
|
Result.append_character ('%"')
|
||||||
end
|
end
|
||||||
|
|
||||||
expression: STRING
|
expression: READABLE_STRING_GENERAL
|
||||||
|
|
||||||
feature -- Evaluation
|
feature -- Evaluation
|
||||||
|
|
||||||
satisfied_for_response (res: CMS_RESPONSE): BOOLEAN
|
satisfied_for_response (res: CMS_RESPONSE): BOOLEAN
|
||||||
local
|
local
|
||||||
exp: like expression
|
exp: like expression
|
||||||
l_path: READABLE_STRING_8
|
l_path: READABLE_STRING_GENERAL
|
||||||
kmp: KMP_WILD
|
kmp: KMP_WILD
|
||||||
do
|
do
|
||||||
exp := expression
|
exp := expression
|
||||||
@@ -61,12 +61,12 @@ feature -- Evaluation
|
|||||||
Result := kmp.pattern_matches
|
Result := kmp.pattern_matches
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
Result := res.location.same_string (l_path)
|
Result := l_path.same_string (res.location)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
note
|
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)"
|
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -994,7 +994,7 @@ feature -- Message
|
|||||||
|
|
||||||
add_debug_message (a_msg: READABLE_STRING_8)
|
add_debug_message (a_msg: READABLE_STRING_8)
|
||||||
do
|
do
|
||||||
if api.is_debug_enabled then
|
if api.is_debug then
|
||||||
add_message (a_msg, "debug")
|
add_message (a_msg, "debug")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user