diff --git a/library/src/configuration/cms_default_setup.e b/library/src/configuration/cms_default_setup.e index 03a37bb..7a9cb48 100644 --- a/library/src/configuration/cms_default_setup.e +++ b/library/src/configuration/cms_default_setup.e @@ -41,8 +41,12 @@ feature {NONE} -- Initialization themes_location := configuration.themes_location theme_name := configuration.theme_name ("default") + debug ("refactor_fixme") + fixme ("Review export clause for configuration and layout") + end + compute_theme_location - compute_theme_resource_location + compute_theme_assets_location end initialize_modules @@ -100,14 +104,15 @@ feature -- Compute location theme_location := themes_location.extended (theme_name) end - compute_theme_resource_location + compute_theme_assets_location -- assets (js, css, images, etc) -- Not used at the moment. do debug ("refactor_fixme") fixme ("Check if we really need it") end - theme_resource_location := theme_location + -- Check how to get this path from the CMS_THEME information. + theme_assets_location := theme_location.extended ("assets") end end diff --git a/library/src/configuration/cms_setup.e b/library/src/configuration/cms_setup.e index e2ffd30..789dc8e 100644 --- a/library/src/configuration/cms_setup.e +++ b/library/src/configuration/cms_setup.e @@ -54,8 +54,8 @@ feature -- Access: Theme theme_location: PATH -- Path to a particular theme. - theme_resource_location: PATH - -- Path to a particular theme resource. + theme_assets_location: PATH + -- Path to a particular theme assets folder. theme_information_location: PATH -- theme informations. diff --git a/library/src/hooks/cms_hook_auto_register.e b/library/src/hooks/cms_hook_auto_register.e index 5b94484..a9238bb 100644 --- a/library/src/hooks/cms_hook_auto_register.e +++ b/library/src/hooks/cms_hook_auto_register.e @@ -30,6 +30,9 @@ feature -- Hook if attached {CMS_HOOK_FORM_ALTER} Current as h_form then a_response.subscribe_to_form_alter_hook (h_form) end + if attached {CMS_HOOK_VALUE_TABLE_ALTER} Current as h_value then + a_response.subscribe_to_value_table_alter_hook (h_value) + end end end diff --git a/library/src/modules/cms_debug_module.e b/library/src/modules/cms_debug_module.e new file mode 100644 index 0000000..da1c39f --- /dev/null +++ b/library/src/modules/cms_debug_module.e @@ -0,0 +1,140 @@ +note + description: "Summary description for {CMS_DEBUG_MODULE}." + date: "$Date: 2014-08-28 13:21:49 +0200 (jeu., 28 août 2014) $" + revision: "$Revision: 95708 $" + +class + CMS_DEBUG_MODULE + +inherit + CMS_MODULE + redefine + register_hooks + end + +-- CMS_HOOK_BLOCK + + CMS_HOOK_AUTO_REGISTER + + SHARED_EXECUTION_ENVIRONMENT + export + {NONE} all + end + +create + make + +feature {NONE} -- Initialization + + make + do + name := "debug" + version := "1.0" + description := "Debug" + package := "cms" + end + +feature -- Router + + router (a_api: CMS_API): WSF_ROUTER + -- Router configuration. + do + create Result.make (1) + Result.handle ("/debug/", create {WSF_URI_TEMPLATE_AGENT_HANDLER}.make (agent handle_debug (a_api, ?, ?))) + end + +feature -- Hooks configuration + + register_hooks (a_response: CMS_RESPONSE) + -- Module hooks configuration. + do + auto_subscribe_to_hooks (a_response) +-- a_response.subscribe_to_block_hook (Current) + end + +feature -- Hooks + +-- block_list: ITERABLE [like {CMS_BLOCK}.name] +-- do +-- Result := <<"debug-info">> +-- end + +-- get_block_view (a_block_id: READABLE_STRING_8; a_response: CMS_RESPONSE) +-- local +-- b: CMS_CONTENT_BLOCK +-- do +-- create b.make ("debug-info", "Debug", "... ", a_response.formats.plain_text) +-- a_response.add_block (b, Void) +-- end + +feature -- Handler + + handle_debug (api: CMS_API; req: WSF_REQUEST; res: WSF_RESPONSE) + local + r: CMS_RESPONSE + s: STRING + do + if req.is_get_request_method then + create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, api) + r.set_title ("DEBUG") + + create s.make_empty + append_info_to ("Name", api.setup.site_name, r, s) + append_info_to ("Url", api.setup.site_url, r, s) + + if attached api.setup.configuration.configuration_location as l_loc then + s.append ("
") + append_info_to ("Configuration file", l_loc.name, r, s) + end + + s.append ("
") + + append_info_to ("Current dir", execution_environment.current_working_path.utf_8_name, r, s) +-- append_info_to ("Base url", cms.base_url, r, s) +-- append_info_to ("Script url", cms.script_url, r, s) + s.append ("
") + append_info_to ("Site dir", api.setup.layout.path.utf_8_name, r, s) + append_info_to ("Www dir", api.setup.layout.www_path.utf_8_name, r, s) + append_info_to ("Assets dir", api.setup.layout.assets_path.utf_8_name, r, s) + append_info_to ("Config dir", api.setup.layout.config_path.utf_8_name, r, s) + s.append ("
") + append_info_to ("Theme", api.setup.theme_name, r, s) + append_info_to ("Theme location", api.setup.themes_location.utf_8_name, r, s) + s.append ("
") +-- append_info_to ("Files location", api...files_location.utf_8_name, r, s) +-- s.append ("
") + + append_info_to ("Url", r.url ("/", Void), r, s) +-- if attached r.user as u then +-- append_info_to ("User", u.name, r, s) +-- append_info_to ("User url", r.user_url (u), r, s) +-- end + + r.set_main_content (s) + else + create {NOT_FOUND_ERROR_CMS_RESPONSE} r.make (req, res, api) + end + r.execute + end + + append_info_to (n: READABLE_STRING_8; v: detachable READABLE_STRING_GENERAL; r: CMS_RESPONSE; t: STRING) + do + t.append ("
  • ") + t.append ("" + n + ": ") + if v /= Void then + t.append (r.html_encoded (v)) + end + t.append ("
  • ") + end + +note + copyright: "Copyright (c) 1984-2013, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" +end diff --git a/library/src/service/cms_service.e b/library/src/service/cms_service.e index f37b1cb..a5a6c48 100644 --- a/library/src/service/cms_service.e +++ b/library/src/service/cms_service.e @@ -144,6 +144,16 @@ feature -- Settings: router fhdl: WSF_FILE_SYSTEM_HANDLER do log.write_debug (generator + ".configure_api_file_handler") + + create fhdl.make_hidden_with_path (setup.theme_assets_location) + fhdl.disable_index + fhdl.set_not_found_handler (agent (ia_uri: READABLE_STRING_8; ia_req: WSF_REQUEST; ia_res: WSF_RESPONSE) + do + execute_default (ia_req, ia_res) + end) + a_router.handle_with_request_methods ("/theme/", fhdl, router.methods_GET) + + create fhdl.make_hidden_with_path (setup.layout.www_path) fhdl.disable_index fhdl.set_not_found_handler (agent (ia_uri: READABLE_STRING_8; ia_req: WSF_REQUEST; ia_res: WSF_RESPONSE) @@ -244,8 +254,12 @@ feature -- Execution execute_default (req: WSF_REQUEST; res: WSF_RESPONSE) -- Default request handler if no other are relevant + local + r: NOT_FOUND_ERROR_CMS_RESPONSE do to_implement ("Default response for CMS_SERVICE") + create r.make (req, res, api) + r.execute end note diff --git a/library/src/service/response/cms_response.e b/library/src/service/response/cms_response.e index b8ad61f..6d52e5f 100644 --- a/library/src/service/response/cms_response.e +++ b/library/src/service/response/cms_response.e @@ -88,7 +88,7 @@ feature -- URL utilities local l_path_info: READABLE_STRING_8 do - l_path_info := request.path_info + l_path_info := request.percent_encoded_path_info if attached setup.front_page_path as l_front_page_path then Result := l_front_page_path.same_string (l_path_info) else @@ -964,8 +964,13 @@ feature {NONE} -- Execution local cms_page: CMS_HTML_PAGE page: CMS_HTML_PAGE_RESPONSE + utf: UTF_CONVERTER do - create cms_page.make + if attached {READABLE_STRING_GENERAL} values.item ("optional_content_type") as l_type then + create cms_page.make_typed (utf.utf_32_string_to_utf_8_string_8 (l_type)) + else + create cms_page.make + end prepare (cms_page) create page.make (theme.page_html (cms_page)) page.set_status_code (status_code) diff --git a/library/src/service/response/not_found_error_cms_response.e b/library/src/service/response/not_found_error_cms_response.e new file mode 100644 index 0000000..1f6c87c --- /dev/null +++ b/library/src/service/response/not_found_error_cms_response.e @@ -0,0 +1,38 @@ +note + description: "Summary description for {NOT_FOUND_ERROR_CMS_RESPONSE}." + date: "$Date$" + revision: "$Revision$" + +class + NOT_FOUND_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}.not_found) + page.register_variable (page.status_code.out, "code") + end + +feature -- Execution + + process + -- Computed response message. + do + set_title ("Not Found") + set_page_title ("Not Found") + set_main_content ("The requested page could not be found.") + end +end + diff --git a/library/src/service/response/not_implemented_error_cms_response.e b/library/src/service/response/not_implemented_error_cms_response.e index 2d37558..b2c9e81 100644 --- a/library/src/service/response/not_implemented_error_cms_response.e +++ b/library/src/service/response/not_implemented_error_cms_response.e @@ -21,8 +21,8 @@ feature -- Generation custom_prepare (page: CMS_HTML_PAGE) do page.register_variable (request.absolute_script_url (request.path_info), "request") - page.register_variable ("501", "code") - page.set_status_code (501) + page.set_status_code ({HTTP_STATUS_CODE}.not_implemented) + page.register_variable (page.status_code.out, "code") end feature -- Execution @@ -32,6 +32,7 @@ feature -- Execution do set_title ("Not Implemented") set_page_title (Void) + set_main_content (request.percent_encoded_path_info + " is not implemented!") end end diff --git a/library/src/theme/cms_html_page.e b/library/src/theme/cms_html_page.e index 3b06281..ca3353e 100644 --- a/library/src/theme/cms_html_page.e +++ b/library/src/theme/cms_html_page.e @@ -13,7 +13,7 @@ create feature {NONE} -- Initialization - make_typed (a_type: like type) + make_typed (a_type: attached like type) -- Make current page with optional page type `a_type'. do make