Added url routing for /files/... and /module/{modname}/files/...
Added CMS_HOOK_RESPONSE_ALTER to give a last chance to alter the response before rendering. This hook should not be used, when there are other alternative hook that answer the need, but this is proposed for now, as a way to alter response by adding css, js url, ... Moved blog under official modules folder. Cleaned theme of demo example project. Renamed NODE_MODULE as CMS_NODE_MODULE.
This commit is contained in:
@@ -347,6 +347,12 @@ feature -- Environment/ theme
|
||||
Result := setup.site_location
|
||||
end
|
||||
|
||||
files_location: PATH
|
||||
-- CMS public files location.
|
||||
do
|
||||
Result := setup.files_location
|
||||
end
|
||||
|
||||
theme_location: PATH
|
||||
-- Active theme location.
|
||||
do
|
||||
|
||||
@@ -164,7 +164,19 @@ feature -- Settings: router
|
||||
end)
|
||||
a_router.handle ("/theme/", fhdl, router.methods_GET)
|
||||
|
||||
-- "/files/.."
|
||||
create fhdl.make_hidden_with_path (api.files_location)
|
||||
fhdl.disable_index
|
||||
fhdl.set_not_found_handler (agent (ia_uri: READABLE_STRING_8; ia_req: WSF_REQUEST; ia_res: WSF_RESPONSE)
|
||||
do
|
||||
execute_default (ia_req, ia_res)
|
||||
end)
|
||||
a_router.handle ("/files/", fhdl, router.methods_GET)
|
||||
|
||||
-- files folder from specific module.
|
||||
a_router.handle ("/module/{modname}/files{/vars}", create {WSF_URI_TEMPLATE_AGENT_HANDLER}.make (agent handle_module_files), a_router.methods_get)
|
||||
|
||||
-- www folder. Should we keep this??
|
||||
create fhdl.make_hidden_with_path (setup.environment.www_path)
|
||||
fhdl.disable_index
|
||||
fhdl.set_not_found_handler (agent (ia_uri: READABLE_STRING_8; ia_req: WSF_REQUEST; ia_res: WSF_RESPONSE)
|
||||
@@ -263,6 +275,27 @@ feature -- Execution
|
||||
end
|
||||
end
|
||||
|
||||
handle_module_files (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Handle files per modules.
|
||||
-- i.e: "/module/{modname}/files{/vars}"
|
||||
local
|
||||
fhdl: WSF_FILE_SYSTEM_HANDLER
|
||||
r: NOT_FOUND_ERROR_CMS_RESPONSE
|
||||
do
|
||||
if attached {WSF_STRING} req.path_parameter ("modname") as l_mod_name then
|
||||
create fhdl.make_with_path (api.module_location_by_name (l_mod_name.url_encoded_value).extended ("files"))
|
||||
fhdl.disable_index
|
||||
fhdl.set_not_found_handler (agent (ia_uri: READABLE_STRING_8; ia_req: WSF_REQUEST; ia_res: WSF_RESPONSE)
|
||||
do
|
||||
execute_default (ia_req, ia_res)
|
||||
end)
|
||||
fhdl.execute_starts_with ("/module/" + l_mod_name.url_encoded_value + "/files/", req, res)
|
||||
else
|
||||
create r.make (req, res, api)
|
||||
r.execute
|
||||
end
|
||||
end
|
||||
|
||||
execute_default (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Default request handler if no other are relevant
|
||||
local
|
||||
@@ -274,7 +307,7 @@ feature -- Execution
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2014, Jocelyn Fiat, 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)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
|
||||
@@ -613,6 +613,28 @@ feature -- Hook: value alter
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Hook: response
|
||||
|
||||
subscribe_to_response_alter_hook (h: CMS_HOOK_RESPONSE_ALTER)
|
||||
-- Add `h' as subscriber of response alter hooks CMS_HOOK_RESPONSE_ALTER.
|
||||
do
|
||||
subscribe_to_hook (h, {CMS_HOOK_RESPONSE_ALTER})
|
||||
end
|
||||
|
||||
invoke_response_alter (a_response: CMS_RESPONSE)
|
||||
-- Invoke value table alter hook for table `a_table'.
|
||||
do
|
||||
if attached hook_subscribers.item ({CMS_HOOK_RESPONSE_ALTER}) as lst then
|
||||
across
|
||||
lst as c
|
||||
loop
|
||||
if attached {CMS_HOOK_RESPONSE_ALTER} c.item as h then
|
||||
h.response_alter (a_response)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Hook: menu_system_alter
|
||||
|
||||
subscribe_to_menu_system_alter_hook (h: CMS_HOOK_MENU_SYSTEM_ALTER)
|
||||
@@ -868,6 +890,9 @@ feature -- Generation
|
||||
common_prepare (page)
|
||||
custom_prepare (page)
|
||||
|
||||
-- Cms response
|
||||
invoke_response_alter (Current)
|
||||
|
||||
-- Cms values
|
||||
invoke_value_table_alter (values)
|
||||
|
||||
@@ -1132,4 +1157,7 @@ feature {NONE} -- Execution
|
||||
|
||||
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)"
|
||||
end
|
||||
|
||||
@@ -30,8 +30,9 @@ feature -- Execution
|
||||
process
|
||||
-- Computed response message.
|
||||
do
|
||||
-- set_title ("CMS")
|
||||
-- set_page_title (Void)
|
||||
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)"
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user