Merged CMS based on concurrent EWF (i.e ewf_v1) with blog branch.

This commit is contained in:
Jocelyn Fiat
2015-06-15 11:27:44 +02:00
75 changed files with 2069 additions and 512 deletions

View File

@@ -148,17 +148,15 @@ feature -- Permissions system
feature -- Query: module
module (a_type: TYPE [detachable CMS_MODULE]): detachable CMS_MODULE
module (a_type: TYPE [CMS_MODULE]): detachable CMS_MODULE
-- Enabled module typed `a_type', if any.
--| usage: if attached module ({FOO_MODULE}) as mod then ...
local
t: STRING_8
-- t: STRING_8
l_type: TYPE [detachable CMS_MODULE]
do
t := a_type.name
if t.starts_with ("!") then
t.remove_head (1)
end
-- t := type_name_without_annotation (a_type)
across
setup.modules as ic
until
@@ -171,8 +169,12 @@ feature -- Query: module
l_type := Result.generating_type
if a_type ~ l_type then
-- Found
elseif t.same_string (l_type.name) then
elseif
attached a_type.attempt (Result) and then attached l_type.generating_type.attempt (a_type)
then
-- Found
-- elseif t.same_string (type_name_without_annotation (l_type)) then
-- -- Found
else
Result := Void
end
@@ -185,8 +187,11 @@ feature -- Query: module
module_api (a_type: TYPE [CMS_MODULE]): detachable CMS_MODULE_API
-- Enabled module API associated with module typed `a_type'.
do
if attached {CMS_MODULE} module (a_type) as mod then
if attached module (a_type) as mod then
if mod.is_enabled then
if not mod.is_initialized then
mod.initialize (Current)
end
Result := mod.module_api
end
end
@@ -236,9 +241,16 @@ feature -- Query: API
feature -- Path aliases
is_valid_path_alias (a_alias: READABLE_STRING_8): BOOLEAN
do
Result := a_alias.is_empty or else not a_alias.starts_with_general ("/")
end
set_path_alias (a_source, a_alias: READABLE_STRING_8; a_keep_previous: BOOLEAN)
-- Set `a_alias' as alias of `a_source',
-- and eventually unset previous alias if any.
require
valid_alias: is_valid_path_alias (a_alias)
local
l_continue: BOOLEAN
do
@@ -283,8 +295,8 @@ feature -- Path aliases
-- Resolved path for alias `a_alias'.
--| the CMS supports aliases for path, and then this function simply returns
--| the effective target path/url for this `a_alias'.
--| For instance: /articles/2015/may/this-is-an-article can be an alias to /node/123
--| This function will return "/node/123".
--| For instance: articles/2015/may/this-is-an-article can be an alias to node/123
--| This function will return "node/123".
--| If the alias is bad (i.e does not alias real path), then this function
--| returns the alias itself.
do
@@ -310,6 +322,41 @@ feature {NONE}-- Implemenation
internal_user_api: detachable like user_api
-- Cached value for `user_api'.
type_name_without_annotation (a_type: TYPE [detachable ANY]): STRING
-- Type name for `a_type, without any annotation.
-- Used by `module' to search by type.
local
i,j,n: INTEGER
c: CHARACTER
do
create Result.make_from_string (a_type.name)
from
i := 1
n := Result.count
until
i > n
loop
c := Result[i]
if c = '!' or c = '?' then
Result.remove (i)
n := n - 1
elseif c.is_lower then
j := Result.index_of (' ', i + 1)
if j > 0 then
Result.remove_substring (i, j)
n := n - (j - i)
end
else
i := i + 1
end
end
if Result.starts_with ("!") or Result.starts_with ("?") then
Result.remove_head (1)
elseif Result.starts_with ("detachable ") then
Result.remove_head (11)
end
end
feature -- Environment
module_configuration (a_module_name: READABLE_STRING_GENERAL; a_name: detachable READABLE_STRING_GENERAL): detachable CONFIG_READER