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:
@@ -2,8 +2,8 @@ note
|
||||
description: "[
|
||||
Default CMS_SETUP that can be reused easily, and/or redefined to match specific setup.
|
||||
]"
|
||||
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
|
||||
CMS_DEFAULT_SETUP
|
||||
@@ -86,7 +86,11 @@ feature {NONE} -- Initialization
|
||||
local
|
||||
m: CMS_MODULE
|
||||
do
|
||||
-- -- Core
|
||||
-- Core
|
||||
-- create {BASIC_AUTH_MODULE} m.make
|
||||
-- m.enable
|
||||
-- register_module (m)
|
||||
|
||||
-- create {USER_MODULE} m.make (Current)
|
||||
-- m.enable
|
||||
-- register_module (m)
|
||||
@@ -130,19 +134,6 @@ feature -- Access
|
||||
end
|
||||
end
|
||||
|
||||
is_html: BOOLEAN
|
||||
-- <Precursor>
|
||||
do
|
||||
-- Enable change the mode
|
||||
Result := (create {CMS_JSON_CONFIGURATION}).is_html_mode (layout.application_config_path)
|
||||
end
|
||||
|
||||
is_web: BOOLEAN
|
||||
-- <Precursor>
|
||||
do
|
||||
Result := (create {CMS_JSON_CONFIGURATION}).is_web_mode (layout.application_config_path)
|
||||
end
|
||||
|
||||
build_auth_engine
|
||||
do
|
||||
to_implement ("Not implemented authentication")
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
note
|
||||
description: "Class that enable to set basic configuration, application layout, core modules and themes."
|
||||
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 $"
|
||||
|
||||
deferred class
|
||||
CMS_SETUP
|
||||
@@ -14,16 +14,6 @@ feature -- Access
|
||||
layout: CMS_LAYOUT
|
||||
-- CMS layout.
|
||||
|
||||
is_html: BOOLEAN
|
||||
-- api with progressive enhancements css and js, server side rendering.
|
||||
deferred
|
||||
end
|
||||
|
||||
is_web: BOOLEAN
|
||||
-- web: Web Site with progressive enhancements css and js and Ajax calls.
|
||||
deferred
|
||||
end
|
||||
|
||||
enabled_modules: CMS_MODULE_COLLECTION
|
||||
-- List of enabled modules.
|
||||
local
|
||||
@@ -42,7 +32,7 @@ feature -- Access
|
||||
only_enabled_modules: across Result as ic all ic.item.is_enabled end
|
||||
end
|
||||
|
||||
feature {CMS_MODULE} -- Restricted access
|
||||
feature {CMS_MODULE, CMS_API} -- Restricted access
|
||||
|
||||
modules: CMS_MODULE_COLLECTION
|
||||
-- List of available modules.
|
||||
@@ -129,13 +119,10 @@ feature -- Access: storage
|
||||
attached storage_drivers.item (l_database_config.driver) as l_builder
|
||||
then
|
||||
Result := l_builder.storage (Current)
|
||||
else
|
||||
create {CMS_STORAGE_NULL} Result
|
||||
end
|
||||
else
|
||||
to_implement ("Workaround code, persistence layer does not implement yet this kind of error handling.")
|
||||
-- error hanling.
|
||||
create {CMS_STORAGE_NULL} Result
|
||||
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
|
||||
@@ -161,11 +148,24 @@ feature -- Access: storage
|
||||
|
||||
feature -- Element change
|
||||
|
||||
module_registered (m: CMS_MODULE): BOOLEAN
|
||||
do
|
||||
Result := modules.has (m)
|
||||
end
|
||||
|
||||
module_with_same_type_registered (m: CMS_MODULE): BOOLEAN
|
||||
do
|
||||
Result := modules.has_module_with_same_type (m)
|
||||
end
|
||||
|
||||
register_module (m: CMS_MODULE)
|
||||
-- Add module `m' to `modules'
|
||||
require
|
||||
module_not_registered: not module_registered (m)
|
||||
no_module_with_same_type_registered: not module_with_same_type_registered (m)
|
||||
deferred
|
||||
ensure
|
||||
module_added: modules.has (m)
|
||||
module_registered: module_registered (m)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
note
|
||||
description: "Describe content to be placed inside Regions."
|
||||
date: "$Date: 2014-11-17 18:47:30 +0100 (lun., 17 nov. 2014) $"
|
||||
date: "$Date: 2015-01-30 19:37:02 +0100 (ven., 30 janv. 2015) $"
|
||||
|
||||
deferred class
|
||||
CMS_BLOCK
|
||||
|
||||
@@ -1,35 +1,38 @@
|
||||
note
|
||||
description: "Summary description for {CMS_ENCODERS}."
|
||||
author: ""
|
||||
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
|
||||
CMS_ENCODERS
|
||||
|
||||
inherit
|
||||
ANY
|
||||
|
||||
SHARED_HTML_ENCODER
|
||||
export
|
||||
{NONE} all
|
||||
end
|
||||
|
||||
SHARED_WSF_PERCENT_ENCODER
|
||||
export
|
||||
{NONE} all
|
||||
end
|
||||
|
||||
feature -- Encoders
|
||||
|
||||
url_encoded (s: detachable READABLE_STRING_GENERAL): STRING_8
|
||||
local
|
||||
enc: URL_ENCODER
|
||||
html_encoded (a_string: READABLE_STRING_GENERAL): STRING_8
|
||||
-- `a_string' encoded for html output.
|
||||
do
|
||||
create enc
|
||||
if s /= Void then
|
||||
Result := enc.general_encoded_string (s)
|
||||
else
|
||||
create Result.make_empty
|
||||
end
|
||||
Result := html_encoder.general_encoded_string (a_string)
|
||||
end
|
||||
|
||||
html_encoded (s: detachable READABLE_STRING_GENERAL): STRING_8
|
||||
local
|
||||
enc: HTML_ENCODER
|
||||
url_encoded,
|
||||
percent_encoded (a_string: READABLE_STRING_GENERAL): STRING_8
|
||||
-- `a_string' encoded with percent encoding, mainly used for url.
|
||||
do
|
||||
create enc
|
||||
if s /= Void then
|
||||
Result := enc.general_encoded_string (s)
|
||||
else
|
||||
create Result.make_empty
|
||||
end
|
||||
Result := percent_encoder.percent_encoded_string (a_string)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
98
src/modules/node/cms_node_api.e
Normal file
98
src/modules/node/cms_node_api.e
Normal 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
|
||||
16
src/modules/node/handler/cms_node_handler.e
Normal file
16
src/modules/node/handler/cms_node_handler.e
Normal 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
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -3,8 +3,8 @@ note
|
||||
description : "[
|
||||
CMS interface to storage
|
||||
]"
|
||||
date: "$Date: 2015-01-27 19:15:02 +0100 (mar., 27 janv. 2015) $"
|
||||
revision: "$Revision: 96542 $"
|
||||
date: "$Date: 2015-02-09 22:29:56 +0100 (lun., 09 févr. 2015) $"
|
||||
revision: "$Revision: 96596 $"
|
||||
|
||||
deferred class
|
||||
CMS_STORAGE
|
||||
@@ -22,6 +22,18 @@ feature {NONE} -- Initialization
|
||||
do
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_available: BOOLEAN
|
||||
-- Is storage available?
|
||||
deferred
|
||||
end
|
||||
|
||||
is_initialized: BOOLEAN
|
||||
-- Is storage initialized?
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- Error Handling
|
||||
|
||||
error_handler: ERROR_HANDLER
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
note
|
||||
description: "Summary description for {CMS_STORAGE_NULL}."
|
||||
date: "$Date: 2015-01-27 19:15:02 +0100 (mar., 27 janv. 2015) $"
|
||||
revision: "$Revision: 96542 $"
|
||||
date: "$Date: 2015-02-09 22:29:56 +0100 (lun., 09 févr. 2015) $"
|
||||
revision: "$Revision: 96596 $"
|
||||
|
||||
class
|
||||
CMS_STORAGE_NULL
|
||||
@@ -26,6 +26,20 @@ feature -- Initialization
|
||||
create error_handler.make
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_available: BOOLEAN
|
||||
-- Is storage available?
|
||||
do
|
||||
Result := True
|
||||
end
|
||||
|
||||
is_initialized: BOOLEAN
|
||||
-- Is storage initialized?
|
||||
do
|
||||
Result := True
|
||||
end
|
||||
|
||||
feature -- Access: user
|
||||
|
||||
has_user: BOOLEAN
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
note
|
||||
description: "Summary description for {CMS_STORAGE_SQL}."
|
||||
author: ""
|
||||
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 $"
|
||||
|
||||
deferred class
|
||||
CMS_STORAGE_SQL
|
||||
@@ -10,9 +10,22 @@ deferred class
|
||||
feature -- Error handler
|
||||
|
||||
error_handler: ERROR_HANDLER
|
||||
-- Error handler.
|
||||
deferred
|
||||
end
|
||||
|
||||
has_error: BOOLEAN
|
||||
-- Last operation reported error.
|
||||
do
|
||||
Result := error_handler.has_error
|
||||
end
|
||||
|
||||
reset_error
|
||||
-- Reset errors.
|
||||
do
|
||||
error_handler.reset
|
||||
end
|
||||
|
||||
feature -- Execution
|
||||
|
||||
sql_begin_transaction
|
||||
@@ -29,6 +42,7 @@ feature -- Execution
|
||||
|
||||
sql_post_execution
|
||||
-- Post database execution.
|
||||
-- note: execute after each `sql_query' and `sql_change'.
|
||||
deferred
|
||||
end
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
note
|
||||
description: "Summary description for {CMS_NODE_STORAGE_SQL}."
|
||||
author: ""
|
||||
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 $"
|
||||
|
||||
deferred class
|
||||
CMS_NODE_STORAGE_SQL
|
||||
@@ -27,7 +27,6 @@ feature -- Access
|
||||
if sql_rows_count = 1 then
|
||||
Result := sql_read_integer_64 (1)
|
||||
end
|
||||
sql_post_execution
|
||||
end
|
||||
|
||||
nodes: LIST [CMS_NODE]
|
||||
@@ -40,7 +39,6 @@ feature -- Access
|
||||
|
||||
from
|
||||
sql_query (select_nodes, Void)
|
||||
sql_post_execution
|
||||
sql_start
|
||||
until
|
||||
sql_after
|
||||
@@ -50,7 +48,6 @@ feature -- Access
|
||||
end
|
||||
sql_forth
|
||||
end
|
||||
sql_post_execution
|
||||
end
|
||||
|
||||
recent_nodes (a_lower: INTEGER; a_count: INTEGER): LIST [CMS_NODE]
|
||||
@@ -68,7 +65,6 @@ feature -- Access
|
||||
l_parameters.put (a_count, "rows")
|
||||
l_parameters.put (a_lower, "offset")
|
||||
sql_query (select_recent_nodes, l_parameters)
|
||||
sql_post_execution
|
||||
sql_start
|
||||
until
|
||||
sql_after
|
||||
@@ -78,7 +74,6 @@ feature -- Access
|
||||
end
|
||||
sql_forth
|
||||
end
|
||||
sql_post_execution
|
||||
end
|
||||
|
||||
node_by_id (a_id: INTEGER_64): detachable CMS_NODE
|
||||
@@ -94,7 +89,6 @@ feature -- Access
|
||||
if sql_rows_count = 1 then
|
||||
Result := fetch_node
|
||||
end
|
||||
sql_post_execution
|
||||
end
|
||||
|
||||
node_author (a_id: like {CMS_NODE}.id): detachable CMS_USER
|
||||
@@ -110,7 +104,6 @@ feature -- Access
|
||||
if sql_rows_count >= 1 then
|
||||
Result := fetch_author
|
||||
end
|
||||
sql_post_execution
|
||||
end
|
||||
|
||||
last_inserted_node_id: INTEGER_64
|
||||
@@ -122,7 +115,6 @@ feature -- Access
|
||||
if sql_rows_count = 1 then
|
||||
Result := sql_read_integer_64 (1)
|
||||
end
|
||||
sql_post_execution
|
||||
end
|
||||
|
||||
feature -- Change: Node
|
||||
@@ -151,10 +143,8 @@ feature -- Change: Node
|
||||
l_parameters.put (0, "author")
|
||||
end
|
||||
sql_change (sql_insert_node, l_parameters)
|
||||
sql_post_execution
|
||||
if not error_handler.has_error then
|
||||
a_node.set_id (last_inserted_node_id)
|
||||
sql_post_execution
|
||||
end
|
||||
end
|
||||
|
||||
@@ -169,7 +159,6 @@ feature -- Change: Node
|
||||
create l_parameters.make (1)
|
||||
l_parameters.put (a_id, "id")
|
||||
sql_change (sql_delete_node, l_parameters)
|
||||
sql_post_execution
|
||||
end
|
||||
|
||||
update_node (a_node: CMS_NODE)
|
||||
@@ -194,7 +183,6 @@ feature -- Change: Node
|
||||
l_parameters.put (0, "author")
|
||||
end
|
||||
sql_change (sql_update_node, l_parameters)
|
||||
sql_post_execution
|
||||
if not error_handler.has_error then
|
||||
a_node.set_modification_date (now)
|
||||
end
|
||||
@@ -213,7 +201,6 @@ feature -- Change: Node
|
||||
l_parameters.put (create {DATE_TIME}.make_now_utc, "changed")
|
||||
l_parameters.put (a_node_id, "nid")
|
||||
sql_change (sql_update_node_title, l_parameters)
|
||||
sql_post_execution
|
||||
end
|
||||
|
||||
update_node_summary (a_user_id: Like {CMS_USER}.id; a_node_id: like {CMS_NODE}.id; a_summary: READABLE_STRING_32)
|
||||
@@ -229,7 +216,6 @@ feature -- Change: Node
|
||||
l_parameters.put (create {DATE_TIME}.make_now_utc, "changed")
|
||||
l_parameters.put (a_node_id, "nid")
|
||||
sql_change (sql_update_node_summary, l_parameters)
|
||||
sql_post_execution
|
||||
end
|
||||
|
||||
update_node_content (a_user_id: Like {CMS_USER}.id;a_node_id: like {CMS_NODE}.id; a_content: READABLE_STRING_32)
|
||||
@@ -245,7 +231,6 @@ feature -- Change: Node
|
||||
l_parameters.put (create {DATE_TIME}.make_now_utc, "changed")
|
||||
l_parameters.put (a_node_id, "nid")
|
||||
sql_change (sql_update_node_content, l_parameters)
|
||||
sql_post_execution
|
||||
end
|
||||
|
||||
feature {NONE} -- Queries
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
note
|
||||
description: "Summary description for {CMS_USER_STORAGE_SQL}."
|
||||
author: ""
|
||||
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 $"
|
||||
|
||||
deferred class
|
||||
CMS_USER_STORAGE_SQL
|
||||
@@ -34,7 +34,6 @@ feature -- Access: user
|
||||
if sql_rows_count = 1 then
|
||||
Result := sql_read_integer_32 (1)
|
||||
end
|
||||
sql_post_execution
|
||||
end
|
||||
|
||||
users: LIST [CMS_USER]
|
||||
@@ -46,7 +45,6 @@ feature -- Access: user
|
||||
|
||||
from
|
||||
sql_query (select_users, Void)
|
||||
sql_post_execution
|
||||
sql_start
|
||||
until
|
||||
sql_after
|
||||
@@ -56,7 +54,6 @@ feature -- Access: user
|
||||
end
|
||||
sql_forth
|
||||
end
|
||||
sql_post_execution
|
||||
end
|
||||
|
||||
user_by_id (a_id: like {CMS_USER}.id): detachable CMS_USER
|
||||
@@ -74,7 +71,6 @@ feature -- Access: user
|
||||
else
|
||||
check no_more_than_one: sql_rows_count = 0 end
|
||||
end
|
||||
sql_post_execution
|
||||
end
|
||||
|
||||
user_by_name (a_name: like {CMS_USER}.name): detachable CMS_USER
|
||||
@@ -92,7 +88,6 @@ feature -- Access: user
|
||||
else
|
||||
check no_more_than_one: sql_rows_count = 0 end
|
||||
end
|
||||
sql_post_execution
|
||||
end
|
||||
|
||||
user_by_email (a_email: like {CMS_USER}.email): detachable CMS_USER
|
||||
@@ -110,7 +105,6 @@ feature -- Access: user
|
||||
else
|
||||
check no_more_than_one: sql_rows_count = 0 end
|
||||
end
|
||||
sql_post_execution
|
||||
end
|
||||
|
||||
is_valid_credential (l_auth_login, l_auth_password: READABLE_STRING_32): BOOLEAN
|
||||
@@ -163,10 +157,8 @@ feature -- Change: user
|
||||
l_parameters.put (create {DATE_TIME}.make_now_utc, "created")
|
||||
|
||||
sql_change (sql_insert_user, l_parameters)
|
||||
sql_post_execution
|
||||
if not error_handler.has_error then
|
||||
a_user.set_id (last_inserted_user_id)
|
||||
sql_post_execution
|
||||
end
|
||||
sql_commit_transaction
|
||||
else
|
||||
@@ -207,7 +199,6 @@ feature -- Change: user
|
||||
l_parameters.put (create {DATE_TIME}.make_now_utc, "changed")
|
||||
|
||||
sql_change (sql_update_user, l_parameters)
|
||||
sql_post_execution
|
||||
else
|
||||
-- set error
|
||||
error_handler.add_custom_error (-1, "bad request" , "Missing password or email")
|
||||
@@ -251,7 +242,6 @@ feature {NONE} -- Implementation
|
||||
Result := l_salt
|
||||
end
|
||||
end
|
||||
sql_post_execution
|
||||
end
|
||||
|
||||
fetch_user: detachable CMS_USER
|
||||
@@ -297,7 +287,6 @@ feature {NONE} -- Implementation
|
||||
if sql_rows_count = 1 then
|
||||
Result := sql_read_integer_64 (1)
|
||||
end
|
||||
sql_post_execution
|
||||
end
|
||||
|
||||
feature {NONE} -- Sql Queries: USER
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
note
|
||||
description: "API for a CMS"
|
||||
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
|
||||
CMS_API
|
||||
@@ -11,35 +11,25 @@ inherit
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
SHARED_HTML_ENCODER
|
||||
export
|
||||
{NONE} all
|
||||
end
|
||||
|
||||
SHARED_WSF_PERCENT_ENCODER
|
||||
export
|
||||
{NONE} all
|
||||
end
|
||||
CMS_ENCODERS
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Initialize
|
||||
feature {NONE} -- Initialize
|
||||
|
||||
make (a_setup: CMS_SETUP)
|
||||
-- Create the API service with a setup `a_setup'
|
||||
do
|
||||
setup := a_setup
|
||||
create error_handler.make
|
||||
create {CMS_ENV_LOGGER} logger.make
|
||||
initialize
|
||||
ensure
|
||||
setup_set: setup = a_setup
|
||||
error_handler_set: not error_handler.has_error
|
||||
end
|
||||
|
||||
setup: CMS_SETUP
|
||||
-- CMS setup.
|
||||
|
||||
initialize
|
||||
-- Initialize the persitent layer.
|
||||
do
|
||||
@@ -51,7 +41,18 @@ feature -- Initialize
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Access: Error
|
||||
feature -- Access
|
||||
|
||||
setup: CMS_SETUP
|
||||
-- CMS setup.
|
||||
|
||||
logger: CMS_LOGGER
|
||||
-- Logger
|
||||
|
||||
storage: CMS_STORAGE
|
||||
-- Persistence storage.
|
||||
|
||||
feature -- Status Report
|
||||
|
||||
has_error: BOOLEAN
|
||||
-- Has error?
|
||||
@@ -59,162 +60,82 @@ feature -- Access: Error
|
||||
Result := error_handler.has_error
|
||||
end
|
||||
|
||||
as_string_representation: STRING_32
|
||||
string_representation_of_errors: STRING_32
|
||||
-- String representation of all error(s).
|
||||
do
|
||||
Result := error_handler.as_string_representation
|
||||
end
|
||||
|
||||
feature -- Query: module
|
||||
|
||||
module (a_type: TYPE [CMS_MODULE]): detachable CMS_MODULE
|
||||
-- Enabled module typed `a_type', if any.
|
||||
--| usage: if attached module ({FOO_MODULE}) as mod then ...
|
||||
do
|
||||
across
|
||||
setup.modules as ic
|
||||
until
|
||||
Result /= Void
|
||||
loop
|
||||
Result := ic.item
|
||||
if
|
||||
not Result.is_enabled
|
||||
or else Result.generating_type /~ a_type
|
||||
then
|
||||
Result := Void
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
module_by_name (a_name: READABLE_STRING_GENERAL): detachable CMS_MODULE
|
||||
-- Enabled module named `a_name', if any.
|
||||
do
|
||||
across
|
||||
setup.modules as ic
|
||||
until
|
||||
Result /= Void
|
||||
loop
|
||||
Result := ic.item
|
||||
if
|
||||
not Result.is_enabled
|
||||
or else not Result.name.is_case_insensitive_equal_general (a_name)
|
||||
then
|
||||
Result := Void
|
||||
end
|
||||
end
|
||||
ensure
|
||||
Result /= Void implies Result.name.is_case_insensitive_equal_general (a_name)
|
||||
end
|
||||
|
||||
feature -- Query: API
|
||||
|
||||
user_api: CMS_USER_API
|
||||
local
|
||||
l_api: like internal_user_api
|
||||
do
|
||||
l_api := internal_user_api
|
||||
if l_api = Void then
|
||||
create l_api.make (Current)
|
||||
internal_user_api := l_api
|
||||
end
|
||||
Result := l_api
|
||||
end
|
||||
|
||||
feature -- Element Change: Error
|
||||
|
||||
reset
|
||||
reset_error
|
||||
-- Reset error handler.
|
||||
do
|
||||
error_handler.reset
|
||||
end
|
||||
|
||||
feature {NONE}-- Error handler implemenations
|
||||
feature {NONE}-- Implemenation
|
||||
|
||||
error_handler: ERROR_HANDLER
|
||||
-- Error handler.
|
||||
|
||||
feature -- Status Report
|
||||
|
||||
is_valid_credential (a_auth_login, a_auth_password: READABLE_STRING_32): BOOLEAN
|
||||
-- Is the credentials `a_auth_login' and `a_auth_password' valid?
|
||||
do
|
||||
Result := storage.is_valid_credential (a_auth_login, a_auth_password)
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
|
||||
feature -- Access: User
|
||||
|
||||
user_by_name (a_username: READABLE_STRING_32): detachable CMS_USER
|
||||
-- User by name `a_user_name', if any.
|
||||
do
|
||||
Result := storage.user_by_name (a_username)
|
||||
end
|
||||
|
||||
feature -- Change User
|
||||
|
||||
new_user (a_user: CMS_USER)
|
||||
-- Add a new user `a_user'.
|
||||
require
|
||||
no_id: not a_user.has_id
|
||||
no_hashed_password: a_user.hashed_password = Void
|
||||
do
|
||||
if
|
||||
attached a_user.password as l_password and then
|
||||
attached a_user.email as l_email
|
||||
then
|
||||
storage.new_user (a_user)
|
||||
else
|
||||
debug ("refactor_fixme")
|
||||
fixme ("Add error")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
update_user (a_user: CMS_USER)
|
||||
-- Update user `a_user'.
|
||||
require
|
||||
has_id: a_user.has_id
|
||||
do
|
||||
storage.update_user (a_user)
|
||||
end
|
||||
|
||||
feature -- Helpers
|
||||
|
||||
html_encoded (a_string: READABLE_STRING_GENERAL): STRING_8
|
||||
-- `a_string' encoded for html output.
|
||||
do
|
||||
Result := html_encoder.general_encoded_string (a_string)
|
||||
end
|
||||
|
||||
percent_encoded (a_string: READABLE_STRING_GENERAL): STRING_8
|
||||
-- `a_string' encoded with percent encoding, mainly used for url.
|
||||
do
|
||||
Result := percent_encoder.percent_encoded_string (a_string)
|
||||
end
|
||||
internal_user_api: detachable like user_api
|
||||
-- Cached value for `user_api'.
|
||||
|
||||
feature -- Layout
|
||||
|
||||
@@ -249,10 +170,5 @@ feature -- Layout
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implemenataion
|
||||
|
||||
storage: CMS_STORAGE
|
||||
-- Persistence storage.
|
||||
|
||||
end
|
||||
|
||||
|
||||
26
src/service/cms_module_api.e
Normal file
26
src/service/cms_module_api.e
Normal file
@@ -0,0 +1,26 @@
|
||||
note
|
||||
description: "Summary description for {CMS_MODULE_API}."
|
||||
author: ""
|
||||
date: "$Date: 2015-02-13 14:54:27 +0100 (ven., 13 févr. 2015) $"
|
||||
revision: "$Revision: 96620 $"
|
||||
|
||||
deferred class
|
||||
CMS_MODULE_API
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
make (a_api: CMS_API)
|
||||
do
|
||||
api := a_api
|
||||
end
|
||||
|
||||
feature {CMS_MODULE, CMS_API} -- Restricted access
|
||||
|
||||
api: CMS_API
|
||||
|
||||
storage: CMS_STORAGE
|
||||
do
|
||||
Result := api.storage
|
||||
end
|
||||
|
||||
end
|
||||
@@ -97,7 +97,7 @@ feature -- Settings: router
|
||||
l_api: like api
|
||||
l_router: like router
|
||||
do
|
||||
log.write_debug (generator + ".setup_router")
|
||||
api.logger.put_debug (generator + ".setup_router", Void)
|
||||
-- Configure root of api handler.
|
||||
|
||||
l_router := router
|
||||
@@ -120,7 +120,7 @@ feature -- Settings: router
|
||||
l_root_handler: CMS_ROOT_HANDLER
|
||||
l_methods: WSF_REQUEST_METHODS
|
||||
do
|
||||
log.write_debug (generator + ".configure_api_root")
|
||||
api.logger.put_debug (generator + ".configure_api_root", Void)
|
||||
create l_root_handler.make (api)
|
||||
create l_methods
|
||||
l_methods.enable_get
|
||||
@@ -133,7 +133,7 @@ feature -- Settings: router
|
||||
local
|
||||
fhdl: WSF_FILE_SYSTEM_HANDLER
|
||||
do
|
||||
log.write_debug (generator + ".configure_api_file_handler")
|
||||
api.logger.put_information (generator + ".configure_api_file_handler", Void)
|
||||
|
||||
create fhdl.make_hidden_with_path (setup.theme_assets_location)
|
||||
fhdl.disable_index
|
||||
@@ -172,7 +172,7 @@ feature -- Filters
|
||||
l_module: CMS_MODULE
|
||||
l_api: like api
|
||||
do
|
||||
log.write_debug (generator + ".create_filter")
|
||||
api.logger.put_debug (generator + ".create_filter", Void)
|
||||
l_filter := Void
|
||||
|
||||
-- Maintenance
|
||||
@@ -211,7 +211,7 @@ feature -- Filters
|
||||
local
|
||||
f: WSF_FILTER
|
||||
do
|
||||
log.write_debug (generator + ".setup_filter")
|
||||
api.logger.put_debug (generator + ".setup_filter", Void)
|
||||
|
||||
from
|
||||
f := filter
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
note
|
||||
description: "Summary description for {CMS_ERROR_FILTER}."
|
||||
date: "$Date: 2014-12-19 14:17:32 +0100 (ven., 19 déc. 2014) $"
|
||||
revision: "$Revision: 96402 $"
|
||||
date: "$Date: 2015-02-13 13:08:13 +0100 (ven., 13 févr. 2015) $"
|
||||
revision: "$Revision: 96616 $"
|
||||
|
||||
class
|
||||
CMS_ERROR_FILTER
|
||||
@@ -22,18 +22,18 @@ feature -- Basic operations
|
||||
do
|
||||
fixme ("Check if it's ok to add new fetures CMS_API.has_error:BOOLEAN and CMS_API.error_description.")
|
||||
if not api.has_error then
|
||||
log.write_information (generator + ".execute with req: " + req.debug_output)
|
||||
api.logger.put_information (generator + ".execute with req: " + req.debug_output, Void)
|
||||
if attached req.raw_header_data as l_header_data then
|
||||
log.write_debug (generator + ".execute with req header: " + l_header_data)
|
||||
api.logger.put_debug (generator + ".execute with req header: " + l_header_data, Void)
|
||||
end
|
||||
if attached req.raw_input_data as l_input_data then
|
||||
log.write_debug (generator + ".execute with req input: " + l_input_data)
|
||||
api.logger.put_debug (generator + ".execute with req input: " + l_input_data, Void)
|
||||
end
|
||||
execute_next (req, res)
|
||||
else
|
||||
log.write_critical (generator + ".execute" + api.as_string_representation )
|
||||
api.logger.put_critical (generator + ".execute" + api.string_representation_of_errors, Void)
|
||||
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
api.reset
|
||||
api.reset_error
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,36 +1,27 @@
|
||||
note
|
||||
description: "Summary description for {CMS_HANDLER}."
|
||||
author: ""
|
||||
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 $"
|
||||
|
||||
deferred class
|
||||
CMS_HANDLER
|
||||
|
||||
inherit
|
||||
|
||||
WSF_HANDLER
|
||||
|
||||
CMS_REQUEST_UTIL
|
||||
|
||||
SHARED_LOGGER
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_api: CMS_API)
|
||||
-- Initialize Current handler with `a_api'.
|
||||
do
|
||||
api := a_api
|
||||
end
|
||||
|
||||
feature -- Setup
|
||||
|
||||
setup: CMS_SETUP
|
||||
do
|
||||
Result := api.setup
|
||||
end
|
||||
|
||||
feature -- API Service
|
||||
|
||||
api: CMS_API
|
||||
|
||||
27
src/service/handler/cms_module_handler.e
Normal file
27
src/service/handler/cms_module_handler.e
Normal file
@@ -0,0 +1,27 @@
|
||||
note
|
||||
description: "Summary description for {CMS_MODULE_HANDLER}."
|
||||
author: ""
|
||||
date: "$Date: 2015-02-13 13:08:13 +0100 (ven., 13 févr. 2015) $"
|
||||
revision: "$Revision: 96616 $"
|
||||
|
||||
deferred class
|
||||
CMS_MODULE_HANDLER [G -> CMS_MODULE_API]
|
||||
|
||||
inherit
|
||||
CMS_HANDLER
|
||||
rename
|
||||
make as cms_make
|
||||
end
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_api: CMS_API; a_module_api: G)
|
||||
do
|
||||
cms_make (a_api)
|
||||
module_api := a_module_api
|
||||
end
|
||||
|
||||
module_api: G
|
||||
-- Node api
|
||||
|
||||
end
|
||||
@@ -1,20 +1,16 @@
|
||||
note
|
||||
description: "Summary description for {CMS_ROOT_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
|
||||
CMS_ROOT_HANDLER
|
||||
|
||||
inherit
|
||||
|
||||
CMS_HANDLER
|
||||
|
||||
WSF_FILTER
|
||||
|
||||
WSF_URI_HANDLER
|
||||
rename
|
||||
execute as uri_execute,
|
||||
new_mapping as new_uri_mapping
|
||||
end
|
||||
|
||||
@@ -32,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
|
||||
|
||||
60
src/service/logger/cms_env_logger.e
Normal file
60
src/service/logger/cms_env_logger.e
Normal file
@@ -0,0 +1,60 @@
|
||||
note
|
||||
description : "Objects that ..."
|
||||
author : "$Author: jfiat $"
|
||||
date : "$Date: 2015-02-13 13:08:13 +0100 (ven., 13 févr. 2015) $"
|
||||
revision : "$Revision: 96616 $"
|
||||
|
||||
class
|
||||
CMS_ENV_LOGGER
|
||||
|
||||
inherit
|
||||
CMS_LOGGER
|
||||
|
||||
SHARED_LOGGER
|
||||
rename
|
||||
log as log_facility
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
-- Initialize `Current'.
|
||||
do
|
||||
end
|
||||
|
||||
feature -- Logging
|
||||
|
||||
put_information (a_message: READABLE_STRING_8; a_data: detachable ANY)
|
||||
do
|
||||
log_facility.write_information (log_message (a_message, a_data))
|
||||
end
|
||||
|
||||
put_error (a_message: READABLE_STRING_8; a_data: detachable ANY)
|
||||
do
|
||||
log_facility.write_error (log_message (a_message, a_data))
|
||||
end
|
||||
|
||||
put_warning (a_message: READABLE_STRING_8; a_data: detachable ANY)
|
||||
do
|
||||
log_facility.write_warning (log_message (a_message, a_data))
|
||||
end
|
||||
|
||||
put_critical (a_message: READABLE_STRING_8; a_data: detachable ANY)
|
||||
do
|
||||
log_facility.write_critical (log_message (a_message, a_data))
|
||||
end
|
||||
|
||||
put_alert (a_message: READABLE_STRING_8; a_data: detachable ANY)
|
||||
do
|
||||
log_facility.write_alert (log_message (a_message, a_data))
|
||||
end
|
||||
|
||||
put_debug (a_message: READABLE_STRING_8; a_data: detachable ANY)
|
||||
do
|
||||
log_facility.write_debug (log_message (a_message, a_data))
|
||||
end
|
||||
|
||||
end
|
||||
55
src/service/logger/cms_logger.e
Normal file
55
src/service/logger/cms_logger.e
Normal file
@@ -0,0 +1,55 @@
|
||||
note
|
||||
description : "Objects that ..."
|
||||
author : "$Author: jfiat $"
|
||||
date : "$Date: 2015-02-13 13:08:13 +0100 (ven., 13 févr. 2015) $"
|
||||
revision : "$Revision: 96616 $"
|
||||
|
||||
deferred class
|
||||
CMS_LOGGER
|
||||
|
||||
feature -- Logging
|
||||
|
||||
put_information (a_message: READABLE_STRING_8; a_data: detachable ANY)
|
||||
deferred
|
||||
end
|
||||
|
||||
put_error (a_message: READABLE_STRING_8; a_data: detachable ANY)
|
||||
deferred
|
||||
end
|
||||
|
||||
put_warning (a_message: READABLE_STRING_8; a_data: detachable ANY)
|
||||
deferred
|
||||
end
|
||||
|
||||
put_critical (a_message: READABLE_STRING_8; a_data: detachable ANY)
|
||||
deferred
|
||||
end
|
||||
|
||||
put_alert (a_message: READABLE_STRING_8; a_data: detachable ANY)
|
||||
deferred
|
||||
end
|
||||
|
||||
put_debug (a_message: READABLE_STRING_8; a_data: detachable ANY)
|
||||
deferred
|
||||
end
|
||||
|
||||
feature {NONE} -- Logging
|
||||
|
||||
log_message (a_message: READABLE_STRING_8; a_data: detachable ANY): STRING
|
||||
do
|
||||
create Result.make (a_message.count)
|
||||
if attached {CMS_MODULE} a_data as a_module then
|
||||
Result.append_character ('[')
|
||||
Result.append (a_module.name)
|
||||
Result.append_character (']')
|
||||
Result.append_character (' ')
|
||||
elseif attached {TYPE [detachable ANY]} a_data as a_type then
|
||||
Result.append_character ('{')
|
||||
Result.append (a_type.out)
|
||||
Result.append_character ('}')
|
||||
Result.append_character (' ')
|
||||
end
|
||||
Result.append (a_message)
|
||||
end
|
||||
|
||||
end
|
||||
39
src/service/logger/cms_null_logger.e
Normal file
39
src/service/logger/cms_null_logger.e
Normal file
@@ -0,0 +1,39 @@
|
||||
note
|
||||
description : "Objects that ..."
|
||||
author : "$Author: jfiat $"
|
||||
date : "$Date: 2015-02-13 13:08:13 +0100 (ven., 13 févr. 2015) $"
|
||||
revision : "$Revision: 96616 $"
|
||||
|
||||
class
|
||||
CMS_NULL_LOGGER
|
||||
|
||||
inherit
|
||||
CMS_LOGGER
|
||||
|
||||
feature -- Logging
|
||||
|
||||
put_information (a_message: READABLE_STRING_8; a_data: detachable ANY)
|
||||
do
|
||||
end
|
||||
|
||||
put_error (a_message: READABLE_STRING_8; a_data: detachable ANY)
|
||||
do
|
||||
end
|
||||
|
||||
put_warning (a_message: READABLE_STRING_8; a_data: detachable ANY)
|
||||
do
|
||||
end
|
||||
|
||||
put_critical (a_message: READABLE_STRING_8; a_data: detachable ANY)
|
||||
do
|
||||
end
|
||||
|
||||
put_alert (a_message: READABLE_STRING_8; a_data: detachable ANY)
|
||||
do
|
||||
end
|
||||
|
||||
put_debug (a_message: READABLE_STRING_8; a_data: detachable ANY)
|
||||
do
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,14 +1,13 @@
|
||||
note
|
||||
description: "Summary description for {CMS_REQUEST_UTIL}."
|
||||
author: ""
|
||||
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 $"
|
||||
|
||||
deferred class
|
||||
CMS_REQUEST_UTIL
|
||||
|
||||
inherit
|
||||
|
||||
CMS_ENCODERS
|
||||
|
||||
REFACTORING_HELPER
|
||||
@@ -30,11 +29,25 @@ feature -- User
|
||||
note
|
||||
EIS: "eiffel:?class=AUTHENTICATION_FILTER&feature=execute"
|
||||
do
|
||||
if attached {CMS_USER} req.execution_variable ("user") as l_user then
|
||||
if attached {CMS_USER} req.execution_variable ("_cms_active_user_") as l_user then
|
||||
Result := l_user
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Change
|
||||
|
||||
set_current_user (req: WSF_REQUEST; a_user: detachable CMS_USER)
|
||||
-- Set `a_user' as `current_user'.
|
||||
do
|
||||
if a_user = Void then
|
||||
req.unset_execution_variable ("_cms_active_user_")
|
||||
else
|
||||
req.set_execution_variable ("_cms_active_user_", a_user)
|
||||
end
|
||||
ensure
|
||||
user_set: current_user (req) ~ a_user
|
||||
end
|
||||
|
||||
feature -- Media Type
|
||||
|
||||
current_media_type (req: WSF_REQUEST): detachable READABLE_STRING_32
|
||||
@@ -1,8 +1,8 @@
|
||||
note
|
||||
description: "Summary description for {CMS_URL_UTILITIES}."
|
||||
author: ""
|
||||
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 $"
|
||||
|
||||
deferred class
|
||||
CMS_URL_UTILITIES
|
||||
@@ -1,7 +1,7 @@
|
||||
note
|
||||
description: "Generic CMS Response.It builds the content to get process to render the output"
|
||||
date: "$Date: 2014-12-15 21:43:38 +0100 (lun., 15 déc. 2014) $"
|
||||
revision: "$Revision: 96346 $"
|
||||
date: "$Date: 2015-02-13 13:08:13 +0100 (ven., 13 févr. 2015) $"
|
||||
revision: "$Revision: 96616 $"
|
||||
|
||||
deferred class
|
||||
CMS_RESPONSE
|
||||
@@ -357,7 +357,6 @@ feature -- Blocks regions
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
feature -- Blocks
|
||||
|
||||
add_block (b: CMS_BLOCK; a_default_region: detachable READABLE_STRING_8)
|
||||
@@ -369,7 +368,6 @@ feature -- Blocks
|
||||
l_region.extend (b)
|
||||
end
|
||||
|
||||
|
||||
get_blocks
|
||||
do
|
||||
debug ("refactor_fixme")
|
||||
@@ -754,9 +752,13 @@ feature -- Element Change
|
||||
feature -- Generation
|
||||
|
||||
prepare (page: CMS_HTML_PAGE)
|
||||
local
|
||||
lnk: CMS_LINK
|
||||
do
|
||||
-- Menu
|
||||
add_to_primary_menu (create {CMS_LOCAL_LINK}.make ("Home", "/"))
|
||||
create {CMS_LOCAL_LINK} lnk.make ("Home", "/")
|
||||
lnk.set_weight (-10)
|
||||
add_to_primary_menu (lnk)
|
||||
invoke_menu_system_alter (menu_system)
|
||||
prepare_menu_system (menu_system)
|
||||
|
||||
@@ -774,6 +776,11 @@ feature -- Generation
|
||||
end
|
||||
end
|
||||
|
||||
-- Sort items
|
||||
across menu_system as ic loop
|
||||
ic.item.sort
|
||||
end
|
||||
|
||||
-- Values
|
||||
common_prepare (page)
|
||||
custom_prepare (page)
|
||||
@@ -843,10 +850,6 @@ feature -- Generation
|
||||
page.register_variable (title, "site_title")
|
||||
page.set_is_front (is_front)
|
||||
|
||||
-- Variables/Setup
|
||||
page.register_variable (setup.is_web, "web")
|
||||
page.register_variable (setup.is_html, "html")
|
||||
|
||||
-- Variables/Misc
|
||||
|
||||
-- FIXME: logo .. could be a settings of theme, managed by admin front-end/database.
|
||||
|
||||
62
src/service/user/cms_user_api.e
Normal file
62
src/service/user/cms_user_api.e
Normal file
@@ -0,0 +1,62 @@
|
||||
note
|
||||
description: "Summary description for {CMS_USER_API}."
|
||||
author: ""
|
||||
date: "$Date: 2015-02-13 13:08:13 +0100 (ven., 13 févr. 2015) $"
|
||||
revision: "$Revision: 96616 $"
|
||||
|
||||
class
|
||||
CMS_USER_API
|
||||
|
||||
inherit
|
||||
CMS_MODULE_API
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Access
|
||||
|
||||
user_by_name (a_username: READABLE_STRING_32): detachable CMS_USER
|
||||
-- User by name `a_user_name', if any.
|
||||
do
|
||||
Result := storage.user_by_name (a_username)
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_valid_credential (a_auth_login, a_auth_password: READABLE_STRING_32): BOOLEAN
|
||||
-- Is the credentials `a_auth_login' and `a_auth_password' valid?
|
||||
do
|
||||
Result := storage.is_valid_credential (a_auth_login, a_auth_password)
|
||||
end
|
||||
|
||||
feature -- Change User
|
||||
|
||||
new_user (a_user: CMS_USER)
|
||||
-- Add a new user `a_user'.
|
||||
require
|
||||
no_id: not a_user.has_id
|
||||
no_hashed_password: a_user.hashed_password = Void
|
||||
do
|
||||
if
|
||||
attached a_user.password as l_password and then
|
||||
attached a_user.email as l_email
|
||||
then
|
||||
storage.new_user (a_user)
|
||||
else
|
||||
debug ("refactor_fixme")
|
||||
fixme ("Add error")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
update_user (a_user: CMS_USER)
|
||||
-- Update user `a_user'.
|
||||
require
|
||||
has_id: a_user.has_id
|
||||
do
|
||||
storage.update_user (a_user)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,7 +1,7 @@
|
||||
note
|
||||
description: "Abstract class describing a generic theme"
|
||||
date: "$Date: 2014-11-18 02:49:56 +0100 (mar., 18 nov. 2014) $"
|
||||
revision: "$Revision: 96108 $"
|
||||
date: "$Date: 2015-02-16 12:52:35 +0100 (lun., 16 févr. 2015) $"
|
||||
revision: "$Revision: 96630 $"
|
||||
|
||||
deferred class
|
||||
CMS_THEME
|
||||
@@ -69,7 +69,7 @@ feature -- Conversion
|
||||
end
|
||||
s.append (a_block.to_html (Current))
|
||||
else
|
||||
create s.make_from_string ("<div class=%"block%" id=%"" + a_block.name + "%">")
|
||||
create s.make_from_string ("<div class=%"block%" id=%"block-" + a_block.name + "%">")
|
||||
if attached a_block.title as l_title then
|
||||
s.append ("<div class=%"title%">" + html_encoded (l_title) + "</div>")
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
note
|
||||
description: "Smarty template CMS theme."
|
||||
date: "$Date: 2014-12-05 22:39:27 +0100 (ven., 05 déc. 2014) $"
|
||||
revision: "$Revision: 96260 $"
|
||||
date: "$Date: 2015-02-09 22:29:56 +0100 (lun., 09 févr. 2015) $"
|
||||
revision: "$Revision: 96596 $"
|
||||
|
||||
class
|
||||
SMARTY_CMS_THEME
|
||||
@@ -56,7 +56,7 @@ feature -- Access
|
||||
else
|
||||
l_regions := <<"top","header", "highlighted","help", "content", "footer", "first_sidebar", "second_sidebar", "bottom">>
|
||||
end
|
||||
internaL_regions := l_regions
|
||||
internal_regions := l_regions
|
||||
end
|
||||
Result := l_regions
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user