diff --git a/cms/src/configuration/cms_default_setup.e b/cms/src/configuration/cms_default_setup.e
index eabc20c..76dcab2 100644
--- a/cms/src/configuration/cms_default_setup.e
+++ b/cms/src/configuration/cms_default_setup.e
@@ -17,7 +17,6 @@ feature {NONE} -- Initialization
make (a_layout: CMS_LAYOUT)
do
- create error_handler.make
layout := a_layout
create configuration.make (layout)
initialize
@@ -27,7 +26,6 @@ feature {NONE} -- Initialization
do
configure
create modules.make (3)
- build_api_service
build_mailer
initialize_modules
end
@@ -85,49 +83,6 @@ feature -- Access
end
- build_api_service
- local
- l_database: DATABASE_CONNECTION
- l_retry: BOOLEAN
- l_message: STRING
- do
- if not l_retry then
- to_implement ("Refactor database setup")
- if attached (create {JSON_CONFIGURATION}).new_database_configuration (layout.application_config_path) as l_database_config then
- create {DATABASE_CONNECTION_MYSQL} l_database.login_with_connection_string (l_database_config.connection_string)
- create api_service.make (create {CMS_STORAGE_MYSQL}.make (l_database))
- else
- create {DATABASE_CONNECTION_NULL} l_database.make_common
- create api_service.make (create {CMS_STORAGE_NULL})
- end
- else
- to_implement ("Workaround code, persistence layer does not implement yet this kind of error handling.")
- -- error hanling.
- create {DATABASE_CONNECTION_NULL} l_database.make_common
- create api_service.make (create {CMS_STORAGE_NULL})
- create l_message.make (1024)
- if attached ((create {EXCEPTION_MANAGER}).last_exception) as l_exception then
- if attached l_exception.description as l_description then
- l_message.append (l_description.as_string_32)
- l_message.append ("%N%N")
- elseif attached l_exception.trace as l_trace then
- l_message.append (l_trace)
- l_message.append ("%N%N")
- else
- l_message.append (l_exception.out)
- l_message.append ("%N%N")
- end
- else
- l_message.append ("The application crash without available information")
- l_message.append ("%N%N")
- end
- error_handler.add_custom_error (0, " Database Connection ", l_message)
- end
- rescue
- l_retry := True
- retry
- end
-
build_auth_engine
do
to_implement ("Not implemented authentication")
diff --git a/cms/src/configuration/cms_setup.e b/cms/src/configuration/cms_setup.e
index 0e6189d..58b0e31 100644
--- a/cms/src/configuration/cms_setup.e
+++ b/cms/src/configuration/cms_setup.e
@@ -14,9 +14,6 @@ feature -- Access
layout: CMS_LAYOUT
-- CMS layout.
- api_service: CMS_API_SERVICE
- -- cms api service.
-
is_html: BOOLEAN
-- api with progressive enhancements css and js, server side rendering.
deferred
@@ -32,12 +29,6 @@ feature -- Access
deferred
end
-
-feature -- Status Report
-
- error_handler: ERROR_HANDLER
- -- Error handler.
-
feature -- Access: Site
site_id: READABLE_STRING_8
@@ -54,6 +45,10 @@ feature -- Access: Site
files_location: PATH
+ front_page_path: detachable READABLE_STRING_8
+ -- Optional path defining the front page.
+ -- By default "" or "/".
+
feature -- Access: Theme
themes_location: PATH
diff --git a/cms/src/hooks/cms_hook_block.e b/cms/src/hooks/cms_hook_block.e
index 54b493a..89d001c 100644
--- a/cms/src/hooks/cms_hook_block.e
+++ b/cms/src/hooks/cms_hook_block.e
@@ -13,10 +13,12 @@ inherit
feature -- Hook
block_list: ITERABLE [like {CMS_BLOCK}.name]
+ -- List of block names, managed by current object.
deferred
end
- get_block_view (a_block_id: detachable READABLE_STRING_8; a_response: CMS_RESPONSE)
+ get_block_view (a_block_id: READABLE_STRING_8; a_response: CMS_RESPONSE)
+ -- Get block object identified by `a_block_id' and associate with `a_response'.
deferred
end
diff --git a/cms/src/kernel/link/cms_menu_system.e b/cms/src/kernel/link/cms_menu_system.e
index 470aba3..5565c5d 100644
--- a/cms/src/kernel/link/cms_menu_system.e
+++ b/cms/src/kernel/link/cms_menu_system.e
@@ -20,9 +20,9 @@ feature {NONE} -- Initialization
do
to_implement ("Refactor, take the info from a Database or Configuration file.")
create items.make (5)
- force (create {CMS_MENU}.make ("primary_nav", 3)) -- primary menu
- force (create {CMS_MENU}.make_with_title ("management_nav", "Management", 3)) -- secondary in admin view.
- force (create {CMS_MENU}.make_with_title ("secondary_nav", "Navigation", 3)) -- secondary
+ force (create {CMS_MENU}.make ("primary", 3)) -- primary menu
+ force (create {CMS_MENU}.make_with_title ("management", "Management", 3)) -- secondary in admin view.
+ force (create {CMS_MENU}.make_with_title ("secondary", "Navigation", 3)) -- secondary
force (create {CMS_MENU}.make_with_title ("user", "User", 3)) -- first_side_bar
end
@@ -41,18 +41,30 @@ feature -- Access
end
main_menu: CMS_MENU
+ obsolete
+ "Use `primary_menu' [Nov/2014]"
do
- Result := item ("primary_nav")
+ Result := primary_menu
+ end
+
+ primary_menu: CMS_MENU
+ do
+ Result := item ("primary")
+ end
+
+ secondary_menu: CMS_MENU
+ do
+ Result := item ("secondary")
end
management_menu: CMS_MENU
do
- Result := item ("management_nav")
+ Result := item ("management")
end
navigation_menu: CMS_MENU
do
- Result := item ("secondary_nav")
+ Result := item ("navigation")
end
user_menu: CMS_MENU
diff --git a/cms/src/modules/basic_auth/basic_auth_module.e b/cms/src/modules/basic_auth/basic_auth_module.e
index 1afac3e..555d2cb 100644
--- a/cms/src/modules/basic_auth/basic_auth_module.e
+++ b/cms/src/modules/basic_auth/basic_auth_module.e
@@ -18,67 +18,56 @@ create
feature {NONE} -- Initialization
- make (a_config: CMS_SETUP)
+ make
do
name := "basic auth"
version := "1.0"
description := "Service to manage basic authentication"
package := "core"
- config := a_config
end
- config: CMS_SETUP
- -- Node configuration.
-
feature -- Access: router
- router: WSF_ROUTER
+ router (a_api: CMS_API): WSF_ROUTER
-- Node router.
do
create Result.make (2)
- configure_api_login (Result)
- configure_api_logoff (Result)
+ configure_api_login (a_api, Result)
+ configure_api_logoff (a_api, Result)
end
feature -- Access: filter
- filters: detachable LIST [WSF_FILTER]
+ filters (a_api: CMS_API): detachable LIST [WSF_FILTER]
-- Possibly list of Filter's module.
do
create {ARRAYED_LIST [WSF_FILTER]} Result.make (2)
Result.extend (create {CORS_FILTER})
- Result.extend (create {BASIC_AUTH_FILTER}.make (config))
+ Result.extend (create {BASIC_AUTH_FILTER}.make (a_api))
end
feature {NONE} -- Implementation: routes
- configure_api_login (a_router: WSF_ROUTER)
+ configure_api_login (api: CMS_API; a_router: WSF_ROUTER)
local
l_bal_handler: BASIC_AUTH_LOGIN_HANDLER
l_methods: WSF_REQUEST_METHODS
do
- create l_bal_handler.make (config)
+ create l_bal_handler.make (api)
create l_methods
l_methods.enable_get
a_router.handle_with_request_methods ("/basic_auth_login", l_bal_handler, l_methods)
end
- configure_api_logoff (a_router: WSF_ROUTER)
+ configure_api_logoff (api: CMS_API; a_router: WSF_ROUTER)
local
l_bal_handler: BASIC_AUTH_LOGOFF_HANDLER
l_methods: WSF_REQUEST_METHODS
do
- create l_bal_handler.make (config)
+ create l_bal_handler.make (api)
create l_methods
l_methods.enable_get
a_router.handle_with_request_methods ("/basic_auth_logoff", l_bal_handler, l_methods)
end
-
-feature -- Hooks
-
- register_hooks (a_response: CMS_RESPONSE)
- do
- end
-
end
diff --git a/cms/src/modules/basic_auth/filter/basic_auth_filter.e b/cms/src/modules/basic_auth/filter/basic_auth_filter.e
index d5abd0a..31ddb21 100644
--- a/cms/src/modules/basic_auth/filter/basic_auth_filter.e
+++ b/cms/src/modules/basic_auth/filter/basic_auth_filter.e
@@ -31,8 +31,8 @@ feature -- Basic operations
-- A valid user
if (attached l_auth.type as l_auth_type and then l_auth_type.is_case_insensitive_equal_general ("basic")) and then
attached l_auth.login as l_auth_login and then attached l_auth.password as l_auth_password then
- if api_service.is_valid_credential (l_auth_login, l_auth_password) then
- if attached api_service.user_by_name (l_auth_login) as l_user then
+ if api.is_valid_credential (l_auth_login, l_auth_password) then
+ if attached api.user_by_name (l_auth_login) as l_user then
req.set_execution_variable ("user", l_user)
execute_next (req, res)
else
diff --git a/cms/src/modules/basic_auth/handler/basic_auth_logoff_handler.e b/cms/src/modules/basic_auth/handler/basic_auth_logoff_handler.e
index ecf3e7b..300eafe 100644
--- a/cms/src/modules/basic_auth/handler/basic_auth_logoff_handler.e
+++ b/cms/src/modules/basic_auth/handler/basic_auth_logoff_handler.e
@@ -50,7 +50,7 @@ feature -- HTTP Methods
if attached req.query_parameter ("prompt") as l_prompt then
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
else
- create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, setup)
+ create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, api)
l_page.set_status_code ({HTTP_STATUS_CODE}.unauthorized)
l_page.execute
end
diff --git a/cms/src/modules/cms_module.e b/cms/src/modules/cms_module.e
index f7d1eac..ce0a9a2 100644
--- a/cms/src/modules/cms_module.e
+++ b/cms/src/modules/cms_module.e
@@ -20,27 +20,25 @@ feature -- Access
feature -- Router
- router: WSF_ROUTER
+ router (a_api: CMS_API): WSF_ROUTER
-- Router configuration.
require
is_enabled: is_enabled
deferred
end
-
-
feature -- Hooks configuration
register_hooks (a_response: CMS_RESPONSE)
-- Module hooks configuration.
require
is_enabled: is_enabled
- deferred
+ do
end
feature -- Filter
- filters: detachable LIST [WSF_FILTER]
+ filters (a_api: CMS_API): detachable LIST [WSF_FILTER]
-- Optional list of filter for Current module.
require
is_enabled: is_enabled
diff --git a/cms/src/modules/node/handler/node_content_handler.e b/cms/src/modules/node/handler/node_content_handler.e
index 4232053..11ebd9d 100644
--- a/cms/src/modules/node/handler/node_content_handler.e
+++ b/cms/src/modules/node/handler/node_content_handler.e
@@ -69,8 +69,8 @@ feature -- HTTP Methods
if attached current_user_name (req) then
-- Existing node
if attached {WSF_STRING} req.path_parameter ("id") as l_id then
- if l_id.is_integer and then attached {CMS_NODE} api_service.node (l_id.integer_value) as l_node then
- create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, setup)
+ if l_id.is_integer and then attached {CMS_NODE} api.node (l_id.integer_value) as l_node then
+ create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, api)
l_page.add_variable (l_node.content, "node_content")
l_page.add_variable (l_id.value, "id")
l_page.execute
@@ -78,7 +78,7 @@ feature -- HTTP Methods
do_error (req, res, l_id)
end
else
- (create {ERROR_500_CMS_RESPONSE}.make (req, res, setup)).execute
+ (create {ERROR_500_CMS_RESPONSE}.make (req, res, api)).execute
end
else
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
@@ -91,19 +91,19 @@ feature -- HTTP Methods
do
if attached current_user_name (req) then
if attached {WSF_STRING} req.path_parameter ("id") as l_id then
- if l_id.is_integer and then attached {CMS_NODE} api_service.node (l_id.integer_value) as l_node then
+ if l_id.is_integer and then attached {CMS_NODE} api.node (l_id.integer_value) as l_node then
if attached {WSF_STRING} req.form_parameter ("method") as l_method then
if l_method.is_case_insensitive_equal ("PUT") then
do_put (req, res)
else
- (create {ERROR_500_CMS_RESPONSE}.make (req, res, setup)).execute
+ (create {ERROR_500_CMS_RESPONSE}.make (req, res, api)).execute
end
end
else
do_error (req, res, l_id)
end
else
- (create {ERROR_500_CMS_RESPONSE}.make (req, res, setup)).execute
+ (create {ERROR_500_CMS_RESPONSE}.make (req, res, api)).execute
end
else
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
@@ -118,16 +118,16 @@ feature -- HTTP Methods
to_implement ("Check if user has permissions")
if attached current_user (req) as l_user then
if attached {WSF_STRING} req.path_parameter ("id") as l_id then
- if l_id.is_integer and then attached {CMS_NODE} api_service.node (l_id.integer_value) as l_node then
+ if l_id.is_integer and then attached {CMS_NODE} api.node (l_id.integer_value) as l_node then
u_node := extract_data_form (req)
u_node.set_id (l_id.integer_value)
- api_service.update_node_content (l_user.id, u_node.id, u_node.content)
+ api.update_node_content (l_user.id, u_node.id, u_node.content)
(create {CMS_GENERIC_RESPONSE}).new_response_redirect (req, res, req.absolute_script_url (""))
else
do_error (req, res, l_id)
end
else
- (create {ERROR_500_CMS_RESPONSE}.make (req, res, setup)).execute
+ (create {ERROR_500_CMS_RESPONSE}.make (req, res, api)).execute
end
else
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
@@ -140,7 +140,7 @@ feature -- Error
local
l_page: CMS_RESPONSE
do
- create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, setup)
+ create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, api)
l_page.add_variable (req.absolute_script_url (req.path_info), "request")
if a_id.is_integer then
-- resource not found
diff --git a/cms/src/modules/node/handler/node_handler.e b/cms/src/modules/node/handler/node_handler.e
index c4e5bf9..2dcb47f 100644
--- a/cms/src/modules/node/handler/node_handler.e
+++ b/cms/src/modules/node/handler/node_handler.e
@@ -68,8 +68,8 @@ feature -- HTTP Methods
do
-- Existing node
if attached {WSF_STRING} req.path_parameter ("id") as l_id then
- if l_id.is_integer and then attached {CMS_NODE} api_service.node (l_id.integer_value) as l_node then
- create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, setup)
+ if l_id.is_integer and then attached {CMS_NODE} api.node (l_id.integer_value) as l_node then
+ create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, api)
l_page.add_variable (l_node, "node")
l_page.execute
else
@@ -89,14 +89,14 @@ feature -- HTTP Methods
to_implement ("Check user permissions!!!")
if attached current_user (req) as l_user then
if attached {WSF_STRING} req.path_parameter ("id") as l_id then
- if l_id.is_integer and then attached {CMS_NODE} api_service.node (l_id.integer_value) as l_node then
+ if l_id.is_integer and then attached {CMS_NODE} api.node (l_id.integer_value) as l_node then
if attached {WSF_STRING} req.form_parameter ("method") as l_method then
if l_method.is_case_insensitive_equal ("DELETE") then
do_delete (req, res)
elseif l_method.is_case_insensitive_equal ("PUT") then
do_put (req, res)
else
- (create {ERROR_500_CMS_RESPONSE}.make (req, res, setup)).execute
+ (create {ERROR_500_CMS_RESPONSE}.make (req, res, api)).execute
end
end
else
@@ -106,7 +106,7 @@ feature -- HTTP Methods
-- New node
u_node := extract_data_form (req)
u_node.set_author (l_user)
- api_service.new_node (u_node)
+ api.new_node (u_node)
(create {CMS_GENERIC_RESPONSE}).new_response_redirect (req, res, req.absolute_script_url (""))
end
else
@@ -122,16 +122,16 @@ feature -- HTTP Methods
if attached current_user (req) as l_user then
if attached {WSF_STRING} req.path_parameter ("id") as l_id then
- if l_id.is_integer and then attached {CMS_NODE} api_service.node (l_id.integer_value) as l_node then
+ if l_id.is_integer and then attached {CMS_NODE} api.node (l_id.integer_value) as l_node then
u_node := extract_data_form (req)
u_node.set_id (l_id.integer_value)
- api_service.update_node (l_user.id,u_node)
+ api.update_node (l_user.id,u_node)
(create {CMS_GENERIC_RESPONSE}).new_response_redirect (req, res, req.absolute_script_url (""))
else
do_error (req, res, l_id)
end
else
- (create {ERROR_500_CMS_RESPONSE}.make (req, res, setup)).execute
+ (create {ERROR_500_CMS_RESPONSE}.make (req, res, api)).execute
end
else
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
@@ -144,14 +144,14 @@ feature -- HTTP Methods
do
if attached current_user_name (req) then
if attached {WSF_STRING} req.path_parameter ("id") as l_id then
- if l_id.is_integer and then attached {CMS_NODE} api_service.node (l_id.integer_value) as l_node then
- api_service.delete_node (l_id.integer_value)
+ if l_id.is_integer and then attached {CMS_NODE} api.node (l_id.integer_value) as l_node then
+ api.delete_node (l_id.integer_value)
(create {CMS_GENERIC_RESPONSE}).new_response_redirect (req, res, req.absolute_script_url (""))
else
do_error (req, res, l_id)
end
else
- (create {ERROR_500_CMS_RESPONSE}.make (req, res, setup)).execute
+ (create {ERROR_500_CMS_RESPONSE}.make (req, res, api)).execute
end
else
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
@@ -165,7 +165,7 @@ feature -- Error
local
l_page: CMS_RESPONSE
do
- create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, setup)
+ create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, api)
l_page.add_variable (req.absolute_script_url (req.path_info), "request")
if a_id.is_integer then
-- resource not found
@@ -186,7 +186,7 @@ feature {NONE} -- Node
l_page: CMS_RESPONSE
do
if attached current_user_name (req) then
- create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, setup)
+ create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, api)
l_page.add_variable (setup.is_html, "html")
l_page.add_variable (setup.is_web, "web")
l_page.execute
diff --git a/cms/src/modules/node/handler/node_summary_handler.e b/cms/src/modules/node/handler/node_summary_handler.e
index 585a050..01553b2 100644
--- a/cms/src/modules/node/handler/node_summary_handler.e
+++ b/cms/src/modules/node/handler/node_summary_handler.e
@@ -68,8 +68,8 @@ feature -- HTTP Methods
if attached current_user_name (req) then
-- Existing node
if attached {WSF_STRING} req.path_parameter ("id") as l_id then
- if l_id.is_integer and then attached {CMS_NODE} api_service.node (l_id.integer_value) as l_node then
- create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, setup)
+ if l_id.is_integer and then attached {CMS_NODE} api.node (l_id.integer_value) as l_node then
+ create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, api)
l_page.add_variable (l_id.value, "id")
l_page.add_variable (l_node.summary, "node_summary")
l_page.execute
@@ -77,7 +77,7 @@ feature -- HTTP Methods
do_error (req, res, l_id)
end
else
- (create {ERROR_500_CMS_RESPONSE}.make (req, res, setup)).execute
+ (create {ERROR_500_CMS_RESPONSE}.make (req, res, api)).execute
end
else
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
@@ -90,19 +90,19 @@ feature -- HTTP Methods
do
if attached current_user_name (req) then
if attached {WSF_STRING} req.path_parameter ("id") as l_id then
- if l_id.is_integer and then attached {CMS_NODE} api_service.node (l_id.integer_value) as l_node then
+ if l_id.is_integer and then attached {CMS_NODE} api.node (l_id.integer_value) as l_node then
if attached {WSF_STRING} req.form_parameter ("method") as l_method then
if l_method.is_case_insensitive_equal ("PUT") then
do_put (req, res)
else
- (create {ERROR_500_CMS_RESPONSE}.make (req, res, setup)).execute
+ (create {ERROR_500_CMS_RESPONSE}.make (req, res, api)).execute
end
end
else
do_error (req, res, l_id)
end
else
- (create {ERROR_500_CMS_RESPONSE}.make (req, res, setup)).execute
+ (create {ERROR_500_CMS_RESPONSE}.make (req, res, api)).execute
end
else
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
@@ -116,16 +116,16 @@ feature -- HTTP Methods
do
if attached current_user (req) as l_user then
if attached {WSF_STRING} req.path_parameter ("id") as l_id then
- if l_id.is_integer and then attached {CMS_NODE} api_service.node (l_id.integer_value) as l_node then
+ if l_id.is_integer and then attached {CMS_NODE} api.node (l_id.integer_value) as l_node then
u_node := extract_data_form (req)
u_node.set_id (l_id.integer_value)
- api_service.update_node_summary (l_user.id,u_node.id, u_node.summary)
+ api.update_node_summary (l_user.id,u_node.id, u_node.summary)
(create {CMS_GENERIC_RESPONSE}).new_response_redirect (req, res, req.absolute_script_url (""))
else
do_error (req, res, l_id)
end
else
- (create {ERROR_500_CMS_RESPONSE}.make (req, res, setup)).execute
+ (create {ERROR_500_CMS_RESPONSE}.make (req, res, api)).execute
end
else
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
@@ -140,7 +140,7 @@ feature -- Error
local
l_page: CMS_RESPONSE
do
- create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, setup)
+ create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, api)
l_page.add_variable (req.absolute_script_url (req.path_info), "request")
if a_id.is_integer then
-- resource not found
diff --git a/cms/src/modules/node/handler/node_title_handler.e b/cms/src/modules/node/handler/node_title_handler.e
index e1baa7b..0cfe30d 100644
--- a/cms/src/modules/node/handler/node_title_handler.e
+++ b/cms/src/modules/node/handler/node_title_handler.e
@@ -68,8 +68,8 @@ feature -- HTTP Methods
if attached current_user_name (req) as l_user then
-- Existing node
if attached {WSF_STRING} req.path_parameter ("id") as l_id then
- if l_id.is_integer and then attached {CMS_NODE} api_service.node (l_id.integer_value) as l_node then
- create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, setup)
+ if l_id.is_integer and then attached {CMS_NODE} api.node (l_id.integer_value) as l_node then
+ create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, api)
l_page.add_variable (l_node.title, "node_title")
l_page.add_variable (l_id.value, "id")
l_page.execute
@@ -77,7 +77,7 @@ feature -- HTTP Methods
do_error (req, res, l_id)
end
else
- (create {ERROR_500_CMS_RESPONSE}.make (req, res, setup)).execute
+ (create {ERROR_500_CMS_RESPONSE}.make (req, res, api)).execute
end
else
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
@@ -89,19 +89,19 @@ feature -- HTTP Methods
do
if attached current_user_name (req) as l_user then
if attached {WSF_STRING} req.path_parameter ("id") as l_id then
- if l_id.is_integer and then attached {CMS_NODE} api_service.node (l_id.integer_value) as l_node then
+ if l_id.is_integer and then attached {CMS_NODE} api.node (l_id.integer_value) as l_node then
if attached {WSF_STRING} req.form_parameter ("method") as l_method then
if l_method.is_case_insensitive_equal ("PUT") then
do_put (req, res)
else
- (create {ERROR_500_CMS_RESPONSE}.make (req, res, setup)).execute
+ (create {ERROR_500_CMS_RESPONSE}.make (req, res, api)).execute
end
end
else
do_error (req, res, l_id)
end
else
- (create {ERROR_500_CMS_RESPONSE}.make (req, res, setup)).execute
+ (create {ERROR_500_CMS_RESPONSE}.make (req, res, api)).execute
end
else
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
@@ -116,16 +116,16 @@ feature -- HTTP Methods
to_implement ("Check if user has permissions")
if attached current_user (req) as l_user then
if attached {WSF_STRING} req.path_parameter ("id") as l_id then
- if l_id.is_integer and then attached {CMS_NODE} api_service.node (l_id.integer_value) as l_node then
+ if l_id.is_integer and then attached {CMS_NODE} api.node (l_id.integer_value) as l_node then
u_node := extract_data_form (req)
u_node.set_id (l_id.integer_value)
- api_service.update_node_title (l_user.id,u_node.id, u_node.title)
+ api.update_node_title (l_user.id,u_node.id, u_node.title)
(create {CMS_GENERIC_RESPONSE}).new_response_redirect (req, res, req.absolute_script_url (""))
else
do_error (req, res, l_id)
end
else
- (create {ERROR_500_CMS_RESPONSE}.make (req, res, setup)).execute
+ (create {ERROR_500_CMS_RESPONSE}.make (req, res, api)).execute
end
else
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
@@ -139,7 +139,7 @@ feature -- Error
local
l_page: CMS_RESPONSE
do
- create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, setup)
+ create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, api)
l_page.add_variable (req.absolute_script_url (req.path_info), "request")
if a_id.is_integer then
-- resource not found
diff --git a/cms/src/modules/node/handler/nodes_handler.e b/cms/src/modules/node/handler/nodes_handler.e
index 4251f70..651e8e7 100644
--- a/cms/src/modules/node/handler/nodes_handler.e
+++ b/cms/src/modules/node/handler/nodes_handler.e
@@ -52,8 +52,8 @@ feature -- HTTP Methods
-- At the moment the template is hardcoded, but we can
-- get them from the configuration file and load them into
-- the setup class.
- create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, setup)
- l_page.add_variable (api_service.nodes, "nodes")
+ create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, api)
+ l_page.add_variable (api.nodes, "nodes")
l_page.execute
end
end
diff --git a/cms/src/modules/node/node_module.e b/cms/src/modules/node/node_module.e
index e1e59a5..f5c7349 100644
--- a/cms/src/modules/node/node_module.e
+++ b/cms/src/modules/node/node_module.e
@@ -9,6 +9,9 @@ class
inherit
CMS_MODULE
+ redefine
+ register_hooks
+ end
CMS_HOOK_MENU_ALTER
@@ -20,72 +23,74 @@ create
feature {NONE} -- Initialization
- make (a_config: CMS_SETUP)
+ make (a_setup: CMS_SETUP)
-- Create Current module, disabled by default.
do
name := "node"
version := "1.0"
description := "Service to manage content based on 'node'"
package := "core"
- config := a_config
+ config := a_setup
end
+
config: CMS_SETUP
-- Node configuration.
feature -- Access: router
- router: WSF_ROUTER
+ router (a_api: CMS_API): WSF_ROUTER
-- Node router.
do
create Result.make (5)
- configure_api_node (Result)
- configure_api_nodes (Result)
- configure_api_node_title (Result)
- configure_api_node_summary (Result)
- configure_api_node_content (Result)
+ configure_api_node (a_api, Result)
+ configure_api_nodes (a_api, Result)
+ configure_api_node_title (a_api, Result)
+ configure_api_node_summary (a_api, Result)
+ configure_api_node_content (a_api, Result)
end
feature {NONE} -- Implementation: routes
- configure_api_node (a_router: WSF_ROUTER)
+ configure_api_node (api: CMS_API; a_router: WSF_ROUTER)
local
l_node_handler: NODE_HANDLER
l_methods: WSF_REQUEST_METHODS
do
- create l_node_handler.make (config)
+ create l_node_handler.make (api)
create l_methods
l_methods.enable_get
l_methods.enable_post
l_methods.enable_put
a_router.handle_with_request_methods ("/node", l_node_handler, l_methods)
- create l_node_handler.make (config)
+ create l_node_handler.make (api)
create l_methods
l_methods.enable_get
l_methods.enable_post
l_methods.enable_put
l_methods.enable_delete
a_router.handle_with_request_methods ("/node/{id}", l_node_handler, l_methods)
+ a_router.handle_with_request_methods ("/nodes/", create {WSF_URI_AGENT_HANDLER}.make (agent do_get_nodes (?,?, api)), a_router.methods_get)
end
- configure_api_nodes (a_router: WSF_ROUTER)
+ configure_api_nodes (api: CMS_API; a_router: WSF_ROUTER)
local
l_nodes_handler: NODES_HANDLER
l_methods: WSF_REQUEST_METHODS
do
- create l_nodes_handler.make (config)
+ create l_nodes_handler.make (api)
create l_methods
l_methods.enable_get
a_router.handle_with_request_methods ("/nodes", l_nodes_handler, l_methods)
end
- configure_api_node_summary (a_router: WSF_ROUTER)
+ configure_api_node_summary (api: CMS_API; a_router: WSF_ROUTER)
local
l_report_handler: NODE_SUMMARY_HANDLER
l_methods: WSF_REQUEST_METHODS
do
- create l_report_handler.make (config)
+ create l_report_handler.make (api)
create l_methods
l_methods.enable_get
l_methods.enable_post
@@ -93,13 +98,12 @@ feature {NONE} -- Implementation: routes
a_router.handle_with_request_methods ("/node/{id}/summary", l_report_handler, l_methods)
end
-
- configure_api_node_title (a_router: WSF_ROUTER)
+ configure_api_node_title (api: CMS_API; a_router: WSF_ROUTER)
local
l_report_handler: NODE_TITLE_HANDLER
l_methods: WSF_REQUEST_METHODS
do
- create l_report_handler.make (config)
+ create l_report_handler.make (api)
create l_methods
l_methods.enable_get
l_methods.enable_post
@@ -107,12 +111,12 @@ feature {NONE} -- Implementation: routes
a_router.handle_with_request_methods ("/node/{id}/title", l_report_handler, l_methods)
end
- configure_api_node_content (a_router: WSF_ROUTER)
+ configure_api_node_content (api: CMS_API; a_router: WSF_ROUTER)
local
l_report_handler: NODE_CONTENT_HANDLER
l_methods: WSF_REQUEST_METHODS
do
- create l_report_handler.make (config)
+ create l_report_handler.make (api)
create l_methods
l_methods.enable_get
l_methods.enable_post
@@ -120,7 +124,6 @@ feature {NONE} -- Implementation: routes
a_router.handle_with_request_methods ("/node/{id}/content", l_report_handler, l_methods)
end
-
feature -- Hooks
register_hooks (a_response: CMS_RESPONSE)
@@ -134,26 +137,33 @@ feature -- Hooks
Result := <<"node-info">>
end
- get_block_view (a_block_id: detachable READABLE_STRING_8; a_response: CMS_RESPONSE)
--- local
+ get_block_view (a_block_id: READABLE_STRING_8; a_response: CMS_RESPONSE)
+ local
-- b: CMS_CONTENT_BLOCK
do
--- if
--- a_execution.is_front and then
--- attached a_execution.user as u
--- then
--- create b.make ("node-info", "Node", "Node ...", a_execution.formats.plain_text)
--- a_execution.add_block (b, Void)
--- end
+-- create b.make (a_block_id, "Block::node", "This is a block test", Void)
+-- a_response.add_block (b, "sidebar_second")
end
menu_alter (a_menu_system: CMS_MENU_SYSTEM; a_response: CMS_RESPONSE)
local
lnk: CMS_LOCAL_LINK
- perms: detachable ARRAYED_LIST [READABLE_STRING_8]
+-- perms: detachable ARRAYED_LIST [READABLE_STRING_8]
do
- create lnk.make ("List of nodes", "/nodes")
- a_menu_system.main_menu.extend (lnk)
+ create lnk.make ("List of nodes", a_response.url ("/nodes", Void))
+ a_menu_system.primary_menu.extend (lnk)
+ end
+
+feature -- Handler
+
+ do_get_nodes (req: WSF_REQUEST; res: WSF_RESPONSE; a_api: CMS_API)
+ local
+ r: CMS_RESPONSE
+ do
+ create {NOT_IMPLEMENTED_ERROR_CMS_RESPONSE} r.make (req, res, a_api)
+ r.set_main_content ("Sorry: listing the CMS nodes is not yet implemented.")
+ r.add_block (create {CMS_CONTENT_BLOCK}.make ("nodes_warning", Void, "/nodes/ is not yet implemented", Void), "highlighted")
+ r.execute
end
end
diff --git a/cms/src/service/cms_api_service.e b/cms/src/service/cms_api.e
similarity index 55%
rename from cms/src/service/cms_api_service.e
rename to cms/src/service/cms_api.e
index a7d4c8f..877bbf7 100644
--- a/cms/src/service/cms_api_service.e
+++ b/cms/src/service/cms_api.e
@@ -1,33 +1,86 @@
note
- description: "Summary description for {CMS_API_SERVICE}."
+ description: "Summary description for {CMS_API}."
date: "$Date$"
revision: "$Revision$"
class
- CMS_API_SERVICE
+ CMS_API
inherit
SHARED_ERROR
- REFACTORING_HELPER
+ REFACTORING_HELPER
create
make
feature -- Initialize
- make (a_storage: CMS_STORAGE)
+ make (a_setup: CMS_SETUP)
-- Create the API service with an storege `a_storage'.
do
- storage := a_storage
+ setup := a_setup
+ create error_handler.make
+ initialize
set_successful
ensure
- storage_set: storage = a_storage
+-- storage_set: storage = a_storage
+ end
+
+ setup: CMS_SETUP
+ -- CMS setup.
+
+ initialize
+ local
+ l_database: DATABASE_CONNECTION
+ retried: BOOLEAN
+ l_message: STRING
+ do
+ if not retried then
+ to_implement ("Refactor database setup")
+ if attached (create {JSON_CONFIGURATION}).new_database_configuration (setup.layout.application_config_path) as l_database_config then
+ create {DATABASE_CONNECTION_MYSQL} l_database.login_with_connection_string (l_database_config.connection_string)
+ create {CMS_STORAGE_MYSQL} storage.make (l_database)
+ else
+ create {DATABASE_CONNECTION_NULL} l_database.make_common
+ create {CMS_STORAGE_NULL} storage
+ end
+ else
+ to_implement ("Workaround code, persistence layer does not implement yet this kind of error handling.")
+ -- error hanling.
+ create {DATABASE_CONNECTION_NULL} l_database.make_common
+ create {CMS_STORAGE_NULL} storage
+ create l_message.make (1024)
+ if attached ((create {EXCEPTION_MANAGER}).last_exception) as l_exception then
+ if attached l_exception.description as l_description then
+ l_message.append (l_description.as_string_32)
+ l_message.append ("%N%N")
+ elseif attached l_exception.trace as l_trace then
+ l_message.append (l_trace)
+ l_message.append ("%N%N")
+ else
+ l_message.append (l_exception.out)
+ l_message.append ("%N%N")
+ end
+ else
+ l_message.append ("The application crash without available information")
+ l_message.append ("%N%N")
+ end
+ error_handler.add_custom_error (0, " Database Connection ", l_message)
+ end
+ rescue
+ retried := True
+ retry
end
feature -- Access
+ error_handler: ERROR_HANDLER
+ -- Error handler.
+
+feature -- Status Report
+
is_valid_credential (l_auth_login, l_auth_password: READABLE_STRING_32): BOOLEAN
do
Result := storage.is_valid_credential (l_auth_login, l_auth_password)
diff --git a/cms/src/service/cms_api_options.e b/cms/src/service/cms_api_options.e
new file mode 100644
index 0000000..1a5dc6e
--- /dev/null
+++ b/cms/src/service/cms_api_options.e
@@ -0,0 +1,17 @@
+note
+ description: "Summary description for {CMS_API_OPTIONS}."
+ author: ""
+ date: "$Date$"
+ revision: "$Revision$"
+
+class
+ CMS_API_OPTIONS
+
+inherit
+ WSF_API_OPTIONS
+
+create
+ make,
+ make_from_manifest
+
+end
diff --git a/cms/src/service/cms_request_util.e b/cms/src/service/cms_request_util.e
index e9e26c8..e6a1be6 100644
--- a/cms/src/service/cms_request_util.e
+++ b/cms/src/service/cms_request_util.e
@@ -9,6 +9,8 @@ deferred class
inherit
+ CMS_ENCODERS
+
REFACTORING_HELPER
feature -- User
@@ -21,8 +23,6 @@ feature -- User
if attached {CMS_USER} current_user (req) as l_user then
Result := l_user.name
end
-
-
end
current_user (req: WSF_REQUEST): detachable CMS_USER
diff --git a/cms/src/service/cms_service.e b/cms/src/service/cms_service.e
index 84b67e6..973bc6e 100644
--- a/cms/src/service/cms_service.e
+++ b/cms/src/service/cms_service.e
@@ -41,11 +41,11 @@ create
feature {NONE} -- Initialization
- make (a_setup: CMS_SETUP)
+ make (a_api: CMS_API)
-- Build a CMS service with `a_setup' configuration.
do
- setup := a_setup
- configuration := a_setup.configuration
+ api := a_api
+ configuration := a_api.setup.configuration
initialize
end
@@ -103,36 +103,41 @@ feature -- Settings: router
--