Simplify CMS_SERVICE initialization, and CMS server (launcher).

Renamed "layout" lib as "app_env" with APPLICATION_ENVIRONMENT interface.
  applied changed to callers.
Added CMS_THEME.has_region (a_name): BOOLEAN to know if a region is declared in a defined theme.
This commit is contained in:
2015-04-29 23:01:42 +02:00
parent 0eb2b70d0f
commit 6ff7a6493c
34 changed files with 214 additions and 154 deletions

View File

@@ -18,11 +18,11 @@ create
feature {NONE} -- Initialization
make (a_layout: CMS_LAYOUT)
-- Create a default setup with `a_layout'.
make (a_env: CMS_ENVIRONMENT)
-- Create a default setup with `a_env'.
do
layout := a_layout
create {INI_CONFIG} configuration.make_from_file (layout.cms_config_ini_path)
environment := a_env
create {INI_CONFIG} configuration.make_from_file (a_env.cms_config_ini_path)
initialize
end
@@ -61,14 +61,14 @@ feature {NONE} -- Initialization
if attached text_item ("themes-dir") as s then
create themes_location.make_from_string (s)
else
themes_location := layout.www_path.extended ("themes")
themes_location := environment.www_path.extended ("themes")
end
-- Selected theme's name
theme_name := text_item_or_default ("theme", "default")
debug ("refactor_fixme")
fixme ("Review export clause for configuration and layout")
fixme ("Review export clause for configuration and environment")
end
compute_theme_location

View File

@@ -1,6 +1,6 @@
note
description: "[
CMS Layout providing file system locations for
CMS Environment providing file system locations for
- config
- application
- logs
@@ -11,11 +11,10 @@ note
revision: "$Revision: 96797 $"
class
CMS_LAYOUT
CMS_ENVIRONMENT
inherit
APPLICATION_LAYOUT
APPLICATION_ENVIRONMENT
create
make_default,

View File

@@ -1,6 +1,6 @@
note
description: "[
Class that enable to set basic configuration, application layout, core modules and themes.
Class that enable to set basic configuration, application environment, core modules and themes.
]"
date: "$Date: 2015-02-13 13:08:13 +0100 (ven., 13 févr. 2015) $"
revision: "$Revision: 96616 $"
@@ -13,8 +13,15 @@ inherit
feature -- Access
layout: CMS_LAYOUT
-- CMS layout.
environment: CMS_ENVIRONMENT
-- CMS environment.
layout: CMS_ENVIRONMENT
-- CMS environment.
obsolete "use `environment' [april-2015]"
do
Result := environment
end
enabled_modules: CMS_MODULE_COLLECTION
-- List of enabled modules.
@@ -122,7 +129,7 @@ feature -- Access: storage
if not retried then
to_implement ("Refactor database setup")
if
attached (create {APPLICATION_JSON_CONFIGURATION_HELPER}).new_database_configuration (layout.application_config_path) as l_database_config and then
attached (create {APPLICATION_JSON_CONFIGURATION_HELPER}).new_database_configuration (environment.application_config_path) as l_database_config and then
attached storage_drivers.item (l_database_config.driver) as l_builder
then
Result := l_builder.storage (Current)

View File

@@ -12,7 +12,7 @@ inherit
register_hooks
end
-- CMS_HOOK_BLOCK
CMS_HOOK_BLOCK
CMS_HOOK_AUTO_REGISTER
@@ -49,23 +49,30 @@ feature -- Hooks configuration
-- Module hooks configuration.
do
auto_subscribe_to_hooks (a_response)
-- a_response.subscribe_to_block_hook (Current)
a_response.subscribe_to_block_hook (Current)
end
feature -- Hooks
-- block_list: ITERABLE [like {CMS_BLOCK}.name]
-- do
-- Result := <<"debug-info">>
-- end
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
get_block_view (a_block_id: READABLE_STRING_8; a_response: CMS_RESPONSE)
local
b: CMS_CONTENT_BLOCK
dbg: WSF_DEBUG_INFORMATION
s: STRING
do
if a_response.theme.has_region ("debug") then
create dbg.make
create s.make_empty
dbg.append_information_to (a_response.request, a_response.response, s)
create b.make ("debug-info", "Debug", s, a_response.api.formats.plain_text)
a_response.add_block (b, "footer")
end
end
feature -- Handler
@@ -82,7 +89,7 @@ feature -- Handler
append_info_to ("Name", api.setup.site_name, r, s)
append_info_to ("Url", api.setup.site_url, r, s)
if attached api.setup.layout.cms_config_ini_path as l_loc then
if attached api.setup.environment.cms_config_ini_path as l_loc then
s.append ("<hr/>")
append_info_to ("Configuration file", l_loc.name, r, s)
end
@@ -93,10 +100,10 @@ feature -- Handler
-- append_info_to ("Base url", cms.base_url, r, s)
-- append_info_to ("Script url", cms.script_url, r, s)
s.append ("<hr/>")
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)
append_info_to ("Site dir", api.setup.environment.path.utf_8_name, r, s)
append_info_to ("Www dir", api.setup.environment.www_path.utf_8_name, r, s)
append_info_to ("Assets dir", api.setup.environment.assets_path.utf_8_name, r, s)
append_info_to ("Config dir", api.setup.environment.config_path.utf_8_name, r, s)
s.append ("<hr/>")
append_info_to ("Theme", api.setup.theme_name, r, s)
append_info_to ("Theme location", api.setup.themes_location.utf_8_name, r, s)

View File

@@ -98,7 +98,7 @@ feature {CMS_API} -- Module management
do
-- Schema
if attached {CMS_STORAGE_SQL_I} api.storage as l_sql_storage then
l_sql_storage.sql_execute_file_script (api.setup.layout.path.extended ("scripts").extended (name).appended_with_extension ("sql"))
l_sql_storage.sql_execute_file_script (api.setup.environment.path.extended ("scripts").extended (name).appended_with_extension ("sql"))
end
end
@@ -127,7 +127,6 @@ feature -- Access: router
local
l_node_handler: NODE_HANDLER
l_nodes_handler: NODES_HANDLER
l_methods: WSF_REQUEST_METHODS
l_uri_mapping: WSF_URI_MAPPING
do
-- TODO: for now, focused only on web interface, add REST api later. [2015-April-29]

View File

@@ -246,7 +246,7 @@ feature {NONE}-- Implemenation
internal_user_api: detachable like user_api
-- Cached value for `user_api'.
feature -- Layout
feature -- Environment
module_configuration (a_module_name: READABLE_STRING_GENERAL; a_name: detachable READABLE_STRING_GENERAL): detachable CONFIG_READER
-- Configuration reader for `a_module', and if `a_name' is set, using name `a_name'.
@@ -254,7 +254,7 @@ feature -- Layout
p, l_path: PATH
ut: FILE_UTILITIES
do
p := setup.layout.config_path.extended ("modules").extended (a_module_name)
p := setup.environment.config_path.extended ("modules").extended (a_module_name)
if a_name = Void then
p := p.extended (a_module_name)
else

View File

@@ -41,13 +41,11 @@ create
feature {NONE} -- Initialization
make (a_api: CMS_API)
make (a_setup: CMS_SETUP)
-- Build a CMS service with `a_api'
do
api := a_api
create api.make (a_setup)
initialize
ensure
api_set: api = a_api
end
initialize
@@ -138,7 +136,7 @@ feature -- Settings: router
a_router.handle_with_request_methods ("/theme/", fhdl, router.methods_GET)
create fhdl.make_hidden_with_path (setup.layout.www_path)
create fhdl.make_hidden_with_path (setup.environment.www_path)
fhdl.disable_index
fhdl.set_not_found_handler (agent (ia_uri: READABLE_STRING_8; ia_req: WSF_REQUEST; ia_res: WSF_RESPONSE)
do

View File

@@ -107,7 +107,7 @@ feature -- Module
module_assets_location (a_module: CMS_MODULE): PATH
-- Location for the assets associated with `a_module'.
do
Result := setup.layout.path.extended ("modules").extended (a_module.name)
Result := setup.environment.path.extended ("modules").extended (a_module.name)
end
module_assets_theme_location (a_module: CMS_MODULE): PATH

View File

@@ -33,6 +33,14 @@ feature -- Access
deferred
end
feature -- Status report
has_region (a_region_name: READABLE_STRING_GENERAL): BOOLEAN
-- Current theme has region `a_region_name' declared?
do
Result := across regions as ic some a_region_name.is_case_insensitive_equal (ic.item) end
end
feature -- Conversion
menu_html (a_menu: CMS_MENU; is_horizontal: BOOLEAN; a_options: detachable CMS_HTML_OPTIONS): STRING_8