diff --git a/draft/application/cms/example/cms.ini b/draft/application/cms/example/cms.ini
index 362ca504..cf723b06 100644
--- a/draft/application/cms/example/cms.ini
+++ b/draft/application/cms/example/cms.ini
@@ -1,8 +1,8 @@
site.name=EWF Web CMS
#site.base_url=/demo
site.email=your@email.com
-root-dir=www
+root-dir=../www
var-dir=var
-files-dir=www/files
-themes-dir=www/themes
+files-dir=files
+themes-dir=../www/themes
theme=test
diff --git a/draft/application/cms/example/src/module/demo/demo_module.e b/draft/application/cms/example/src/module/demo/demo_module.e
index 8e028ead..685a310d 100644
--- a/draft/application/cms/example/src/module/demo/demo_module.e
+++ b/draft/application/cms/example/src/module/demo/demo_module.e
@@ -15,9 +15,8 @@ create
feature {NONE} -- Initialization
- make (a_service: like service)
+ make
do
- service := a_service
name := "demo"
version := "1.0"
description := "demo"
@@ -26,12 +25,13 @@ feature {NONE} -- Initialization
feature {CMS_SERVICE} -- Registration
- service: CMS_SERVICE
+ service: detachable 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)
+ service := a_service
+ a_service.map_uri_template ("/demo/date/{arg}", agent handle_date_time_demo (a_service, ?, ?))
+ a_service.map_uri_template ("/demo/format/{arg}", agent handle_format_demo (a_service, ?, ?))
end
feature -- Hooks
@@ -41,20 +41,20 @@ feature -- Hooks
local
-- lnk: CMS_MODULE_LINK
do
- create Result.make (3)
+ create Result.make (0)
-- 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)
+ handle_date_time_demo (cms: CMS_SERVICE; req: WSF_REQUEST; res: WSF_RESPONSE)
do
- (create {ANY_CMS_EXECUTION}.make_with_text (req, res, service, "
Demo::date/time
")).execute
+ (create {ANY_CMS_EXECUTION}.make_with_text (req, res, cms, "Demo::date/time
")).execute
end
- handle_format_demo (req: WSF_REQUEST; res: WSF_RESPONSE)
+ handle_format_demo (cms: CMS_SERVICE; req: WSF_REQUEST; res: WSF_RESPONSE)
do
- (create {ANY_CMS_EXECUTION}.make_with_text (req, res, service, "Demo::format
")).execute
+ (create {ANY_CMS_EXECUTION}.make_with_text (req, res, cms, "Demo::format
")).execute
end
end
diff --git a/draft/application/cms/example/src/web_cms.e b/draft/application/cms/example/src/web_cms.e
index d86e4b4a..3374cf65 100644
--- a/draft/application/cms/example/src/web_cms.e
+++ b/draft/application/cms/example/src/web_cms.e
@@ -8,10 +8,10 @@ class
WEB_CMS
inherit
- CMS_SERVICE
- redefine
- modules
- end
+-- CMS_SERVICE
+-- redefine
+-- modules
+-- end
WSF_DEFAULT_SERVICE
redefine
@@ -21,37 +21,6 @@ inherit
create
make_and_launch
-feature -- Initialization
-
- base_url: detachable READABLE_STRING_8
-
- server_base_url: detachable READABLE_STRING_8
- -- Base url (related to absolute path).
- --| Mainly pertinent when run from a standalone server.
- do
- Result := base_url
- end
-
- modules: ARRAYED_LIST [CMS_MODULE]
- local
- m: CMS_MODULE
- once
- Result := Precursor
-
- -- Others
- create {DEMO_MODULE} m.make (Current)
- m.enable
- Result.extend (m)
-
- create {SHUTDOWN_MODULE} m.make
- m.enable
- Result.extend (m)
-
--- create {EIFFEL_LOGIN_MODULE} m.make
--- m.enable
--- Result.extend (m)
- end
-
feature {NONE} -- Initialization
initialize
@@ -59,9 +28,8 @@ feature {NONE} -- Initialization
args: ARGUMENTS
cfg: detachable STRING
i,n: INTEGER
- cms_config: CMS_CONFIGURATION
- opts: WSF_SERVICE_LAUNCHER_OPTIONS_FROM_INI
do
+ --| Arguments
create args
from
i := 1
@@ -83,35 +51,80 @@ feature {NONE} -- Initialization
cfg := "cms.ini"
end
end
- if cfg /= Void then
- create cms_config.make_from_file (cfg)
--- (create {EXECUTION_ENVIRONMENT}).change_working_directory (dir)
- else
- create cms_config.make
- end
--| EWF settings
- create opts.make_from_file ("ewf.ini")
- service_options := opts
+ service_options := create {WSF_SERVICE_LAUNCHER_OPTIONS_FROM_INI}.make_from_file ("ewf.ini")
Precursor
- --| CMS settings
- base_url := cms_config.site_base_url (base_url)
- initialize_cms (cms_config)
- site_email := cms_config.site_email (site_email)
- site_name := cms_config.site_name (site_name)
-
- on_launched
+ --| CMS initialization
+ launch_cms (cms_setup (cfg))
end
- on_launched
+ cms_setup (a_cfg_fn: detachable READABLE_STRING_8): CMS_CUSTOM_SETUP
+ do
+ if a_cfg_fn /= Void then
+ create Result.make_from_file (a_cfg_fn)
+ else
+ create Result -- Default
+ end
+ setup_modules (Result)
+ setup_storage (Result)
+ end
+
+ launch_cms (a_setup: CMS_SETUP)
+ local
+ cms: CMS_SERVICE
+ do
+ create cms.make (a_setup)
+ on_launched (cms)
+ cms_service := cms
+ end
+
+feature -- Execution
+
+ cms_service: CMS_SERVICE
+
+ execute (req: WSF_REQUEST; res: WSF_RESPONSE)
+ do
+ cms_service.execute (req, res)
+ end
+
+feature -- Access
+
+ setup_modules (a_setup: CMS_SETUP)
+ local
+ m: CMS_MODULE
+ do
+ create {DEMO_MODULE} m.make
+ m.enable
+ a_setup.add_module (m)
+
+ create {SHUTDOWN_MODULE} m.make
+ m.enable
+ a_setup.add_module (m)
+
+ create {DEBUG_MODULE} m.make
+ m.enable
+ a_setup.add_module (m)
+ end
+
+ setup_storage (a_setup: CMS_SETUP)
+ do
+
+ end
+
+feature -- Event
+
+ on_launched (cms: CMS_SERVICE)
local
e: CMS_EMAIL
do
- create e.make (site_email, site_email, "[" + site_name + "] launched...", "The site [" + site_name + "] was launched at " + (create {DATE_TIME}.make_now_utc).out + " UTC.")
- mailer.safe_process_email (e)
+ create e.make (cms.site_email, cms.site_email, "[" + cms.site_name + "] launched...", "The site [" + cms.site_name + "] was launched at " + (create {DATE_TIME}.make_now_utc).out + " UTC.")
+ cms.mailer.safe_process_email (e)
end
+feature -- Helper
+
file_exists (fn: STRING): BOOLEAN
local
f: RAW_FILE
diff --git a/draft/application/cms/src/cms_configuration.e b/draft/application/cms/src/cms_configuration.e
index d805c3fb..2292c362 100644
--- a/draft/application/cms/src/cms_configuration.e
+++ b/draft/application/cms/src/cms_configuration.e
@@ -7,9 +7,6 @@ note
class
CMS_CONFIGURATION
---inherit
--- SHARED_EXECUTION_ENVIRONMENT
-
create
make,
make_from_file
@@ -26,6 +23,7 @@ feature {NONE} -- Initialization
-- Initialize `Current'.
do
make
+ configuration_location := a_filename
import (a_filename)
analyze
end
@@ -40,6 +38,8 @@ feature {NONE} -- Initialization
feature -- Access
+ configuration_location: detachable READABLE_STRING_8
+
option (a_name: READABLE_STRING_GENERAL): detachable ANY
do
Result := options.item (a_name.as_string_8)
@@ -161,7 +161,6 @@ feature -- Change
var_location := res
end
-
get_root_location
local
res: STRING_32
diff --git a/draft/application/cms/src/cms_custom_setup.e b/draft/application/cms/src/cms_custom_setup.e
new file mode 100644
index 00000000..bc37ed0f
--- /dev/null
+++ b/draft/application/cms/src/cms_custom_setup.e
@@ -0,0 +1,18 @@
+note
+ description: "Summary description for {CMS_CUSTOM_SETUP}."
+ author: ""
+ date: "$Date$"
+ revision: "$Revision$"
+
+class
+ CMS_CUSTOM_SETUP
+
+inherit
+ CMS_DEFAULT_SETUP
+
+create
+ default_create,
+ make,
+ make_from_file
+
+end
diff --git a/draft/application/cms/src/cms_default_setup.e b/draft/application/cms/src/cms_default_setup.e
new file mode 100644
index 00000000..f9b61bea
--- /dev/null
+++ b/draft/application/cms/src/cms_default_setup.e
@@ -0,0 +1,134 @@
+note
+ description: "Summary description for {CMS_DEFAULT_SETUP}."
+ author: ""
+ date: "$Date$"
+ revision: "$Revision$"
+
+class
+ CMS_DEFAULT_SETUP
+
+inherit
+ CMS_SETUP
+ redefine
+ default_create
+ end
+
+create
+ default_create,
+ make,
+ make_from_file
+
+feature {NONE} -- Initialization
+
+ make (a_cfg: CMS_CONFIGURATION)
+ do
+ configuration := a_cfg
+ default_create
+ end
+
+ make_from_file (fn: READABLE_STRING_8)
+ local
+ cfg: CMS_CONFIGURATION
+ do
+ create cfg.make_from_file (fn)
+ make (cfg)
+ end
+
+ default_create
+ do
+ Precursor
+ build_modules
+ build_storage
+ build_session_manager
+ build_auth_engine
+ build_mailer
+ end
+
+feature -- Access
+
+ modules: ARRAYED_LIST [CMS_MODULE]
+
+ storage: CMS_STORAGE
+ -- CMS persistent layer
+
+ session_manager: WSF_SESSION_MANAGER
+ -- CMS Session manager
+
+ auth_engine: CMS_AUTH_ENGINE
+ -- CMS Authentication engine
+
+ mailer: CMS_MAILER
+
+feature {NONE} -- Initialization
+
+ build_modules
+ local
+ m: CMS_MODULE
+ do
+ create modules.make (3)
+
+ -- Core
+ create {USER_MODULE} m.make
+ m.enable
+ modules.extend (m)
+
+ create {ADMIN_MODULE} m.make
+ m.enable
+ modules.extend (m)
+
+ create {NODE_MODULE} m.make
+ m.enable
+ modules.extend (m)
+ end
+
+ build_storage
+ local
+ dn: DIRECTORY_NAME
+ do
+ if attached configuration as cfg and then attached cfg.var_location as l_site_var_dir then
+ create dn.make_from_string (l_site_var_dir)
+ else
+ create dn.make
+ end
+ dn.extend ("_storage_")
+ create {CMS_SED_STORAGE} storage.make (dn.string)
+ end
+
+ build_session_manager
+ local
+ dn: DIRECTORY_NAME
+ do
+ if attached configuration as cfg and then attached cfg.var_location as l_site_var_dir then
+ create dn.make_from_string (l_site_var_dir)
+ else
+ create dn.make
+ end
+ dn.extend ("_storage_")
+ dn.extend ("_sessions_")
+ create {WSF_FS_SESSION_MANAGER} session_manager.make_with_folder (dn.string)
+ end
+
+ build_auth_engine
+ do
+ create {CMS_STORAGE_AUTH_ENGINE} auth_engine.make (storage)
+ end
+
+ build_mailer
+ local
+ ch_mailer: CMS_CHAIN_MAILER
+ st_mailer: CMS_STORAGE_MAILER
+ do
+ create st_mailer.make (storage)
+ create ch_mailer.make (st_mailer)
+ ch_mailer.set_next (create {CMS_SENDMAIL_MAILER})
+ mailer := ch_mailer
+ end
+
+feature -- Change
+
+ add_module (m: CMS_MODULE)
+ do
+ modules.force (m)
+ end
+
+end
diff --git a/draft/application/cms/src/cms_service.e b/draft/application/cms/src/cms_service.e
index 87cb6c6a..28657126 100644
--- a/draft/application/cms/src/cms_service.e
+++ b/draft/application/cms/src/cms_service.e
@@ -6,25 +6,28 @@ note
even for a specific handler.
]"
-deferred class
+class
CMS_SERVICE
-feature -- Initialization
+inherit
+ WSF_SERVICE
- initialize_cms (a_base_url: like base_url; a_cfg: detachable CMS_CONFIGURATION)
+create
+ make
+
+feature {NONE} -- Initialization
+
+ make (a_setup: CMS_SETUP)
local
cfg: detachable CMS_CONFIGURATION
do
- cfg := a_cfg
+ cfg := a_setup.configuration
if cfg = Void then
create cfg.make
end
- if a_base_url /= Void and then not a_base_url.is_empty then
- base_url := a_base_url
- else
- base_url := Void
- end
+ configuration := cfg
+ base_url := a_setup.base_url
site_url := cfg.site_url ("")
site_name := cfg.site_name ("EWF::CMS")
@@ -39,8 +42,14 @@ feature -- Initialization
compute_theme_resource_location
-
create content_types.make (3)
+
+ modules := a_setup.modules
+ storage := a_setup.storage
+ session_manager := a_setup.session_manager
+ auth_engine := a_setup.auth_engine
+ mailer := a_setup.mailer
+
initialize_storage
initialize_auth_engine
initialize_session_manager
@@ -50,23 +59,17 @@ feature -- Initialization
end
initialize_session_manager
- local
- dn: DIRECTORY_NAME
+-- local
+-- dn: DIRECTORY_NAME
do
- create dn.make_from_string (site_var_dir)
- dn.extend ("_storage_")
- dn.extend ("_sessions_")
- create {WSF_FS_SESSION_MANAGER} session_manager.make_with_folder (dn.string)
+-- create dn.make_from_string (site_var_dir)
+-- dn.extend ("_storage_")
+-- dn.extend ("_sessions_")
+-- create {WSF_FS_SESSION_MANAGER} session_manager.make_with_folder (dn.string)
end
initialize_storage
- local
- dn: DIRECTORY_NAME
--- u: CMS_USER
do
- create dn.make_from_string (site_var_dir)
- dn.extend ("_storage_")
- create {CMS_SED_STORAGE} storage.make (dn.string)
if not storage.has_user then
initialize_users
end
@@ -85,13 +88,13 @@ feature -- Initialization
initialize_mailer
local
- ch_mailer: CMS_CHAIN_MAILER
- st_mailer: CMS_STORAGE_MAILER
+-- ch_mailer: CMS_CHAIN_MAILER
+-- st_mailer: CMS_STORAGE_MAILER
do
- create st_mailer.make (storage)
- create ch_mailer.make (st_mailer)
- ch_mailer.set_next (create {CMS_SENDMAIL_MAILER})
- mailer := ch_mailer
+-- create st_mailer.make (storage)
+-- create ch_mailer.make (st_mailer)
+-- ch_mailer.set_next (create {CMS_SENDMAIL_MAILER})
+-- mailer := ch_mailer
end
initialize_router
@@ -133,31 +136,16 @@ feature -- Initialization
initialize_auth_engine
do
- create {CMS_STORAGE_AUTH_ENGINE} auth_engine.make (storage)
+-- create {CMS_STORAGE_AUTH_ENGINE} auth_engine.make (storage)
end
feature -- Access
+ configuration: CMS_CONFIGURATION
+
auth_engine: CMS_AUTH_ENGINE
- modules: ARRAYED_LIST [CMS_MODULE]
- local
- m: CMS_MODULE
- once
- create Result.make (10)
- -- Core
- create {USER_MODULE} m.make (Current)
- m.enable
- Result.extend (m)
-
- create {ADMIN_MODULE} m.make (Current)
- m.enable
- Result.extend (m)
-
- create {NODE_MODULE} m.make (Current)
- m.enable
- Result.extend (m)
- end
+ modules: LIST [CMS_MODULE]
feature -- Hook: menu_alter
@@ -313,18 +301,6 @@ feature -- URL related
base_url: detachable READABLE_STRING_8
-- Base url (related to the script path).
--- deferred
--- ensure
--- valid_base_url: (Result /= Void and then Result.is_empty) implies (Result.starts_with ("/") and not Result.ends_with ("/"))
--- end
-
--- server_base_url: detachable READABLE_STRING_8
--- -- Base url (related to absolute path).
--- deferred
--- ensure
--- valid_base_url: (Result /= Void and then Result.is_empty) implies (Result.starts_with ("/") and not Result.ends_with ("/"))
--- end
-
script_url: detachable READABLE_STRING_8
set_script_url (a_url: like script_url)
@@ -435,16 +411,10 @@ feature -- Core Execution
(create {HOME_CMS_EXECUTION}.make (req, res, Current)).execute
end
--- handle_theme (req: WSF_REQUEST; res: WSF_RESPONSE)
--- do
--- (create {THEME_CMS_EXECUTION}.make (req, res, Current)).execute
--- end
-
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
-- Default request handler if no other are relevant
local
e: CMS_EXECUTION
--- not_found: WSF_NOT_FOUND_RESPONSE
do
initialize_urls (req)
if attached router.dispatch_and_return_handler (req, res) as p then
@@ -452,8 +422,6 @@ feature -- Core Execution
else
create {NOT_FOUND_CMS_EXECUTION} e.make (req, res, Current)
e.execute
--- create not_found.make
--- res.send (not_found)
end
end
diff --git a/draft/application/cms/src/cms_setup.e b/draft/application/cms/src/cms_setup.e
new file mode 100644
index 00000000..09dff63b
--- /dev/null
+++ b/draft/application/cms/src/cms_setup.e
@@ -0,0 +1,62 @@
+note
+ description: "Summary description for {CMS_SETUP}."
+ author: ""
+ date: "$Date$"
+ revision: "$Revision$"
+
+deferred class
+ CMS_SETUP
+
+feature -- Initialization
+
+ initialize_storage (a_cms: CMS_SERVICE)
+ do
+
+ end
+
+feature -- Access
+
+ configuration: detachable CMS_CONFIGURATION
+
+ base_url: detachable READABLE_STRING_8
+
+ modules: LIST [CMS_MODULE]
+ deferred
+ end
+
+ storage: CMS_STORAGE
+ -- CMS persistent layer
+ deferred
+ end
+
+ session_manager: WSF_SESSION_MANAGER
+ -- CMS Session manager
+ deferred
+ end
+
+ auth_engine: CMS_AUTH_ENGINE
+ -- CMS Authentication engine
+ deferred
+ end
+
+ mailer: CMS_MAILER
+ -- CMS email engine
+ deferred
+ end
+
+feature -- Change
+
+ set_base_url (a_base_url: like base_url)
+ do
+ if a_base_url /= Void and then not a_base_url.is_empty then
+ base_url := a_base_url
+ else
+ base_url := Void
+ end
+ end
+
+ add_module (m: CMS_MODULE)
+ deferred
+ end
+
+end
diff --git a/draft/application/cms/src/modules/admin/admin_module.e b/draft/application/cms/src/modules/admin/admin_module.e
index a669ab28..6dd4c9bb 100644
--- a/draft/application/cms/src/modules/admin/admin_module.e
+++ b/draft/application/cms/src/modules/admin/admin_module.e
@@ -17,9 +17,8 @@ create
feature {NONE} -- Initialization
- make (a_service: like service)
+ make
do
- service := a_service
name := "admin"
version := "1.0"
description := "Set of service to administrate the site"
@@ -30,16 +29,17 @@ feature {NONE} -- Initialization
feature {CMS_SERVICE} -- Registration
- service: CMS_SERVICE
+ service: detachable CMS_SERVICE
register (a_service: CMS_SERVICE)
do
- a_service.map_uri ("/admin/", agent handle_admin)
- a_service.map_uri ("/admin/users/", agent handle_admin_users)
- a_service.map_uri ("/admin/blocks/", agent handle_admin_blocks)
- a_service.map_uri ("/admin/modules/", agent handle_admin_modules)
- a_service.map_uri ("/admin/logs/", agent handle_admin_logs)
- a_service.map_uri_template ("/admin/log/{log-id}", agent handle_admin_log_view)
+ service := a_service
+ a_service.map_uri ("/admin/", agent handle_admin (a_service, ?, ?))
+ a_service.map_uri ("/admin/users/", agent handle_admin_users (a_service, ?, ?))
+ a_service.map_uri ("/admin/blocks/", agent handle_admin_blocks (a_service, ?, ?))
+ a_service.map_uri ("/admin/modules/", agent handle_admin_modules (a_service, ?, ?))
+ a_service.map_uri ("/admin/logs/", agent handle_admin_logs (a_service, ?, ?))
+ a_service.map_uri_template ("/admin/log/{log-id}", agent handle_admin_log_view (a_service, ?, ?))
a_service.add_menu_alter_hook (Current)
end
@@ -57,43 +57,40 @@ 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
+ create Result.make (0)
end
- handle_admin (req: WSF_REQUEST; res: WSF_RESPONSE)
+feature -- Handler
+
+ handle_admin (cms: CMS_SERVICE; req: WSF_REQUEST; res: WSF_RESPONSE)
do
- (create {ADMIN_CMS_EXECUTION}.make (req, res, service)).execute
+ (create {ADMIN_CMS_EXECUTION}.make (req, res, cms)).execute
end
- handle_admin_users (req: WSF_REQUEST; res: WSF_RESPONSE)
+ handle_admin_users (cms: CMS_SERVICE; req: WSF_REQUEST; res: WSF_RESPONSE)
do
- (create {ADMIN_USERS_CMS_EXECUTION}.make (req, res, service)).execute
+ (create {ADMIN_USERS_CMS_EXECUTION}.make (req, res, cms)).execute
end
- handle_admin_blocks (req: WSF_REQUEST; res: WSF_RESPONSE)
+ handle_admin_blocks (cms: CMS_SERVICE; req: WSF_REQUEST; res: WSF_RESPONSE)
do
- (create {ADMIN_BLOCKS_CMS_EXECUTION}.make (req, res, service)).execute
+ (create {ADMIN_BLOCKS_CMS_EXECUTION}.make (req, res, cms)).execute
end
- handle_admin_modules (req: WSF_REQUEST; res: WSF_RESPONSE)
+ handle_admin_modules (cms: CMS_SERVICE; req: WSF_REQUEST; res: WSF_RESPONSE)
do
- (create {ADMIN_MODULES_CMS_EXECUTION}.make (req, res, service)).execute
+ (create {ADMIN_MODULES_CMS_EXECUTION}.make (req, res, cms)).execute
end
- handle_admin_logs (req: WSF_REQUEST; res: WSF_RESPONSE)
+ handle_admin_logs (cms: CMS_SERVICE; req: WSF_REQUEST; res: WSF_RESPONSE)
do
- (create {ADMIN_LOGS_CMS_EXECUTION}.make (req, res, service)).execute
+ (create {ADMIN_LOGS_CMS_EXECUTION}.make (req, res, cms)).execute
end
- handle_admin_log_view (req: WSF_REQUEST; res: WSF_RESPONSE)
+ handle_admin_log_view (cms: CMS_SERVICE; req: WSF_REQUEST; res: WSF_RESPONSE)
do
- (create {LOG_VIEW_CMS_EXECUTION}.make (req, res, service)).execute
+ (create {LOG_VIEW_CMS_EXECUTION}.make (req, res, cms)).execute
end
diff --git a/draft/application/cms/src/modules/debug/debug_module.e b/draft/application/cms/src/modules/debug/debug_module.e
new file mode 100644
index 00000000..fa1c2de7
--- /dev/null
+++ b/draft/application/cms/src/modules/debug/debug_module.e
@@ -0,0 +1,136 @@
+note
+ description: "Summary description for {DEBUG_MODULE}."
+ date: "$Date$"
+ revision: "$Revision$"
+
+class
+ DEBUG_MODULE
+
+inherit
+ CMS_MODULE
+
+-- CMS_HOOK_BLOCK
+
+ CMS_HOOK_AUTO_REGISTER
+
+create
+ make
+
+feature {NONE} -- Initialization
+
+ make
+ do
+ name := "debug"
+ version := "1.0"
+ description := "Debug"
+ package := "cms"
+ end
+
+feature {CMS_SERVICE} -- Registration
+
+ service: detachable CMS_SERVICE
+
+ register (a_service: CMS_SERVICE)
+ do
+ service := a_service
+ a_service.map_uri_template ("/debug/", agent handle_debug (a_service, ?, ?))
+ end
+
+feature -- Hooks
+
+ links: HASH_TABLE [CMS_MODULE_LINK, STRING]
+ -- Link indexed by path
+ local
+-- lnk: CMS_MODULE_LINK
+ do
+ create Result.make (0)
+-- create lnk.make ("Date/time demo")
+-- lnk.set_callback (agent process_date_time_demo, <<"arg">>)
+-- Result["/demo/date/{arg}"] := lnk
+ end
+
+feature -- Hooks
+
+-- block_list: ITERABLE [like {CMS_BLOCK}.name]
+-- do
+-- Result := <<"debug-info">>
+-- end
+
+-- get_block_view (a_block_id: detachable READABLE_STRING_8; a_execution: CMS_EXECUTION)
+-- local
+-- b: CMS_CONTENT_BLOCK
+-- do
+-- create b.make ("debug-info", "Debug", "... ", a_execution.formats.plain_text)
+-- a_execution.add_block (b, Void)
+-- end
+
+feature -- Handler
+
+ handle_debug (cms: CMS_SERVICE; req: WSF_REQUEST; res: WSF_RESPONSE)
+ local
+ e: CMS_EXECUTION
+ s: STRING
+ do
+ if req.is_get_request_method then
+ create {ANY_CMS_EXECUTION} e.make (req, res, cms)
+ e.set_title ("DEBUG")
+
+ create s.make_empty
+ append_info_to ("Name", cms.site_name, e, s)
+ append_info_to ("Url", cms.site_url, e, s)
+
+ if attached cms.configuration as cfg and then attached cfg.configuration_location as l_loc then
+ s.append ("
")
+ append_info_to ("Configuration file", l_loc, e, s)
+ end
+
+ s.append ("
")
+
+ append_info_to ("Current dir", (create {EXECUTION_ENVIRONMENT}).current_working_path.name, e, s)
+ append_info_to ("Base url", cms.base_url, e, s)
+ append_info_to ("Script url", cms.script_url, e, s)
+ s.append ("
")
+ append_info_to ("Dir", cms.site_dir, e, s)
+ append_info_to ("Var dir", cms.site_var_dir, e, s)
+ s.append ("
")
+ append_info_to ("Theme", cms.theme_name, e, s)
+ append_info_to ("Theme location", cms.theme_resource_location, e, s)
+ s.append ("
")
+ append_info_to ("Files location", cms.files_location, e, s)
+ s.append ("
")
+
+ append_info_to ("Url", e.url ("/", Void), e, s)
+ if attached e.user as u then
+ append_info_to ("User", u.name, e, s)
+ append_info_to ("User url", e.user_url (u), e, s)
+
+ end
+
+ e.set_main_content (s)
+ else
+ create {NOT_FOUND_CMS_EXECUTION} e.make (req, res, cms)
+ end
+ e.execute
+ end
+
+ append_info_to (n: READABLE_STRING_8; v: detachable READABLE_STRING_GENERAL; e: CMS_EXECUTION; t: STRING)
+ do
+ t.append ("")
+ t.append ("" + n + ": ")
+ if v /= Void then
+ t.append (e.html_encoded (v))
+ end
+ t.append ("")
+ end
+
+note
+ copyright: "Copyright (c) 1984-2013, Eiffel Software and others"
+ license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
+ source: "[
+ Eiffel Software
+ 5949 Hollister Ave., Goleta, CA 93117 USA
+ Telephone 805-685-1006, Fax 805-685-6869
+ Website http://www.eiffel.com
+ Customer support http://support.eiffel.com
+ ]"
+end
diff --git a/draft/application/cms/src/modules/node/node_module.e b/draft/application/cms/src/modules/node/node_module.e
index 72724c44..8dc62272 100644
--- a/draft/application/cms/src/modules/node/node_module.e
+++ b/draft/application/cms/src/modules/node/node_module.e
@@ -19,9 +19,8 @@ create
feature {NONE} -- Initialization
- make (a_service: like service)
+ make
do
- service := a_service
name := "node"
version := "1.0"
description := "Service to manage content based on 'node'"
@@ -32,20 +31,21 @@ feature {NONE} -- Initialization
feature {CMS_SERVICE} -- Registration
- service: CMS_SERVICE
+ service: detachable CMS_SERVICE
register (a_service: CMS_SERVICE)
local
h: CMS_HANDLER
do
- a_service.map_uri ("/node/add", agent handle_node_add)
- a_service.map_uri_template ("/node/add/{type}", agent handle_node_add)
+ service := a_service
+ a_service.map_uri ("/node/add", agent handle_node_add (a_service, ?, ?))
+ a_service.map_uri_template ("/node/add/{type}", agent handle_node_add (a_service, ?, ?))
- create {CMS_HANDLER} h.make (agent handle_node_view)
+ create {CMS_HANDLER} h.make (agent handle_node_view (a_service, ?, ?))
a_service.router.map (create {WSF_URI_TEMPLATE_MAPPING}.make ("/node/{nid}", h))
a_service.router.map (create {WSF_URI_TEMPLATE_MAPPING}.make ("/node/{nid}/view", h))
- a_service.map_uri_template ("/node/{nid}/edit", agent handle_node_edit)
+ a_service.map_uri_template ("/node/{nid}/edit", agent handle_node_edit (a_service, ?, ?))
a_service.add_content_type (create {CMS_PAGE_CONTENT_TYPE}.make)
@@ -86,28 +86,23 @@ 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
+ create Result.make (0)
end
- handle_node_view (req: WSF_REQUEST; res: WSF_RESPONSE)
+ handle_node_view (cms: CMS_SERVICE; req: WSF_REQUEST; res: WSF_RESPONSE)
do
- (create {NODE_VIEW_CMS_EXECUTION}.make (req, res, service)).execute
+ (create {NODE_VIEW_CMS_EXECUTION}.make (req, res, cms)).execute
end
- handle_node_edit (req: WSF_REQUEST; res: WSF_RESPONSE)
+ handle_node_edit (cms: CMS_SERVICE; req: WSF_REQUEST; res: WSF_RESPONSE)
do
- (create {NODE_EDIT_CMS_EXECUTION}.make (req, res, service)).execute
+ (create {NODE_EDIT_CMS_EXECUTION}.make (req, res, cms)).execute
end
- handle_node_add (req: WSF_REQUEST; res: WSF_RESPONSE)
+ handle_node_add (cms: CMS_SERVICE; req: WSF_REQUEST; res: WSF_RESPONSE)
do
- (create {NODE_ADD_CMS_EXECUTION}.make (req, res, service)).execute
+ (create {NODE_ADD_CMS_EXECUTION}.make (req, res, cms)).execute
end
end
diff --git a/draft/application/cms/src/modules/user/user_login_cms_execution.e b/draft/application/cms/src/modules/user/user_login_cms_execution.e
deleted file mode 100644
index 9fd23483..00000000
--- a/draft/application/cms/src/modules/user/user_login_cms_execution.e
+++ /dev/null
@@ -1,112 +0,0 @@
-note
- description: "[
- ]"
-
-class
- USER_LOGIN_CMS_EXECUTION
-
-inherit
- CMS_EXECUTION
-
- CMS_AUTH_ENGINE
-
-create
- make
-
-feature -- Status
-
- valid_credential (u,p: READABLE_STRING_32): BOOLEAN
- do
- Result := service.storage.is_valid_credential (u, p)
- end
-
-feature -- Execution
-
- process
- -- Computed response message.
- local
- auth_engine: CMS_AUTH_ENGINE
- l_url: detachable READABLE_STRING_8
- err: detachable STRING_8
- b: STRING_8
- u: detachable STRING_32
- do
- if request.is_request_method ("post") then
- if
- attached {WSF_STRING} request.form_parameter (form_login_name) as s_login and then not s_login.is_empty and
- attached {WSF_STRING} request.form_parameter (form_password_name) as s_passwd and then not s_passwd.is_empty
- then
- auth_engine := Current
- u := s_login.value
- if attached service.storage.user_by_name (u) as l_user and auth_engine.valid_credential (u, s_passwd.value) then
- login (l_user, request)
- else
- err := "Authentication failed for [" + html_encoded (u) + "]"
- end
- if attached {WSF_STRING} request.form_parameter ("form-destination") as s_dest then
- l_url := request.script_url (s_dest.value)
- end
- end
- else
- if
- attached {WSF_STRING} request.item ("destination") as s_dest
- then
- l_url := request.script_url (s_dest.value)
- end
- end
-
- if l_url = Void then
- l_url := request.script_url ("/user")
- end
-
- if authenticated then
- set_redirection (l_url)
- set_title ("Login")
- create b.make_empty
- b.append ("Login
%N")
- set_main_content (b)
- else
- set_title ("Login")
- create b.make_empty
- b.append ("Login
%N")
-
- if err /= Void then
- b.append ("" + err + "
")
- end
-
- b.append ("%N")
-
- set_main_content (b)
- end
- end
-
- form_login_name: STRING = "login"
- form_password_name: STRING = "password"
-
-end
diff --git a/draft/application/cms/src/modules/user/user_module.e b/draft/application/cms/src/modules/user/user_module.e
index 44996556..06482de4 100644
--- a/draft/application/cms/src/modules/user/user_module.e
+++ b/draft/application/cms/src/modules/user/user_module.e
@@ -19,9 +19,8 @@ create
feature {NONE} -- Initialization
- make (a_service: like service)
+ make
do
- service := a_service
name := "user"
version := "1.0"
description := "Users management"
@@ -32,22 +31,23 @@ feature {NONE} -- Initialization
feature {CMS_SERVICE} -- Registration
- service: CMS_SERVICE
+ service: detachable CMS_SERVICE
register (a_service: CMS_SERVICE)
local
h: CMS_HANDLER
do
--- a_service.map_uri ("/user", agent handle_login)
- a_service.map_uri ("/user/logout", agent handle_logout)
- a_service.map_uri ("/user/register", agent handle_register)
- a_service.map_uri ("/user/password", agent handle_request_new_password)
+ service := a_service
- create {CMS_HANDLER} h.make (agent handle_user)
+ a_service.map_uri ("/user/logout", agent handle_logout (a_service, ?, ?))
+ a_service.map_uri ("/user/register", agent handle_register (a_service, ?, ?))
+ a_service.map_uri ("/user/password", agent handle_request_new_password (a_service, ?, ?))
+
+ create {CMS_HANDLER} h.make (agent handle_user (a_service, ?, ?))
a_service.router.map (create {WSF_URI_TEMPLATE_MAPPING}.make ("/user/{uid}", h))
a_service.router.map (create {WSF_URI_MAPPING}.make_trailing_slash_ignored ("/user", h))
- a_service.map_uri_template ("/user/{uid}/edit", agent handle_edit)
- a_service.map_uri_template ("/user/reset/{uid}/{last-signed}/{extra}", agent handle_reset_password)
+ a_service.map_uri_template ("/user/{uid}/edit", agent handle_edit (a_service, ?, ?))
+ a_service.map_uri_template ("/user/reset/{uid}/{last-signed}/{extra}", agent handle_reset_password (a_service, ?, ?))
a_service.add_menu_alter_hook (Current)
a_service.add_block_hook (Current)
@@ -104,53 +104,40 @@ 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
+ create Result.make (0)
end
--- handle_login (req: WSF_REQUEST; res: WSF_RESPONSE)
--- do
--- (create {USER_LOGIN_CMS_EXECUTION}.make (req, res, service)).execute
--- end
+feature -- Handlers
- handle_logout (req: WSF_REQUEST; res: WSF_RESPONSE)
+ handle_logout (cms: CMS_SERVICE; req: WSF_REQUEST; res: WSF_RESPONSE)
do
- (create {USER_LOGOUT_CMS_EXECUTION}.make (req, res, service)).execute
+ (create {USER_LOGOUT_CMS_EXECUTION}.make (req, res, cms)).execute
end
- handle_user (req: WSF_REQUEST; res: WSF_RESPONSE)
+ handle_user (cms: CMS_SERVICE; req: WSF_REQUEST; res: WSF_RESPONSE)
do
- (create {USER_CMS_EXECUTION}.make (req, res, service)).execute
+ (create {USER_CMS_EXECUTION}.make (req, res, cms)).execute
end
- handle_edit (req: WSF_REQUEST; res: WSF_RESPONSE)
+ handle_edit (cms: CMS_SERVICE; req: WSF_REQUEST; res: WSF_RESPONSE)
do
- (create {USER_EDIT_CMS_EXECUTION}.make (req, res, service)).execute
+ (create {USER_EDIT_CMS_EXECUTION}.make (req, res, cms)).execute
end
--- handle_account (req: WSF_REQUEST; res: WSF_RESPONSE)
--- do
--- (create {USER_ACCOUNT_CMS_EXECUTION}.make (req, res, service)).execute
--- end
-
- handle_register (req: WSF_REQUEST; res: WSF_RESPONSE)
+ handle_register (cms: CMS_SERVICE; req: WSF_REQUEST; res: WSF_RESPONSE)
do
- (create {USER_REGISTER_CMS_EXECUTION}.make (req, res, service)).execute
+ (create {USER_REGISTER_CMS_EXECUTION}.make (req, res, cms)).execute
end
- handle_request_new_password (req: WSF_REQUEST; res: WSF_RESPONSE)
+ handle_request_new_password (cms: CMS_SERVICE; req: WSF_REQUEST; res: WSF_RESPONSE)
do
- (create {USER_NEW_PASSWORD_CMS_EXECUTION}.make (req, res, service)).execute
+ (create {USER_NEW_PASSWORD_CMS_EXECUTION}.make (req, res, cms)).execute
end
- handle_reset_password (req: WSF_REQUEST; res: WSF_RESPONSE)
+ handle_reset_password (cms: CMS_SERVICE; req: WSF_REQUEST; res: WSF_RESPONSE)
do
- (create {USER_RESET_PASSWORD_CMS_EXECUTION}.make (req, res, service)).execute
+ (create {USER_RESET_PASSWORD_CMS_EXECUTION}.make (req, res, cms)).execute
end