Added support for log stored in CMS_STORAGE.
Added support for custom value stored in CMS_STORAGE. Added optional css classes addition to CMS_BLOCK output. Refactored storage, to manage node from node module code only (or mostly). TODO: improved view for a cms node, for now hardcoded.
This commit is contained in:
@@ -47,6 +47,10 @@ feature {NONE} -- Initialize
|
||||
setup.enabled_modules as ic
|
||||
loop
|
||||
l_module := ic.item
|
||||
-- FIXME: should we initialize first, and then install
|
||||
-- or the reverse, or merge installation and initialization
|
||||
-- and leave the responsability to the module to know
|
||||
-- if this is installed or not...
|
||||
if not l_module.is_installed (Current) then
|
||||
l_module.install (Current)
|
||||
end
|
||||
@@ -72,6 +76,11 @@ feature -- Formats
|
||||
create Result
|
||||
end
|
||||
|
||||
format (a_format_name: detachable READABLE_STRING_GENERAL): detachable CONTENT_FORMAT
|
||||
do
|
||||
Result := formats.item (a_format_name)
|
||||
end
|
||||
|
||||
feature -- Status Report
|
||||
|
||||
has_error: BOOLEAN
|
||||
@@ -86,6 +95,47 @@ feature -- Status Report
|
||||
Result := error_handler.as_string_representation
|
||||
end
|
||||
|
||||
feature -- Logging
|
||||
|
||||
log (a_category: READABLE_STRING_8; a_message: READABLE_STRING_8; a_level: INTEGER; a_link: detachable CMS_LINK)
|
||||
local
|
||||
l_log: CMS_LOG
|
||||
m: STRING
|
||||
do
|
||||
create l_log.make (a_category, a_message, a_level, Void)
|
||||
if a_link /= Void then
|
||||
l_log.set_link (a_link)
|
||||
end
|
||||
storage.save_log (l_log)
|
||||
|
||||
create m.make_from_string ("[" + a_category + "] ")
|
||||
m.append (a_message)
|
||||
if a_link /= Void then
|
||||
m.append (" [" + url_encoded (a_link.title) + "]("+ a_link.location +")")
|
||||
end
|
||||
|
||||
inspect a_level
|
||||
when {CMS_LOG}.level_emergency then
|
||||
logger.put_alert (m, Void)
|
||||
when {CMS_LOG}.level_alert then
|
||||
logger.put_alert (m, Void)
|
||||
when {CMS_LOG}.level_critical then
|
||||
logger.put_critical (m, Void)
|
||||
when {CMS_LOG}.level_error then
|
||||
logger.put_error (m, Void)
|
||||
when {CMS_LOG}.level_warning then
|
||||
logger.put_warning (m, Void)
|
||||
when {CMS_LOG}.level_notice then
|
||||
logger.put_information (m, Void)
|
||||
when {CMS_LOG}.level_info then
|
||||
logger.put_information (m, Void)
|
||||
when {CMS_LOG}.level_debug then
|
||||
logger.put_debug (m, Void)
|
||||
else
|
||||
logger.put_debug (m, Void)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Permissions system
|
||||
|
||||
user_has_permission (a_user: detachable CMS_USER; a_permission: detachable READABLE_STRING_GENERAL): BOOLEAN
|
||||
@@ -114,6 +164,16 @@ feature -- Query: module
|
||||
Result := Void
|
||||
end
|
||||
end
|
||||
ensure
|
||||
Result /= Void implies (Result.is_enabled and Result.generating_type ~ a_type)
|
||||
end
|
||||
|
||||
module_api (a_type: TYPE [CMS_MODULE]): detachable CMS_MODULE_API
|
||||
-- Enabled module API associated with module typed `a_type'.
|
||||
do
|
||||
if attached module (a_type) as mod then
|
||||
Result := mod.module_api
|
||||
end
|
||||
end
|
||||
|
||||
module_by_name (a_name: READABLE_STRING_GENERAL): detachable CMS_MODULE
|
||||
@@ -133,7 +193,15 @@ feature -- Query: module
|
||||
end
|
||||
end
|
||||
ensure
|
||||
Result /= Void implies Result.name.is_case_insensitive_equal_general (a_name)
|
||||
Result /= Void implies (Result.is_enabled and Result.name.is_case_insensitive_equal_general (a_name))
|
||||
end
|
||||
|
||||
module_api_by_name (a_name: READABLE_STRING_GENERAL): detachable CMS_MODULE_API
|
||||
-- Enabled module API associated with module named `a_name'.
|
||||
do
|
||||
if attached module_by_name (a_name) as mod then
|
||||
Result := mod.module_api
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Query: API
|
||||
|
||||
@@ -36,10 +36,37 @@ feature -- Response helpers
|
||||
-- res.send (create {CMS_REDIRECTION_RESPONSE_MESSAGE}.make (a_location))
|
||||
end
|
||||
|
||||
send_access_denied (res: WSF_RESPONSE)
|
||||
send_access_denied_message (res: WSF_RESPONSE)
|
||||
-- Send via `res' an access denied response.
|
||||
do
|
||||
res.send (create {CMS_FORBIDDEN_RESPONSE_MESSAGE}.make)
|
||||
end
|
||||
|
||||
send_access_denied (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Forbidden response.
|
||||
local
|
||||
r: CMS_RESPONSE
|
||||
do
|
||||
create {FORBIDDEN_ERROR_CMS_RESPONSE} r.make (req, res, api)
|
||||
r.execute
|
||||
end
|
||||
|
||||
send_not_found (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Send via `res' a not found response.
|
||||
local
|
||||
r: CMS_RESPONSE
|
||||
do
|
||||
create {NOT_FOUND_ERROR_CMS_RESPONSE} r.make (req, res, api)
|
||||
r.execute
|
||||
end
|
||||
|
||||
send_bad_request (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Send via `res' a bad request response.
|
||||
local
|
||||
r: CMS_RESPONSE
|
||||
do
|
||||
create {BAD_REQUEST_ERROR_CMS_RESPONSE} r.make (req, res, api)
|
||||
r.execute
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -9,7 +9,11 @@ deferred class
|
||||
|
||||
feature -- Logging
|
||||
|
||||
put_information (a_message: READABLE_STRING_8; a_data: detachable ANY)
|
||||
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
|
||||
|
||||
@@ -21,11 +25,7 @@ feature -- Logging
|
||||
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)
|
||||
put_information (a_message: READABLE_STRING_8; a_data: detachable ANY)
|
||||
deferred
|
||||
end
|
||||
|
||||
|
||||
@@ -162,9 +162,14 @@ feature -- Access: CMS
|
||||
-- Associated values indexed by string name.
|
||||
|
||||
|
||||
feature -- User access
|
||||
|
||||
user: detachable CMS_USER
|
||||
do
|
||||
Result := current_user (request)
|
||||
end
|
||||
|
||||
feature -- Permission
|
||||
-- FIXME: to be implemented has_permissions and has_permission.
|
||||
|
||||
has_permission (a_permission: READABLE_STRING_GENERAL): BOOLEAN
|
||||
-- Does current user has permission `a_permission' ?
|
||||
@@ -442,6 +447,9 @@ feature -- Blocks
|
||||
do
|
||||
if attached primary_tabs as m and then not m.is_empty then
|
||||
create Result.make (m)
|
||||
Result.is_horizontal := True
|
||||
Result.set_is_raw (True)
|
||||
Result.add_css_class ("tabs")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -459,7 +467,7 @@ feature -- Blocks
|
||||
s: STRING
|
||||
l_hb: STRING
|
||||
do
|
||||
create s.make_from_string (theme.menu_html (primary_menu, True))
|
||||
create s.make_from_string (theme.menu_html (primary_menu, True, Void))
|
||||
create l_hb.make_empty
|
||||
create Result.make ("header", Void, l_hb, Void)
|
||||
Result.set_is_raw (True)
|
||||
@@ -469,7 +477,15 @@ feature -- Blocks
|
||||
do
|
||||
create Result.make_empty
|
||||
Result.append ("<div id=%"menu-bar%">")
|
||||
Result.append (theme.menu_html (primary_menu, True))
|
||||
Result.append (theme.menu_html (primary_menu, True, Void))
|
||||
Result.append ("</div>")
|
||||
end
|
||||
|
||||
horizontal_primary_tabs_html: STRING
|
||||
do
|
||||
create Result.make_empty
|
||||
Result.append ("<div id=%"tabs-bar%">")
|
||||
Result.append (theme.menu_html (primary_tabs, True, Void))
|
||||
Result.append ("</div>")
|
||||
end
|
||||
|
||||
@@ -652,6 +668,11 @@ feature -- Menu: change
|
||||
add_to_menu (lnk, primary_menu)
|
||||
end
|
||||
|
||||
add_to_primary_tabs (lnk: CMS_LINK)
|
||||
do
|
||||
add_to_menu (lnk, primary_tabs)
|
||||
end
|
||||
|
||||
add_to_menu (lnk: CMS_LINK; m: CMS_MENU)
|
||||
do
|
||||
-- if attached {CMS_LOCAL_LINK} lnk as l_local then
|
||||
@@ -872,6 +893,7 @@ feature -- Generation
|
||||
|
||||
-- Menu...
|
||||
page.register_variable (horizontal_primary_menu_html, "primary_nav")
|
||||
page.register_variable (horizontal_primary_tabs_html, "primary_tabs")
|
||||
|
||||
-- Page related
|
||||
if attached page_title as l_page_title then
|
||||
|
||||
38
src/service/response/error/forbidden_error_cms_response.e
Normal file
38
src/service/response/error/forbidden_error_cms_response.e
Normal file
@@ -0,0 +1,38 @@
|
||||
note
|
||||
description: "Summary description for {FORBIDDEN_ERROR_CMS_RESPONSE}."
|
||||
date: "$Date: 2014-11-13 19:34:00 +0100 (jeu., 13 nov. 2014) $"
|
||||
revision: "$Revision: 96086 $"
|
||||
|
||||
class
|
||||
FORBIDDEN_ERROR_CMS_RESPONSE
|
||||
|
||||
inherit
|
||||
|
||||
CMS_RESPONSE
|
||||
redefine
|
||||
custom_prepare
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Generation
|
||||
|
||||
custom_prepare (page: CMS_HTML_PAGE)
|
||||
do
|
||||
page.register_variable (request.absolute_script_url (request.path_info), "request")
|
||||
page.set_status_code ({HTTP_STATUS_CODE}.forbidden)
|
||||
page.register_variable (page.status_code.out, "code")
|
||||
end
|
||||
|
||||
feature -- Execution
|
||||
|
||||
process
|
||||
-- Computed response message.
|
||||
do
|
||||
set_title ("Forbidden")
|
||||
set_page_title ("Forbidden")
|
||||
set_main_content ("<em>Access denied for resource <strong>" + request.request_uri + "</strong>.</em>")
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user