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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user