Merge branch 'ewf_v1' of https://github.com/EiffelWebFramework/ROC into roc_account
This commit is contained in:
@@ -77,7 +77,7 @@ CREATE TABLE tb_demo(
|
|||||||
api.logger.put_error ("Could not initialize database for demo module", generating_type)
|
api.logger.put_error ("Could not initialize database for demo module", generating_type)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
api.storage.set_custom_value ("is_initialized", "module-" + name, "yes")
|
Precursor {CMS_MODULE}(api)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ feature -- Access
|
|||||||
Result := environment
|
Result := environment
|
||||||
end
|
end
|
||||||
|
|
||||||
|
feature {CMS_API} -- API Access
|
||||||
|
|
||||||
enabled_modules: CMS_MODULE_COLLECTION
|
enabled_modules: CMS_MODULE_COLLECTION
|
||||||
-- List of enabled modules.
|
-- List of enabled modules.
|
||||||
local
|
local
|
||||||
@@ -51,7 +53,14 @@ feature -- Access
|
|||||||
only_enabled_modules: across Result as ic all ic.item.is_enabled end
|
only_enabled_modules: across Result as ic all ic.item.is_enabled end
|
||||||
end
|
end
|
||||||
|
|
||||||
feature {CMS_MODULE, CMS_API} -- Restricted access
|
feature {CMS_MODULE, CMS_API, CMS_SETUP_ACCESS} -- Restricted access
|
||||||
|
|
||||||
|
modules: CMS_MODULE_COLLECTION
|
||||||
|
-- List of available modules.
|
||||||
|
deferred
|
||||||
|
end
|
||||||
|
|
||||||
|
feature {NONE} -- Implementation: update
|
||||||
|
|
||||||
update_module_status_within (a_module: CMS_MODULE; a_collection: CMS_MODULE_COLLECTION)
|
update_module_status_within (a_module: CMS_MODULE; a_collection: CMS_MODULE_COLLECTION)
|
||||||
-- Update status of module `a_module', taking into account its dependencies within the collection `a_collection'.
|
-- Update status of module `a_module', taking into account its dependencies within the collection `a_collection'.
|
||||||
@@ -101,11 +110,6 @@ feature {CMS_MODULE, CMS_API} -- Restricted access
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
modules: CMS_MODULE_COLLECTION
|
|
||||||
-- List of available modules.
|
|
||||||
deferred
|
|
||||||
end
|
|
||||||
|
|
||||||
feature -- Access: Site
|
feature -- Access: Site
|
||||||
|
|
||||||
site_id: READABLE_STRING_8
|
site_id: READABLE_STRING_8
|
||||||
|
|||||||
12
src/configuration/cms_setup_access.e
Normal file
12
src/configuration/cms_setup_access.e
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
note
|
||||||
|
description: "Interface to access restricted data from {CMS_SETUP}."
|
||||||
|
date: "$Date$"
|
||||||
|
revision: "$Revision$"
|
||||||
|
|
||||||
|
deferred class
|
||||||
|
CMS_SETUP_ACCESS
|
||||||
|
|
||||||
|
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
|
||||||
15
src/service/cms_access.e
Normal file
15
src/service/cms_access.e
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
note
|
||||||
|
description: "Interface giving access to internal CMS features."
|
||||||
|
date: "$Date$"
|
||||||
|
revision: "$Revision$"
|
||||||
|
|
||||||
|
deferred class
|
||||||
|
CMS_ACCESS
|
||||||
|
|
||||||
|
inherit
|
||||||
|
CMS_SETUP_ACCESS
|
||||||
|
|
||||||
|
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
|
||||||
@@ -34,6 +34,8 @@ feature {NONE} -- Initialize
|
|||||||
-- Initialize the persitent layer.
|
-- Initialize the persitent layer.
|
||||||
local
|
local
|
||||||
l_module: CMS_MODULE
|
l_module: CMS_MODULE
|
||||||
|
l_enabled_modules: CMS_MODULE_COLLECTION
|
||||||
|
l_uninstalled_mods: detachable ARRAYED_LIST [CMS_MODULE]
|
||||||
do
|
do
|
||||||
-- Initialize formats.
|
-- Initialize formats.
|
||||||
initialize_formats
|
initialize_formats
|
||||||
@@ -45,22 +47,40 @@ feature {NONE} -- Initialize
|
|||||||
create {CMS_STORAGE_NULL} storage
|
create {CMS_STORAGE_NULL} storage
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Keep enable modules list.
|
||||||
|
l_enabled_modules := setup.enabled_modules
|
||||||
|
enabled_modules := l_enabled_modules
|
||||||
|
|
||||||
-- Complete storage setup.
|
-- Complete storage setup.
|
||||||
storage.set_api (Current)
|
storage.set_api (Current)
|
||||||
|
|
||||||
-- Initialize enabled modules.
|
-- Initialize enabled modules.
|
||||||
across
|
across
|
||||||
setup.enabled_modules as ic
|
l_enabled_modules as ic
|
||||||
loop
|
loop
|
||||||
l_module := ic.item
|
l_module := ic.item
|
||||||
-- FIXME: should we initialize first, and then install
|
-- FIXME: should we initialize first, and then install
|
||||||
-- or the reverse, or merge installation and initialization
|
-- or the reverse, or merge installation and initialization
|
||||||
-- and leave the responsability to the module to know
|
-- and leave the responsability to the module to know
|
||||||
-- if this is installed or not...
|
-- if this is installed or not...
|
||||||
if not l_module.is_installed (Current) then
|
-- if not l_module.is_installed (Current) then
|
||||||
l_module.install (Current)
|
-- l_module.install (Current)
|
||||||
|
-- end
|
||||||
|
if l_module.is_installed (Current) then
|
||||||
|
l_module.initialize (Current)
|
||||||
|
else
|
||||||
|
if l_uninstalled_mods = Void then
|
||||||
|
create l_uninstalled_mods.make (1)
|
||||||
|
end
|
||||||
|
l_uninstalled_mods.force (l_module)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if l_uninstalled_mods /= Void then
|
||||||
|
across
|
||||||
|
l_uninstalled_mods as ic
|
||||||
|
loop
|
||||||
|
l_enabled_modules.remove (ic.item)
|
||||||
end
|
end
|
||||||
l_module.initialize (Current)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -81,6 +101,30 @@ feature {NONE} -- Initialize
|
|||||||
formats.extend (f)
|
formats.extend (f)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
feature {CMS_ACCESS} -- Installation
|
||||||
|
|
||||||
|
install
|
||||||
|
-- Install CMS or uninstalled module which are enabled.
|
||||||
|
local
|
||||||
|
l_module: CMS_MODULE
|
||||||
|
do
|
||||||
|
across
|
||||||
|
setup.modules as ic
|
||||||
|
loop
|
||||||
|
l_module := ic.item
|
||||||
|
-- FIXME: should we initialize first, and then install
|
||||||
|
-- or the reverse, or merge installation and initialization
|
||||||
|
-- and leave the responsability to the module to know
|
||||||
|
-- if this is installed or not...
|
||||||
|
if not l_module.is_installed (Current) then
|
||||||
|
l_module.install (Current)
|
||||||
|
if l_module.is_enabled then
|
||||||
|
l_module.initialize (Current)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
feature -- Access
|
feature -- Access
|
||||||
|
|
||||||
setup: CMS_SETUP
|
setup: CMS_SETUP
|
||||||
@@ -197,6 +241,14 @@ feature -- Permissions system
|
|||||||
|
|
||||||
feature -- Query: module
|
feature -- Query: module
|
||||||
|
|
||||||
|
is_module_installed (a_module: CMS_MODULE): BOOLEAN
|
||||||
|
-- Is `a_module' installed?
|
||||||
|
do
|
||||||
|
Result := a_module.is_installed (Current)
|
||||||
|
end
|
||||||
|
|
||||||
|
enabled_modules: CMS_MODULE_COLLECTION
|
||||||
|
|
||||||
module (a_type: TYPE [CMS_MODULE]): detachable CMS_MODULE
|
module (a_type: TYPE [CMS_MODULE]): detachable CMS_MODULE
|
||||||
-- Enabled module typed `a_type', if any.
|
-- Enabled module typed `a_type', if any.
|
||||||
--| usage: if attached module ({FOO_MODULE}) as mod then ...
|
--| usage: if attached module ({FOO_MODULE}) as mod then ...
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ feature {NONE} -- Initialization
|
|||||||
setup_storage (l_setup)
|
setup_storage (l_setup)
|
||||||
setup_modules (l_setup)
|
setup_modules (l_setup)
|
||||||
create api.make (l_setup)
|
create api.make (l_setup)
|
||||||
modules := setup.enabled_modules
|
modules := api.enabled_modules
|
||||||
|
|
||||||
initialize_cms
|
initialize_cms
|
||||||
Precursor
|
Precursor
|
||||||
@@ -66,7 +66,7 @@ feature {NONE} -- Initialization
|
|||||||
initialize_modules
|
initialize_modules
|
||||||
-- Intialize modules and keep only enabled modules.
|
-- Intialize modules and keep only enabled modules.
|
||||||
do
|
do
|
||||||
modules := setup.enabled_modules
|
modules := api.enabled_modules
|
||||||
ensure
|
ensure
|
||||||
only_enabled_modules: across modules as ic all ic.item.is_enabled end
|
only_enabled_modules: across modules as ic all ic.item.is_enabled end
|
||||||
end
|
end
|
||||||
@@ -118,6 +118,7 @@ feature -- Settings: router
|
|||||||
local
|
local
|
||||||
l_api: like api
|
l_api: like api
|
||||||
l_router: like router
|
l_router: like router
|
||||||
|
l_module: CMS_MODULE
|
||||||
do
|
do
|
||||||
api.logger.put_debug (generator + ".setup_router", Void)
|
api.logger.put_debug (generator + ".setup_router", Void)
|
||||||
-- Configure root of api handler.
|
-- Configure root of api handler.
|
||||||
@@ -130,7 +131,10 @@ feature -- Settings: router
|
|||||||
across
|
across
|
||||||
modules as ic
|
modules as ic
|
||||||
loop
|
loop
|
||||||
ic.item.setup_router (l_router, l_api)
|
l_module := ic.item
|
||||||
|
if l_module.is_initialized then
|
||||||
|
l_module.setup_router (l_router, l_api)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
-- Configure files handler.
|
-- Configure files handler.
|
||||||
configure_api_file_handler (l_router)
|
configure_api_file_handler (l_router)
|
||||||
@@ -148,6 +152,8 @@ feature -- Settings: router
|
|||||||
a_router.handle ("/", l_root_handler, l_methods)
|
a_router.handle ("/", l_root_handler, l_methods)
|
||||||
a_router.handle ("", l_root_handler, l_methods)
|
a_router.handle ("", l_root_handler, l_methods)
|
||||||
map_uri_agent ("/favicon.ico", agent handle_favicon, a_router.methods_head_get)
|
map_uri_agent ("/favicon.ico", agent handle_favicon, a_router.methods_head_get)
|
||||||
|
|
||||||
|
map_uri ("/admin/install", create {CMS_ADMIN_INSTALL_HANDLER}.make (api), a_router.methods_head_get)
|
||||||
end
|
end
|
||||||
|
|
||||||
configure_api_file_handler (a_router: WSF_ROUTER)
|
configure_api_file_handler (a_router: WSF_ROUTER)
|
||||||
|
|||||||
@@ -86,14 +86,14 @@ feature {CMS_API} -- Module management
|
|||||||
require
|
require
|
||||||
is_not_installed: not is_installed (api)
|
is_not_installed: not is_installed (api)
|
||||||
do
|
do
|
||||||
api.storage.set_custom_value ("is_initialized", "module-" + name, "yes")
|
api.storage.set_custom_value ("is_initialized", "yes", "module-" + name)
|
||||||
end
|
end
|
||||||
|
|
||||||
uninstall (api: CMS_API)
|
uninstall (api: CMS_API)
|
||||||
require
|
require
|
||||||
is_installed: is_installed (api)
|
is_installed: is_installed (api)
|
||||||
do
|
do
|
||||||
api.storage.set_custom_value ("is_initialized", "module-" + name, "no")
|
api.storage.set_custom_value ("is_initialized", "no", "module-" + name)
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Router
|
feature -- Router
|
||||||
|
|||||||
80
src/service/handler/cms_admin_install_handler.e
Normal file
80
src/service/handler/cms_admin_install_handler.e
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
note
|
||||||
|
description: "Handler to process CMS installation process."
|
||||||
|
date: "$Date: 2015-02-13 13:08:13 +0100 (ven., 13 févr. 2015) $"
|
||||||
|
revision: "$Revision: 96616 $"
|
||||||
|
|
||||||
|
class
|
||||||
|
CMS_ADMIN_INSTALL_HANDLER
|
||||||
|
|
||||||
|
inherit
|
||||||
|
CMS_HANDLER
|
||||||
|
|
||||||
|
WSF_URI_HANDLER
|
||||||
|
rename
|
||||||
|
new_mapping as new_uri_mapping
|
||||||
|
end
|
||||||
|
|
||||||
|
WSF_RESOURCE_HANDLER_HELPER
|
||||||
|
redefine
|
||||||
|
do_get
|
||||||
|
end
|
||||||
|
|
||||||
|
CMS_ACCESS
|
||||||
|
|
||||||
|
REFACTORING_HELPER
|
||||||
|
|
||||||
|
create
|
||||||
|
make
|
||||||
|
|
||||||
|
feature -- execute
|
||||||
|
|
||||||
|
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||||
|
-- Execute request handler
|
||||||
|
do
|
||||||
|
execute_methods (req, res)
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- HTTP Methods
|
||||||
|
|
||||||
|
do_get (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||||
|
-- <Precursor>
|
||||||
|
local
|
||||||
|
r: CMS_RESPONSE
|
||||||
|
l_module: CMS_MODULE
|
||||||
|
s: STRING
|
||||||
|
lst: ARRAYED_LIST [CMS_MODULE]
|
||||||
|
do
|
||||||
|
create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, api)
|
||||||
|
r.set_title (r.translation ("CMS Installation ...", Void))
|
||||||
|
create s.make_from_string ("<h1>Modules</h1><ul>")
|
||||||
|
create lst.make (1)
|
||||||
|
across
|
||||||
|
api.setup.modules as ic
|
||||||
|
loop
|
||||||
|
l_module := ic.item
|
||||||
|
if api.is_module_installed (l_module) then
|
||||||
|
s.append ("<li>" + l_module.name + " is already installed.</li>%N")
|
||||||
|
else
|
||||||
|
lst.force (l_module)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
api.install
|
||||||
|
across
|
||||||
|
lst as ic
|
||||||
|
loop
|
||||||
|
l_module := ic.item
|
||||||
|
if api.is_module_installed (l_module) then
|
||||||
|
s.append ("<li>" + l_module.name + " was successfully installed.</li>%N")
|
||||||
|
else
|
||||||
|
s.append ("<li>" + l_module.name + " could not be installed!</li>%N")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
s.append ("</ul>")
|
||||||
|
r.set_main_content (s)
|
||||||
|
r.execute
|
||||||
|
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
|
||||||
@@ -71,7 +71,7 @@ feature {NONE} -- Initialization
|
|||||||
l_module: CMS_MODULE
|
l_module: CMS_MODULE
|
||||||
l_enabled_modules: CMS_MODULE_COLLECTION
|
l_enabled_modules: CMS_MODULE_COLLECTION
|
||||||
do
|
do
|
||||||
l_enabled_modules := setup.enabled_modules
|
l_enabled_modules := api.enabled_modules
|
||||||
across
|
across
|
||||||
l_enabled_modules as ic
|
l_enabled_modules as ic
|
||||||
loop
|
loop
|
||||||
|
|||||||
Reference in New Issue
Block a user