Added weight into to the CMS_LINK and provide a `sort' feature for CMS_MENU and related.

Protected cms service from registering many time the same module type.
Moved library/persistence/implementation/* under library/persistence/.
Moved site/www/themes to site/themes
For SQLite storage driver, auto create sqlite db file using associated sql script (to be completed).
Added code in demo module to reuse storage for module purpose.
Always call sql_post_execution in sql_query and sql_change, and not anymore by the callers.
Removed is_web and is_html from {CMS_SETUP}, it was not used.
Reused SHARED_*_ENCODER in CMS_ENCODERS
Added CMS_API.logger rather than using directly the SHARED_LOGGER.log ...
Centralize the implementation of current_user in CMS_REQUEST_UTIL
Removed the inheritance on WSF_FILTER for node handlers, since it is useless and unused.
Added CMS_NODE_API and CMS_USER_API
Prefix html id for block generated html items with "block-", to avoid css name conflict on "main", "content" or similar.
Code cleaning
This commit is contained in:
2015-02-16 13:01:06 +01:00
parent a810b1176c
commit 8d59d25ace
165 changed files with 1430 additions and 2206 deletions

View File

@@ -1,18 +1,24 @@
note
description: "This module allows the use of HTTP Basic Authentication to restrict access by looking up users in the given providers."
date: "$Date: 2014-11-13 16:23:47 +0100 (jeu., 13 nov. 2014) $"
revision: "$Revision: 96085 $"
date: "$Date: 2015-02-09 22:29:56 +0100 (lun., 09 févr. 2015) $"
revision: "$Revision: 96596 $"
class
BASIC_AUTH_MODULE
inherit
CMS_MODULE
redefine
filters
filters,
register_hooks
end
CMS_HOOK_AUTO_REGISTER
CMS_HOOK_BLOCK
CMS_HOOK_MENU_SYSTEM_ALTER
create
make
@@ -70,4 +76,46 @@ feature {NONE} -- Implementation: routes
a_router.handle_with_request_methods ("/basic_auth_logoff", l_bal_handler, l_methods)
end
feature -- Hooks configuration
register_hooks (a_response: CMS_RESPONSE)
-- Module hooks configuration.
do
-- a_response.subscribe_to_block_hook (Current)
end
feature -- Hooks
block_list: ITERABLE [like {CMS_BLOCK}.name]
-- List of block names, managed by current object.
do
Result := <<"basic_auth_login_form">>
end
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'.
do
if a_block_id.same_string ("basic_auth_login_form") then
end
end
menu_system_alter (a_menu_system: CMS_MENU_SYSTEM; a_response: CMS_RESPONSE)
-- Hook execution on collection of menu contained by `a_menu_system'
-- for related response `a_response'.
local
lnk: CMS_LOCAL_LINK
do
if attached a_response.current_user (a_response.request) as u then
create lnk.make ("Logout", "/basic_auth_logoff")
else
create lnk.make ("Login", "/basic_auth_login")
end
-- if not a_menu_system.primary_menu.has (lnk) then
lnk.set_weight (99)
a_menu_system.primary_menu.extend (lnk)
-- end
end
end

View File

@@ -1,13 +1,12 @@
note
description: "Processes a HTTP request's BASIC authorization headers, putting the result into the execution variable user."
date: "$Date: 2014-11-13 16:23:47 +0100 (jeu., 13 nov. 2014) $"
revision: "$Revision: 96085 $"
date: "$Date: 2015-02-13 13:08:13 +0100 (ven., 13 févr. 2015) $"
revision: "$Revision: 96616 $"
class
BASIC_AUTH_FILTER
inherit
WSF_URI_TEMPLATE_HANDLER
CMS_HANDLER
WSF_FILTER
@@ -22,22 +21,24 @@ feature -- Basic operations
local
l_auth: HTTP_AUTHORIZATION
do
log.write_debug (generator + ".execute " )
api.logger.put_debug (generator + ".execute ", Void)
create l_auth.make (req.http_authorization)
if attached req.raw_header_data as l_raw_data then
log.write_debug (generator + ".execute " + l_raw_data )
api.logger.put_debug (generator + ".execute " + l_raw_data, Void)
end
-- 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.is_valid_credential (l_auth_login, l_auth_password) then
if attached api.user_by_name (l_auth_login) as l_user then
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.user_api.is_valid_credential (l_auth_login, l_auth_password) then
if attached api.user_api.user_by_name (l_auth_login) as l_user then
debug ("refactor_fixme")
fixme ("Maybe we need to store in the credentials in a shared context SECURITY_CONTEXT")
-- req.set_execution_variable ("security_content", create SECURITY_CONTEXT.make (l_user))
-- other authentication filters (OpenID, etc) should implement the same approach.
end
req.set_execution_variable ("user", l_user)
set_current_user (req, l_user)
execute_next (req, res)
else
debug ("refactor_fixme")
@@ -45,11 +46,11 @@ feature -- Basic operations
end
end
else
log.write_error (generator + ".execute login_valid failed for: " + l_auth_login )
api.logger.put_error (generator + ".execute login_valid failed for: " + l_auth_login, Void)
execute_next (req, res)
end
else
log.write_error (generator + ".execute Not valid")
api.logger.put_error (generator + ".execute Not valid", Void)
execute_next (req, res)
end
end

View File

@@ -1,7 +1,7 @@
note
description: "Summary description for {BASIC_AUTH_LOGIN_HANDLER}."
date: "$Date: 2014-11-13 16:23:47 +0100 (jeu., 13 nov. 2014) $"
revision: "$Revision: 96085 $"
date: "$Date: 2015-02-13 13:08:13 +0100 (ven., 13 févr. 2015) $"
revision: "$Revision: 96616 $"
class
BASIC_AUTH_LOGIN_HANDLER
@@ -48,7 +48,7 @@ feature -- HTTP Methods
do_get (req: WSF_REQUEST; res: WSF_RESPONSE)
-- <Precursor>
do
log.write_information(generator + ".do_get Processing basic auth login")
api.logger.put_information (generator + ".do_get Processing basic auth login", Void)
if attached {STRING_32} current_user_name (req) as l_user then
(create {CMS_GENERIC_RESPONSE}).new_response_redirect (req, res, req.absolute_script_url("/"))
else

View File

@@ -1,7 +1,7 @@
note
description: "Summary description for {BASIC_AUTH_LOGOFF_HANDLER}."
date: "$Date: 2014-11-13 16:23:47 +0100 (jeu., 13 nov. 2014) $"
revision: "$Revision: 96085 $"
date: "$Date: 2015-02-13 13:08:13 +0100 (ven., 13 févr. 2015) $"
revision: "$Revision: 96616 $"
class
BASIC_AUTH_LOGOFF_HANDLER
@@ -46,7 +46,7 @@ feature -- HTTP Methods
local
l_page: CMS_RESPONSE
do
log.write_information(generator + ".do_get Processing basic auth logoff")
api.logger.put_information (generator + ".do_get Processing basic auth logoff", Void)
if attached req.query_parameter ("prompt") as l_prompt then
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
else

View File

@@ -1,8 +1,8 @@
note
description: "Summary description for {CMS_MODULE_COLLECTION}."
author: ""
date: "$Date: 2014-11-13 16:23:47 +0100 (jeu., 13 nov. 2014) $"
revision: "$Revision: 96085 $"
date: "$Date: 2015-02-09 22:29:56 +0100 (lun., 09 févr. 2015) $"
revision: "$Revision: 96596 $"
class
CMS_MODULE_COLLECTION
@@ -36,6 +36,21 @@ feature -- Status report
Result := modules.has (a_module)
end
has_module_with_same_type (a_module: CMS_MODULE): BOOLEAN
-- Has module of type `a_type' already inserted?
local
l_type: TYPE [detachable CMS_MODULE]
do
l_type := a_module.generating_type
across
modules as ic
until
Result
loop
Result := ic.item = a_module or else ic.item.generating_type = l_type
end
end
count: INTEGER
-- Number of modules.
do
@@ -47,7 +62,9 @@ feature -- Element change
extend (a_module: CMS_MODULE)
-- Add module
do
modules.force (a_module)
if not has (a_module) then
modules.force (a_module)
end
end
remove (a_module: CMS_MODULE)

View File

@@ -0,0 +1,98 @@
note
description: "Summary description for {CMS_NODE_API}."
author: ""
date: "$Date: 2015-02-13 13:08:13 +0100 (ven., 13 févr. 2015) $"
revision: "$Revision: 96616 $"
class
CMS_NODE_API
inherit
CMS_MODULE_API
REFACTORING_HELPER
create
make
feature -- Access: Node
nodes_count: INTEGER_64
do
Result := storage.nodes_count
end
nodes: LIST [CMS_NODE]
-- List of nodes.
do
Result := storage.nodes
end
recent_nodes (a_offset, a_rows: INTEGER): LIST [CMS_NODE]
-- List of the `a_rows' most recent nodes starting from `a_offset'.
do
Result := storage.recent_nodes (a_offset, a_rows)
end
node (a_id: INTEGER_64): detachable CMS_NODE
-- Node by ID.
do
debug ("refactor_fixme")
fixme ("Check preconditions")
end
Result := storage.node_by_id (a_id)
end
feature -- Change: Node
new_node (a_node: CMS_NODE)
-- Add a new node `a_node'
require
no_id: not a_node.has_id
do
storage.new_node (a_node)
end
delete_node (a_node: CMS_NODE)
-- Delete `a_node'.
do
if a_node.has_id then
storage.delete_node (a_node)
end
end
update_node (a_node: CMS_NODE)
-- Update node `a_node' data.
do
storage.update_node (a_node)
end
update_node_title (a_user_id: like {CMS_USER}.id; a_node_id: like {CMS_NODE}.id; a_title: READABLE_STRING_32)
-- Update node title, with user identified by `a_id', with node id `a_node_id' and a new title `a_title'.
do
debug ("refactor_fixme")
fixme ("Check preconditions")
end
storage.update_node_title (a_user_id, a_node_id, a_title)
end
update_node_summary (a_user_id: like {CMS_USER}.id; a_node_id: like {CMS_NODE}.id; a_summary: READABLE_STRING_32)
-- Update node summary, with user identified by `a_user_id', with node id `a_node_id' and a new summary `a_summary'.
do
debug ("refactor_fixme")
fixme ("Check preconditions")
end
storage.update_node_summary (a_user_id, a_node_id, a_summary)
end
update_node_content (a_user_id: like {CMS_USER}.id; a_node_id: like {CMS_NODE}.id; a_content: READABLE_STRING_32)
-- Update node content, with user identified by `a_user_id', with node id `a_node_id' and a new content `a_content'.
do
debug ("refactor_fixme")
fixme ("Check preconditions")
end
storage.update_node_content (a_user_id, a_node_id, a_content)
end
end

View File

@@ -0,0 +1,16 @@
note
description: "Summary description for {CMS_NODE_HANDLER}."
author: ""
date: "$Date: 2015-02-13 13:08:13 +0100 (ven., 13 févr. 2015) $"
revision: "$Revision: 96616 $"
deferred class
CMS_NODE_HANDLER
inherit
CMS_MODULE_HANDLER [CMS_NODE_API]
rename
module_api as node_api
end
end

View File

@@ -1,16 +1,13 @@
note
description: "Summary description for {NEW_CONTENT_HANDLER}."
date: "$Date: 2015-01-27 19:15:02 +0100 (mar., 27 janv. 2015) $"
revision: "$Revision: 96542 $"
date: "$Date: 2015-02-13 13:08:13 +0100 (ven., 13 févr. 2015) $"
revision: "$Revision: 96616 $"
class
NODE_CONTENT_HANDLER
inherit
CMS_HANDLER
WSF_FILTER
CMS_NODE_HANDLER
WSF_URI_HANDLER
rename
@@ -44,19 +41,18 @@ feature -- execute
-- Execute request handler
do
execute_methods (req, res)
execute_next (req, res)
end
uri_execute (req: WSF_REQUEST; res: WSF_RESPONSE)
-- Execute request handler
do
execute_methods (req, res)
execute (req, res)
end
uri_template_execute (req: WSF_REQUEST; res: WSF_RESPONSE)
-- Execute request handler
do
execute_methods (req, res)
execute (req, res)
end
feature -- HTTP Methods
@@ -69,7 +65,7 @@ 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.node (l_id.integer_value) as l_node then
if l_id.is_integer and then attached 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")
@@ -91,7 +87,7 @@ 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.node (l_id.integer_value) as l_node then
if l_id.is_integer and then attached 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)
@@ -118,10 +114,10 @@ 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.node (l_id.integer_value) as l_node then
if l_id.is_integer and then attached node_api.node (l_id.integer_value) as l_node then
u_node := extract_data_form (req)
u_node.set_id (l_id.value.to_integer_64)
api.update_node_content (l_user.id, u_node.id, u_node.content)
node_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)

View File

@@ -1,15 +1,13 @@
note
description: "Summary description for {NODE_HANDLER}."
date: "$Date: 2015-01-27 19:15:02 +0100 (mar., 27 janv. 2015) $"
revision: "$Revision: 96542 $"
date: "$Date: 2015-02-13 13:08:13 +0100 (ven., 13 févr. 2015) $"
revision: "$Revision: 96616 $"
class
NODE_HANDLER
inherit
CMS_HANDLER
WSF_FILTER
CMS_NODE_HANDLER
WSF_URI_HANDLER
rename
@@ -44,19 +42,18 @@ feature -- execute
-- Execute request handler
do
execute_methods (req, res)
execute_next (req, res)
end
uri_execute (req: WSF_REQUEST; res: WSF_RESPONSE)
-- Execute request handler
do
execute_methods (req, res)
execute (req, res)
end
uri_template_execute (req: WSF_REQUEST; res: WSF_RESPONSE)
-- Execute request handler
do
execute_methods (req, res)
execute (req, res)
end
feature -- HTTP Methods
@@ -70,7 +67,7 @@ feature -- HTTP Methods
if attached {WSF_STRING} req.path_parameter ("id") as l_id then
if
l_id.is_integer and then
attached api.node (l_id.value.to_integer_64) as l_node
attached node_api.node (l_id.value.to_integer_64) as l_node
then
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, api)
l_page.add_variable (l_node, "node")
@@ -94,7 +91,7 @@ feature -- HTTP Methods
if attached {WSF_STRING} req.path_parameter ("id") as l_id then
if
l_id.is_integer and then
attached {CMS_NODE} api.node (l_id.value.to_integer_64) as l_node
attached node_api.node (l_id.value.to_integer_64) 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
@@ -113,7 +110,7 @@ feature -- HTTP Methods
create u_node.make ("", "", "")
update_node_from_data_form (req, u_node)
u_node.set_author (l_user)
api.new_node (u_node)
node_api.new_node (u_node)
(create {CMS_GENERIC_RESPONSE}).new_response_redirect (req, res, req.absolute_script_url (""))
end
else
@@ -129,11 +126,11 @@ feature -- HTTP Methods
if attached {WSF_STRING} req.path_parameter ("id") as l_id then
if
l_id.is_integer and then
attached api.node (l_id.value.to_integer_64) as l_node
attached node_api.node (l_id.value.to_integer_64) as l_node
then
update_node_from_data_form (req, l_node)
l_node.set_author (l_user)
api.update_node (l_node)
node_api.update_node (l_node)
(create {CMS_GENERIC_RESPONSE}).new_response_redirect (req, res, req.absolute_script_url (""))
else
do_error (req, res, l_id)
@@ -153,9 +150,9 @@ feature -- HTTP Methods
if attached {WSF_STRING} req.path_parameter ("id") as l_id then
if
l_id.is_integer and then
attached api.node (l_id.integer_value) as l_node
attached node_api.node (l_id.integer_value) as l_node
then
api.delete_node (l_node)
node_api.delete_node (l_node)
(create {CMS_GENERIC_RESPONSE}).new_response_redirect (req, res, req.absolute_script_url (""))
else
do_error (req, res, l_id)
@@ -197,10 +194,7 @@ feature {NONE} -- Node
do
if attached current_user_name (req) then
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
else
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
end

View File

@@ -1,15 +1,13 @@
note
description: "Summary description for {NODE_SUMMARY_HANDLER}."
date: "$Date: 2015-01-27 19:15:02 +0100 (mar., 27 janv. 2015) $"
revision: "$Revision: 96542 $"
date: "$Date: 2015-02-13 13:08:13 +0100 (ven., 13 févr. 2015) $"
revision: "$Revision: 96616 $"
class
NODE_SUMMARY_HANDLER
inherit
CMS_HANDLER
WSF_FILTER
CMS_NODE_HANDLER
WSF_URI_HANDLER
rename
@@ -43,19 +41,18 @@ feature -- execute
-- Execute request handler
do
execute_methods (req, res)
execute_next (req, res)
end
uri_execute (req: WSF_REQUEST; res: WSF_RESPONSE)
-- Execute request handler
do
execute_methods (req, res)
execute (req, res)
end
uri_template_execute (req: WSF_REQUEST; res: WSF_RESPONSE)
-- Execute request handler
do
execute_methods (req, res)
execute (req, res)
end
feature -- HTTP Methods
@@ -68,7 +65,7 @@ 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.node (l_id.integer_value) as l_node then
if l_id.is_integer and then attached 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")
@@ -90,7 +87,7 @@ 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.node (l_id.integer_value) as l_node then
if l_id.is_integer and then attached 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)
@@ -116,10 +113,10 @@ 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.node (l_id.integer_value) as l_node then
if l_id.is_integer and then attached node_api.node (l_id.integer_value) as l_node then
u_node := extract_data_form (req)
u_node.set_id (l_id.value.to_integer_64)
api.update_node_summary (l_user.id,u_node.id, u_node.summary)
node_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)

View File

@@ -1,15 +1,13 @@
note
description: "Summary description for {NODE_TITLE_HANDLER}."
date: "$Date: 2015-01-27 19:15:02 +0100 (mar., 27 janv. 2015) $"
revision: "$Revision: 96542 $"
date: "$Date: 2015-02-13 13:08:13 +0100 (ven., 13 févr. 2015) $"
revision: "$Revision: 96616 $"
class
NODE_TITLE_HANDLER
inherit
CMS_HANDLER
WSF_FILTER
CMS_NODE_HANDLER
WSF_URI_HANDLER
rename
@@ -43,19 +41,18 @@ feature -- execute
-- Execute request handler
do
execute_methods (req, res)
execute_next (req, res)
end
uri_execute (req: WSF_REQUEST; res: WSF_RESPONSE)
-- Execute request handler
do
execute_methods (req, res)
execute (req, res)
end
uri_template_execute (req: WSF_REQUEST; res: WSF_RESPONSE)
-- Execute request handler
do
execute_methods (req, res)
execute (req, res)
end
feature -- HTTP Methods
@@ -68,7 +65,7 @@ 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.node (l_id.integer_value) as l_node then
if l_id.is_integer and then attached 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")
@@ -89,7 +86,7 @@ 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.node (l_id.integer_value) as l_node then
if l_id.is_integer and then attached 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)
@@ -116,10 +113,10 @@ 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.node (l_id.integer_value) as l_node then
if l_id.is_integer and then attached node_api.node (l_id.integer_value) as l_node then
u_node := extract_data_form (req)
u_node.set_id (l_id.value.to_integer_64)
api.update_node_title (l_user.id,u_node.id, u_node.title)
node_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)

View File

@@ -1,19 +1,16 @@
note
description: "Summary description for {NODES_HANDLER}."
date: "$Date: 2014-11-13 16:23:47 +0100 (jeu., 13 nov. 2014) $"
revision: "$Revision: 96085 $"
date: "$Date: 2015-02-13 13:08:13 +0100 (ven., 13 févr. 2015) $"
revision: "$Revision: 96616 $"
class
NODES_HANDLER
inherit
CMS_HANDLER
WSF_FILTER
CMS_NODE_HANDLER
WSF_URI_HANDLER
rename
execute as uri_execute,
new_mapping as new_uri_mapping
end
@@ -31,13 +28,6 @@ feature -- execute
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
-- Execute request handler
do
execute_methods (req, res)
execute_next (req, res)
end
uri_execute (req: WSF_REQUEST; res: WSF_RESPONSE)
-- Execute request handler
do
execute_methods (req, res)
end
@@ -53,7 +43,7 @@ feature -- HTTP Methods
-- get them from the configuration file and load them into
-- the setup class.
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, api)
l_page.add_variable (api.nodes, "nodes")
l_page.add_variable (node_api.nodes, "nodes")
l_page.execute
end
end

View File

@@ -1,7 +1,7 @@
note
description: "CMS module that bring support for NODE management."
date: "$Date: 2015-01-27 19:15:02 +0100 (mar., 27 janv. 2015) $"
revision: "$Revision: 96542 $"
date: "$Date: 2015-02-13 13:08:13 +0100 (ven., 13 févr. 2015) $"
revision: "$Revision: 96616 $"
class
NODE_MODULE
@@ -40,56 +40,59 @@ feature -- Access: router
router (a_api: CMS_API): WSF_ROUTER
-- Node router.
local
l_node_api: CMS_NODE_API
do
create l_node_api.make (a_api)
create Result.make (5)
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)
configure_api_node (a_api, l_node_api, Result)
configure_api_nodes (a_api, l_node_api, Result)
configure_api_node_title (a_api, l_node_api, Result)
configure_api_node_summary (a_api, l_node_api, Result)
configure_api_node_content (a_api, l_node_api, Result)
end
feature {NONE} -- Implementation: routes
configure_api_node (api: CMS_API; a_router: WSF_ROUTER)
configure_api_node (a_api: CMS_API; a_node_api: CMS_NODE_API; a_router: WSF_ROUTER)
local
l_node_handler: NODE_HANDLER
l_methods: WSF_REQUEST_METHODS
do
create l_node_handler.make (api)
create l_node_handler.make (a_api, a_node_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 (api)
create l_node_handler.make (a_api, a_node_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)
a_router.handle_with_request_methods ("/nodes/", create {WSF_URI_AGENT_HANDLER}.make (agent do_get_nodes (?,?, a_api, a_node_api)), a_router.methods_get)
end
configure_api_nodes (api: CMS_API; a_router: WSF_ROUTER)
configure_api_nodes (a_api: CMS_API; a_node_api: CMS_NODE_API; a_router: WSF_ROUTER)
local
l_nodes_handler: NODES_HANDLER
l_methods: WSF_REQUEST_METHODS
do
create l_nodes_handler.make (api)
create l_nodes_handler.make (a_api, a_node_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 (api: CMS_API; a_router: WSF_ROUTER)
configure_api_node_summary (a_api: CMS_API; a_node_api: CMS_NODE_API; a_router: WSF_ROUTER)
local
l_report_handler: NODE_SUMMARY_HANDLER
l_methods: WSF_REQUEST_METHODS
do
create l_report_handler.make (api)
create l_report_handler.make (a_api, a_node_api)
create l_methods
l_methods.enable_get
l_methods.enable_post
@@ -97,12 +100,12 @@ feature {NONE} -- Implementation: routes
a_router.handle_with_request_methods ("/node/{id}/summary", l_report_handler, l_methods)
end
configure_api_node_title (api: CMS_API; a_router: WSF_ROUTER)
configure_api_node_title (a_api: CMS_API; a_node_api: CMS_NODE_API; a_router: WSF_ROUTER)
local
l_report_handler: NODE_TITLE_HANDLER
l_methods: WSF_REQUEST_METHODS
do
create l_report_handler.make (api)
create l_report_handler.make (a_api, a_node_api)
create l_methods
l_methods.enable_get
l_methods.enable_post
@@ -110,12 +113,12 @@ feature {NONE} -- Implementation: routes
a_router.handle_with_request_methods ("/node/{id}/title", l_report_handler, l_methods)
end
configure_api_node_content (api: CMS_API; a_router: WSF_ROUTER)
configure_api_node_content (a_api: CMS_API; a_node_api: CMS_NODE_API; a_router: WSF_ROUTER)
local
l_report_handler: NODE_CONTENT_HANDLER
l_methods: WSF_REQUEST_METHODS
do
create l_report_handler.make (api)
create l_report_handler.make (a_api, a_node_api)
create l_methods
l_methods.enable_get
l_methods.enable_post
@@ -155,7 +158,7 @@ feature -- Hooks
feature -- Handler
do_get_nodes (req: WSF_REQUEST; res: WSF_RESPONSE; a_api: CMS_API)
do_get_nodes (req: WSF_REQUEST; res: WSF_RESPONSE; a_api: CMS_API; a_node_api: CMS_NODE_API)
local
r: CMS_RESPONSE
s: STRING
@@ -164,22 +167,22 @@ feature -- Handler
do
create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, a_api)
if attached a_api.user_by_name ("foo") as u then
if attached a_api.user_api.user_by_name ("foo") as u then
l_user := u
else
create l_user.make ("foo")
l_user.set_password ("foobar#")
l_user.set_email ("test@example.com")
a_api.new_user (l_user)
a_api.user_api.new_user (l_user)
end
if a_api.nodes_count = 0 then
if a_node_api.nodes_count = 0 then
create l_node.make ({STRING_32} "This is a content", {STRING_32} "And a summary", {STRING_32} "Nice title")
l_node.set_author (l_user)
a_api.new_node (l_node)
a_node_api.new_node (l_node)
end
create s.make_from_string ("<p>Nodes:</p>")
if attached a_api.nodes as lst then
if attached a_node_api.nodes as lst then
across
lst as ic
loop