Merged CMS based on concurrent EWF (i.e ewf_v1) with blog branch.
This commit is contained in:
+57
-10
@@ -148,17 +148,15 @@ feature -- Permissions system
|
||||
|
||||
feature -- Query: module
|
||||
|
||||
module (a_type: TYPE [detachable CMS_MODULE]): detachable CMS_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 ...
|
||||
local
|
||||
t: STRING_8
|
||||
-- t: STRING_8
|
||||
l_type: TYPE [detachable CMS_MODULE]
|
||||
do
|
||||
t := a_type.name
|
||||
if t.starts_with ("!") then
|
||||
t.remove_head (1)
|
||||
end
|
||||
-- t := type_name_without_annotation (a_type)
|
||||
|
||||
across
|
||||
setup.modules as ic
|
||||
until
|
||||
@@ -171,8 +169,12 @@ feature -- Query: module
|
||||
l_type := Result.generating_type
|
||||
if a_type ~ l_type then
|
||||
-- Found
|
||||
elseif t.same_string (l_type.name) then
|
||||
elseif
|
||||
attached a_type.attempt (Result) and then attached l_type.generating_type.attempt (a_type)
|
||||
then
|
||||
-- Found
|
||||
-- elseif t.same_string (type_name_without_annotation (l_type)) then
|
||||
-- -- Found
|
||||
else
|
||||
Result := Void
|
||||
end
|
||||
@@ -185,8 +187,11 @@ feature -- Query: module
|
||||
module_api (a_type: TYPE [CMS_MODULE]): detachable CMS_MODULE_API
|
||||
-- Enabled module API associated with module typed `a_type'.
|
||||
do
|
||||
if attached {CMS_MODULE} module (a_type) as mod then
|
||||
if attached module (a_type) as mod then
|
||||
if mod.is_enabled then
|
||||
if not mod.is_initialized then
|
||||
mod.initialize (Current)
|
||||
end
|
||||
Result := mod.module_api
|
||||
end
|
||||
end
|
||||
@@ -236,9 +241,16 @@ feature -- Query: API
|
||||
|
||||
feature -- Path aliases
|
||||
|
||||
is_valid_path_alias (a_alias: READABLE_STRING_8): BOOLEAN
|
||||
do
|
||||
Result := a_alias.is_empty or else not a_alias.starts_with_general ("/")
|
||||
end
|
||||
|
||||
set_path_alias (a_source, a_alias: READABLE_STRING_8; a_keep_previous: BOOLEAN)
|
||||
-- Set `a_alias' as alias of `a_source',
|
||||
-- and eventually unset previous alias if any.
|
||||
require
|
||||
valid_alias: is_valid_path_alias (a_alias)
|
||||
local
|
||||
l_continue: BOOLEAN
|
||||
do
|
||||
@@ -283,8 +295,8 @@ feature -- Path aliases
|
||||
-- Resolved path for alias `a_alias'.
|
||||
--| the CMS supports aliases for path, and then this function simply returns
|
||||
--| the effective target path/url for this `a_alias'.
|
||||
--| For instance: /articles/2015/may/this-is-an-article can be an alias to /node/123
|
||||
--| This function will return "/node/123".
|
||||
--| For instance: articles/2015/may/this-is-an-article can be an alias to node/123
|
||||
--| This function will return "node/123".
|
||||
--| If the alias is bad (i.e does not alias real path), then this function
|
||||
--| returns the alias itself.
|
||||
do
|
||||
@@ -310,6 +322,41 @@ feature {NONE}-- Implemenation
|
||||
internal_user_api: detachable like user_api
|
||||
-- Cached value for `user_api'.
|
||||
|
||||
type_name_without_annotation (a_type: TYPE [detachable ANY]): STRING
|
||||
-- Type name for `a_type, without any annotation.
|
||||
-- Used by `module' to search by type.
|
||||
local
|
||||
i,j,n: INTEGER
|
||||
c: CHARACTER
|
||||
do
|
||||
create Result.make_from_string (a_type.name)
|
||||
from
|
||||
i := 1
|
||||
n := Result.count
|
||||
until
|
||||
i > n
|
||||
loop
|
||||
c := Result[i]
|
||||
if c = '!' or c = '?' then
|
||||
Result.remove (i)
|
||||
n := n - 1
|
||||
elseif c.is_lower then
|
||||
j := Result.index_of (' ', i + 1)
|
||||
if j > 0 then
|
||||
Result.remove_substring (i, j)
|
||||
n := n - (j - i)
|
||||
end
|
||||
else
|
||||
i := i + 1
|
||||
end
|
||||
end
|
||||
if Result.starts_with ("!") or Result.starts_with ("?") then
|
||||
Result.remove_head (1)
|
||||
elseif Result.starts_with ("detachable ") then
|
||||
Result.remove_head (11)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Environment
|
||||
|
||||
module_configuration (a_module_name: READABLE_STRING_GENERAL; a_name: detachable READABLE_STRING_GENERAL): detachable CONFIG_READER
|
||||
|
||||
@@ -14,4 +14,10 @@ create
|
||||
make,
|
||||
make_from_manifest
|
||||
|
||||
convert
|
||||
make_from_manifest ({ ARRAY [TUPLE [key: STRING; value: detachable ANY]],
|
||||
ARRAY [TUPLE [STRING_8, ARRAY [TUPLE [STRING_8, STRING_32]]]],
|
||||
ARRAY [TUPLE [STRING_8, ARRAY [TUPLE [STRING_8, STRING_8]]]]
|
||||
})
|
||||
|
||||
end
|
||||
|
||||
@@ -6,56 +6,56 @@ note
|
||||
even for a specific handler.
|
||||
]"
|
||||
|
||||
class
|
||||
CMS_SERVICE
|
||||
deferred class
|
||||
CMS_EXECUTION
|
||||
|
||||
inherit
|
||||
WSF_ROUTED_SKELETON_SERVICE
|
||||
rename
|
||||
execute as execute_service
|
||||
WSF_FILTERED_ROUTED_SKELETON_EXECUTION
|
||||
undefine
|
||||
requires_proxy
|
||||
redefine
|
||||
create_router, router,
|
||||
execute_default,
|
||||
create_router,
|
||||
router
|
||||
end
|
||||
|
||||
WSF_FILTERED_SERVICE
|
||||
|
||||
WSF_FILTER
|
||||
rename
|
||||
execute as execute_filter
|
||||
filter_execute,
|
||||
initialize
|
||||
end
|
||||
|
||||
WSF_NO_PROXY_POLICY
|
||||
|
||||
WSF_URI_HELPER_FOR_ROUTED_SERVICE
|
||||
WSF_URI_HELPER_FOR_ROUTED_EXECUTION
|
||||
|
||||
WSF_URI_TEMPLATE_HELPER_FOR_ROUTED_SERVICE
|
||||
WSF_URI_TEMPLATE_HELPER_FOR_ROUTED_EXECUTION
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
SHARED_LOGGER
|
||||
|
||||
create
|
||||
make
|
||||
--create
|
||||
-- make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_setup: CMS_SETUP)
|
||||
initialize
|
||||
-- Build a CMS service with `a_api'
|
||||
local
|
||||
l_setup: CMS_SETUP
|
||||
do
|
||||
create api.make (a_setup)
|
||||
initialize
|
||||
l_setup := initial_cms_setup
|
||||
setup_storage (l_setup)
|
||||
setup_modules (l_setup)
|
||||
create api.make (l_setup)
|
||||
modules := setup.enabled_modules
|
||||
|
||||
initialize_cms
|
||||
Precursor
|
||||
end
|
||||
|
||||
initialize
|
||||
-- Initialize various parts of the CMS service.
|
||||
initialize_cms
|
||||
do
|
||||
initialize_modules
|
||||
initialize_users
|
||||
initialize_mailer
|
||||
write_debug_log (generator + ".initialize_cms")
|
||||
|
||||
-- CMS Initialization
|
||||
|
||||
-- initialize_router
|
||||
-- initialize_filter: expanded here, for void-safety concern.
|
||||
create_filter
|
||||
@@ -71,20 +71,41 @@ feature {NONE} -- Initialization
|
||||
only_enabled_modules: across modules as ic all ic.item.is_enabled end
|
||||
end
|
||||
|
||||
initialize_users
|
||||
-- Initialize users.
|
||||
do
|
||||
feature -- Factory
|
||||
|
||||
initial_cms_setup: CMS_SETUP
|
||||
deferred
|
||||
end
|
||||
|
||||
initialize_mailer
|
||||
-- Initialize mailer engine.
|
||||
feature -- Access
|
||||
|
||||
api: CMS_API
|
||||
-- API service.
|
||||
|
||||
setup: CMS_SETUP
|
||||
-- CMS Setup.
|
||||
do
|
||||
to_implement ("To Implement mailer")
|
||||
Result := api.setup
|
||||
end
|
||||
|
||||
modules: CMS_MODULE_COLLECTION
|
||||
-- Configurator of possible modules.
|
||||
|
||||
feature -- CMS setup
|
||||
|
||||
setup_modules (a_setup: CMS_SETUP)
|
||||
-- Setup additional modules.
|
||||
deferred
|
||||
end
|
||||
|
||||
setup_storage (a_setup: CMS_SETUP)
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- Settings: router
|
||||
|
||||
router: CMS_ROUTER
|
||||
-- <Precursor>
|
||||
|
||||
create_router
|
||||
-- Create `router'.
|
||||
@@ -124,9 +145,9 @@ feature -- Settings: router
|
||||
create l_root_handler.make (api)
|
||||
create l_methods
|
||||
l_methods.enable_get
|
||||
a_router.handle_with_request_methods ("/", l_root_handler, l_methods)
|
||||
a_router.handle_with_request_methods ("", l_root_handler, l_methods)
|
||||
map_uri_agent_with_request_methods ("/favicon.ico", agent handle_favicon, a_router.methods_head_get)
|
||||
a_router.handle ("/", l_root_handler, l_methods)
|
||||
a_router.handle ("", l_root_handler, l_methods)
|
||||
map_uri_agent ("/favicon.ico", agent handle_favicon, a_router.methods_head_get)
|
||||
end
|
||||
|
||||
configure_api_file_handler (a_router: WSF_ROUTER)
|
||||
@@ -137,11 +158,11 @@ feature -- Settings: router
|
||||
|
||||
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)
|
||||
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)
|
||||
a_router.handle ("/theme/", fhdl, router.methods_GET)
|
||||
|
||||
|
||||
create fhdl.make_hidden_with_path (setup.environment.www_path)
|
||||
@@ -150,17 +171,17 @@ feature -- Settings: router
|
||||
do
|
||||
execute_default (ia_req, ia_res)
|
||||
end)
|
||||
a_router.handle_with_request_methods ("/", fhdl, router.methods_GET)
|
||||
a_router.handle ("/", fhdl, router.methods_GET)
|
||||
end
|
||||
|
||||
feature -- Execute Filter
|
||||
|
||||
execute_filter (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
filter_execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute the filter.
|
||||
do
|
||||
res.put_header_line ("Date: " + (create {HTTP_DATE}.make_now_utc).string)
|
||||
res.put_header_line ("X-EWF-Server: CMS_v1.0")
|
||||
execute_service (req, res)
|
||||
Precursor (req, res)
|
||||
end
|
||||
|
||||
feature -- Filters
|
||||
@@ -180,10 +201,10 @@ feature -- Filters
|
||||
f.set_next (l_filter)
|
||||
l_filter := f
|
||||
|
||||
-- Error Filter
|
||||
create {CMS_ERROR_FILTER} f.make (api)
|
||||
f.set_next (l_filter)
|
||||
l_filter := f
|
||||
-- -- Error Filter
|
||||
-- create {CMS_ERROR_FILTER} f.make (api)
|
||||
-- f.set_next (l_filter)
|
||||
-- l_filter := f
|
||||
|
||||
-- Include filters from modules
|
||||
l_api := api
|
||||
@@ -223,20 +244,6 @@ feature -- Filters
|
||||
f.set_next (Current)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
api: CMS_API
|
||||
-- API service.
|
||||
|
||||
setup: CMS_SETUP
|
||||
-- CMS setup.
|
||||
do
|
||||
Result := api.setup
|
||||
end
|
||||
|
||||
modules: CMS_MODULE_COLLECTION
|
||||
-- Configurator of possible modules.
|
||||
|
||||
feature -- Execution
|
||||
|
||||
handle_favicon (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
@@ -49,28 +49,32 @@ feature {CMS_API} -- Access: API
|
||||
|
||||
module_api: detachable CMS_MODULE_API
|
||||
-- Eventual module api.
|
||||
require
|
||||
is_initialized: is_initialized
|
||||
do
|
||||
-- No API by default.
|
||||
end
|
||||
|
||||
feature {CMS_API} -- Module management
|
||||
|
||||
is_installed (api: CMS_API): BOOLEAN
|
||||
-- Is Current module installed?
|
||||
do
|
||||
Result := is_enabled
|
||||
-- FIXME: implement proper installation status.
|
||||
Result := attached api.storage.custom_value ("is_initialized", "module-" + name) as v and then v.is_case_insensitive_equal_general ("yes")
|
||||
end
|
||||
|
||||
install (api: CMS_API)
|
||||
require
|
||||
is_not_installed: not is_installed (api)
|
||||
do
|
||||
-- Not Yet Supported
|
||||
api.storage.set_custom_value ("is_initialized", "module-" + name, "yes")
|
||||
end
|
||||
|
||||
uninstall (api: CMS_API)
|
||||
require
|
||||
is_installed: is_installed (api)
|
||||
do
|
||||
-- Not Yet Supported
|
||||
api.storage.set_custom_value ("is_initialized", "module-" + name, "no")
|
||||
end
|
||||
|
||||
feature -- Router
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
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 $"
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
note
|
||||
description: "Summary description for {CMS_MODULE_COLLECTION}."
|
||||
author: ""
|
||||
description: "Collection of CMS modules."
|
||||
date: "$Date: 2015-02-09 22:29:56 +0100 (lun., 09 févr. 2015) $"
|
||||
revision: "$Revision: 96596 $"
|
||||
|
||||
|
||||
@@ -19,15 +19,19 @@ feature -- Basic operations
|
||||
|
||||
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute the filter
|
||||
local
|
||||
utf: UTF_CONVERTER
|
||||
do
|
||||
fixme ("Check if it's ok to add new fetures CMS_API.has_error:BOOLEAN and CMS_API.error_description.")
|
||||
debug ("refactor_fixme")
|
||||
fixme ("Check if it's ok to add new features CMS_API.has_error:BOOLEAN and CMS_API.error_description.")
|
||||
end
|
||||
if not api.has_error then
|
||||
api.logger.put_information (generator + ".execute with req: " + req.debug_output, Void)
|
||||
if attached req.raw_header_data as l_header_data then
|
||||
api.logger.put_debug (generator + ".execute with req header: " + l_header_data, Void)
|
||||
api.logger.put_debug (generator + ".execute with req header: " + utf.escaped_utf_32_string_to_utf_8_string_8 (l_header_data), Void)
|
||||
end
|
||||
if attached req.raw_input_data as l_input_data then
|
||||
api.logger.put_debug (generator + ".execute with req input: " + l_input_data, Void)
|
||||
api.logger.put_debug (generator + ".execute with req input: " + utf.escaped_utf_32_string_to_utf_8_string_8 (l_input_data), Void)
|
||||
end
|
||||
execute_next (req, res)
|
||||
else
|
||||
|
||||
@@ -36,6 +36,18 @@ feature -- Response helpers
|
||||
-- res.send (create {CMS_REDIRECTION_RESPONSE_MESSAGE}.make (a_location))
|
||||
end
|
||||
|
||||
send_bad_request_message (res: WSF_RESPONSE)
|
||||
-- Send via `res' a bad request response.
|
||||
do
|
||||
res.send (create {CMS_CUSTOM_RESPONSE_MESSAGE}.make ({HTTP_STATUS_CODE}.bad_request))
|
||||
end
|
||||
|
||||
send_not_found_message (res: WSF_RESPONSE)
|
||||
-- Send via `res' a bad request response.
|
||||
do
|
||||
res.send (create {CMS_CUSTOM_RESPONSE_MESSAGE}.make ({HTTP_STATUS_CODE}.not_found))
|
||||
end
|
||||
|
||||
send_access_denied_message (res: WSF_RESPONSE)
|
||||
-- Send via `res' an access denied response.
|
||||
do
|
||||
|
||||
@@ -70,14 +70,4 @@ feature -- Media Type
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Absolute Host
|
||||
|
||||
absolute_host (req: WSF_REQUEST; a_path:STRING): STRING
|
||||
do
|
||||
Result := req.absolute_script_url (a_path)
|
||||
if Result.last_index_of ('/', Result.count) = Result.count then
|
||||
Result.remove_tail (1)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -13,6 +13,7 @@ inherit
|
||||
feature -- Core
|
||||
|
||||
site_url: READABLE_STRING_8
|
||||
-- Absolute site URL of Current CMS site.
|
||||
deferred
|
||||
end
|
||||
|
||||
|
||||
@@ -31,8 +31,22 @@ feature {WSF_ROUTER_MAPPING} -- Dispatch helper
|
||||
|
||||
path_to_dispatch (req: WSF_REQUEST): READABLE_STRING_8
|
||||
-- Path used by the router, to apply url dispatching of request `req'.
|
||||
local
|
||||
l_path: STRING_8
|
||||
do
|
||||
Result := api.source_of_path_alias (Precursor (req))
|
||||
create l_path.make_from_string (Precursor (req))
|
||||
if not l_path.is_empty and l_path [1] = '/' then
|
||||
l_path.remove_head (1)
|
||||
end
|
||||
Result := api.source_of_path_alias (l_path)
|
||||
if Result.is_empty then
|
||||
Result := "/"
|
||||
elseif Result [1] /= '/' then
|
||||
create l_path.make (Result.count + 1)
|
||||
l_path.append_character ('/')
|
||||
l_path.append (Result)
|
||||
Result := l_path
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -3,8 +3,8 @@ note
|
||||
Generic CMS Response.
|
||||
It builds the content to get process to render the output.
|
||||
]"
|
||||
date: "$Date: 2015-02-16 20:14:19 +0100 (lun., 16 févr. 2015) $"
|
||||
revision: "$Revision: 96643 $"
|
||||
date: "$Date: 2015-05-20 11:48:26 +0200 (mer., 20 mai 2015) $"
|
||||
revision: "$Revision: 97327 $"
|
||||
|
||||
deferred class
|
||||
CMS_RESPONSE
|
||||
@@ -29,6 +29,7 @@ feature {NONE} -- Initialization
|
||||
|
||||
initialize
|
||||
do
|
||||
initialize_site_url
|
||||
get_theme
|
||||
create menu_system.make
|
||||
initialize_block_region_settings
|
||||
@@ -36,6 +37,35 @@ feature {NONE} -- Initialization
|
||||
register_hooks
|
||||
end
|
||||
|
||||
initialize_site_url
|
||||
-- Initialize site and base url.
|
||||
local
|
||||
l_url: detachable STRING_8
|
||||
i,j: INTEGER
|
||||
do
|
||||
--| WARNING: do not use `absolute_url' and `url', since it relies on site_url and base_url.
|
||||
if attached setup.site_url as l_site_url and then not l_site_url.is_empty then
|
||||
create l_url.make_from_string (l_site_url)
|
||||
else
|
||||
l_url := request.absolute_script_url ("/")
|
||||
end
|
||||
check is_not_empty: not l_url.is_empty end
|
||||
if l_url [l_url.count] /= '/' then
|
||||
l_url.append_character ('/')
|
||||
end
|
||||
site_url := l_url
|
||||
i := l_url.substring_index ("://", 1)
|
||||
if i > 0 then
|
||||
j := l_url.index_of ('/', i + 3)
|
||||
if j > 0 then
|
||||
base_url := l_url.substring (j, l_url.count)
|
||||
end
|
||||
end
|
||||
ensure
|
||||
site_url_set: site_url /= Void
|
||||
site_url_ends_with_slash: site_url.ends_with_general ("/")
|
||||
end
|
||||
|
||||
register_hooks
|
||||
local
|
||||
l_module: CMS_MODULE
|
||||
@@ -76,6 +106,15 @@ feature -- Access
|
||||
redirection: detachable READABLE_STRING_8
|
||||
-- Location for eventual redirection.
|
||||
|
||||
location: STRING_8
|
||||
-- Associated cms local location.
|
||||
do
|
||||
create Result.make_from_string (request.percent_encoded_path_info)
|
||||
if not Result.is_empty and then Result[1] = '/' then
|
||||
Result.remove_head (1)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Internationalization (i18n)
|
||||
|
||||
translation (a_text: READABLE_STRING_GENERAL; opts: detachable CMS_API_OPTIONS): STRING_32
|
||||
@@ -121,9 +160,11 @@ feature -- Module
|
||||
rp: PATH
|
||||
ut: FILE_UTILITIES
|
||||
do
|
||||
-- Check first in selected theme folder.
|
||||
rp := module_assets_theme_location (a_module)
|
||||
Result := rp.extended_path (a_resource)
|
||||
if not ut.file_path_exists (Result) then
|
||||
-- And if not found, look into site/modules/$a_module.name/.... folders.
|
||||
rp := module_assets_location (a_module)
|
||||
Result := rp.extended_path (a_resource)
|
||||
if not ut.file_path_exists (Result) then
|
||||
@@ -163,16 +204,13 @@ feature -- URL utilities
|
||||
end
|
||||
end
|
||||
|
||||
site_url: READABLE_STRING_8
|
||||
do
|
||||
Result := absolute_host (request, "")
|
||||
end
|
||||
site_url: IMMUTABLE_STRING_8
|
||||
-- Absolute site url.
|
||||
|
||||
base_url: detachable READABLE_STRING_8
|
||||
base_url: detachable IMMUTABLE_STRING_8
|
||||
-- Base url if any.
|
||||
--| Usually it is Void, but it could be
|
||||
--| /project/demo/
|
||||
--| FIXME: for now, no way to change that. Always at the root "/"
|
||||
|
||||
feature -- Access: CMS
|
||||
|
||||
@@ -183,7 +221,7 @@ feature -- Access: CMS
|
||||
|
||||
front_page_url: READABLE_STRING_8
|
||||
do
|
||||
Result := request.absolute_script_url ("/")
|
||||
Result := absolute_url ("/", Void)
|
||||
end
|
||||
|
||||
values: CMS_VALUE_TABLE
|
||||
@@ -806,9 +844,9 @@ feature -- Theme
|
||||
create l_info.make_default
|
||||
end
|
||||
if l_info.engine.is_case_insensitive_equal_general ("smarty") then
|
||||
create {SMARTY_CMS_THEME} theme.make (setup, l_info)
|
||||
create {SMARTY_CMS_THEME} theme.make (setup, l_info, site_url)
|
||||
else
|
||||
create {MISSING_CMS_THEME} theme.make (setup)
|
||||
create {MISSING_CMS_THEME} theme.make (setup, l_info, site_url)
|
||||
status_code := {HTTP_STATUS_CODE}.service_unavailable
|
||||
to_implement ("Check how to add the Retry-after, http://tools.ietf.org/html/rfc7231#section-6.6.4 and http://tools.ietf.org/html/rfc7231#section-7.1.3")
|
||||
end
|
||||
@@ -834,7 +872,7 @@ feature -- Generation
|
||||
lnk: CMS_LINK
|
||||
do
|
||||
-- Menu
|
||||
create {CMS_LOCAL_LINK} lnk.make ("Home", "/")
|
||||
create {CMS_LOCAL_LINK} lnk.make ("Home", "")
|
||||
lnk.set_weight (-10)
|
||||
add_to_primary_menu (lnk)
|
||||
invoke_menu_system_alter (menu_system)
|
||||
@@ -920,8 +958,8 @@ feature -- Generation
|
||||
end
|
||||
|
||||
-- Variables
|
||||
page.register_variable (request.absolute_script_url (""), "site_url")
|
||||
page.register_variable (request.absolute_script_url (""), "host") -- Same as `site_url'.
|
||||
page.register_variable (absolute_url ("", Void), "site_url")
|
||||
page.register_variable (absolute_url ("", Void), "host") -- Same as `site_url'.
|
||||
page.register_variable (request.is_https, "is_https")
|
||||
if attached current_user_name (request) as l_user then
|
||||
page.register_variable (l_user, "user")
|
||||
@@ -1029,6 +1067,9 @@ feature -- Generation
|
||||
l_is_active: BOOLEAN
|
||||
do
|
||||
create qs.make_from_string (request.percent_encoded_path_info)
|
||||
if qs.starts_with ("/") then
|
||||
qs.remove_head (1)
|
||||
end
|
||||
l_is_active := qs.same_string (a_lnk.location)
|
||||
if not l_is_active then
|
||||
if attached request.query_string as l_query_string and then not l_query_string.is_empty then
|
||||
@@ -1102,8 +1143,8 @@ feature {NONE} -- Execution
|
||||
-- h.put_location (l_location)
|
||||
response.redirect_now (l_location)
|
||||
else
|
||||
-- h.put_location (request.absolute_script_url (l_location))
|
||||
response.redirect_now (request.absolute_script_url (l_location))
|
||||
-- h.put_location (request.absolute_url (l_location, Void))
|
||||
response.redirect_now (absolute_url (l_location, Void))
|
||||
end
|
||||
else
|
||||
h.put_header_object (header)
|
||||
|
||||
@@ -20,7 +20,7 @@ feature -- Generation
|
||||
|
||||
custom_prepare (page: CMS_HTML_PAGE)
|
||||
do
|
||||
page.register_variable (request.absolute_script_url (request.path_info), "request")
|
||||
page.register_variable (absolute_url (request.path_info, Void), "request")
|
||||
page.set_status_code ({HTTP_STATUS_CODE}.bad_request)
|
||||
page.register_variable (page.status_code.out, "code")
|
||||
end
|
||||
|
||||
@@ -20,7 +20,7 @@ feature -- Generation
|
||||
|
||||
custom_prepare (page: CMS_HTML_PAGE)
|
||||
do
|
||||
page.register_variable (request.absolute_script_url (request.path_info), "request")
|
||||
page.register_variable (absolute_url (request.path_info, Void), "request")
|
||||
page.set_status_code ({HTTP_STATUS_CODE}.forbidden)
|
||||
page.register_variable (page.status_code.out, "code")
|
||||
end
|
||||
|
||||
@@ -20,7 +20,7 @@ feature -- Generation
|
||||
|
||||
custom_prepare (page: CMS_HTML_PAGE)
|
||||
do
|
||||
page.register_variable (request.absolute_script_url (request.path_info), "request")
|
||||
page.register_variable (absolute_url (request.path_info, Void), "request")
|
||||
page.set_status_code ({HTTP_STATUS_CODE}.internal_server_error)
|
||||
page.register_variable (page.status_code.out, "code")
|
||||
end
|
||||
|
||||
@@ -20,7 +20,7 @@ feature -- Generation
|
||||
|
||||
custom_prepare (page: CMS_HTML_PAGE)
|
||||
do
|
||||
page.register_variable (request.absolute_script_url (request.path_info), "request")
|
||||
page.register_variable (absolute_url (request.path_info, Void), "request")
|
||||
page.set_status_code ({HTTP_STATUS_CODE}.not_found)
|
||||
page.register_variable (page.status_code.out, "code")
|
||||
end
|
||||
|
||||
@@ -20,7 +20,7 @@ feature -- Generation
|
||||
|
||||
custom_prepare (page: CMS_HTML_PAGE)
|
||||
do
|
||||
page.register_variable (request.absolute_script_url (request.path_info), "request")
|
||||
page.register_variable (absolute_url (request.path_info, Void), "request")
|
||||
page.set_status_code ({HTTP_STATUS_CODE}.not_implemented)
|
||||
page.register_variable (page.status_code.out, "code")
|
||||
end
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
note
|
||||
description: "Custom cms response message."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CMS_CUSTOM_RESPONSE_MESSAGE
|
||||
|
||||
inherit
|
||||
CMS_RESPONSE_MESSAGE
|
||||
redefine
|
||||
send_payload_to
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_code: INTEGER)
|
||||
-- Set `status_code' to `a_code'.
|
||||
require
|
||||
a_code_valid: a_code > 0
|
||||
do
|
||||
initialize
|
||||
status_code := a_code
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
payload: detachable READABLE_STRING_8
|
||||
-- Optional payload.
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_status_code (a_code: INTEGER)
|
||||
-- Set `status_code' to `a_code'.
|
||||
require
|
||||
a_code_valid: a_code > 0
|
||||
do
|
||||
status_code := a_code
|
||||
end
|
||||
|
||||
set_payload (s: detachable READABLE_STRING_8)
|
||||
-- Set `payload' to `s'.
|
||||
do
|
||||
if s /= Void then
|
||||
payload := s
|
||||
header.put_content_length (s.count)
|
||||
else
|
||||
end
|
||||
end
|
||||
|
||||
feature {WSF_RESPONSE} -- Output
|
||||
|
||||
send_payload_to (res: WSF_RESPONSE)
|
||||
-- Send payload data to response `res'.
|
||||
do
|
||||
if attached payload as s then
|
||||
res.put_string (s)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user