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"?>
|
||||
<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">
|
||||
<root all_classes="true"/>
|
||||
<file_rule>
|
||||
@@ -14,14 +14,16 @@
|
||||
<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="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_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="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="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="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="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"/>
|
||||
@@ -30,7 +32,6 @@
|
||||
<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_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"/>
|
||||
</target>
|
||||
</system>
|
||||
|
||||
5
cms.ecf
5
cms.ecf
@@ -15,14 +15,16 @@
|
||||
<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="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_model" location=".\library\model\cms_model.ecf" readonly="false"/>
|
||||
<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="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="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="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="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"/>
|
||||
@@ -31,7 +33,6 @@
|
||||
<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_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"/>
|
||||
</target>
|
||||
</system>
|
||||
|
||||
@@ -41,6 +41,8 @@ feature -- Evaluation
|
||||
satisfied_for_response (res: CMS_RESPONSE): BOOLEAN
|
||||
local
|
||||
exp: like expression
|
||||
l_path: READABLE_STRING_8
|
||||
kmp: KMP_WILD
|
||||
do
|
||||
exp := expression
|
||||
if exp.same_string ("is_front") then
|
||||
@@ -50,7 +52,17 @@ feature -- Evaluation
|
||||
elseif exp.same_string ("<none>") then
|
||||
Result := False
|
||||
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
|
||||
|
||||
|
||||
@@ -6,7 +6,12 @@ deferred class
|
||||
CMS_BLOCK
|
||||
|
||||
inherit
|
||||
COMPARABLE
|
||||
|
||||
DEBUG_OUTPUT
|
||||
undefine
|
||||
is_equal
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
@@ -23,6 +28,10 @@ feature -- Access
|
||||
html_options: detachable CMS_HTML_OPTIONS
|
||||
-- Optional addition html options.
|
||||
|
||||
weight: INTEGER
|
||||
-- Weight used to order blocks.
|
||||
-- Default: 0;
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_empty: BOOLEAN
|
||||
@@ -42,6 +51,14 @@ feature -- Status report
|
||||
conditions: detachable LIST [CMS_BLOCK_CONDITION]
|
||||
-- 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
|
||||
|
||||
add_css_class (a_class: READABLE_STRING_8)
|
||||
@@ -83,6 +100,12 @@ feature -- Element change
|
||||
l_conditions.force (a_condition)
|
||||
end
|
||||
|
||||
set_weight (w: like weight)
|
||||
-- Set `weight' to `w'.
|
||||
do
|
||||
weight := w
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
to_html (a_theme: CMS_THEME): STRING_8
|
||||
|
||||
@@ -41,6 +41,16 @@ feature -- Element change
|
||||
blocks.prune_all (b)
|
||||
end
|
||||
|
||||
feature -- Sort
|
||||
|
||||
sort
|
||||
local
|
||||
cmp: QUICK_SORTER [CMS_BLOCK]
|
||||
do
|
||||
create cmp.make (create {COMPARABLE_COMPARATOR [CMS_BLOCK]})
|
||||
cmp.sort (blocks)
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
|
||||
@@ -15,9 +15,12 @@ inherit
|
||||
select
|
||||
out
|
||||
end
|
||||
|
||||
SHARED_TEMPLATE_CONTEXT
|
||||
rename
|
||||
out as tpl_out
|
||||
undefine
|
||||
is_equal
|
||||
end
|
||||
|
||||
create
|
||||
|
||||
@@ -423,7 +423,18 @@ feature -- Blocks initialization
|
||||
Result := setup.text_item_or_default ("blocks." + a_block_id + ".region", a_default_region)
|
||||
end
|
||||
|
||||
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]
|
||||
-- Condition associated with `a_block_id' in configuration, if any.
|
||||
@@ -567,6 +578,9 @@ feature -- Blocks
|
||||
end
|
||||
|
||||
get_blocks
|
||||
-- Get block from CMS core, and from modules.
|
||||
local
|
||||
l_region: CMS_BLOCK_REGION
|
||||
do
|
||||
debug ("refactor_fixme")
|
||||
fixme ("find a way to have this in configuration or database, and allow different order")
|
||||
@@ -592,6 +606,19 @@ feature -- Blocks
|
||||
end
|
||||
|
||||
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")
|
||||
put_block (create {CMS_CONTENT_BLOCK}.make ("made_with", Void, "Made with <a href=%"https://www.eiffel.org/%">EWF</a>", Void), "footer", True)
|
||||
end
|
||||
@@ -641,6 +668,7 @@ feature -- Blocks
|
||||
do
|
||||
create s.make_empty
|
||||
create Result.make ("page_top", Void, s, Void)
|
||||
Result.set_weight (-5)
|
||||
Result.set_is_raw (True)
|
||||
end
|
||||
|
||||
@@ -652,6 +680,7 @@ feature -- Blocks
|
||||
create s.make_from_string (theme.menu_html (primary_menu, True, Void))
|
||||
create l_hb.make_empty
|
||||
create Result.make ("header", Void, l_hb, Void)
|
||||
Result.set_weight (-4)
|
||||
Result.set_is_raw (True)
|
||||
end
|
||||
|
||||
@@ -683,6 +712,7 @@ feature -- Blocks
|
||||
if attached message as m and then not m.is_empty then
|
||||
create Result.make ("message", Void, "<div id=%"message%">" + m + "</div>", Void)
|
||||
Result.set_is_raw (True)
|
||||
Result.set_weight (-2)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -699,6 +729,7 @@ feature -- Blocks
|
||||
end
|
||||
end
|
||||
create Result.make ("content", Void, s, Void)
|
||||
Result.set_weight (-1)
|
||||
Result.set_is_raw (True)
|
||||
end
|
||||
|
||||
@@ -922,8 +953,10 @@ feature -- Generation
|
||||
across
|
||||
regions as reg_ic
|
||||
loop
|
||||
l_region := reg_ic.item
|
||||
-- region blocks Already sorted.
|
||||
across
|
||||
reg_ic.item.blocks as ic
|
||||
l_region.blocks as ic
|
||||
loop
|
||||
if attached {CMS_SMARTY_TEMPLATE_BLOCK} ic.item as l_tpl_block then
|
||||
-- Apply page variables to smarty block.
|
||||
|
||||
Reference in New Issue
Block a user