Moved library/src to src
This commit is contained in:
15
src/configuration/cms_custom_setup.e
Normal file
15
src/configuration/cms_custom_setup.e
Normal file
@@ -0,0 +1,15 @@
|
||||
note
|
||||
description: "Summary description for {CMS_CUSTOM_SETUP}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CMS_CUSTOM_SETUP
|
||||
|
||||
inherit
|
||||
CMS_DEFAULT_SETUP
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
end
|
||||
187
src/configuration/cms_default_setup.e
Normal file
187
src/configuration/cms_default_setup.e
Normal file
@@ -0,0 +1,187 @@
|
||||
note
|
||||
description: "[
|
||||
Default CMS_SETUP that can be reused easily, and/or redefined to match specific setup.
|
||||
]"
|
||||
date: "$Date: 2015-01-27 19:15:02 +0100 (mar., 27 janv. 2015) $"
|
||||
revision: "$Revision: 96542 $"
|
||||
|
||||
class
|
||||
CMS_DEFAULT_SETUP
|
||||
|
||||
inherit
|
||||
CMS_SETUP
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_layout: CMS_LAYOUT)
|
||||
-- Create a default setup with `a_layout'.
|
||||
do
|
||||
layout := a_layout
|
||||
create {INI_CONFIG} configuration.make_from_file (layout.cms_config_ini_path)
|
||||
initialize
|
||||
end
|
||||
|
||||
initialize
|
||||
-- Initialize various cms components.
|
||||
do
|
||||
configure
|
||||
create modules.make (3)
|
||||
create storage_drivers.make (2)
|
||||
|
||||
build_mailer
|
||||
initialize_storages
|
||||
initialize_modules
|
||||
end
|
||||
|
||||
configure
|
||||
do
|
||||
--| Site id, used to identified a site, this could be set to a uuid, or else
|
||||
site_id := text_item_or_default ("site.id", "_EWF_CMS_NO_ID_")
|
||||
|
||||
-- Site url: optional, but ending with a slash
|
||||
site_url := string_8_item ("site_url")
|
||||
if attached site_url as l_url and then not l_url.is_empty then
|
||||
if l_url[l_url.count] /= '/' then
|
||||
site_url := l_url + "/"
|
||||
end
|
||||
end
|
||||
-- Site name
|
||||
site_name := text_item_or_default ("site.name", "EWF::CMS")
|
||||
|
||||
-- Site email for any internal notification
|
||||
-- Can be also used to precise the "From:" value for email.
|
||||
site_email := text_item_or_default ("site.email", "webmaster")
|
||||
|
||||
-- Location for theme folders.
|
||||
if attached text_item ("themes-dir") as s then
|
||||
create themes_location.make_from_string (s)
|
||||
else
|
||||
themes_location := layout.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")
|
||||
end
|
||||
|
||||
compute_theme_location
|
||||
compute_theme_assets_location
|
||||
end
|
||||
|
||||
initialize_storages
|
||||
-- Initialize storages
|
||||
do
|
||||
storage_drivers.force (create {CMS_STORAGE_NULL_BUILDER}, "null")
|
||||
end
|
||||
|
||||
initialize_modules
|
||||
-- Intialize core modules.
|
||||
local
|
||||
m: CMS_MODULE
|
||||
do
|
||||
-- -- Core
|
||||
-- create {USER_MODULE} m.make (Current)
|
||||
-- m.enable
|
||||
-- register_module (m)
|
||||
|
||||
-- create {ADMIN_MODULE} m.make (Current)
|
||||
-- m.enable
|
||||
-- register_module (m)
|
||||
|
||||
create {NODE_MODULE} m.make (Current)
|
||||
m.enable
|
||||
register_module (m)
|
||||
end
|
||||
|
||||
feature {NONE} -- Configuration
|
||||
|
||||
configuration: CONFIG_READER
|
||||
-- Association configuration file.
|
||||
|
||||
feature -- Access
|
||||
|
||||
modules: CMS_MODULE_COLLECTION
|
||||
-- <Precursor>
|
||||
|
||||
text_item (a_name: READABLE_STRING_GENERAL): detachable READABLE_STRING_32
|
||||
-- Configuration value associated with `a_name', if any.
|
||||
do
|
||||
Result := configuration.resolved_text_item (a_name)
|
||||
end
|
||||
|
||||
string_8_item (a_name: READABLE_STRING_GENERAL): detachable READABLE_STRING_8
|
||||
-- String 8 configuration value associated with `a_name', if any.
|
||||
local
|
||||
utf: UTF_CONVERTER
|
||||
do
|
||||
if attached text_item (a_name) as s then
|
||||
if s.is_valid_as_string_8 then
|
||||
Result := s.as_string_8
|
||||
else
|
||||
Result := utf.escaped_utf_32_string_to_utf_8_string_8 (s)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
is_html: BOOLEAN
|
||||
-- <Precursor>
|
||||
do
|
||||
-- Enable change the mode
|
||||
Result := (create {CMS_JSON_CONFIGURATION}).is_html_mode (layout.application_config_path)
|
||||
end
|
||||
|
||||
is_web: BOOLEAN
|
||||
-- <Precursor>
|
||||
do
|
||||
Result := (create {CMS_JSON_CONFIGURATION}).is_web_mode (layout.application_config_path)
|
||||
end
|
||||
|
||||
build_auth_engine
|
||||
do
|
||||
to_implement ("Not implemented authentication")
|
||||
end
|
||||
|
||||
build_mailer
|
||||
do
|
||||
to_implement ("Not implemented mailer")
|
||||
end
|
||||
|
||||
feature -- Access: storage
|
||||
|
||||
storage_drivers: STRING_TABLE [CMS_STORAGE_BUILDER]
|
||||
-- Precursor
|
||||
|
||||
feature -- Element change
|
||||
|
||||
register_module (m: CMS_MODULE)
|
||||
-- <Precursor>
|
||||
do
|
||||
modules.extend (m)
|
||||
end
|
||||
|
||||
feature -- Compute location
|
||||
|
||||
compute_theme_location
|
||||
do
|
||||
theme_location := themes_location.extended (theme_name)
|
||||
end
|
||||
|
||||
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
|
||||
-- Check how to get this path from the CMS_THEME information.
|
||||
theme_assets_location := theme_location.extended ("assets")
|
||||
end
|
||||
|
||||
end
|
||||
53
src/configuration/cms_json_configuration.e
Normal file
53
src/configuration/cms_json_configuration.e
Normal file
@@ -0,0 +1,53 @@
|
||||
note
|
||||
description: "Summary description for {CMS_JSON_CONFIGURATION}."
|
||||
date: "$Date: 2015-01-14 16:13:47 +0100 (mer., 14 janv. 2015) $"
|
||||
revision: "$Revision: 96454 $"
|
||||
|
||||
class
|
||||
CMS_JSON_CONFIGURATION
|
||||
|
||||
inherit
|
||||
|
||||
APPLICATION_JSON_CONFIGURATION_HELPER
|
||||
|
||||
feature -- Access
|
||||
|
||||
is_html_mode (a_path: PATH): BOOLEAN
|
||||
-- Is the server running on web mode?
|
||||
local
|
||||
l_parser: JSON_PARSER
|
||||
do
|
||||
if attached json_file_from (a_path) as json_file then
|
||||
l_parser := new_json_parser (json_file)
|
||||
l_parser.parse_content
|
||||
if
|
||||
l_parser.is_valid and then
|
||||
attached l_parser.parsed_json_object as jo and then l_parser.is_parsed and then
|
||||
attached {JSON_OBJECT} jo.item ("server") as l_server and then
|
||||
attached {JSON_STRING} l_server.item ("mode") as l_mode
|
||||
then
|
||||
Result := l_mode.item.is_case_insensitive_equal_general ("html")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
is_web_mode (a_path: PATH): BOOLEAN
|
||||
-- Is the server running on web mode?
|
||||
local
|
||||
l_parser: JSON_PARSER
|
||||
do
|
||||
if attached json_file_from (a_path) as json_file then
|
||||
l_parser := new_json_parser (json_file)
|
||||
l_parser.parse_content
|
||||
if
|
||||
l_parser.is_valid and then
|
||||
attached l_parser.parsed_json_object as jo and then l_parser.is_parsed and then
|
||||
attached {JSON_OBJECT} jo.item ("server") as l_server and then
|
||||
attached {JSON_STRING} l_server.item ("mode") as l_mode
|
||||
then
|
||||
Result := l_mode.item.is_case_insensitive_equal_general ("web")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
59
src/configuration/cms_layout.e
Normal file
59
src/configuration/cms_layout.e
Normal file
@@ -0,0 +1,59 @@
|
||||
note
|
||||
description: "[
|
||||
CMS Layout providing file system locations for
|
||||
- config
|
||||
- application
|
||||
- logs
|
||||
- documentation
|
||||
- themes
|
||||
]"
|
||||
date: "$Date: 2014-12-18 16:37:11 +0100 (jeu., 18 déc. 2014) $"
|
||||
revision: "$Revision: 96383 $"
|
||||
|
||||
class
|
||||
CMS_LAYOUT
|
||||
|
||||
inherit
|
||||
|
||||
APPLICATION_LAYOUT
|
||||
|
||||
create
|
||||
make_default,
|
||||
make_with_path
|
||||
|
||||
|
||||
feature -- Access
|
||||
|
||||
theme_path: PATH
|
||||
-- Directory for templates (HTML, etc).
|
||||
local
|
||||
p: detachable PATH
|
||||
do
|
||||
p := internal_theme_path
|
||||
if p = Void then
|
||||
p := www_path.extended ("theme")
|
||||
internal_theme_path := p
|
||||
end
|
||||
Result := p
|
||||
end
|
||||
|
||||
cms_config_ini_path: PATH
|
||||
-- CMS Configuration file path.
|
||||
local
|
||||
p: detachable PATH
|
||||
do
|
||||
p := internal_cms_config_ini_path
|
||||
if p = Void then
|
||||
p := config_path.extended ("cms.ini")
|
||||
internal_cms_config_ini_path := p
|
||||
end
|
||||
Result := p
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
internal_theme_path: detachable like theme_path
|
||||
|
||||
internal_cms_config_ini_path: detachable like cms_config_ini_path
|
||||
|
||||
end
|
||||
171
src/configuration/cms_setup.e
Normal file
171
src/configuration/cms_setup.e
Normal file
@@ -0,0 +1,171 @@
|
||||
note
|
||||
description: "Class that enable to set basic configuration, application layout, core modules and themes."
|
||||
date: "$Date: 2015-01-27 19:15:02 +0100 (mar., 27 janv. 2015) $"
|
||||
revision: "$Revision: 96542 $"
|
||||
|
||||
deferred class
|
||||
CMS_SETUP
|
||||
|
||||
inherit
|
||||
REFACTORING_HELPER
|
||||
|
||||
feature -- Access
|
||||
|
||||
layout: CMS_LAYOUT
|
||||
-- CMS layout.
|
||||
|
||||
is_html: BOOLEAN
|
||||
-- api with progressive enhancements css and js, server side rendering.
|
||||
deferred
|
||||
end
|
||||
|
||||
is_web: BOOLEAN
|
||||
-- web: Web Site with progressive enhancements css and js and Ajax calls.
|
||||
deferred
|
||||
end
|
||||
|
||||
enabled_modules: CMS_MODULE_COLLECTION
|
||||
-- List of enabled modules.
|
||||
local
|
||||
l_module: CMS_MODULE
|
||||
do
|
||||
create Result.make (modules.count)
|
||||
across
|
||||
modules as ic
|
||||
loop
|
||||
l_module := ic.item
|
||||
if l_module.is_enabled then
|
||||
Result.extend (l_module)
|
||||
end
|
||||
end
|
||||
ensure
|
||||
only_enabled_modules: across Result as ic all ic.item.is_enabled end
|
||||
end
|
||||
|
||||
feature {CMS_MODULE} -- Restricted access
|
||||
|
||||
modules: CMS_MODULE_COLLECTION
|
||||
-- List of available modules.
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- Access: Site
|
||||
|
||||
site_id: READABLE_STRING_8
|
||||
-- String identifying current CMS.
|
||||
-- This could be used in webform, for cookie name, ...
|
||||
|
||||
site_name: READABLE_STRING_32
|
||||
-- Name of the site.
|
||||
|
||||
site_email: READABLE_STRING_8
|
||||
-- Admin email address for the site.
|
||||
-- Mainly used for internal notification.
|
||||
|
||||
site_url: detachable READABLE_STRING_8
|
||||
-- Optional base url of the site.
|
||||
|
||||
front_page_path: detachable READABLE_STRING_8
|
||||
-- Optional path defining the front page.
|
||||
-- By default "" or "/".
|
||||
|
||||
feature -- Query
|
||||
|
||||
text_item (a_name: READABLE_STRING_GENERAL): detachable READABLE_STRING_32
|
||||
-- Configuration value associated with `a_name', if any.
|
||||
deferred
|
||||
end
|
||||
|
||||
text_item_or_default (a_name: READABLE_STRING_GENERAL; a_default_value: READABLE_STRING_GENERAL): READABLE_STRING_32
|
||||
-- `text_item' associated with `a_name' or if none, `a_default_value'.
|
||||
do
|
||||
if attached text_item (a_name) as v then
|
||||
Result := v
|
||||
else
|
||||
Result := a_default_value.as_string_32
|
||||
end
|
||||
end
|
||||
|
||||
string_8_item (a_name: READABLE_STRING_GENERAL): detachable READABLE_STRING_8
|
||||
-- Configuration value associated with `a_name', if any.
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- Access: Theme
|
||||
|
||||
themes_location: PATH
|
||||
-- Path to themes.
|
||||
|
||||
theme_location: PATH
|
||||
-- Path to a active theme.
|
||||
|
||||
theme_assets_location: PATH
|
||||
-- Path to a active theme assets folder.
|
||||
|
||||
theme_information_location: PATH
|
||||
-- Active theme informations.
|
||||
do
|
||||
Result := theme_location.extended ("theme.info")
|
||||
end
|
||||
|
||||
theme_name: READABLE_STRING_32
|
||||
-- theme name.
|
||||
|
||||
feature -- Access: storage
|
||||
|
||||
storage_drivers: STRING_TABLE [CMS_STORAGE_BUILDER]
|
||||
deferred
|
||||
end
|
||||
|
||||
storage (a_error_handler: ERROR_HANDLER): detachable CMS_STORAGE
|
||||
local
|
||||
retried: BOOLEAN
|
||||
l_message: STRING
|
||||
do
|
||||
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 storage_drivers.item (l_database_config.driver) as l_builder
|
||||
then
|
||||
Result := l_builder.storage (Current)
|
||||
else
|
||||
create {CMS_STORAGE_NULL} Result
|
||||
end
|
||||
else
|
||||
to_implement ("Workaround code, persistence layer does not implement yet this kind of error handling.")
|
||||
-- error hanling.
|
||||
create {CMS_STORAGE_NULL} Result
|
||||
create l_message.make (1024)
|
||||
if attached ((create {EXCEPTION_MANAGER}).last_exception) as l_exception then
|
||||
if attached l_exception.description as l_description then
|
||||
l_message.append (l_description.as_string_32)
|
||||
l_message.append ("%N%N")
|
||||
elseif attached l_exception.trace as l_trace then
|
||||
l_message.append (l_trace)
|
||||
l_message.append ("%N%N")
|
||||
else
|
||||
l_message.append (l_exception.out)
|
||||
l_message.append ("%N%N")
|
||||
end
|
||||
else
|
||||
l_message.append ("The application crash without available information")
|
||||
l_message.append ("%N%N")
|
||||
end
|
||||
a_error_handler.add_custom_error (0, " Database Connection ", l_message)
|
||||
end
|
||||
rescue
|
||||
retried := True
|
||||
retry
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
register_module (m: CMS_MODULE)
|
||||
-- Add module `m' to `modules'
|
||||
deferred
|
||||
ensure
|
||||
module_added: modules.has (m)
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user