Redesigned hooks system (moving from CMS_RESPONSE to CMS_API).
Indeed, hooks does not require RESPONSE interface, and should be setup before, at the system level (i.e CMS_API) Added exportation solution via CMS_HOOK_EXPORT. Updated blocks settings for demo example project.
This commit is contained in:
35
src/hooks/export/cms_export_json_utilities.e
Normal file
35
src/hooks/export/cms_export_json_utilities.e
Normal file
@@ -0,0 +1,35 @@
|
||||
note
|
||||
description: "[
|
||||
Usefull routines to export to JSON.
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CMS_EXPORT_JSON_UTILITIES
|
||||
|
||||
feature -- Access
|
||||
|
||||
put_date_into_json (dt: detachable DATE_TIME; a_key: JSON_STRING; j: JSON_OBJECT)
|
||||
local
|
||||
hd: HTTP_DATE
|
||||
do
|
||||
if dt /= Void then
|
||||
create hd.make_from_date_time (dt)
|
||||
j.put_integer (hd.timestamp, a_key)
|
||||
end
|
||||
end
|
||||
|
||||
json_to_string (j: JSON_OBJECT): STRING
|
||||
local
|
||||
pp: JSON_PRETTY_STRING_VISITOR
|
||||
do
|
||||
create Result.make_empty
|
||||
create pp.make (Result)
|
||||
j.accept (pp)
|
||||
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
|
||||
43
src/hooks/export/cms_export_parameters.e
Normal file
43
src/hooks/export/cms_export_parameters.e
Normal file
@@ -0,0 +1,43 @@
|
||||
note
|
||||
description: "[
|
||||
Parameters used by CMS_HOOK_EXPORT subscribers.
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CMS_EXPORT_PARAMETERS
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_location: PATH)
|
||||
do
|
||||
location := a_location
|
||||
create logs.make (10)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
location: PATH
|
||||
-- Location of export folder.
|
||||
|
||||
feature -- Logs
|
||||
|
||||
logs: ARRAYED_LIST [READABLE_STRING_8]
|
||||
-- Associated exportation logs.
|
||||
|
||||
log (m: READABLE_STRING_8)
|
||||
-- Add message `m' into `logs'.
|
||||
do
|
||||
logs.force (m)
|
||||
end
|
||||
|
||||
invariant
|
||||
|
||||
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
|
||||
31
src/hooks/export/cms_hook_export.e
Normal file
31
src/hooks/export/cms_hook_export.e
Normal file
@@ -0,0 +1,31 @@
|
||||
note
|
||||
description: "[
|
||||
CMS HOOK providing a way to export module data according to specific export parameters.
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
CMS_HOOK_EXPORT
|
||||
|
||||
inherit
|
||||
CMS_HOOK
|
||||
|
||||
feature -- Hook
|
||||
|
||||
export_to (a_export_id_list: detachable ITERABLE [READABLE_STRING_GENERAL]; a_export_parameters: CMS_EXPORT_PARAMETERS; a_response: CMS_RESPONSE)
|
||||
-- Export data identified by `a_export_id_list',
|
||||
-- or export all data if `a_export_id_list' is Void.
|
||||
deferred
|
||||
end
|
||||
|
||||
-- export_identifiers: detachable ITERABLE [READABLE_STRING_32]
|
||||
-- -- Optional list of exportation ids, if any.
|
||||
-- do
|
||||
-- -- To redefine if needed.
|
||||
-- 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