Initial implementation with Hooks, Regions and Templates

Updated Modules to support hooks, still work in progress.
This commit is contained in:
jvelilla
2014-11-03 12:40:54 -03:00
parent 5cb26f0b24
commit b11462105a
50 changed files with 1810 additions and 45 deletions

View File

@@ -74,4 +74,11 @@ feature {NONE} -- Implementation: routes
a_router.handle_with_request_methods ("/basic_auth_logoff", l_bal_handler, l_methods)
end
feature -- Hooks
register_hooks (a_response: CMS_RESPONSE)
do
end
end

View File

@@ -50,7 +50,7 @@ feature -- HTTP Methods
if attached req.query_parameter ("prompt") as l_prompt then
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
else
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, setup, "master2/basic_auth/logoff")
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, setup)
l_page.set_status_code ({HTTP_STATUS_CODE}.unauthorized)
l_page.execute
end

View File

@@ -27,6 +27,17 @@ feature -- Router
deferred
end
feature -- Hooks configuration
register_hooks (a_response: CMS_RESPONSE)
-- Module hooks configuration.
require
is_enabled: is_enabled
deferred
end
feature -- Filter
filters: detachable LIST [WSF_FILTER]

View File

@@ -70,7 +70,7 @@ feature -- HTTP Methods
-- Existing node
if attached {WSF_STRING} req.path_parameter ("id") as l_id then
if l_id.is_integer and then attached {CMS_NODE} api_service.node (l_id.integer_value) as l_node then
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, setup, "modules/node_content")
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, setup)
l_page.add_variable (l_node.content, "node_content")
l_page.add_variable (l_id.value, "id")
l_page.execute
@@ -78,7 +78,7 @@ feature -- HTTP Methods
do_error (req, res, l_id)
end
else
(create {ERROR_500_CMS_RESPONSE}.make (req, res, setup, "master2/error")).execute
(create {ERROR_500_CMS_RESPONSE}.make (req, res, setup)).execute
end
else
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
@@ -96,14 +96,14 @@ feature -- HTTP Methods
if l_method.is_case_insensitive_equal ("PUT") then
do_put (req, res)
else
(create {ERROR_500_CMS_RESPONSE}.make (req, res, setup, "master2/error")).execute
(create {ERROR_500_CMS_RESPONSE}.make (req, res, setup)).execute
end
end
else
do_error (req, res, l_id)
end
else
(create {ERROR_500_CMS_RESPONSE}.make (req, res, setup, "master2/error")).execute
(create {ERROR_500_CMS_RESPONSE}.make (req, res, setup)).execute
end
else
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
@@ -127,7 +127,7 @@ feature -- HTTP Methods
do_error (req, res, l_id)
end
else
(create {ERROR_500_CMS_RESPONSE}.make (req, res, setup, "master2/error")).execute
(create {ERROR_500_CMS_RESPONSE}.make (req, res, setup)).execute
end
else
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
@@ -140,7 +140,7 @@ feature -- Error
local
l_page: CMS_RESPONSE
do
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, setup, "master2/error")
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, setup)
l_page.add_variable (req.absolute_script_url (req.path_info), "request")
if a_id.is_integer then
-- resource not found

View File

@@ -69,7 +69,7 @@ feature -- HTTP Methods
-- Existing node
if attached {WSF_STRING} req.path_parameter ("id") as l_id then
if l_id.is_integer and then attached {CMS_NODE} api_service.node (l_id.integer_value) as l_node then
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, setup,"modules/node")
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, setup)
l_page.add_variable (l_node, "node")
l_page.execute
else
@@ -96,7 +96,7 @@ feature -- HTTP Methods
elseif l_method.is_case_insensitive_equal ("PUT") then
do_put (req, res)
else
(create {ERROR_500_CMS_RESPONSE}.make (req, res, setup, "master2/error")).execute
(create {ERROR_500_CMS_RESPONSE}.make (req, res, setup)).execute
end
end
else
@@ -131,7 +131,7 @@ feature -- HTTP Methods
do_error (req, res, l_id)
end
else
(create {ERROR_500_CMS_RESPONSE}.make (req, res, setup, "master2/error")).execute
(create {ERROR_500_CMS_RESPONSE}.make (req, res, setup)).execute
end
else
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
@@ -151,7 +151,7 @@ feature -- HTTP Methods
do_error (req, res, l_id)
end
else
(create {ERROR_500_CMS_RESPONSE}.make (req, res, setup, "master2/error")).execute
(create {ERROR_500_CMS_RESPONSE}.make (req, res, setup)).execute
end
else
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
@@ -165,7 +165,7 @@ feature -- Error
local
l_page: CMS_RESPONSE
do
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, setup, "master2/error")
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, setup)
l_page.add_variable (req.absolute_script_url (req.path_info), "request")
if a_id.is_integer then
-- resource not found
@@ -186,7 +186,7 @@ feature {NONE} -- Node
l_page: CMS_RESPONSE
do
if attached current_user_name (req) then
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, setup, "modules/node")
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, setup)
l_page.add_variable (setup.is_html, "html")
l_page.add_variable (setup.is_web, "web")
l_page.execute

View File

@@ -69,7 +69,7 @@ feature -- HTTP Methods
-- Existing node
if attached {WSF_STRING} req.path_parameter ("id") as l_id then
if l_id.is_integer and then attached {CMS_NODE} api_service.node (l_id.integer_value) as l_node then
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, setup, "modules/node_summary")
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, setup)
l_page.add_variable (l_id.value, "id")
l_page.add_variable (l_node.summary, "node_summary")
l_page.execute
@@ -77,7 +77,7 @@ feature -- HTTP Methods
do_error (req, res, l_id)
end
else
(create {ERROR_500_CMS_RESPONSE}.make (req, res, setup, "master2/error")).execute
(create {ERROR_500_CMS_RESPONSE}.make (req, res, setup)).execute
end
else
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
@@ -95,14 +95,14 @@ feature -- HTTP Methods
if l_method.is_case_insensitive_equal ("PUT") then
do_put (req, res)
else
(create {ERROR_500_CMS_RESPONSE}.make (req, res, setup, "master2/error")).execute
(create {ERROR_500_CMS_RESPONSE}.make (req, res, setup)).execute
end
end
else
do_error (req, res, l_id)
end
else
(create {ERROR_500_CMS_RESPONSE}.make (req, res, setup, "master2/error")).execute
(create {ERROR_500_CMS_RESPONSE}.make (req, res, setup)).execute
end
else
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
@@ -125,7 +125,7 @@ feature -- HTTP Methods
do_error (req, res, l_id)
end
else
(create {ERROR_500_CMS_RESPONSE}.make (req, res, setup, "master2/error")).execute
(create {ERROR_500_CMS_RESPONSE}.make (req, res, setup)).execute
end
else
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
@@ -140,7 +140,7 @@ feature -- Error
local
l_page: CMS_RESPONSE
do
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, setup, "master2/error")
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, setup)
l_page.add_variable (req.absolute_script_url (req.path_info), "request")
if a_id.is_integer then
-- resource not found

View File

@@ -69,7 +69,7 @@ feature -- HTTP Methods
-- Existing node
if attached {WSF_STRING} req.path_parameter ("id") as l_id then
if l_id.is_integer and then attached {CMS_NODE} api_service.node (l_id.integer_value) as l_node then
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, setup, "modules/node_title")
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, setup)
l_page.add_variable (l_node.title, "node_title")
l_page.add_variable (l_id.value, "id")
l_page.execute
@@ -77,7 +77,7 @@ feature -- HTTP Methods
do_error (req, res, l_id)
end
else
(create {ERROR_500_CMS_RESPONSE}.make (req, res, setup, "master2/error")).execute
(create {ERROR_500_CMS_RESPONSE}.make (req, res, setup)).execute
end
else
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
@@ -94,14 +94,14 @@ feature -- HTTP Methods
if l_method.is_case_insensitive_equal ("PUT") then
do_put (req, res)
else
(create {ERROR_500_CMS_RESPONSE}.make (req, res, setup, "master2/error")).execute
(create {ERROR_500_CMS_RESPONSE}.make (req, res, setup)).execute
end
end
else
do_error (req, res, l_id)
end
else
(create {ERROR_500_CMS_RESPONSE}.make (req, res, setup, "master2/error")).execute
(create {ERROR_500_CMS_RESPONSE}.make (req, res, setup)).execute
end
else
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
@@ -125,7 +125,7 @@ feature -- HTTP Methods
do_error (req, res, l_id)
end
else
(create {ERROR_500_CMS_RESPONSE}.make (req, res, setup, "master2/error")).execute
(create {ERROR_500_CMS_RESPONSE}.make (req, res, setup)).execute
end
else
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
@@ -139,7 +139,7 @@ feature -- Error
local
l_page: CMS_RESPONSE
do
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, setup, "master2/error")
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, setup)
l_page.add_variable (req.absolute_script_url (req.path_info), "request")
if a_id.is_integer then
-- resource not found

View File

@@ -52,7 +52,7 @@ feature -- HTTP Methods
-- At the moment the template is hardcoded, but we can
-- get them from the configuration file and load them into
-- the setup class.
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, setup, "modules/nodes")
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, setup)
l_page.add_variable (api_service.nodes, "nodes")
l_page.execute
end

View File

@@ -10,6 +10,11 @@ inherit
CMS_MODULE
CMS_HOOK_MENU_ALTER
CMS_HOOK_BLOCK
create
make
@@ -115,4 +120,40 @@ feature {NONE} -- Implementation: routes
a_router.handle_with_request_methods ("/node/{id}/content", l_report_handler, l_methods)
end
feature -- Hooks
register_hooks (a_response: CMS_RESPONSE)
do
a_response.add_menu_alter_hook (Current)
a_response.add_block_hook (Current)
end
block_list: ITERABLE [like {CMS_BLOCK}.name]
do
Result := <<"node-info">>
end
get_block_view (a_block_id: detachable READABLE_STRING_8; a_response: CMS_RESPONSE)
-- local
-- b: CMS_CONTENT_BLOCK
do
-- if
-- a_execution.is_front and then
-- attached a_execution.user as u
-- then
-- create b.make ("node-info", "Node", "Node ...", a_execution.formats.plain_text)
-- a_execution.add_block (b, Void)
-- end
end
menu_alter (a_menu_system: CMS_MENU_SYSTEM; a_response: CMS_RESPONSE)
local
lnk: CMS_LOCAL_LINK
perms: detachable ARRAYED_LIST [READABLE_STRING_8]
do
create lnk.make ("node", "/node")
a_menu_system.navigation_menu.extend (lnk)
end
end