Improved block condition "path:..." by allowing wildchar.
Added weight data to CMS_BLOCK to be able to sort the block lists,
and thus order the display of blocks.
Set negative weight for various core block, so that they appear first as expected.
The weight can be set and overwritten in cms.ini , by pref blocks.{block_id}.weight=integer_weight.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||||
<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-14-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-14-0 http://www.eiffel.com/developers/xml/configuration-1-14-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"/>
|
||||||
<file_rule>
|
<file_rule>
|
||||||
@@ -14,14 +14,16 @@
|
|||||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||||
<library name="base_extension" location="$ISE_LIBRARY\library\base_extension\base_extension-safe.ecf"/>
|
<library name="base_extension" location="$ISE_LIBRARY\library\base_extension\base_extension-safe.ecf"/>
|
||||||
<library name="cms_app_env" location=".\library\app_env\app_env-safe.ecf"/>
|
<library name="cms_app_env" location=".\library\app_env\app_env-safe.ecf"/>
|
||||||
<library name="cms_model" location=".\library\model\cms_model-safe.ecf" readonly="false"/>
|
|
||||||
<library name="cms_config" location=".\library\configuration\config-safe.ecf"/>
|
<library name="cms_config" location=".\library\configuration\config-safe.ecf"/>
|
||||||
|
<library name="cms_model" location=".\library\model\cms_model-safe.ecf" readonly="false"/>
|
||||||
<library name="crypto" location="$ISE_LIBRARY\unstable\library\text\encryption\crypto\crypto-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="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="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" location="$ISE_LIBRARY\contrib\library\network\protocol\http\http-safe.ecf"/>
|
||||||
<library name="i18n" location="$ISE_LIBRARY\library\i18n\i18n-safe.ecf"/>
|
<library name="i18n" location="$ISE_LIBRARY\library\i18n\i18n-safe.ecf"/>
|
||||||
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json-safe.ecf" readonly="false"/>
|
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json-safe.ecf" readonly="false"/>
|
||||||
|
<library name="kmp_matcher" location="$ISE_LIBRARY\library\text\regexp\kmp_matcher\kmp_matcher-safe.ecf"/>
|
||||||
|
<library name="net" location="$ISE_LIBRARY\library\net\net-safe.ecf"/>
|
||||||
<library name="notification_mailer" location="$ISE_LIBRARY\contrib\library\runtime\process\notification_email\notification_email-safe.ecf"/>
|
<library name="notification_mailer" location="$ISE_LIBRARY\contrib\library\runtime\process\notification_email\notification_email-safe.ecf"/>
|
||||||
<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="text_filter" location="$ISE_LIBRARY\unstable\library\text\text_filter\text_filter-safe.ecf"/>
|
||||||
@@ -30,7 +32,6 @@
|
|||||||
<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="net" location="$ISE_LIBRARY\library\net\net-safe.ecf"/>
|
|
||||||
<cluster name="src" location=".\src\" recursive="true"/>
|
<cluster name="src" location=".\src\" recursive="true"/>
|
||||||
</target>
|
</target>
|
||||||
</system>
|
</system>
|
||||||
|
|||||||
5
cms.ecf
5
cms.ecf
@@ -15,14 +15,16 @@
|
|||||||
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
|
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
|
||||||
<library name="base_extension" location="$ISE_LIBRARY\library\base_extension\base_extension.ecf"/>
|
<library name="base_extension" location="$ISE_LIBRARY\library\base_extension\base_extension.ecf"/>
|
||||||
<library name="cms_app_env" location=".\library\app_env\app_env.ecf"/>
|
<library name="cms_app_env" location=".\library\app_env\app_env.ecf"/>
|
||||||
<library name="cms_model" location=".\library\model\cms_model.ecf" readonly="false"/>
|
|
||||||
<library name="cms_config" location=".\library\configuration\config.ecf"/>
|
<library name="cms_config" location=".\library\configuration\config.ecf"/>
|
||||||
|
<library name="cms_model" location=".\library\model\cms_model.ecf" readonly="false"/>
|
||||||
<library name="crypto" location="$ISE_LIBRARY\unstable\library\text\encryption\crypto\crypto.ecf"/>
|
<library name="crypto" location="$ISE_LIBRARY\unstable\library\text\encryption\crypto\crypto.ecf"/>
|
||||||
<library name="encoder" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\text\encoder\encoder.ecf" readonly="false"/>
|
<library name="encoder" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\text\encoder\encoder.ecf" readonly="false"/>
|
||||||
<library name="error" location="$ISE_LIBRARY\contrib\library\utility\general\error\error.ecf"/>
|
<library name="error" location="$ISE_LIBRARY\contrib\library\utility\general\error\error.ecf"/>
|
||||||
<library name="http" location="$ISE_LIBRARY\contrib\library\network\protocol\http\http.ecf"/>
|
<library name="http" location="$ISE_LIBRARY\contrib\library\network\protocol\http\http.ecf"/>
|
||||||
<library name="i18n" location="$ISE_LIBRARY\library\i18n\i18n.ecf"/>
|
<library name="i18n" location="$ISE_LIBRARY\library\i18n\i18n.ecf"/>
|
||||||
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json.ecf" readonly="false"/>
|
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json.ecf" readonly="false"/>
|
||||||
|
<library name="kmp_matcher" location="$ISE_LIBRARY\library\text\regexp\kmp_matcher\kmp_matcher.ecf"/>
|
||||||
|
<library name="net" location="$ISE_LIBRARY\library\net\net.ecf"/>
|
||||||
<library name="notification_mailer" location="$ISE_LIBRARY\contrib\library\runtime\process\notification_email\notification_email.ecf"/>
|
<library name="notification_mailer" location="$ISE_LIBRARY\contrib\library\runtime\process\notification_email\notification_email.ecf"/>
|
||||||
<library name="smarty" location="$ISE_LIBRARY\contrib\library\text\template\smarty\smarty.ecf" readonly="false"/>
|
<library name="smarty" location="$ISE_LIBRARY\contrib\library\text\template\smarty\smarty.ecf" readonly="false"/>
|
||||||
<library name="text_filter" location="$ISE_LIBRARY\unstable\library\text\text_filter\text_filter.ecf"/>
|
<library name="text_filter" location="$ISE_LIBRARY\unstable\library\text\text_filter\text_filter.ecf"/>
|
||||||
@@ -31,7 +33,6 @@
|
|||||||
<library name="wsf" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf.ecf"/>
|
<library name="wsf" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf.ecf"/>
|
||||||
<library name="wsf_extension" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf_extension.ecf" readonly="false"/>
|
<library name="wsf_extension" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf_extension.ecf" readonly="false"/>
|
||||||
<library name="wsf_html" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf_html\wsf_html.ecf" readonly="false"/>
|
<library name="wsf_html" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf_html\wsf_html.ecf" readonly="false"/>
|
||||||
<library name="net" location="$ISE_LIBRARY\library\net\net.ecf"/>
|
|
||||||
<cluster name="src" location=".\src\" recursive="true"/>
|
<cluster name="src" location=".\src\" recursive="true"/>
|
||||||
</target>
|
</target>
|
||||||
</system>
|
</system>
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ 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
|
||||||
|
kmp: KMP_WILD
|
||||||
do
|
do
|
||||||
exp := expression
|
exp := expression
|
||||||
if exp.same_string ("is_front") then
|
if exp.same_string ("is_front") then
|
||||||
@@ -50,7 +52,17 @@ feature -- Evaluation
|
|||||||
elseif exp.same_string ("<none>") then
|
elseif exp.same_string ("<none>") then
|
||||||
Result := False
|
Result := False
|
||||||
elseif exp.starts_with ("path:") then
|
elseif exp.starts_with ("path:") then
|
||||||
Result := res.location.same_string (exp.substring (6, exp.count))
|
l_path := exp.substring (6, exp.count)
|
||||||
|
if l_path.has ('*') then
|
||||||
|
if l_path.index_of ('*', 1) = l_path.count then
|
||||||
|
Result := res.location.starts_with_general (l_path.substring (1, l_path.count - 1))
|
||||||
|
else
|
||||||
|
create kmp.make (l_path, res.location)
|
||||||
|
Result := kmp.pattern_matches
|
||||||
|
end
|
||||||
|
else
|
||||||
|
Result := res.location.same_string (l_path)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,12 @@ deferred class
|
|||||||
CMS_BLOCK
|
CMS_BLOCK
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
|
COMPARABLE
|
||||||
|
|
||||||
DEBUG_OUTPUT
|
DEBUG_OUTPUT
|
||||||
|
undefine
|
||||||
|
is_equal
|
||||||
|
end
|
||||||
|
|
||||||
feature -- Access
|
feature -- Access
|
||||||
|
|
||||||
@@ -23,6 +28,10 @@ feature -- Access
|
|||||||
html_options: detachable CMS_HTML_OPTIONS
|
html_options: detachable CMS_HTML_OPTIONS
|
||||||
-- Optional addition html options.
|
-- Optional addition html options.
|
||||||
|
|
||||||
|
weight: INTEGER
|
||||||
|
-- Weight used to order blocks.
|
||||||
|
-- Default: 0;
|
||||||
|
|
||||||
feature -- Status report
|
feature -- Status report
|
||||||
|
|
||||||
is_empty: BOOLEAN
|
is_empty: BOOLEAN
|
||||||
@@ -42,6 +51,14 @@ feature -- Status report
|
|||||||
conditions: detachable LIST [CMS_BLOCK_CONDITION]
|
conditions: detachable LIST [CMS_BLOCK_CONDITION]
|
||||||
-- Optional block condition to be enabled.
|
-- Optional block condition to be enabled.
|
||||||
|
|
||||||
|
feature -- Comparison
|
||||||
|
|
||||||
|
is_less alias "<" (other: like Current): BOOLEAN
|
||||||
|
-- <Precursor>.
|
||||||
|
do
|
||||||
|
Result := weight < other.weight
|
||||||
|
end
|
||||||
|
|
||||||
feature -- Element change
|
feature -- Element change
|
||||||
|
|
||||||
add_css_class (a_class: READABLE_STRING_8)
|
add_css_class (a_class: READABLE_STRING_8)
|
||||||
@@ -83,6 +100,12 @@ feature -- Element change
|
|||||||
l_conditions.force (a_condition)
|
l_conditions.force (a_condition)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
set_weight (w: like weight)
|
||||||
|
-- Set `weight' to `w'.
|
||||||
|
do
|
||||||
|
weight := w
|
||||||
|
end
|
||||||
|
|
||||||
feature -- Conversion
|
feature -- Conversion
|
||||||
|
|
||||||
to_html (a_theme: CMS_THEME): STRING_8
|
to_html (a_theme: CMS_THEME): STRING_8
|
||||||
|
|||||||
@@ -41,6 +41,16 @@ feature -- Element change
|
|||||||
blocks.prune_all (b)
|
blocks.prune_all (b)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
feature -- Sort
|
||||||
|
|
||||||
|
sort
|
||||||
|
local
|
||||||
|
cmp: QUICK_SORTER [CMS_BLOCK]
|
||||||
|
do
|
||||||
|
create cmp.make (create {COMPARABLE_COMPARATOR [CMS_BLOCK]})
|
||||||
|
cmp.sort (blocks)
|
||||||
|
end
|
||||||
|
|
||||||
note
|
note
|
||||||
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
copyright: "2011-2015, 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)"
|
||||||
|
|||||||
@@ -15,9 +15,12 @@ inherit
|
|||||||
select
|
select
|
||||||
out
|
out
|
||||||
end
|
end
|
||||||
|
|
||||||
SHARED_TEMPLATE_CONTEXT
|
SHARED_TEMPLATE_CONTEXT
|
||||||
rename
|
rename
|
||||||
out as tpl_out
|
out as tpl_out
|
||||||
|
undefine
|
||||||
|
is_equal
|
||||||
end
|
end
|
||||||
|
|
||||||
create
|
create
|
||||||
|
|||||||
@@ -425,6 +425,17 @@ feature -- Blocks initialization
|
|||||||
|
|
||||||
feature -- Block management
|
feature -- Block management
|
||||||
|
|
||||||
|
update_block (a_block: CMS_BLOCK)
|
||||||
|
-- Update parameters for block `a_block' according to configuration.
|
||||||
|
do
|
||||||
|
if
|
||||||
|
attached setup.text_item ("blocks." + a_block.name + ".weight") as w and then
|
||||||
|
w.is_integer
|
||||||
|
then
|
||||||
|
a_block.set_weight (w.to_integer)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
block_conditions (a_block_id: READABLE_STRING_8): detachable ARRAYED_LIST [CMS_BLOCK_EXPRESSION_CONDITION]
|
block_conditions (a_block_id: READABLE_STRING_8): detachable ARRAYED_LIST [CMS_BLOCK_EXPRESSION_CONDITION]
|
||||||
-- Condition associated with `a_block_id' in configuration, if any.
|
-- Condition associated with `a_block_id' in configuration, if any.
|
||||||
do
|
do
|
||||||
@@ -567,6 +578,9 @@ feature -- Blocks
|
|||||||
end
|
end
|
||||||
|
|
||||||
get_blocks
|
get_blocks
|
||||||
|
-- Get block from CMS core, and from modules.
|
||||||
|
local
|
||||||
|
l_region: CMS_BLOCK_REGION
|
||||||
do
|
do
|
||||||
debug ("refactor_fixme")
|
debug ("refactor_fixme")
|
||||||
fixme ("find a way to have this in configuration or database, and allow different order")
|
fixme ("find a way to have this in configuration or database, and allow different order")
|
||||||
@@ -592,6 +606,19 @@ feature -- Blocks
|
|||||||
end
|
end
|
||||||
|
|
||||||
hooks.invoke_block (Current)
|
hooks.invoke_block (Current)
|
||||||
|
|
||||||
|
across
|
||||||
|
regions as reg_ic
|
||||||
|
loop
|
||||||
|
l_region := reg_ic.item
|
||||||
|
across
|
||||||
|
l_region.blocks as ic
|
||||||
|
loop
|
||||||
|
update_block (ic.item)
|
||||||
|
end
|
||||||
|
l_region.sort
|
||||||
|
end
|
||||||
|
|
||||||
debug ("cms")
|
debug ("cms")
|
||||||
put_block (create {CMS_CONTENT_BLOCK}.make ("made_with", Void, "Made with <a href=%"https://www.eiffel.org/%">EWF</a>", Void), "footer", True)
|
put_block (create {CMS_CONTENT_BLOCK}.make ("made_with", Void, "Made with <a href=%"https://www.eiffel.org/%">EWF</a>", Void), "footer", True)
|
||||||
end
|
end
|
||||||
@@ -641,6 +668,7 @@ feature -- Blocks
|
|||||||
do
|
do
|
||||||
create s.make_empty
|
create s.make_empty
|
||||||
create Result.make ("page_top", Void, s, Void)
|
create Result.make ("page_top", Void, s, Void)
|
||||||
|
Result.set_weight (-5)
|
||||||
Result.set_is_raw (True)
|
Result.set_is_raw (True)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -652,6 +680,7 @@ feature -- Blocks
|
|||||||
create s.make_from_string (theme.menu_html (primary_menu, True, Void))
|
create s.make_from_string (theme.menu_html (primary_menu, True, Void))
|
||||||
create l_hb.make_empty
|
create l_hb.make_empty
|
||||||
create Result.make ("header", Void, l_hb, Void)
|
create Result.make ("header", Void, l_hb, Void)
|
||||||
|
Result.set_weight (-4)
|
||||||
Result.set_is_raw (True)
|
Result.set_is_raw (True)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -683,6 +712,7 @@ feature -- Blocks
|
|||||||
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>", Void)
|
create Result.make ("message", Void, "<div id=%"message%">" + m + "</div>", Void)
|
||||||
Result.set_is_raw (True)
|
Result.set_is_raw (True)
|
||||||
|
Result.set_weight (-2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -699,6 +729,7 @@ feature -- Blocks
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
create Result.make ("content", Void, s, Void)
|
create Result.make ("content", Void, s, Void)
|
||||||
|
Result.set_weight (-1)
|
||||||
Result.set_is_raw (True)
|
Result.set_is_raw (True)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -922,8 +953,10 @@ feature -- Generation
|
|||||||
across
|
across
|
||||||
regions as reg_ic
|
regions as reg_ic
|
||||||
loop
|
loop
|
||||||
|
l_region := reg_ic.item
|
||||||
|
-- region blocks Already sorted.
|
||||||
across
|
across
|
||||||
reg_ic.item.blocks as ic
|
l_region.blocks as ic
|
||||||
loop
|
loop
|
||||||
if attached {CMS_SMARTY_TEMPLATE_BLOCK} ic.item as l_tpl_block then
|
if attached {CMS_SMARTY_TEMPLATE_BLOCK} ic.item as l_tpl_block then
|
||||||
-- Apply page variables to smarty block.
|
-- Apply page variables to smarty block.
|
||||||
|
|||||||
Reference in New Issue
Block a user