Updated CMS code.

Separated code to have a lib and an example.
Improved design, fixed a few issues related to folder location.

This is still experimental and require more work to be really friendly to use.
This commit is contained in:
Jocelyn Fiat
2013-01-31 15:33:24 +01:00
parent 40ea982293
commit ce469b6ede
136 changed files with 1841 additions and 299 deletions

View File

@@ -0,0 +1,60 @@
note
description: "Summary description for {CMS_MODULE}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
DEMO_MODULE
inherit
CMS_MODULE
create
make
feature {NONE} -- Initialization
make (a_service: like service)
do
service := a_service
name := "demo"
version := "1.0"
description := "demo"
package := "misc"
end
feature {CMS_SERVICE} -- Registration
service: CMS_SERVICE
register (a_service: CMS_SERVICE)
do
a_service.map_uri_template ("/demo/date/{arg}", agent handle_date_time_demo)
a_service.map_uri_template ("/demo/format/{arg}", agent handle_format_demo)
end
feature -- Hooks
links: HASH_TABLE [CMS_MODULE_LINK, STRING]
-- Link indexed by path
local
-- lnk: CMS_MODULE_LINK
do
create Result.make (3)
-- create lnk.make ("Date/time demo")
-- lnk.set_callback (agent process_date_time_demo, <<"arg">>)
-- Result["/demo/date/{arg}"] := lnk
end
handle_date_time_demo (req: WSF_REQUEST; res: WSF_RESPONSE)
do
(create {ANY_CMS_EXECUTION}.make_with_text (req, res, service, "<h1>Demo::date/time</h1>")).execute
end
handle_format_demo (req: WSF_REQUEST; res: WSF_RESPONSE)
do
(create {ANY_CMS_EXECUTION}.make_with_text (req, res, service, "<h1>Demo::format</h1>")).execute
end
end

View File

@@ -0,0 +1,33 @@
note
description: "Summary description for {SHUTDOWN_CMS_EXECUTION}."
date: "$Date$"
revision: "$Revision$"
class
SHUTDOWN_CMS_EXECUTION
inherit
CMS_EXECUTION
create
make
feature -- Execution
process
local
b: STRING
do
create b.make_empty
set_title ("Shutting down the service ...")
if has_permission ("admin shutdown") then
if attached {WGI_NINO_CONNECTOR} request.wgi_connector as nino then
nino.server.shutdown_server
end
else
b.append ("Access denied")
end
set_main_content (b)
end
end

View File

@@ -0,0 +1,72 @@
note
description: "Summary description for {SHUTDOWN_MODULE}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
SHUTDOWN_MODULE
inherit
CMS_MODULE
CMS_HOOK_MENU_ALTER
create
make
feature {NONE} -- Initialization
make
do
name := "shutdown"
version := "1.0"
description := "Shutdown the service if this is EWF Nino or FCGI"
package := "server"
end
feature {CMS_SERVICE} -- Registration
service: detachable CMS_SERVICE
register (a_service: CMS_SERVICE)
do
a_service.map_uri ("/admin/shutdown/", agent handle_shutdown)
a_service.add_menu_alter_hook (Current)
service := a_service
end
feature -- Hooks
menu_alter (a_menu_system: CMS_MENU_SYSTEM; a_execution: CMS_EXECUTION)
local
lnk: CMS_LOCAL_LINK
do
create lnk.make ("Shutdown", "/admin/shutdown/")
lnk.set_permission_arguments (<<"admin shutdown">>)
a_menu_system.management_menu.extend (lnk)
end
links: HASH_TABLE [CMS_MODULE_LINK, STRING]
-- Link indexed by path
local
-- lnk: CMS_MODULE_LINK
do
create Result.make (3)
-- create lnk.make ("Date/time demo")
-- lnk.set_callback (agent process_date_time_demo, <<"arg">>)
-- Result["/demo/date/{arg}"] := lnk
end
handle_shutdown (req: WSF_REQUEST; res: WSF_RESPONSE)
do
if attached service as l_service then
(create {SHUTDOWN_CMS_EXECUTION}.make (req, res, l_service)).execute ;
else
res.set_status_code ({HTTP_STATUS_CODE}.expectation_failed)
end
end
end