Compare commits
34 Commits
minor_chan
...
storage_re
| Author | SHA1 | Date | |
|---|---|---|---|
| 4dcc1b0e04 | |||
| db9e40cec4 | |||
|
|
792880aa7a | ||
|
|
5ad8c680a6 | ||
|
|
e2f02953f4 | ||
|
|
bd26deb6c1 | ||
|
|
a9109ca8f7 | ||
| 09e5dc4032 | |||
| d082326784 | |||
| 51462829c7 | |||
| ba58fcdf75 | |||
|
|
d84f164dbd | ||
|
|
c3d022ce46 | ||
|
|
aac01e093a | ||
|
|
fb62a1bb3e | ||
|
|
6162432d52 | ||
|
|
ebed52ae01 | ||
| b58eeeac26 | |||
|
|
9169bdcd43 | ||
|
|
e36465f86d | ||
| 76190de218 | |||
|
|
0edff7853b | ||
|
|
e20a7af301 | ||
|
|
089b367c95 | ||
|
|
503f2faf08 | ||
|
|
b887c13664 | ||
|
|
bbfe063b5c | ||
|
|
1a4e2935da | ||
|
|
c3a582f85c | ||
| 8bfb66af30 | |||
| 6aad460b11 | |||
|
|
0dc12b82b8 | ||
|
|
8047880c2b | ||
|
|
48283742aa |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,4 +1,5 @@
|
||||
EIFGENs
|
||||
*.swp
|
||||
*.log*
|
||||
*.rc
|
||||
*.rc
|
||||
*.bak
|
||||
@@ -25,7 +25,10 @@ The goal of the library is to provide the following features.
|
||||
- doc -- Documentation.
|
||||
|
||||
**Documentation**
|
||||
>[CMS design](https://github.com/EiffelWebFramework/ROC).
|
||||
>[CMS concepts](https://github.com/EiffelWebFramework/ROC).
|
||||
|
||||
>[CMS concepts](/doc/concepts.md).
|
||||
|
||||
|
||||
>[CMS design](/doc/design.md).
|
||||
|
||||
>[CMS tutorial](/doc/tutorial.md).
|
||||
|
||||
|
||||
15
cms-safe.ecf
15
cms-safe.ecf
@@ -2,26 +2,25 @@
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-13-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-13-0 http://www.eiffel.com/developers/xml/configuration-1-13-0.xsd" name="cms" uuid="8CC0D052-57D1-4CAA-AFF1-448FA290734B" library_target="cms">
|
||||
<target name="cms">
|
||||
<root all_classes="true"/>
|
||||
<option warning="true" full_class_checking="false" is_attached_by_default="true" void_safety="transitional" syntax="transitional">
|
||||
<option warning="true" full_class_checking="false" is_attached_by_default="true" void_safety="all" syntax="transitional">
|
||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||
</option>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="config" location=".\library\configuration\config-safe.ecf"/>
|
||||
<library name="crypto" location="$ISE_LIBRARY\unstable\library\text\encryption\crypto\crypto-safe.ecf"/>
|
||||
<library name="encoder" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\text\encoder\encoder-safe.ecf" readonly="false"/>
|
||||
<library name="error" location="$ISE_LIBRARY\contrib\library\utility\general\error\error-safe.ecf"/>
|
||||
<library name="http" location="$ISE_LIBRARY\contrib\library\network\protocol\http\http-safe.ecf"/>
|
||||
<library name="http_authorization" location="$ISE_LIBRARY\contrib\library\network\authentication\http_authorization\http_authorization-safe.ecf" readonly="false"/>
|
||||
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json-safe.ecf" readonly="false"/>
|
||||
<library name="layout" location=".\library\layout\layout-safe.ecf"/>
|
||||
<library name="model" location=".\library\model\cms_model-safe.ecf" readonly="false"/>
|
||||
<library name="encoder" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\text\encoder\encoder-safe.ecf" readonly="false"/>
|
||||
<library name="text_filter" location="$ISE_LIBRARY\unstable\library\text\text_filter\text_filter-safe.ecf"/>
|
||||
|
||||
<library name="error" location="$ISE_LIBRARY\contrib\library\utility\general\error\error-safe.ecf"/>
|
||||
<library name="http_authorization" location="$ISE_LIBRARY\contrib\library\network\authentication\http_authorization\http_authorization-safe.ecf" readonly="false"/>
|
||||
<library name="persistence_mysql" location=".\library\persistence\implementation\mysql\persistence_mysql-safe.ecf" readonly="false"/>
|
||||
<library name="smarty" location="$ISE_LIBRARY\contrib\library\text\template\smarty\smarty-safe.ecf" readonly="false"/>
|
||||
<library name="text_filter" location="$ISE_LIBRARY\unstable\library\text\text_filter\text_filter-safe.ecf"/>
|
||||
<library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/>
|
||||
<library name="wsf" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf-safe.ecf"/>
|
||||
<library name="wsf_extension" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf_extension-safe.ecf" readonly="false"/>
|
||||
<library name="wsf_html" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf_html\wsf_html-safe.ecf" readonly="false"/>
|
||||
<library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/>
|
||||
<cluster name="src" location=".\library\src\" recursive="true">
|
||||
<file_rule>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
|
||||
33
cms.ecf
Normal file
33
cms.ecf
Normal file
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-13-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-13-0 http://www.eiffel.com/developers/xml/configuration-1-13-0.xsd" name="cms" uuid="8CC0D052-57D1-4CAA-AFF1-448FA290734B" library_target="cms">
|
||||
<target name="cms">
|
||||
<root all_classes="true"/>
|
||||
<option warning="true" full_class_checking="false" void_safety="none" syntax="transitional">
|
||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||
</option>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
|
||||
<library name="crypto" location="$ISE_LIBRARY\unstable\library\text\encryption\crypto\crypto.ecf"/>
|
||||
<library name="encoder" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\text\encoder\encoder.ecf" readonly="false"/>
|
||||
<library name="error" location="$ISE_LIBRARY\contrib\library\utility\general\error\error.ecf"/>
|
||||
<library name="http" location="$ISE_LIBRARY\contrib\library\network\protocol\http\http.ecf"/>
|
||||
<library name="http_authorization" location="$ISE_LIBRARY\contrib\library\network\authentication\http_authorization\http_authorization.ecf" readonly="false"/>
|
||||
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json.ecf" readonly="false"/>
|
||||
<library name="config" location=".\library\configuration\config.ecf"/>
|
||||
<library name="layout" location=".\library\layout\layout.ecf"/>
|
||||
<library name="model" location=".\library\model\cms_model.ecf" readonly="false"/>
|
||||
<library name="persistence_mysql" location=".\library\persistence\implementation\mysql\persistence_mysql.ecf" readonly="false"/>
|
||||
<library name="smarty" location="$ISE_LIBRARY\contrib\library\text\template\smarty\smarty.ecf" readonly="false"/>
|
||||
<library name="text_filter" location="$ISE_LIBRARY\unstable\library\text\text_filter\text_filter.ecf"/>
|
||||
<library name="time" location="$ISE_LIBRARY\library\time\time.ecf"/>
|
||||
<library name="wsf" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf.ecf"/>
|
||||
<library name="wsf_extension" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf_extension.ecf" readonly="false"/>
|
||||
<library name="wsf_html" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf_html\wsf_html.ecf" readonly="false"/>
|
||||
<cluster name="src" location=".\library\src\" recursive="true">
|
||||
<file_rule>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
<exclude>/CVS$</exclude>
|
||||
<exclude>/.svn$</exclude>
|
||||
</file_rule>
|
||||
</cluster>
|
||||
</target>
|
||||
</system>
|
||||
93
doc/concepts.md
Normal file
93
doc/concepts.md
Normal file
@@ -0,0 +1,93 @@
|
||||
CMS Concepts
|
||||
============
|
||||
>Current implemented concepts
|
||||
|
||||
##### Table of Contents
|
||||
|
||||
1. [**Theme**](#theme)
|
||||
2. [**Regions**](#regions)
|
||||
- [**Default Page Layout**](#page_layout)
|
||||
- [**Regions Holds blocks**](#regions_blocks)
|
||||
3. [**Blocks**](#blocks)
|
||||
4. [**Modules**](#modules)
|
||||
5. [**Hooks**](#hooks)
|
||||
|
||||
|
||||
<a name="theme"/>
|
||||
Theme
|
||||
-----
|
||||
In a CMS , a theme is a collection of templates files (HTML, CSS, Images, etc ) that determine how a CMS web site looks. The goal of a theme is to let you change the look and feel of the site.
|
||||
Eiffel CMS is inspired by Drupal, and use the same default region names as default drupal theme.
|
||||
|
||||
#### Important Classes
|
||||
|
||||
* [CMS_THEME] (/library/src/theme/cms_theme.e): Abstraction defining the interface of a CMS theme.
|
||||
* [SMARTY_CMS_THEME] (/library/src/theme/smarty_theme/smarty_cms_theme.e): Theme implemented using the [Eiffel Smarty library] (https://github.com/eiffelhub/template-smarty).
|
||||
* [CMS_TEMPLATE] (/library/src/theme/cms_template.e): Template Abstraction that contains theme, variables needed by template when rendering page as html. At the moment there is only one implementation SMARTY_CMS_PAGE_TEMPLATE. At the moment there is only one implementation [SMARTY_CMS_PAGE_TEMPLATE] (/library/src/theme/smarty_theme/smarty_cms_page_template.e).
|
||||
|
||||
<a name="regions"/>
|
||||
Regions
|
||||
-------
|
||||
The layout of a CMS web page has predefined area called **regions**. The Eiffel CMS uses the same default regions as Drupal, so let's see them in the following image.
|
||||
|
||||
<a name="page_layout"/>
|
||||

|
||||
|
||||
```
|
||||
regions[page_top] = Top
|
||||
regions[header] = Header
|
||||
regions[content] = Content
|
||||
regions[highlighted] = Highlighted
|
||||
regions[help] = Help
|
||||
regions[footer] = Footer
|
||||
regions[first_sidebar] = first sidebar
|
||||
regions[second_sidebar] = second sidebar
|
||||
regions[page_bottom] = Bottom
|
||||
```
|
||||
<a name="regions_blocks"/>
|
||||
**A Region holds blocks**
|
||||
|
||||
**What goes inside regions?**
|
||||
Generally, regions hold smaller piece of content called blocks. Blocks hold chunks of content, like the user login form, navigation menu or the information for the footer.
|
||||
|
||||
Regions are defined in a configuration file theme.info.
|
||||
|
||||
|
||||
<a name="blocks"/>
|
||||
CMS_BLOCK
|
||||
---------
|
||||
**What is a cms block?**
|
||||
Blocks are chunk of content that can be created to display whatever you want, and then can be placed in various resgions in your template (theme) layout.
|
||||
|
||||
#### Important Classes
|
||||
|
||||
* [CMS_BLOCK] (/library/src/kernel/content/cms_block.e): The deferred class CMS_BLOCK provides an abstraction to describe content to be placed inside Regions.
|
||||
* [CMS_CONTENT_BLOCK] (/library/src/kernel/content/cms_content_block.e): The class CMS_CONTENT_BLOCK describe how to provide generic content.
|
||||
* [CMS_MENU_BLOCK](/library/src/kernel/content/cms_menu_block.e): The class CMS_MENU_BLOCK describe how to provides a menu of navigational links.
|
||||
* [CMS_SMARTY_TEMPLATE_BLOCK] (/library/src/kernel/content/cms_smarty_templateblock.e) The class CMS_SMARTY_TEMPLATE_BLOCK describe how to use a CMS block with smarty template file content.
|
||||
|
||||
|
||||
<a name="modules"/>
|
||||
CMS_MODULES
|
||||
-----------
|
||||
**What is a cms module?**
|
||||
Modules are piece of code that adds one or more features to your web site.
|
||||
Modules can be plugged and combined to provide a web site customized to your needs. There are modules for many purposes, for example Administratiton, Basic Authentication, etc.
|
||||
|
||||
#### Important Classes
|
||||
* [CMS_MODULE] (/library/src/modules/cms_module.e): The deferred class CMS_MODULE provides an abstraction to describe a generic module that add features to your web site.
|
||||
* [CMS_RESPONSE](/library/src/service/response/cms_response.e). The deferred class CMS_RESPONSE provide an abstraction to builds the content to get process to render the output.
|
||||
|
||||
|
||||
<a name="hooks">
|
||||
CMS_HOOK
|
||||
--------
|
||||
Hooks is a mechanism which provide a way for modules to interact with each other and extending blocks of the current CMS.
|
||||
|
||||
* [CMS_HOOK] (/library/src/hooks/cms_hook.e): The deferred class CMS_HOOK is a marker interface for CMS Hook
|
||||
* [CMS_HOOK_AUTO_REGISTER] (/library/src/hooks/cms_hook_auto_register.e): The deferred class provides an abstraction that when inheriting from this class, the declared hooks are automatically registered, otherwise, each descendant has to add it to the cms service itself.
|
||||
* [CMS_HOOK_BLOCK](/library/src/hooks/cms_hook_block.e): The class CMS_HOOK_BLOCK describe a hook providing a way to alter a generic block.
|
||||
* [CMS_HOOK_FORM_ALTER](/library/src/hooks/cms_hook_form_alter.e): The class CMS_HOOK_FORM_ATLER describe a hook providing a way to alter a form.
|
||||
* [CMS_HOOK_MENU_ALTER](/library/src/hooks/cms_hook_menu_alter.e): The class CMS_HOOK_MENU_ATLER describe a hook providing a way to alter a menu.
|
||||
* [CMS_HOOK_MENU_SYSTEM_ALTER](/library/src/hooks/cms_hook_menu_system_alter.e): The class CMS_HOOK_MENU_SYSTEM_ALTER describe a hook providing a way to alter the CMS menu system.
|
||||
* [CMS_HOOK_VALUE_TABLE_ALTER](/library/src/hooks/cms_hook_value_table_alter.e):: The class CMS_HOOK_VALUE_TABLE_ALTER describe a hook providing a way to alter the value table for a response.
|
||||
121
doc/tutorial.md
Normal file
121
doc/tutorial.md
Normal file
@@ -0,0 +1,121 @@
|
||||
CMS Tutorial
|
||||
============
|
||||
[Work in progress]
|
||||
|
||||
##### Table of Contents
|
||||
[Getting Started](#init)
|
||||
[Building your module](#module)
|
||||
[Lifecycle](#cycle)
|
||||
|
||||
|
||||
<a name="init"/>
|
||||
Getting Started
|
||||
-------------
|
||||
|
||||
|
||||
<a name="module"/>
|
||||
Building your own module
|
||||
------------------------
|
||||
A [Module](/doc/concepts.md#modules) as we already describe it, enable us to add functionallity based on your needs.
|
||||
|
||||
Here we will describe the basics steps to write your own modules.
|
||||
|
||||
* The first thing to do is inherit from the class [CMS_MODULE] () and redefine the register_hooks (2) feature.
|
||||
* Implement (via inheritance) the needed [Hooks] (/doc/concepts.md#hooks).
|
||||
* Define the module API through route definition. (1)
|
||||
* Define the list of block to be handle by the current module (3).
|
||||
* Render the block (4) (could be defined in Eiffel itself or using a template file (smarty)).
|
||||
* API implementation (5).
|
||||
|
||||
```
|
||||
class MY_NEW_MODULE
|
||||
|
||||
inherit
|
||||
|
||||
CMS_MODULE
|
||||
redefine
|
||||
register_hooks
|
||||
end
|
||||
|
||||
CMS_HOOK_BLOCK
|
||||
|
||||
CMS_HOOK_MENU_SYSTEM_ALTER
|
||||
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
-- Create current module
|
||||
do
|
||||
name := "new module"
|
||||
version := "1.0"
|
||||
description := "Eiffel new module"
|
||||
package := "example"
|
||||
end
|
||||
|
||||
feature -- Access: router
|
||||
|
||||
router (a_api: CMS_API): WSF_ROUTER
|
||||
-- (1) Node router.
|
||||
do
|
||||
create Result.make (1)
|
||||
Result.handle_with_request_methods ("/demo", create {WSF_URI_AGENT_HANDLER}.make (agent handle_demo (a_api, ?, ?)), Result.methods_head_get)
|
||||
end
|
||||
|
||||
feature -- Hooks
|
||||
|
||||
register_hooks (a_response: CMS_RESPONSE)
|
||||
do
|
||||
-- (2)
|
||||
a_response.subscribe_to_menu_system_alter_hook (Current)
|
||||
a_response.subscribe_to_block_hook (Current)
|
||||
end
|
||||
|
||||
block_list: ITERABLE [like {CMS_BLOCK}.name]
|
||||
do
|
||||
-- (3) List of block names, managed by current object.
|
||||
end
|
||||
|
||||
get_block_view (a_block_id: READABLE_STRING_8; a_response: CMS_RESPONSE)
|
||||
do
|
||||
-- (4) Get block object identified by `a_block_id' and associate with `a_response'.
|
||||
end
|
||||
|
||||
menu_system_alter (a_menu_system: CMS_MENU_SYSTEM; a_response: CMS_RESPONSE)
|
||||
local
|
||||
lnk: CMS_LOCAL_LINK
|
||||
do
|
||||
create lnk.make ("Demo", "/demo/")
|
||||
a_menu_system.primary_menu.extend (lnk)
|
||||
end
|
||||
|
||||
feature -- Handler
|
||||
|
||||
handle_demo (a_api: CMS_API; req: WSF_REQUEST; res: WSF_RESPONSE;)
|
||||
local
|
||||
r: NOT_IMPLEMENTED_ERROR_CMS_RESPONSE
|
||||
do
|
||||
-- (5)
|
||||
create r.make (req, res, a_api)
|
||||
r.set_main_content ("NODE module does not yet implement %"" + req.path_info + "%" ...")
|
||||
r.add_error_message ("NODE Module: not yet implemented")
|
||||
r.execute
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="cycle"/>
|
||||
Lifecycle
|
||||
---------
|
||||
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="cms" location="..\..\cms-safe.ecf" readonly="false"/>
|
||||
<library name="cms_demo_module" location="modules\demo\cms_demo_module-safe.ecf" readonly="false"/>
|
||||
<library name="persistence_mysql" location="..\..\library\persistence\implementation\mysql\persistence_mysql-safe.ecf" readonly="false"/>
|
||||
|
||||
<library name="layout" location="..\..\library\layout\layout-safe.ecf" readonly="false"/>
|
||||
<library name="wsf" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf-safe.ecf"/>
|
||||
<library name="wsf_extension" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf_extension-safe.ecf" readonly="false"/>
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
engine=smarty
|
||||
site.name=EWF Web CMS
|
||||
site.email=your@email.com
|
||||
var-dir=var
|
||||
files-dir=files
|
||||
[layout]
|
||||
root-dir=site/www
|
||||
themes-dir=site/themes
|
||||
|
||||
[site]
|
||||
name=Eiffel CMS
|
||||
email=your@email.com
|
||||
theme=bootstrap
|
||||
|
||||
[misc]
|
||||
smtp=localhost
|
||||
|
||||
@@ -2,8 +2,8 @@ note
|
||||
description: "[
|
||||
application service
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
date: "$Date: 2014-11-20 15:03:29 +0100 (jeu., 20 nov. 2014) $"
|
||||
revision: "$Revision: 96138 $"
|
||||
|
||||
class
|
||||
EWF_ROC_SERVER
|
||||
@@ -101,7 +101,7 @@ feature {NONE} -- Launch operation
|
||||
|
||||
feature -- CMS Initialization
|
||||
|
||||
cms_setup: CMS_CUSTOM_SETUP
|
||||
cms_setup: CMS_DEFAULT_SETUP
|
||||
do
|
||||
if attached separate_character_option_value ('d') as l_dir then
|
||||
log.write_debug (generator + ".cms_setup using a command line argument -d " + l_dir )
|
||||
@@ -135,11 +135,11 @@ feature -- CMS setup
|
||||
do
|
||||
create {BASIC_AUTH_MODULE} m.make
|
||||
m.enable
|
||||
a_setup.modules.extend (m)
|
||||
a_setup.register_module (m)
|
||||
|
||||
create {CMS_DEMO_MODULE} m.make
|
||||
m.enable
|
||||
a_setup.modules.extend (m)
|
||||
a_setup.register_module (m)
|
||||
end
|
||||
|
||||
setup_storage (a_setup: CMS_SETUP)
|
||||
@@ -147,6 +147,8 @@ feature -- CMS setup
|
||||
debug ("refactor_fixme")
|
||||
to_implement ("To implement custom storage")
|
||||
end
|
||||
a_setup.storage_drivers.force (create {CMS_STORAGE_MYSQL_BUILDER}.make, "mysql")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
16
library/configuration/config-safe.ecf
Normal file
16
library/configuration/config-safe.ecf
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-13-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-13-0 http://www.eiffel.com/developers/xml/configuration-1-13-0.xsd" name="config" uuid="A3762109-D650-40A1-B55A-7D236A17903F" library_target="config">
|
||||
<target name="config">
|
||||
<root all_classes="true"/>
|
||||
<file_rule>
|
||||
<exclude>/.git$</exclude>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
<exclude>/.svn$</exclude>
|
||||
</file_rule>
|
||||
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all" syntax="standard">
|
||||
</option>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json-safe.ecf"/>
|
||||
<cluster name="src" location=".\src\" recursive="true"/>
|
||||
</target>
|
||||
</system>
|
||||
16
library/configuration/config.ecf
Normal file
16
library/configuration/config.ecf
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-13-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-13-0 http://www.eiffel.com/developers/xml/configuration-1-13-0.xsd" name="config" uuid="A3762109-D650-40A1-B55A-7D236A17903F" library_target="config">
|
||||
<target name="config">
|
||||
<root all_classes="true"/>
|
||||
<file_rule>
|
||||
<exclude>/.git$</exclude>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
<exclude>/.svn$</exclude>
|
||||
</file_rule>
|
||||
<option warning="true" full_class_checking="true" is_attached_by_default="false" void_safety="none" syntax="standard">
|
||||
</option>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
|
||||
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json.ecf"/>
|
||||
<cluster name="src" location=".\src\" recursive="true"/>
|
||||
</target>
|
||||
</system>
|
||||
10
library/configuration/license.lic
Normal file
10
library/configuration/license.lic
Normal file
@@ -0,0 +1,10 @@
|
||||
${NOTE_KEYWORD}
|
||||
copyright: "2011-${YEAR}, Jocelyn Fiat, 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
|
||||
]"
|
||||
121
library/configuration/src/config_reader.e
Normal file
121
library/configuration/src/config_reader.e
Normal file
@@ -0,0 +1,121 @@
|
||||
note
|
||||
description: "Summary description for {CONFIG_READER}."
|
||||
author: ""
|
||||
date: "$Date: 2014-12-18 16:37:11 +0100 (jeu., 18 déc. 2014) $"
|
||||
revision: "$Revision: 96383 $"
|
||||
|
||||
deferred class
|
||||
CONFIG_READER
|
||||
|
||||
inherit
|
||||
SHARED_EXECUTION_ENVIRONMENT
|
||||
|
||||
feature -- Status report
|
||||
|
||||
has_item (k: READABLE_STRING_GENERAL): BOOLEAN
|
||||
-- Has item associated with key `k'?
|
||||
deferred
|
||||
end
|
||||
|
||||
has_error: BOOLEAN
|
||||
-- Has error?
|
||||
--| Syntax error, source not found, ...
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- Query
|
||||
|
||||
resolved_text_item (k: READABLE_STRING_GENERAL): detachable READABLE_STRING_32
|
||||
-- String item associated with key `k' and expanded to resolved variables ${varname}.
|
||||
do
|
||||
if attached text_item (k) as s then
|
||||
Result := resolved_expression (s)
|
||||
end
|
||||
end
|
||||
|
||||
text_item (k: READABLE_STRING_GENERAL): detachable READABLE_STRING_32
|
||||
-- String item associated with key `k'.
|
||||
deferred
|
||||
end
|
||||
|
||||
integer_item (k: READABLE_STRING_GENERAL): INTEGER
|
||||
-- Integer item associated with key `k'.
|
||||
deferred
|
||||
ensure
|
||||
not has_item (k) implies Result = 0
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
resolved_items: detachable STRING_TABLE [READABLE_STRING_32]
|
||||
-- Resolved items indexed by expression.
|
||||
|
||||
resolved_expression (exp: READABLE_STRING_GENERAL): STRING_32
|
||||
-- Resolved `exp' using `Current' or else environment variables.
|
||||
local
|
||||
i,n,b,e: INTEGER
|
||||
k: detachable READABLE_STRING_GENERAL
|
||||
c: CHARACTER_32
|
||||
l_resolved_items: like resolved_items
|
||||
l_text: detachable READABLE_STRING_GENERAL
|
||||
do
|
||||
from
|
||||
i := 1
|
||||
n := exp.count
|
||||
create Result.make (n)
|
||||
until
|
||||
i > n
|
||||
loop
|
||||
c := exp[i]
|
||||
if i + 1 < n and then c = '$' and then exp[i+1] = '{' then
|
||||
b := i + 2
|
||||
e := exp.index_of ('}', b) - 1
|
||||
if e > 0 then
|
||||
k := exp.substring (b, e)
|
||||
l_text := Void
|
||||
l_resolved_items := resolved_items
|
||||
if
|
||||
l_resolved_items /= Void and then
|
||||
attached l_resolved_items.item (k) as s
|
||||
then
|
||||
-- Already resolved, reuse value.
|
||||
l_text := s
|
||||
elseif attached text_item (k) as s then
|
||||
-- has such item
|
||||
l_text := s
|
||||
elseif attached execution_environment.item (k) as v then
|
||||
-- Or from environment
|
||||
l_text := v
|
||||
else
|
||||
l_text := exp.substring (i, e + 1)
|
||||
end
|
||||
i := e + 1
|
||||
Result.append_string_general (l_text)
|
||||
else
|
||||
Result.extend (c)
|
||||
end
|
||||
else
|
||||
Result.extend (c)
|
||||
end
|
||||
i := i + 1
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Duplication
|
||||
|
||||
sub_config (k: READABLE_STRING_GENERAL): detachable CONFIG_READER
|
||||
-- Configuration representing a subset of Current for key `k'.
|
||||
deferred
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2014, Jocelyn Fiat, 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
|
||||
463
library/configuration/src/ini_config.e
Normal file
463
library/configuration/src/ini_config.e
Normal file
@@ -0,0 +1,463 @@
|
||||
note
|
||||
description: "[
|
||||
Object parsing a .ini file.
|
||||
|
||||
Lines starting by '#', or ';', or "--" are comments
|
||||
Section are declared using brackets "[section_name]"
|
||||
Values are declared as "key = value"
|
||||
List values are declared as multiple lines "key[] = value"
|
||||
example:
|
||||
--------------------
|
||||
[first_section]
|
||||
one = abc
|
||||
|
||||
[second_section]
|
||||
two = def
|
||||
lst[] = a
|
||||
lst[] = b
|
||||
lst[] = c
|
||||
|
||||
[third_section]
|
||||
three = ghi
|
||||
table[a] = foo
|
||||
table[b] = bar
|
||||
--------------------
|
||||
|
||||
Values are accessible from `items' or by section from `sections'
|
||||
`item' has smart support for '.'
|
||||
|
||||
item ("one") -> abc
|
||||
item ("two") -> def
|
||||
item ("second_section.two") -> def
|
||||
item ("table[b]") -> foo
|
||||
item ("table.b") -> foo
|
||||
item ("third_section.table[b]") -> foo
|
||||
item ("third_section.table.b") -> foo
|
||||
|
||||
notes:
|
||||
it is considered that the .ini file is utf-8 encoded
|
||||
keys are unicode string
|
||||
values are stored UTF-8 string, but one can use unicode_string_item to convert to STRING_32
|
||||
|
||||
Additional features:
|
||||
- Include other files:
|
||||
@include=file-to-include
|
||||
|
||||
]"
|
||||
date: "$Date: 2014-12-18 16:37:11 +0100 (jeu., 18 déc. 2014) $"
|
||||
revision: "$Revision: 96383 $"
|
||||
|
||||
class
|
||||
INI_CONFIG
|
||||
|
||||
inherit
|
||||
CONFIG_READER
|
||||
|
||||
TABLE_ITERABLE [ANY, READABLE_STRING_GENERAL]
|
||||
|
||||
SHARED_EXECUTION_ENVIRONMENT
|
||||
|
||||
create
|
||||
make_from_file,
|
||||
make_from_string,
|
||||
make_from_items
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_from_file (p: PATH)
|
||||
do
|
||||
initialize
|
||||
parse_file (p)
|
||||
end
|
||||
|
||||
make_from_string (a_content: STRING_8)
|
||||
do
|
||||
initialize
|
||||
parse_content (a_content)
|
||||
end
|
||||
|
||||
make_from_items (a_items: like items)
|
||||
do
|
||||
initialize
|
||||
across
|
||||
a_items as ic
|
||||
loop
|
||||
items.force (ic.item, ic.key)
|
||||
end
|
||||
end
|
||||
|
||||
initialize
|
||||
-- Initialize data.
|
||||
do
|
||||
associated_path := Void
|
||||
create utf
|
||||
create items.make (0)
|
||||
create sections.make (0)
|
||||
end
|
||||
|
||||
reset
|
||||
-- Reset internal data.
|
||||
do
|
||||
has_error := False
|
||||
items.wipe_out
|
||||
sections.wipe_out
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
has_item (k: READABLE_STRING_GENERAL): BOOLEAN
|
||||
-- Has item associated with key `k'?
|
||||
do
|
||||
Result := item (k) /= Void
|
||||
end
|
||||
|
||||
has_error: BOOLEAN
|
||||
-- Has error?
|
||||
--| Syntax error, source not found, ...
|
||||
|
||||
feature -- Access: Config Reader
|
||||
|
||||
text_item (k: READABLE_STRING_GENERAL): detachable READABLE_STRING_32
|
||||
-- String item associated with key `k'.
|
||||
local
|
||||
obj: like item
|
||||
do
|
||||
obj := item (k)
|
||||
if attached {READABLE_STRING_32} obj as s32 then
|
||||
Result := s32
|
||||
elseif attached {READABLE_STRING_8} obj as s then
|
||||
Result := utf.utf_8_string_8_to_escaped_string_32 (s)
|
||||
end
|
||||
end
|
||||
|
||||
integer_item (k: READABLE_STRING_GENERAL): INTEGER
|
||||
-- Integer item associated with key `k'.
|
||||
do
|
||||
if attached {READABLE_STRING_GENERAL} item (k) as s then
|
||||
Result := s.to_integer
|
||||
end
|
||||
end
|
||||
|
||||
associated_path: detachable PATH
|
||||
-- If current was built from a filename, return this path.
|
||||
|
||||
feature -- Duplication
|
||||
|
||||
sub_config (k: READABLE_STRING_GENERAL): detachable CONFIG_READER
|
||||
-- Configuration representing a subset of Current for key `k'.
|
||||
do
|
||||
if attached sections.item (k) as l_items then
|
||||
create {INI_CONFIG} Result.make_from_items (l_items)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
item (k: READABLE_STRING_GENERAL): detachable ANY
|
||||
-- Value associated with key `k'.
|
||||
local
|
||||
i: INTEGER
|
||||
s,sk: detachable READABLE_STRING_GENERAL
|
||||
do
|
||||
-- Try first directly in values
|
||||
Result := items.item (k)
|
||||
if Result = Void then
|
||||
--| If there is a dot
|
||||
--| this could be
|
||||
--| section.variable
|
||||
--| variable.name or variable[name]
|
||||
i := k.index_of ('.', 1)
|
||||
if i > 0 then
|
||||
s := k.head (i - 1)
|
||||
-- then search first in section
|
||||
if attached sections.item (s) as l_section then
|
||||
sk := k.substring (i + 1, k.count)
|
||||
Result := l_section.item (sk)
|
||||
if Result = Void then
|
||||
Result := item_from_values (l_section, sk)
|
||||
end
|
||||
end
|
||||
if Result = Void then
|
||||
i := k.index_of ('.', i + 1)
|
||||
if i > 0 then
|
||||
-- There is another dot .. could be due to include
|
||||
across
|
||||
sections as ic
|
||||
until
|
||||
Result /= Void
|
||||
loop
|
||||
s := ic.key
|
||||
-- If has other dot, this may be in sub sections ...
|
||||
if s.has ('.') and then k.starts_with (s) and then k[s.count + 1] = '.' then
|
||||
if attached sections.item (s) as l_section then
|
||||
sk := k.substring (s.count + 2, k.count)
|
||||
Result := l_section.item (sk)
|
||||
if Result = Void then
|
||||
Result := item_from_values (l_section, sk)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if Result = Void then
|
||||
-- otherwise in values object.
|
||||
Result := item_from_values (items, k)
|
||||
end
|
||||
end
|
||||
else
|
||||
--| Could be
|
||||
--| variable[name]
|
||||
Result := item_from_values (items, k)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
items: STRING_TABLE [ANY]
|
||||
|
||||
sections: STRING_TABLE [like items]
|
||||
|
||||
feature -- Access
|
||||
|
||||
new_cursor: TABLE_ITERATION_CURSOR [ANY, READABLE_STRING_GENERAL]
|
||||
-- Fresh cursor associated with current structure
|
||||
do
|
||||
Result := items.new_cursor
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
item_from_values (a_values: STRING_TABLE [ANY]; k: READABLE_STRING_GENERAL): detachable ANY
|
||||
local
|
||||
i,j: INTEGER
|
||||
s: READABLE_STRING_GENERAL
|
||||
do
|
||||
Result := a_values.item (k)
|
||||
if Result = Void then
|
||||
i := k.index_of ('.', 1)
|
||||
if i > 0 then
|
||||
s := k.head (i - 1)
|
||||
if attached {STRING_TABLE [ANY]} a_values.item (s) as l_table then
|
||||
Result := l_table.item (k.substring (i + 1, k.count))
|
||||
end
|
||||
else
|
||||
i := k.index_of ('[', 1)
|
||||
if i > 0 then
|
||||
j := k.index_of (']', i + 1)
|
||||
if j = k.count then
|
||||
s := k.head (i - 1)
|
||||
if attached {STRING_TABLE [ANY]} a_values.item (s) as l_table then
|
||||
Result := l_table.item (k.substring (i + 1, j - 1))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
record_in_section (obj: ANY; k: READABLE_STRING_GENERAL; a_section: READABLE_STRING_GENERAL)
|
||||
local
|
||||
v: detachable like items
|
||||
do
|
||||
v := sections.item (a_section)
|
||||
if v = Void then
|
||||
create v.make (1)
|
||||
sections.force (v, a_section)
|
||||
end
|
||||
v.force (obj, k)
|
||||
end
|
||||
|
||||
parse_content (a_content: STRING_8)
|
||||
local
|
||||
i,j,n: INTEGER
|
||||
s: READABLE_STRING_8
|
||||
do
|
||||
last_section_name := Void
|
||||
from
|
||||
i := 1
|
||||
n := a_content.count
|
||||
until
|
||||
i > n
|
||||
loop
|
||||
j := a_content.index_of ('%N', i)
|
||||
if j > 0 then
|
||||
s := a_content.substring (i, j - 1)
|
||||
i := j + 1
|
||||
if i <= n and then a_content[i] = '%R' then
|
||||
i := i + 1
|
||||
end
|
||||
else
|
||||
j := n
|
||||
s := a_content.substring (i, j)
|
||||
i := j + 1
|
||||
end
|
||||
analyze_line (s, Void)
|
||||
variant
|
||||
i
|
||||
end
|
||||
last_section_name := Void
|
||||
rescue
|
||||
last_section_name := Void
|
||||
has_error := True
|
||||
end
|
||||
|
||||
parse_file (p: PATH)
|
||||
do
|
||||
associated_path := p
|
||||
last_section_name := Void
|
||||
import_path (p, Void)
|
||||
last_section_name := Void
|
||||
end
|
||||
|
||||
import_path (p: PATH; a_section_prefix: detachable READABLE_STRING_32)
|
||||
-- Import config from path `p'.
|
||||
local
|
||||
f: PLAIN_TEXT_FILE
|
||||
l_last_section_name: like last_section_name
|
||||
retried: BOOLEAN
|
||||
do
|
||||
if retried then
|
||||
has_error := True
|
||||
else
|
||||
l_last_section_name := last_section_name
|
||||
last_section_name := Void
|
||||
create f.make_with_path (p)
|
||||
if f.exists and then f.is_access_readable then
|
||||
f.open_read
|
||||
from
|
||||
until
|
||||
f.exhausted or f.end_of_file
|
||||
loop
|
||||
f.read_line_thread_aware
|
||||
analyze_line (f.last_string, a_section_prefix)
|
||||
end
|
||||
f.close
|
||||
else
|
||||
-- File not readable
|
||||
has_error := True
|
||||
end
|
||||
end
|
||||
last_section_name := l_last_section_name
|
||||
rescue
|
||||
retried := True
|
||||
retry
|
||||
end
|
||||
|
||||
analyze_line (a_line: STRING_8; a_section_prefix: detachable READABLE_STRING_32)
|
||||
-- Analyze line `a_line'.
|
||||
local
|
||||
k,sk: STRING_32
|
||||
v: STRING_8
|
||||
obj: detachable ANY
|
||||
lst: LIST [STRING_8]
|
||||
tb: STRING_TABLE [STRING_8]
|
||||
i,j: INTEGER
|
||||
l_section_name: like last_section_name
|
||||
do
|
||||
obj := Void
|
||||
a_line.left_adjust
|
||||
if
|
||||
a_line.is_empty
|
||||
or a_line.is_whitespace
|
||||
or a_line.starts_with_general ("#")
|
||||
or a_line.starts_with_general (";")
|
||||
or a_line.starts_with_general ("--")
|
||||
then
|
||||
-- Ignore
|
||||
elseif a_line.starts_with_general ("[") then
|
||||
i := a_line.index_of (']', 1)
|
||||
l_section_name := utf.utf_8_string_8_to_string_32 (a_line.substring (2, i - 1))
|
||||
l_section_name.left_adjust
|
||||
l_section_name.right_adjust
|
||||
if a_section_prefix /= Void then
|
||||
l_section_name.prepend_character ('.')
|
||||
l_section_name.prepend (a_section_prefix)
|
||||
end
|
||||
last_section_name := l_section_name
|
||||
else
|
||||
i := a_line.index_of ('=', 1)
|
||||
if i > 1 then
|
||||
k := utf.utf_8_string_8_to_string_32 (a_line.head (i - 1))
|
||||
k.right_adjust
|
||||
v := a_line.substring (i + 1, a_line.count)
|
||||
v.left_adjust
|
||||
v.right_adjust
|
||||
|
||||
|
||||
if k.is_case_insensitive_equal_general ("@include") then
|
||||
import_path (create {PATH}.make_from_string (v), last_section_name)
|
||||
else
|
||||
i := k.index_of ('[', 1)
|
||||
if i > 0 then
|
||||
j := k.index_of (']', i + 1)
|
||||
if j = i + 1 then -- ends_with "[]"
|
||||
k.keep_head (i - 1)
|
||||
if attached {LIST [STRING_8]} items.item (k) as l_list then
|
||||
lst := l_list
|
||||
else
|
||||
create {ARRAYED_LIST [STRING_8]} lst.make (1)
|
||||
record_item (lst, k, a_section_prefix)
|
||||
end
|
||||
lst.force (v)
|
||||
obj := lst
|
||||
elseif j > i then
|
||||
-- table
|
||||
sk := k.substring (i + 1, j - 1)
|
||||
sk.left_adjust
|
||||
sk.right_adjust
|
||||
k.keep_head (i - 1)
|
||||
if attached {STRING_TABLE [STRING_8]} items.item (k) as l_table then
|
||||
tb := l_table
|
||||
else
|
||||
create tb.make (1)
|
||||
record_item (tb, k, a_section_prefix)
|
||||
end
|
||||
tb.force (v, sk)
|
||||
obj := tb
|
||||
else
|
||||
-- Error missing closing ']'
|
||||
has_error := True
|
||||
end
|
||||
else
|
||||
record_item (v, k, a_section_prefix)
|
||||
obj := v
|
||||
end
|
||||
|
||||
if attached last_section_name as l_session and then obj /= Void then
|
||||
record_in_section (obj, k, l_session)
|
||||
end
|
||||
end
|
||||
else
|
||||
-- Error
|
||||
has_error := True
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
record_item (v: ANY; k: READABLE_STRING_32; a_section_prefix: detachable READABLE_STRING_32)
|
||||
do
|
||||
if a_section_prefix /= Void then
|
||||
items.force (v, a_section_prefix + {STRING_32} "." + k)
|
||||
else
|
||||
items.force (v, k)
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
last_section_name: detachable STRING_32
|
||||
|
||||
utf: UTF_CONVERTER
|
||||
|
||||
invariant
|
||||
|
||||
note
|
||||
copyright: "2011-2014, Jocelyn Fiat, 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
|
||||
175
library/configuration/src/json_config.e
Normal file
175
library/configuration/src/json_config.e
Normal file
@@ -0,0 +1,175 @@
|
||||
note
|
||||
description: "Object parsing a JSON configuration file."
|
||||
date: "$Date: 2014-12-18 16:37:11 +0100 (jeu., 18 déc. 2014) $"
|
||||
revision: "$Revision: 96383 $"
|
||||
|
||||
class
|
||||
JSON_CONFIG
|
||||
|
||||
inherit
|
||||
CONFIG_READER
|
||||
|
||||
create
|
||||
make_from_file,
|
||||
make_from_string,
|
||||
make_from_json_object
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_from_file (p: PATH)
|
||||
-- Create object from a file `p'
|
||||
do
|
||||
parse (p)
|
||||
end
|
||||
|
||||
make_from_string (a_json: READABLE_STRING_8)
|
||||
-- Create current config from string `a_json'.
|
||||
local
|
||||
l_parser: JSON_PARSER
|
||||
do
|
||||
create l_parser.make_with_string (a_json)
|
||||
l_parser.parse_content
|
||||
if
|
||||
l_parser.is_valid and then
|
||||
attached l_parser.parsed_json_object as j_o
|
||||
then
|
||||
make_from_json_object (j_o)
|
||||
else
|
||||
has_error := True
|
||||
end
|
||||
end
|
||||
|
||||
make_from_json_object (a_object: JSON_OBJECT)
|
||||
-- Create current config from JSON `a_object'.
|
||||
do
|
||||
associated_path := Void
|
||||
json_value := a_object
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
has_item (k: READABLE_STRING_GENERAL): BOOLEAN
|
||||
-- Has item associated with key `k'?
|
||||
do
|
||||
Result := item (k) /= Void
|
||||
end
|
||||
|
||||
has_error: BOOLEAN
|
||||
-- Has error?
|
||||
--| Syntax error, source not found, ...
|
||||
|
||||
feature -- Access: Config Reader
|
||||
|
||||
text_item (k: READABLE_STRING_GENERAL): detachable READABLE_STRING_32
|
||||
-- String item associated with query `k'.
|
||||
do
|
||||
if attached {JSON_STRING} item (k) as l_string then
|
||||
Result := l_string.unescaped_string_32
|
||||
elseif attached {JSON_NUMBER} item (k) as l_number then
|
||||
Result := l_number.item
|
||||
end
|
||||
end
|
||||
|
||||
integer_item (k: READABLE_STRING_GENERAL): INTEGER
|
||||
-- Integer item associated with key `k'.
|
||||
do
|
||||
if attached {JSON_NUMBER} item (k) as l_number then
|
||||
Result := l_number.item.to_integer
|
||||
end
|
||||
end
|
||||
|
||||
associated_path: detachable PATH
|
||||
-- If current was built from a filename, return this path.
|
||||
|
||||
feature -- Duplication
|
||||
|
||||
sub_config (k: READABLE_STRING_GENERAL): detachable CONFIG_READER
|
||||
-- Configuration representing a subset of Current for key `k'.
|
||||
do
|
||||
if attached {JSON_OBJECT} item (k) as j_o then
|
||||
create {JSON_CONFIG} Result.make_from_json_object (j_o)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
item (k: READABLE_STRING_GENERAL): detachable JSON_VALUE
|
||||
-- Item associated with query `k' if any.
|
||||
-- `k' can be a single name such as "foo",
|
||||
-- or a qualified name such as "foo.bar" (assuming that "foo" is associated with a JSON object).
|
||||
do
|
||||
if attached json_value as obj then
|
||||
Result := object_json_value (obj, k.to_string_32)
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
object_json_value (a_object: JSON_OBJECT; a_query: READABLE_STRING_32): detachable JSON_VALUE
|
||||
-- Item associated with query `a_query' from object `a_object' if any.
|
||||
local
|
||||
i: INTEGER
|
||||
h: READABLE_STRING_32
|
||||
do
|
||||
i := a_query.index_of ('.', 1)
|
||||
if i > 1 then
|
||||
h := a_query.head (i - 1)
|
||||
if attached {JSON_OBJECT} a_object.item (h) as l_obj then
|
||||
Result := object_json_value (l_obj, a_query.substring (i + 1, a_query.count))
|
||||
else
|
||||
-- This is not an object...
|
||||
Result := Void
|
||||
end
|
||||
else
|
||||
Result := a_object.item (a_query)
|
||||
end
|
||||
end
|
||||
|
||||
parse (a_path: PATH)
|
||||
local
|
||||
l_parser: JSON_PARSER
|
||||
do
|
||||
associated_path := a_path
|
||||
has_error := False
|
||||
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 jv
|
||||
then
|
||||
json_value := jv
|
||||
else
|
||||
has_error := True
|
||||
end
|
||||
else
|
||||
has_error := True
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- JSON
|
||||
|
||||
json_value: detachable JSON_OBJECT
|
||||
-- Possible json object representation.
|
||||
|
||||
json_file_from (a_fn: PATH): detachable STRING
|
||||
do
|
||||
Result := (create {JSON_FILE_READER}).read_json_from (a_fn.name.out)
|
||||
end
|
||||
|
||||
new_json_parser (a_string: STRING): JSON_PARSER
|
||||
do
|
||||
create Result.make_with_string (a_string)
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2014, Jocelyn Fiat, 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
|
||||
18
library/configuration/tests/config_tests-safe.ecf
Normal file
18
library/configuration/tests/config_tests-safe.ecf
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-13-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-13-0 http://www.eiffel.com/developers/xml/configuration-1-13-0.xsd" name="config_tests" uuid="AD1DE0F7-BC8A-4A17-9A44-56C917BD5604">
|
||||
<target name="config_tests">
|
||||
<root class="TEST_CONFIG_READER_SET" feature="default_create"/>
|
||||
<file_rule>
|
||||
<exclude>/.git$</exclude>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
<exclude>/.svn$</exclude>
|
||||
</file_rule>
|
||||
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="transitional" syntax="standard">
|
||||
</option>
|
||||
<setting name="concurrency" value="none"/>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="config" location="..\config-safe.ecf" readonly="false"/>
|
||||
<library name="testing" location="$ISE_LIBRARY\library\testing\testing-safe.ecf"/>
|
||||
<tests name="src" location=".\"/>
|
||||
</target>
|
||||
</system>
|
||||
18
library/configuration/tests/config_tests.ecf
Normal file
18
library/configuration/tests/config_tests.ecf
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-13-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-13-0 http://www.eiffel.com/developers/xml/configuration-1-13-0.xsd" name="config_tests" uuid="AD1DE0F7-BC8A-4A17-9A44-56C917BD5604">
|
||||
<target name="config_tests">
|
||||
<root class="TEST_CONFIG_READER_SET" feature="default_create"/>
|
||||
<file_rule>
|
||||
<exclude>/.git$</exclude>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
<exclude>/.svn$</exclude>
|
||||
</file_rule>
|
||||
<option warning="true" full_class_checking="true" void_safety="none" syntax="standard">
|
||||
</option>
|
||||
<setting name="concurrency" value="none"/>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
|
||||
<library name="config" location="..\config.ecf" readonly="false"/>
|
||||
<library name="testing" location="$ISE_LIBRARY\library\testing\testing.ecf"/>
|
||||
<tests name="src" location=".\"/>
|
||||
</target>
|
||||
</system>
|
||||
177
library/configuration/tests/test_config_reader_set.e
Normal file
177
library/configuration/tests/test_config_reader_set.e
Normal file
@@ -0,0 +1,177 @@
|
||||
note
|
||||
description: "[
|
||||
Testing suite for CONFIG_READER .
|
||||
]"
|
||||
author: "$Author: jfiat $"
|
||||
date: "$Date: 2014-12-18 16:37:11 +0100 (jeu., 18 déc. 2014) $"
|
||||
revision: "$Revision: 96383 $"
|
||||
|
||||
class
|
||||
TEST_CONFIG_READER_SET
|
||||
|
||||
inherit
|
||||
EQA_TEST_SET
|
||||
|
||||
feature -- Test
|
||||
|
||||
test_ini
|
||||
local
|
||||
cfg: CONFIG_READER
|
||||
do
|
||||
create {INI_CONFIG} cfg.make_from_string ("[
|
||||
foo = bar
|
||||
|
||||
[first]
|
||||
abc = 1
|
||||
def = and so on
|
||||
ghi = "path"
|
||||
|
||||
[ second ]
|
||||
this = 1
|
||||
is = 2
|
||||
the = 3
|
||||
end = 4
|
||||
|
||||
]")
|
||||
|
||||
assert ("is valid", not cfg.has_error)
|
||||
assert ("has_item (foo)", cfg.has_item ("foo"))
|
||||
assert ("has_item (abc)", cfg.has_item ("abc"))
|
||||
assert ("has_item (def)", cfg.has_item ("def"))
|
||||
assert ("has_item (ghi)", cfg.has_item ("ghi"))
|
||||
assert ("has_item (this)", cfg.has_item ("this"))
|
||||
assert ("has_item (is)", cfg.has_item ("is"))
|
||||
assert ("has_item (the)", cfg.has_item ("the"))
|
||||
assert ("has_item (end)", cfg.has_item ("end"))
|
||||
|
||||
assert ("item (foo)", attached cfg.text_item ("foo") as v and then v.same_string_general ("bar"))
|
||||
assert ("item (abc)", attached cfg.text_item ("abc") as v and then v.same_string_general ("1"))
|
||||
assert ("item (def)", attached cfg.text_item ("def") as v and then v.same_string_general ("and so on"))
|
||||
assert ("item (ghi)", attached cfg.text_item ("ghi") as v and then v.same_string_general ("%"path%""))
|
||||
assert ("item (this)", attached cfg.text_item ("this") as v and then v.same_string_general ("1"))
|
||||
assert ("item (is)", attached cfg.text_item ("is") as v and then v.same_string_general ("2"))
|
||||
assert ("item (the)", attached cfg.text_item ("the") as v and then v.same_string_general ("3"))
|
||||
assert ("item (end)", attached cfg.text_item ("end") as v and then v.same_string_general ("4"))
|
||||
|
||||
assert ("has_item (first.abc)", cfg.has_item ("first.abc"))
|
||||
assert ("item (first.abc)", attached cfg.text_item ("first.abc") as v and then v.same_string_general ("1"))
|
||||
assert ("has_item (second.is)", cfg.has_item ("second.is"))
|
||||
assert ("item (second.is)", attached cfg.text_item ("second.is") as v and then v.same_string_general ("2"))
|
||||
|
||||
if attached cfg.sub_config ("second") as cfg_second then
|
||||
assert ("has_item (is)", cfg_second.has_item ("is"))
|
||||
assert ("item (is)", attached cfg_second.text_item ("is") as v and then v.same_string_general ("2"))
|
||||
|
||||
else
|
||||
assert ("has second", False)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
test_resolver_ini
|
||||
local
|
||||
cfg: CONFIG_READER
|
||||
do
|
||||
create {INI_CONFIG} cfg.make_from_string ("[
|
||||
foo = bar
|
||||
|
||||
[extra]
|
||||
a.b.c = abc
|
||||
|
||||
[expression]
|
||||
text = ${foo}/${a.b.c}
|
||||
]")
|
||||
|
||||
assert ("is valid", not cfg.has_error)
|
||||
assert ("has_item (extra.a.b.c)", cfg.has_item ("extra.a.b.c"))
|
||||
assert ("has_item (extra.a.b.c)", cfg.has_item ("extra.a.b.c"))
|
||||
assert ("has_item (expression.text)", cfg.has_item ("expression.text"))
|
||||
assert ("item (expression.text)", attached cfg.resolved_text_item ("expression.text") as s and then s.same_string_general ("bar/abc"))
|
||||
end
|
||||
|
||||
test_deep_ini
|
||||
local
|
||||
cfg: CONFIG_READER
|
||||
f: RAW_FILE
|
||||
do
|
||||
|
||||
create f.make_with_name ("test_deep.ini")
|
||||
f.create_read_write
|
||||
f.put_string ("[
|
||||
test = extra
|
||||
[new]
|
||||
enabled = true
|
||||
]"
|
||||
)
|
||||
f.close
|
||||
create {INI_CONFIG} cfg.make_from_string ("[
|
||||
foo = bar
|
||||
|
||||
[extra]
|
||||
a.b.c = abc
|
||||
|
||||
[outside]
|
||||
before = include
|
||||
@include=test_deep.ini
|
||||
|
||||
]")
|
||||
f.delete
|
||||
|
||||
assert ("is valid", not cfg.has_error)
|
||||
assert ("has_item (extra.a.b.c)", cfg.has_item ("extra.a.b.c"))
|
||||
assert ("has_item (extra.a.b.c)", cfg.has_item ("extra.a.b.c"))
|
||||
assert ("has_item (outside.new.enabled)", cfg.has_item ("outside.new.enabled"))
|
||||
end
|
||||
|
||||
|
||||
test_json
|
||||
local
|
||||
cfg: CONFIG_READER
|
||||
do
|
||||
create {JSON_CONFIG} cfg.make_from_string ("[
|
||||
{
|
||||
"foo": "bar",
|
||||
"first": {
|
||||
"abc": 1,
|
||||
"def": "and so on",
|
||||
"ghi": "\"path\""
|
||||
},
|
||||
"second": {
|
||||
"this": 1,
|
||||
"is": 2,
|
||||
"the": 3,
|
||||
"end": 4
|
||||
}
|
||||
}
|
||||
]")
|
||||
|
||||
assert ("is valid", not cfg.has_error)
|
||||
assert ("has_item (foo)", cfg.has_item ("foo"))
|
||||
assert ("has_item (first.abc)", cfg.has_item ("first.abc"))
|
||||
assert ("has_item (first.def)", cfg.has_item ("first.def"))
|
||||
assert ("has_item (first.ghi)", cfg.has_item ("first.ghi"))
|
||||
assert ("has_item (second.this)", cfg.has_item ("second.this"))
|
||||
assert ("has_item (second.is)", cfg.has_item ("second.is"))
|
||||
assert ("has_item (second.the)", cfg.has_item ("second.the"))
|
||||
assert ("has_item (second.end)", cfg.has_item ("second.end"))
|
||||
|
||||
assert ("item (foo)", attached cfg.text_item ("foo") as v and then v.same_string_general ("bar"))
|
||||
assert ("item (first.abc)", attached cfg.text_item ("first.abc") as v and then v.same_string_general ("1"))
|
||||
assert ("item (first.def)", attached cfg.text_item ("first.def") as v and then v.same_string_general ("and so on"))
|
||||
assert ("item (first.ghi)", attached cfg.text_item ("first.ghi") as v and then v.same_string_general ("%"path%""))
|
||||
assert ("item (second.this)", attached cfg.text_item ("second.this") as v and then v.same_string_general ("1"))
|
||||
assert ("item (second.is)", attached cfg.text_item ("second.is") as v and then v.same_string_general ("2"))
|
||||
assert ("item (second.the)", attached cfg.text_item ("second.the") as v and then v.same_string_general ("3"))
|
||||
assert ("item (second.end)", attached cfg.text_item ("second.end") as v and then v.same_string_general ("4"))
|
||||
|
||||
if attached cfg.sub_config ("second") as cfg_second then
|
||||
assert ("has_item (is)", cfg_second.has_item ("is"))
|
||||
assert ("item (is)", attached cfg_second.text_item ("is") as v and then v.same_string_general ("2"))
|
||||
|
||||
else
|
||||
assert ("has second", False)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
@@ -2,7 +2,7 @@
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-13-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-13-0 http://www.eiffel.com/developers/xml/configuration-1-13-0.xsd" name="layout" uuid="7AE9E48B-5A15-43F8-B99A-04F4185DED6B" library_target="layout">
|
||||
<target name="layout">
|
||||
<root all_classes="true"/>
|
||||
<option warning="true">
|
||||
<option warning="true" void_safety="all">
|
||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||
</option>
|
||||
<setting name="console_application" value="true"/>
|
||||
|
||||
21
library/layout/layout.ecf
Normal file
21
library/layout/layout.ecf
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-13-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-13-0 http://www.eiffel.com/developers/xml/configuration-1-13-0.xsd" name="layout" uuid="7AE9E48B-5A15-43F8-B99A-04F4185DED6B" library_target="layout">
|
||||
<target name="layout">
|
||||
<root all_classes="true"/>
|
||||
<option warning="true" void_safety="none">
|
||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||
</option>
|
||||
<setting name="console_application" value="true"/>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
|
||||
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json.ecf" readonly="false"/>
|
||||
<library name="logging" location="$ISE_LIBRARY\library\runtime\logging\logging.ecf"/>
|
||||
<library name="thread" location="$ISE_LIBRARY\library\thread\thread.ecf"/>
|
||||
<cluster name="src" location=".\src\" recursive="true">
|
||||
<file_rule>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
<exclude>/CVS$</exclude>
|
||||
<exclude>/.svn$</exclude>
|
||||
</file_rule>
|
||||
</cluster>
|
||||
</target>
|
||||
</system>
|
||||
@@ -0,0 +1,119 @@
|
||||
note
|
||||
description: "Provide access to json configuration"
|
||||
date: "$Date: 2015-01-14 16:13:47 +0100 (mer., 14 janv. 2015) $"
|
||||
revision: "$Revision: 96454 $"
|
||||
|
||||
class
|
||||
APPLICATION_JSON_CONFIGURATION_HELPER
|
||||
|
||||
feature -- Application Configuration
|
||||
|
||||
new_smtp_configuration (a_path: PATH): READABLE_STRING_32
|
||||
-- Build a new database configuration.
|
||||
local
|
||||
l_parser: JSON_PARSER
|
||||
do
|
||||
Result := ""
|
||||
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 {JSON_OBJECT} l_parser.parsed_json_value as jv and then
|
||||
attached {JSON_OBJECT} jv.item ("smtp") as l_smtp and then
|
||||
attached {JSON_STRING} l_smtp.item ("server") as l_server
|
||||
then
|
||||
Result := l_server.item
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
new_database_configuration (a_path: PATH): detachable DATABASE_CONFIGURATION
|
||||
-- Build a new database configuration.
|
||||
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 {JSON_OBJECT} l_parser.parsed_json_value as jv and then
|
||||
attached {JSON_OBJECT} jv.item ("database") as l_database and then
|
||||
attached {JSON_OBJECT} l_database.item ("datasource") as l_datasource and then
|
||||
attached {JSON_STRING} l_datasource.item ("driver") as l_driver and then
|
||||
attached {JSON_STRING} l_datasource.item ("environment") as l_envrionment and then
|
||||
attached {JSON_OBJECT} l_database.item ("environments") as l_environments and then
|
||||
attached {JSON_OBJECT} l_environments.item (l_envrionment.item) as l_environment_selected and then
|
||||
attached {JSON_STRING} l_environment_selected.item ("connection_string") as l_connection_string
|
||||
then
|
||||
create Result.make (l_driver.item, l_connection_string.unescaped_string_8)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
new_logger_level_configuration (a_path: PATH): READABLE_STRING_32
|
||||
-- Retrieve a new logger level configuration.
|
||||
-- By default, level is set to `DEBUG'.
|
||||
local
|
||||
l_parser: JSON_PARSER
|
||||
do
|
||||
Result := "DEBUG"
|
||||
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 {JSON_OBJECT} l_parser.parsed_json_value as jv and then
|
||||
attached {JSON_OBJECT} jv.item ("logger") as l_logger and then
|
||||
attached {JSON_STRING} l_logger.item ("level") as l_level
|
||||
then
|
||||
Result := l_level.item
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
new_database_configuration_test (a_path: PATH): detachable DATABASE_CONFIGURATION
|
||||
-- Build a new database configuration for testing purposes.
|
||||
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 {JSON_OBJECT} l_parser.parsed_json_value as jv and then
|
||||
l_parser.is_parsed and then
|
||||
attached {JSON_OBJECT} jv.item ("database") as l_database and then
|
||||
attached {JSON_OBJECT} l_database.item ("datasource") as l_datasource and then
|
||||
attached {JSON_STRING} l_datasource.item ("driver") as l_driver and then
|
||||
attached {JSON_STRING} l_datasource.item ("environment") as l_envrionment and then
|
||||
attached {JSON_STRING} l_datasource.item ("trusted") as l_trusted and then
|
||||
attached {JSON_OBJECT} l_database.item ("environments") as l_environments and then
|
||||
attached {JSON_OBJECT} l_environments.item ("test") as l_environment_selected and then
|
||||
attached {JSON_STRING} l_environment_selected.item ("connection_string") as l_connection_string and then
|
||||
attached {JSON_STRING} l_environment_selected.item ("name") as l_name
|
||||
then
|
||||
create Result.make (l_driver.item, l_connection_string.unescaped_string_8)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- JSON
|
||||
|
||||
json_file_from (a_fn: PATH): detachable STRING
|
||||
do
|
||||
Result := (create {JSON_FILE_READER}).read_json_from (a_fn.name.out)
|
||||
end
|
||||
|
||||
new_json_parser (a_string: STRING): JSON_PARSER
|
||||
do
|
||||
create Result.make_with_string (a_string)
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2015, Javier Velilla, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
|
||||
end
|
||||
@@ -1,7 +1,7 @@
|
||||
note
|
||||
description: "Object that represent Database configuration settings"
|
||||
date: "$Date: 2014-08-20 15:21:15 -0300 (mi., 20 ago. 2014) $"
|
||||
revision: "$Revision: 95678 $"
|
||||
date: "$Date: 2015-01-14 16:13:47 +0100 (mer., 14 janv. 2015) $"
|
||||
revision: "$Revision: 96454 $"
|
||||
|
||||
class
|
||||
DATABASE_CONFIGURATION
|
||||
@@ -25,10 +25,10 @@ feature {NONE} -- Initialization
|
||||
feature -- Access
|
||||
|
||||
driver: READABLE_STRING_32
|
||||
--Database driver.
|
||||
--Database driver.
|
||||
|
||||
database_string: READABLE_STRING_32
|
||||
-- Database connection.
|
||||
-- Database connection.
|
||||
|
||||
connection_string: READABLE_STRING_32
|
||||
-- Connection string
|
||||
|
||||
@@ -1,103 +0,0 @@
|
||||
note
|
||||
description: "Provide access to json configuration"
|
||||
date: "$Date: 2014-08-20 15:21:15 -0300 (mi., 20 ago. 2014) $"
|
||||
revision: "$Revision: 95678 $"
|
||||
|
||||
class
|
||||
JSON_CONFIGURATION
|
||||
|
||||
feature -- Application Configuration
|
||||
|
||||
new_smtp_configuration (a_path: PATH): READABLE_STRING_32
|
||||
-- Build a new database configuration.
|
||||
local
|
||||
l_parser: JSON_PARSER
|
||||
do
|
||||
Result := ""
|
||||
if attached json_file_from (a_path) as json_file then
|
||||
l_parser := new_json_parser (json_file)
|
||||
if attached {JSON_OBJECT} l_parser.parse as jv and then l_parser.is_parsed and then
|
||||
attached {JSON_OBJECT} jv.item ("smtp") as l_smtp and then
|
||||
attached {JSON_STRING} l_smtp.item ("server") as l_server then
|
||||
Result := l_server.item
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
new_database_configuration (a_path: PATH): detachable DATABASE_CONFIGURATION
|
||||
-- Build a new database configuration.
|
||||
local
|
||||
l_parser: JSON_PARSER
|
||||
do
|
||||
if attached json_file_from (a_path) as json_file then
|
||||
l_parser := new_json_parser (json_file)
|
||||
if attached {JSON_OBJECT} l_parser.parse as jv and then l_parser.is_parsed and then
|
||||
attached {JSON_OBJECT} jv.item ("database") as l_database and then
|
||||
attached {JSON_OBJECT} l_database.item ("datasource") as l_datasource and then
|
||||
attached {JSON_STRING} l_datasource.item ("driver") as l_driver and then
|
||||
attached {JSON_STRING} l_datasource.item ("environment") as l_envrionment and then
|
||||
attached {JSON_OBJECT} l_database.item ("environments") as l_environments and then
|
||||
attached {JSON_OBJECT} l_environments.item (l_envrionment.item) as l_environment_selected and then
|
||||
attached {JSON_STRING} l_environment_selected.item ("connection_string") as l_connection_string then
|
||||
create Result.make (l_driver.item, l_connection_string.unescaped_string_8)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
new_logger_level_configuration (a_path: PATH): READABLE_STRING_32
|
||||
-- Retrieve a new logger level configuration.
|
||||
-- By default, level is set to `DEBUG'.
|
||||
local
|
||||
l_parser: JSON_PARSER
|
||||
do
|
||||
Result := "DEBUG"
|
||||
if attached json_file_from (a_path) as json_file then
|
||||
l_parser := new_json_parser (json_file)
|
||||
if attached {JSON_OBJECT} l_parser.parse as jv and then l_parser.is_parsed and then
|
||||
attached {JSON_OBJECT} jv.item ("logger") as l_logger and then
|
||||
attached {JSON_STRING} l_logger.item ("level") as l_level then
|
||||
Result := l_level.item
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
new_database_configuration_test (a_path: PATH): detachable DATABASE_CONFIGURATION
|
||||
-- Build a new database configuration for testing purposes.
|
||||
local
|
||||
l_parser: JSON_PARSER
|
||||
do
|
||||
if attached json_file_from (a_path) as json_file then
|
||||
l_parser := new_json_parser (json_file)
|
||||
if attached {JSON_OBJECT} l_parser.parse as jv and then l_parser.is_parsed and then
|
||||
attached {JSON_OBJECT} jv.item ("database") as l_database and then
|
||||
attached {JSON_OBJECT} l_database.item ("datasource") as l_datasource and then
|
||||
attached {JSON_STRING} l_datasource.item ("driver") as l_driver and then
|
||||
attached {JSON_STRING} l_datasource.item ("environment") as l_envrionment and then
|
||||
attached {JSON_STRING} l_datasource.item ("trusted") as l_trusted and then
|
||||
attached {JSON_OBJECT} l_database.item ("environments") as l_environments and then
|
||||
attached {JSON_OBJECT} l_environments.item ("test") as l_environment_selected and then
|
||||
attached {JSON_STRING} l_environment_selected.item ("connection_string") as l_connection_string and then
|
||||
attached {JSON_STRING} l_environment_selected.item ("name") as l_name then
|
||||
create Result.make (l_driver.item, l_connection_string.unescaped_string_8)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
feature {NONE} -- JSON
|
||||
|
||||
json_file_from (a_fn: PATH): detachable STRING
|
||||
do
|
||||
Result := (create {JSON_FILE_READER}).read_json_from (a_fn.name.out)
|
||||
end
|
||||
|
||||
new_json_parser (a_string: STRING): JSON_PARSER
|
||||
do
|
||||
create Result.make_parser (a_string)
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2014, Javier Velilla, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
end
|
||||
@@ -1,7 +1,7 @@
|
||||
note
|
||||
description: "Provides logger information"
|
||||
date: "$Date: 2014-08-20 15:21:15 -0300 (mi., 20 ago. 2014) $"
|
||||
revision: "$Revision: 95678 $"
|
||||
date: "$Date: 2015-01-15 00:00:58 +0100 (jeu., 15 janv. 2015) $"
|
||||
revision: "$Revision: 96461 $"
|
||||
|
||||
class
|
||||
SHARED_LOGGER
|
||||
@@ -29,7 +29,7 @@ feature -- Logger
|
||||
create l_environment
|
||||
if attached separate_character_option_value ('d') as l_dir then
|
||||
l_path := create {PATH}.make_from_string (l_dir)
|
||||
create l_log_writer.make_at_location (l_path.extended ("..").appended ("\api.log"))
|
||||
create l_log_writer.make_at_location (l_path.extended ("logs").appended ("\api.log"))
|
||||
else
|
||||
l_path := create {PATH}.make_current
|
||||
create l_log_writer.make_at_location (l_path.extended("api.log"))
|
||||
@@ -107,6 +107,6 @@ feature {NONE} -- JSON
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2014, Javier Velilla, Jocelyn Fiat, Eiffel Software and others"
|
||||
copyright: "2011-2015, Javier Velilla, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
end
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-13-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-13-0 http://www.eiffel.com/developers/xml/configuration-1-13-0.xsd" name="cms_model" uuid="57C6F407-E894-4554-8A59-C8D1F3BBC5D7" library_target="cms_model">
|
||||
<target name="cms_model">
|
||||
<root all_classes="True"/>
|
||||
<option warning="true">
|
||||
<root all_classes="true"/>
|
||||
<option warning="true" void_safety="all">
|
||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||
</option>
|
||||
<setting name="console_application" value="true"/>
|
||||
<library name="base" location="$ISE_LIBRARY/library/base/base-safe.ecf"/>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/>
|
||||
<cluster name="cms_model" location=".\src" recursive="true">
|
||||
<cluster name="cms_model" location=".\src\" recursive="true">
|
||||
<file_rule>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
<exclude>/.svn$</exclude>
|
||||
<exclude>/CVS$</exclude>
|
||||
<exclude>/.svn$</exclude>
|
||||
</file_rule>
|
||||
</cluster>
|
||||
</target>
|
||||
|
||||
19
library/model/cms_model.ecf
Normal file
19
library/model/cms_model.ecf
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-13-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-13-0 http://www.eiffel.com/developers/xml/configuration-1-13-0.xsd" name="cms_model" uuid="57C6F407-E894-4554-8A59-C8D1F3BBC5D7" library_target="cms_model">
|
||||
<target name="cms_model">
|
||||
<root all_classes="true"/>
|
||||
<option warning="true" void_safety="none">
|
||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||
</option>
|
||||
<setting name="console_application" value="true"/>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
|
||||
<library name="time" location="$ISE_LIBRARY\library\time\time.ecf"/>
|
||||
<cluster name="cms_model" location=".\src\" recursive="true">
|
||||
<file_rule>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
<exclude>/CVS$</exclude>
|
||||
<exclude>/.svn$</exclude>
|
||||
</file_rule>
|
||||
</cluster>
|
||||
</target>
|
||||
</system>
|
||||
@@ -1,7 +1,7 @@
|
||||
note
|
||||
description: "Object that handle a database connection for ODBC"
|
||||
date: "$Date: 2014-08-20 15:21:15 -0300 (mi., 20 ago. 2014) $"
|
||||
revision: "$Revision: 95678 $"
|
||||
date: "$Date: 2014-11-13 12:23:47 -0300 (ju., 13 nov. 2014) $"
|
||||
revision: "$Revision: 96085 $"
|
||||
|
||||
class
|
||||
DATABASE_CONNECTION_ODBC
|
||||
@@ -13,6 +13,8 @@ inherit
|
||||
db_application
|
||||
end
|
||||
|
||||
SHARED_LOGGER
|
||||
|
||||
create
|
||||
make, make_common, make_basic, login_with_connection_string
|
||||
|
||||
@@ -24,7 +26,7 @@ feature -- Initialization
|
||||
l_retried: BOOLEAN
|
||||
do
|
||||
create db_application.login (username, password)
|
||||
|
||||
create database_error_handler.make
|
||||
if not l_retried then
|
||||
db_application.set_hostname (hostname)
|
||||
db_application.set_data_source (database_name)
|
||||
@@ -34,14 +36,13 @@ feature -- Initialization
|
||||
if keep_connection then
|
||||
connect
|
||||
end
|
||||
set_successful
|
||||
else
|
||||
create db_control.make
|
||||
end
|
||||
rescue
|
||||
create db_control.make
|
||||
set_last_error_from_exception ("Connection execution")
|
||||
log.write_critical (generator + ".make_common:" + last_error_message)
|
||||
-- set_last_error_from_exception ("Connection execution")
|
||||
-- log.write_critical (generator + ".make_common:" + last_error_message)
|
||||
if is_connected then
|
||||
disconnect
|
||||
end
|
||||
@@ -56,7 +57,7 @@ feature -- Initialization
|
||||
l_retried: BOOLEAN
|
||||
do
|
||||
create db_application.login (username, password)
|
||||
|
||||
create database_error_handler.make
|
||||
if not l_retried then
|
||||
db_application.set_hostname (hostname)
|
||||
db_application.set_data_source (a_database_name)
|
||||
@@ -66,14 +67,13 @@ feature -- Initialization
|
||||
if keep_connection then
|
||||
connect
|
||||
end
|
||||
set_successful
|
||||
else
|
||||
create db_control.make
|
||||
end
|
||||
rescue
|
||||
create db_control.make
|
||||
set_last_error_from_exception ("Connection execution")
|
||||
log.write_critical (generator + ".make_common:" + last_error_message)
|
||||
-- set_last_error_from_exception ("Connection execution")
|
||||
-- log.write_critical (generator + ".make_common:" + last_error_message)
|
||||
if is_connected then
|
||||
disconnect
|
||||
end
|
||||
@@ -88,6 +88,7 @@ feature -- Initialization
|
||||
-- `database_name' to `a_database_name'
|
||||
-- `connection' to `a_connection'
|
||||
do
|
||||
create database_error_handler.make
|
||||
create db_application.login (a_username, a_password)
|
||||
db_application.set_hostname (a_hostname)
|
||||
db_application.set_data_source (a_database_name)
|
||||
@@ -104,6 +105,7 @@ feature -- Initialization
|
||||
do
|
||||
log.write_debug (generator +".login_with_connection_string")
|
||||
create db_application.login_with_connection_string (a_string)
|
||||
create database_error_handler.make
|
||||
db_application.set_base
|
||||
create db_control.make
|
||||
log.write_debug (generator +".login_with_connection_string, is_keep_connection? "+ is_keep_connection.out )
|
||||
|
||||
@@ -45,14 +45,14 @@ feature -- Functionality Store Procedures
|
||||
execute_store_reader
|
||||
-- Execute a `store' to read data.
|
||||
require
|
||||
store_not_void: store /= void
|
||||
store_not_void: store /= Void
|
||||
deferred
|
||||
end
|
||||
|
||||
execute_store_writer
|
||||
-- Execute a `store' to write data.
|
||||
require
|
||||
store_not_void: store /= void
|
||||
store_not_void: store /= Void
|
||||
deferred
|
||||
end
|
||||
|
||||
@@ -61,14 +61,14 @@ feature -- SQL Queries
|
||||
execute_query
|
||||
-- Execute sql query, the read data from the database.
|
||||
require
|
||||
query_not_void: query /= void
|
||||
query_not_void: query /= Void
|
||||
deferred
|
||||
end
|
||||
|
||||
execute_change
|
||||
-- Execute sql query that update/add data.
|
||||
require
|
||||
query_not_void: query /= void
|
||||
query_not_void: query /= Void
|
||||
deferred
|
||||
end
|
||||
|
||||
|
||||
@@ -7,18 +7,23 @@
|
||||
</option>
|
||||
<setting name="console_application" value="true"/>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="cms" location="..\..\..\..\cms-safe.ecf"/>
|
||||
<library name="crypto" location="$ISE_LIBRARY\unstable\library\text\encryption\crypto\crypto-safe.ecf"/>
|
||||
<library name="encoder" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\text\encoder\encoder-safe.ecf"/>
|
||||
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json-safe.ecf" readonly="false"/>
|
||||
<library name="error" location="$ISE_LIBRARY\contrib\library\utility\general\error\error-safe.ecf"/>
|
||||
|
||||
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json-safe.ecf" readonly="false"/>
|
||||
<library name="layout" location="..\..\..\layout\layout-safe.ecf"/>
|
||||
<library name="model" location="..\..\..\model\cms_model-safe.ecf"/>
|
||||
<library name="logging" location="$ISE_LIBRARY\library\runtime\logging\logging-safe.ecf"/>
|
||||
<library name="model" location="..\..\..\model\cms_model-safe.ecf"/>
|
||||
<library name="mysql" location="$ISE_LIBRARY\library\store\dbms\rdbms\mysql\mysql-safe.ecf"/>
|
||||
<library name="store" location="$ISE_LIBRARY\library\store\store-safe.ecf" readonly="false"/>
|
||||
<library name="thread" location="$ISE_LIBRARY\library\thread\thread-safe.ecf"/>
|
||||
<library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/>
|
||||
<cluster name="common" location="..\common\" recursive="true">
|
||||
<file_rule>
|
||||
<exclude>/database/database_connection_odbc.e</exclude>
|
||||
</file_rule>
|
||||
</cluster>
|
||||
<cluster name="persistence_mysql" location=".\src\" recursive="true">
|
||||
<file_rule>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
@@ -26,12 +31,5 @@
|
||||
<exclude>/.svn$</exclude>
|
||||
</file_rule>
|
||||
</cluster>
|
||||
<cluster name="interface" location="..\..\interface\" recursive="true"/>
|
||||
<cluster name="common" location="..\common\" recursive="true">
|
||||
<file_rule>
|
||||
<exclude>/database/database_connection_odbc.e</exclude>
|
||||
</file_rule>
|
||||
</cluster>
|
||||
|
||||
</target>
|
||||
</system>
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-13-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-13-0 http://www.eiffel.com/developers/xml/configuration-1-13-0.xsd" name="persistence_mysql" uuid="DC757CBD-D8C4-44D6-A07F-C1148D8D233E" library_target="persistence_mysql">
|
||||
<target name="persistence_mysql">
|
||||
<root all_classes="true"/>
|
||||
<option warning="true" void_safety="none">
|
||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||
</option>
|
||||
<setting name="console_application" value="true"/>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
|
||||
<library name="crypto" location="$ISE_LIBRARY\unstable\library\text\encryption\crypto\crypto.ecf"/>
|
||||
<library name="encoder" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\text\encoder\encoder.ecf"/>
|
||||
<library name="error" location="$ISE_LIBRARY\contrib\library\utility\general\error\error.ecf"/>
|
||||
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json.ecf" readonly="false"/>
|
||||
<library name="layout" location="..\..\..\layout\layout.ecf"/>
|
||||
<library name="logging" location="$ISE_LIBRARY\library\runtime\logging\logging.ecf"/>
|
||||
<library name="model" location="..\..\..\model\cms_model.ecf"/>
|
||||
<library name="mysql" location="$ISE_LIBRARY\library\store\dbms\rdbms\mysql\mysql.ecf"/>
|
||||
<library name="store" location="$ISE_LIBRARY\library\store\store.ecf" readonly="false"/>
|
||||
<library name="thread" location="$ISE_LIBRARY\library\thread\thread.ecf"/>
|
||||
<library name="time" location="$ISE_LIBRARY\library\time\time.ecf"/>
|
||||
<cluster name="common" location="..\common\" recursive="true">
|
||||
<file_rule>
|
||||
<exclude>/database/database_connection_odbc.e</exclude>
|
||||
</file_rule>
|
||||
</cluster>
|
||||
<cluster name="interface" location="..\..\interface\" recursive="true"/>
|
||||
<cluster name="persistence_mysql" location=".\src\" recursive="true">
|
||||
<file_rule>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
<exclude>/CVS$</exclude>
|
||||
<exclude>/.svn$</exclude>
|
||||
</file_rule>
|
||||
</cluster>
|
||||
</target>
|
||||
</system>
|
||||
@@ -0,0 +1,35 @@
|
||||
note
|
||||
description: "[
|
||||
Objects that ...
|
||||
]"
|
||||
author: "$Author$"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CMS_STORAGE_MYSQL_BUILDER
|
||||
|
||||
inherit
|
||||
CMS_STORAGE_BUILDER
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
-- Initialize `Current'.
|
||||
do
|
||||
end
|
||||
|
||||
feature -- Factory
|
||||
|
||||
storage (a_setup: CMS_SETUP): detachable CMS_STORAGE_MYSQL
|
||||
do
|
||||
if attached (create {APPLICATION_JSON_CONFIGURATION_HELPER}).new_database_configuration (a_setup.layout.application_config_path) as l_database_config then
|
||||
create Result.make (create {DATABASE_CONNECTION_MYSQL}.login_with_connection_string (l_database_config.connection_string))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
@@ -9,16 +9,15 @@
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="crypto" location="$ISE_LIBRARY\unstable\library\text\encryption\crypto\crypto-safe.ecf"/>
|
||||
<library name="encoder" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\text\encoder\encoder-safe.ecf"/>
|
||||
<library name="error" location="$ISE_LIBRARY\contrib\library\utility\general\error\error-safe.ecf"/>
|
||||
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json-safe.ecf" readonly="false"/>
|
||||
<library name="layout" location="..\..\..\layout\layout-safe.ecf"/>
|
||||
<library name="model" location="..\..\..\model\cms_model-safe.ecf"/>
|
||||
<library name="logging" location="$ISE_LIBRARY\library\runtime\logging\logging-safe.ecf"/>
|
||||
<library name="mysql" location="$ISE_LIBRARY\library\store\dbms\rdbms\mysql\mysql-safe.ecf"/>
|
||||
<library name="model" location="..\..\..\model\cms_model-safe.ecf"/>
|
||||
<library name="odbc" location="$ISE_LIBRARY\library\store\dbms\rdbms\odbc\odbc-safe.ecf"/>
|
||||
<library name="store" location="$ISE_LIBRARY\library\store\store-safe.ecf" readonly="false"/>
|
||||
<library name="thread" location="$ISE_LIBRARY\library\thread\thread-safe.ecf"/>
|
||||
<library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/>
|
||||
<library name="error" location="$ISE_LIBRARY\contrib\library\utility\general\error\error-safe.ecf"/>
|
||||
<cluster name="common" location="..\common\" recursive="true"/>
|
||||
<cluster name="interface" location="..\..\interface\" recursive="true"/>
|
||||
<cluster name="persistence_sqlite" location=".\src\" recursive="true">
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-13-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-13-0 http://www.eiffel.com/developers/xml/configuration-1-13-0.xsd" name="persistence_sqlite" uuid="8FD9D3B3-5FC1-495F-A05D-0205EC966841" library_target="persistence_sqlite">
|
||||
<target name="persistence_sqlite">
|
||||
<root all_classes="true"/>
|
||||
<option warning="true" void_safety="none">
|
||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||
</option>
|
||||
<setting name="console_application" value="true"/>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
|
||||
<library name="crypto" location="$ISE_LIBRARY\unstable\library\text\encryption\crypto\crypto.ecf"/>
|
||||
<library name="encoder" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\text\encoder\encoder.ecf"/>
|
||||
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json.ecf" readonly="false"/>
|
||||
<library name="layout" location="..\..\..\layout\layout.ecf"/>
|
||||
<library name="model" location="..\..\..\model\cms_model.ecf"/>
|
||||
<library name="logging" location="$ISE_LIBRARY\library\runtime\logging\logging.ecf"/>
|
||||
<library name="odbc" location="$ISE_LIBRARY\library\store\dbms\rdbms\odbc\odbc.ecf"/>
|
||||
<library name="store" location="$ISE_LIBRARY\library\store\store.ecf" readonly="false"/>
|
||||
<library name="thread" location="$ISE_LIBRARY\library\thread\thread.ecf"/>
|
||||
<library name="time" location="$ISE_LIBRARY\library\time\time.ecf"/>
|
||||
<library name="error" location="$ISE_LIBRARY\contrib\library\utility\general\error\error.ecf"/>
|
||||
<cluster name="common" location="..\common\" recursive="true"/>
|
||||
<cluster name="interface" location="..\..\interface\" recursive="true"/>
|
||||
<cluster name="persistence_sqlite" location=".\src\" recursive="true">
|
||||
<file_rule>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
<exclude>/CVS$</exclude>
|
||||
<exclude>/.svn$</exclude>
|
||||
</file_rule>
|
||||
</cluster>
|
||||
</target>
|
||||
</system>
|
||||
@@ -1,7 +1,7 @@
|
||||
note
|
||||
description: "Summary description for {CMS_STORAGE_MYSQL}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
date: "$Date: 2014-11-13 12:23:47 -0300 (ju., 13 nov. 2014) $"
|
||||
revision: "$Revision: 96085 $"
|
||||
|
||||
class
|
||||
CMS_STORAGE_SQLITE
|
||||
@@ -24,8 +24,7 @@ feature {NONE} -- Initialization
|
||||
log.write_information (generator+".make_with_database is database connected? "+ a_connection.is_connected.out )
|
||||
create node_provider.make (a_connection)
|
||||
create user_provider.make (a_connection)
|
||||
post_node_provider_execution
|
||||
post_user_provider_execution
|
||||
create error_handler.make
|
||||
end
|
||||
|
||||
|
||||
@@ -35,7 +34,7 @@ feature -- Access: user
|
||||
-- Has any user?
|
||||
do
|
||||
Result := user_provider.has_user
|
||||
post_user_provider_execution
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -48,19 +47,19 @@ feature -- Access: user
|
||||
user_by_id (a_id: like {CMS_USER}.id): detachable CMS_USER
|
||||
do
|
||||
Result := user_provider.user (a_id)
|
||||
post_user_provider_execution
|
||||
|
||||
end
|
||||
|
||||
user_by_name (a_name: like {CMS_USER}.name): detachable CMS_USER
|
||||
do
|
||||
Result := user_provider.user_by_name (a_name)
|
||||
post_user_provider_execution
|
||||
|
||||
end
|
||||
|
||||
user_by_email (a_email: like {CMS_USER}.email): detachable CMS_USER
|
||||
do
|
||||
Result := user_provider.user_by_email (a_email)
|
||||
post_user_provider_execution
|
||||
|
||||
end
|
||||
|
||||
is_valid_credential (l_auth_login, l_auth_password: READABLE_STRING_32): BOOLEAN
|
||||
@@ -82,7 +81,7 @@ feature -- Access: user
|
||||
log.write_information (generator + ".login_valid User:" + l_auth_login + "does not exist" )
|
||||
end
|
||||
end
|
||||
post_user_provider_execution
|
||||
|
||||
end
|
||||
|
||||
feature -- Change: user
|
||||
@@ -149,7 +148,7 @@ feature -- Access: node
|
||||
across node_provider.nodes as c loop
|
||||
Result.force (c.item)
|
||||
end
|
||||
post_node_provider_execution
|
||||
|
||||
end
|
||||
|
||||
recent_nodes (a_lower: INTEGER; a_count: INTEGER): LIST [CMS_NODE]
|
||||
@@ -159,14 +158,14 @@ feature -- Access: node
|
||||
across node_provider.recent_nodes (a_lower,a_count) as c loop
|
||||
Result.force (c.item)
|
||||
end
|
||||
post_node_provider_execution
|
||||
|
||||
end
|
||||
|
||||
node (a_id: INTEGER_64): detachable CMS_NODE
|
||||
--
|
||||
do
|
||||
Result := node_provider.node (a_id)
|
||||
post_node_provider_execution
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -176,37 +175,37 @@ feature -- Node
|
||||
-- Add a new node
|
||||
do
|
||||
node_provider.new_node (a_node)
|
||||
post_node_provider_execution
|
||||
|
||||
end
|
||||
|
||||
delete_node (a_id: INTEGER_64)
|
||||
do
|
||||
node_provider.delete_node (a_id)
|
||||
post_node_provider_execution
|
||||
|
||||
end
|
||||
|
||||
update_node (a_id: like {CMS_USER}.id; a_node: CMS_NODE)
|
||||
do
|
||||
node_provider.update_node (a_node)
|
||||
post_node_provider_execution
|
||||
|
||||
end
|
||||
|
||||
update_node_title (a_id: like {CMS_USER}.id; a_node_id: like {CMS_NODE}.id; a_title: READABLE_STRING_32)
|
||||
do
|
||||
node_provider.update_node_title (a_id, a_title)
|
||||
post_node_provider_execution
|
||||
|
||||
end
|
||||
|
||||
update_node_summary (a_id: like {CMS_USER}.id; a_node_id: like {CMS_NODE}.id; a_summary: READABLE_STRING_32)
|
||||
do
|
||||
node_provider.update_node_summary (a_id, a_summary)
|
||||
post_node_provider_execution
|
||||
|
||||
end
|
||||
|
||||
update_node_content (a_id: like {CMS_USER}.id; a_node_id: like {CMS_NODE}.id; a_content: READABLE_STRING_32)
|
||||
do
|
||||
node_provider.update_node_content (a_id, a_content)
|
||||
post_node_provider_execution
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -239,29 +238,7 @@ feature -- User
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Post process
|
||||
|
||||
post_node_provider_execution
|
||||
do
|
||||
if node_provider.successful then
|
||||
set_successful
|
||||
else
|
||||
if attached node_provider.last_error then
|
||||
set_last_error_from_handler (node_provider.last_error)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
post_user_provider_execution
|
||||
do
|
||||
if user_provider.successful then
|
||||
set_successful
|
||||
else
|
||||
if attached user_provider.last_error then
|
||||
set_last_error_from_handler (user_provider.last_error)
|
||||
end
|
||||
end
|
||||
end
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
node_provider: NODE_DATA_PROVIDER
|
||||
-- Node Data provider.
|
||||
|
||||
@@ -1,145 +0,0 @@
|
||||
note
|
||||
description: "Object that handle a database connection for ODBC"
|
||||
date: "$Date: 2014-08-20 15:21:15 -0300 (mi., 20 ago. 2014) $"
|
||||
revision: "$Revision: 95678 $"
|
||||
|
||||
class
|
||||
DATABASE_CONNECTION_MYSQL
|
||||
|
||||
inherit
|
||||
|
||||
DATABASE_CONNECTION
|
||||
redefine
|
||||
db_application
|
||||
end
|
||||
|
||||
create
|
||||
make, make_common, make_basic, login_with_connection_string, login_with_schema
|
||||
|
||||
feature -- Initialization
|
||||
|
||||
make_common
|
||||
-- Create a database handler for MYSQL with common settings.
|
||||
local
|
||||
l_retried: BOOLEAN
|
||||
do
|
||||
create db_application.login (username, password)
|
||||
|
||||
if not l_retried then
|
||||
db_application.set_hostname (hostname)
|
||||
db_application.set_data_source (database_name)
|
||||
db_application.set_base
|
||||
create db_control.make
|
||||
keep_connection := is_keep_connection
|
||||
if keep_connection then
|
||||
connect
|
||||
end
|
||||
set_successful
|
||||
else
|
||||
create db_control.make
|
||||
end
|
||||
rescue
|
||||
create db_control.make
|
||||
set_last_error_from_exception ("Connection execution")
|
||||
log.write_critical (generator + ".make_common:" + last_error_message)
|
||||
if is_connected then
|
||||
disconnect
|
||||
end
|
||||
l_retried := True
|
||||
retry
|
||||
end
|
||||
|
||||
make_basic (a_database_name: STRING)
|
||||
-- Create a database handler and
|
||||
-- set database_name to `a_database_name'.
|
||||
local
|
||||
l_retried: BOOLEAN
|
||||
do
|
||||
create db_application.login (username, password)
|
||||
|
||||
if not l_retried then
|
||||
db_application.set_hostname (hostname)
|
||||
db_application.set_data_source (a_database_name)
|
||||
db_application.set_base
|
||||
create db_control.make
|
||||
keep_connection := is_keep_connection
|
||||
if keep_connection then
|
||||
connect
|
||||
end
|
||||
set_successful
|
||||
else
|
||||
create db_control.make
|
||||
end
|
||||
rescue
|
||||
create db_control.make
|
||||
set_last_error_from_exception ("Connection execution")
|
||||
log.write_critical (generator + ".make_common:" + last_error_message)
|
||||
if is_connected then
|
||||
disconnect
|
||||
end
|
||||
l_retried := True
|
||||
retry
|
||||
end
|
||||
|
||||
make (a_username: STRING; a_password: STRING; a_hostname: STRING; a_database_name: STRING; connection: BOOLEAN)
|
||||
|
||||
-- Create a database handler for ODBC and set `username' to `a_username',
|
||||
-- `password' to `a_password'
|
||||
-- `database_name' to `a_database_name'
|
||||
-- `connection' to `a_connection'
|
||||
do
|
||||
create db_application.login (a_username, a_password)
|
||||
db_application.set_hostname (a_hostname)
|
||||
db_application.set_data_source (a_database_name)
|
||||
db_application.set_base
|
||||
create db_control.make
|
||||
keep_connection := connection
|
||||
if keep_connection then
|
||||
connect
|
||||
end
|
||||
end
|
||||
|
||||
login_with_connection_string (a_string: STRING)
|
||||
-- Login with `a_connection_string'and immediately connect to database.
|
||||
local
|
||||
l_string: LIST[STRING]
|
||||
l_server: STRING
|
||||
l_port: STRING
|
||||
l_schema: STRING
|
||||
l_user: STRING
|
||||
l_password: STRING
|
||||
do
|
||||
l_string := a_string.split (';')
|
||||
l_server := l_string.at (2).split ('=').at (2)
|
||||
l_port := l_string.at (3).split ('=').at (2)
|
||||
l_schema := l_string.at (4).split ('=').at (2)
|
||||
l_user := l_string.at (5).split ('=').at (2)
|
||||
l_password := l_string.at (6).split ('=').at (2)
|
||||
|
||||
create db_application
|
||||
db_application.set_application (l_schema)
|
||||
db_application.set_hostname (l_server + ":" + l_port)
|
||||
db_application.login_and_connect (l_user, l_password)
|
||||
db_application.set_base
|
||||
create db_control.make
|
||||
keep_connection := is_keep_connection
|
||||
|
||||
end
|
||||
|
||||
login_with_schema (a_schema: STRING; a_username: STRING; a_password: STRING)
|
||||
-- Login with `a_connection_string'and immediately connect to database.
|
||||
do
|
||||
create db_application
|
||||
db_application.set_application (a_schema)
|
||||
db_application.login_and_connect (a_username, a_password)
|
||||
db_application.set_base
|
||||
create db_control.make
|
||||
keep_connection := is_keep_connection
|
||||
end
|
||||
|
||||
feature -- Databse Connection
|
||||
|
||||
db_application: DATABASE_APPL [MYSQL]
|
||||
-- Database application.
|
||||
|
||||
end
|
||||
@@ -1,7 +1,7 @@
|
||||
note
|
||||
description: "Database access for node uses cases."
|
||||
date: "$Date: 2014-08-20 15:21:15 -0300 (mi., 20 ago. 2014) $"
|
||||
revision: "$Revision: 95678 $"
|
||||
date: "$Date: 2014-11-13 12:23:47 -0300 (ju., 13 nov. 2014) $"
|
||||
revision: "$Revision: 96085 $"
|
||||
|
||||
class
|
||||
NODE_DATA_PROVIDER
|
||||
@@ -23,7 +23,7 @@ feature -- Initialization
|
||||
-- Create a data provider.
|
||||
do
|
||||
create {DATABASE_HANDLER_IMPL} db_handler.make (a_connection)
|
||||
post_execution
|
||||
|
||||
end
|
||||
|
||||
db_handler: DATABASE_HANDLER
|
||||
@@ -34,7 +34,7 @@ feature -- Status Report
|
||||
is_successful: BOOLEAN
|
||||
-- Is the last execution sucessful?
|
||||
do
|
||||
Result := db_handler.successful
|
||||
Result := not db_handler.has_error
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
@@ -49,7 +49,7 @@ feature -- Access
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (Select_nodes, l_parameters))
|
||||
db_handler.execute_query
|
||||
create Result.make (db_handler, agent fetch_node)
|
||||
post_execution
|
||||
|
||||
end
|
||||
|
||||
recent_nodes (a_lower, a_rows: INTEGER): DATABASE_ITERATION_CURSOR [CMS_NODE]
|
||||
@@ -66,7 +66,7 @@ feature -- Access
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (l_query, l_parameters))
|
||||
db_handler.execute_query
|
||||
create Result.make (db_handler, agent fetch_node)
|
||||
post_execution
|
||||
|
||||
end
|
||||
|
||||
node (a_id: INTEGER_64): detachable CMS_NODE
|
||||
@@ -82,7 +82,7 @@ feature -- Access
|
||||
if db_handler.count = 1 then
|
||||
Result := fetch_node
|
||||
end
|
||||
post_execution
|
||||
|
||||
end
|
||||
|
||||
count: INTEGER
|
||||
@@ -97,7 +97,7 @@ feature -- Access
|
||||
if db_handler.count = 1 then
|
||||
Result := db_handler.read_integer_32 (1)
|
||||
end
|
||||
post_execution
|
||||
|
||||
end
|
||||
|
||||
feature -- Basic operations
|
||||
@@ -117,7 +117,7 @@ feature -- Basic operations
|
||||
l_parameters.put (a_node.modification_date, "modification_date")
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (sql_insert_node, l_parameters))
|
||||
db_handler.execute_change
|
||||
post_execution
|
||||
|
||||
end
|
||||
|
||||
update_node_title (a_id: INTEGER_64; a_title: READABLE_STRING_32)
|
||||
@@ -132,7 +132,7 @@ feature -- Basic operations
|
||||
l_parameters.put (a_id, "id")
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (sql_update_node_title, l_parameters))
|
||||
db_handler.execute_change
|
||||
post_execution
|
||||
|
||||
end
|
||||
|
||||
update_node_summary (a_id: INTEGER_64; a_summary: READABLE_STRING_32)
|
||||
@@ -147,7 +147,7 @@ feature -- Basic operations
|
||||
l_parameters.put (a_id, "id")
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (sql_update_node_summary, l_parameters))
|
||||
db_handler.execute_change
|
||||
post_execution
|
||||
|
||||
end
|
||||
|
||||
update_node_content (a_id: INTEGER_64; a_content: READABLE_STRING_32)
|
||||
@@ -162,7 +162,7 @@ feature -- Basic operations
|
||||
l_parameters.put (a_id, "id")
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (sql_update_node_content, l_parameters))
|
||||
db_handler.execute_change
|
||||
post_execution
|
||||
|
||||
end
|
||||
|
||||
update_node (a_node: CMS_NODE)
|
||||
@@ -181,7 +181,7 @@ feature -- Basic operations
|
||||
l_parameters.put (a_node.id, "id")
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (sql_update_node, l_parameters))
|
||||
db_handler.execute_change
|
||||
post_execution
|
||||
|
||||
end
|
||||
|
||||
delete_node (a_id: INTEGER_64;)
|
||||
@@ -194,7 +194,6 @@ feature -- Basic operations
|
||||
l_parameters.put (a_id, "id")
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (sql_delete_node, l_parameters))
|
||||
db_handler.execute_change
|
||||
post_execution
|
||||
end
|
||||
|
||||
feature -- Connection
|
||||
@@ -272,18 +271,5 @@ feature -- New Object
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
post_execution
|
||||
-- Post database execution.
|
||||
do
|
||||
if db_handler.successful then
|
||||
set_successful
|
||||
else
|
||||
if attached db_handler.last_error then
|
||||
set_last_error_from_handler (db_handler.last_error)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
note
|
||||
description: "Summary description for {USER_DATA_PROVIDER}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
date: "$Date: 2014-11-13 12:23:47 -0300 (ju., 13 nov. 2014) $"
|
||||
revision: "$Revision: 96085 $"
|
||||
|
||||
class
|
||||
USER_DATA_PROVIDER
|
||||
@@ -23,7 +23,7 @@ feature -- Initialization
|
||||
-- Create a data provider.
|
||||
do
|
||||
create {DATABASE_HANDLER_IMPL} db_handler.make (a_connection)
|
||||
post_execution
|
||||
|
||||
end
|
||||
|
||||
db_handler: DATABASE_HANDLER
|
||||
@@ -34,7 +34,7 @@ feature -- Status Report
|
||||
is_successful: BOOLEAN
|
||||
-- Is the last execution sucessful?
|
||||
do
|
||||
Result := db_handler.successful
|
||||
Result := not db_handler.has_error
|
||||
end
|
||||
|
||||
has_user: BOOLEAN
|
||||
@@ -64,7 +64,7 @@ feature -- Basic Operations
|
||||
l_parameters.put (a_email,"email")
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (sql_insert_user, l_parameters))
|
||||
db_handler.execute_change
|
||||
post_execution
|
||||
|
||||
end
|
||||
|
||||
user (a_id: INTEGER_64): detachable CMS_USER
|
||||
@@ -80,7 +80,7 @@ feature -- Basic Operations
|
||||
if db_handler.count = 1 then
|
||||
Result := fetch_user
|
||||
end
|
||||
post_execution
|
||||
|
||||
end
|
||||
|
||||
user_by_name (a_name: READABLE_STRING_32): detachable CMS_USER
|
||||
@@ -96,7 +96,7 @@ feature -- Basic Operations
|
||||
if db_handler.count = 1 then
|
||||
Result := fetch_user
|
||||
end
|
||||
post_execution
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ feature -- Basic Operations
|
||||
if db_handler.count = 1 then
|
||||
Result := fetch_user
|
||||
end
|
||||
post_execution
|
||||
|
||||
end
|
||||
|
||||
user_salt (a_username: READABLE_STRING_32): detachable READABLE_STRING_32
|
||||
@@ -131,7 +131,7 @@ feature -- Basic Operations
|
||||
Result := l_salt.as_string_32
|
||||
end
|
||||
end
|
||||
post_execution
|
||||
|
||||
end
|
||||
|
||||
count: INTEGER
|
||||
@@ -146,7 +146,7 @@ feature -- Basic Operations
|
||||
if db_handler.count = 1 then
|
||||
Result := db_handler.read_integer_32 (1)
|
||||
end
|
||||
post_execution
|
||||
|
||||
end
|
||||
|
||||
feature -- New Object
|
||||
@@ -189,18 +189,5 @@ feature -- Sql Queries
|
||||
-- SQL Insert to add a new node.
|
||||
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
post_execution
|
||||
-- Post database execution.
|
||||
do
|
||||
if db_handler.successful then
|
||||
set_successful
|
||||
else
|
||||
if attached db_handler.last_error then
|
||||
set_last_error_from_handler (db_handler.last_error)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
<setting name="concurrency" value="thread"/>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="crypto" location="$ISE_LIBRARY\unstable\library\text\encryption\crypto\crypto-safe.ecf"/>
|
||||
<library name="model" location="..\..\..\..\model\cms_model-safe.ecf"/>
|
||||
<library name="persitence_sqlite" location="..\persistence_sqlite-safe.ecf" readonly="false"/>
|
||||
<library name="process" location="$ISE_LIBRARY\library\process\process-safe.ecf"/>
|
||||
<library name="testing" location="$ISE_LIBRARY\library\testing\testing-safe.ecf"/>
|
||||
|
||||
@@ -1,306 +0,0 @@
|
||||
note
|
||||
description: "[
|
||||
Configure the basic settings for a CMS application,
|
||||
i.e: where to look for themes, name of the application, etc...
|
||||
|
||||
The settings can be configured by default:
|
||||
- using the current working directory,
|
||||
- using the commands provided by the class
|
||||
- or by an external configuration file.
|
||||
]"
|
||||
|
||||
class
|
||||
CMS_CONFIGURATION
|
||||
|
||||
inherit
|
||||
ANY
|
||||
|
||||
SHARED_EXECUTION_ENVIRONMENT
|
||||
export
|
||||
{NONE} all
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_layout: CMS_LAYOUT)
|
||||
-- Initialize `Current' with layout `a_layout'.
|
||||
do
|
||||
layout := a_layout
|
||||
create options.make_equal (10)
|
||||
configuration_location := layout.cms_config_ini_path
|
||||
import_from_path (layout.cms_config_ini_path)
|
||||
analyze
|
||||
end
|
||||
|
||||
analyze
|
||||
do
|
||||
get_root_location
|
||||
get_var_location
|
||||
get_themes_location
|
||||
get_files_location
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
|
||||
configuration_location: detachable PATH
|
||||
-- Path to configuration location.
|
||||
|
||||
option (a_name: READABLE_STRING_GENERAL): detachable ANY
|
||||
do
|
||||
Result := options.item (a_name)
|
||||
end
|
||||
|
||||
options: STRING_TABLE [STRING_32]
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
append_to_string (s: STRING)
|
||||
local
|
||||
utf: UTF_CONVERTER
|
||||
do
|
||||
s.append ("Options:%N")
|
||||
across
|
||||
options as c
|
||||
loop
|
||||
s.append (c.key.to_string_8)
|
||||
s.append_character ('=')
|
||||
utf.string_32_into_utf_8_string_8 (c.item, s)
|
||||
s.append_character ('%N')
|
||||
end
|
||||
|
||||
s.append ("Specific:%N")
|
||||
s.append ("root_location=" + root_location.utf_8_name + "%N")
|
||||
s.append ("var_location=" + var_location.utf_8_name + "%N")
|
||||
s.append ("files_location=" + files_location.utf_8_name + "%N")
|
||||
s.append ("themes_location=" + themes_location.utf_8_name + "%N")
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_option (a_name: READABLE_STRING_GENERAL; a_value: STRING_32)
|
||||
do
|
||||
options.force (a_value, a_name.as_string_8)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
var_location: PATH
|
||||
|
||||
root_location: PATH
|
||||
|
||||
files_location: PATH
|
||||
|
||||
themes_location: PATH
|
||||
|
||||
theme_name (dft: detachable like theme_name): READABLE_STRING_8
|
||||
do
|
||||
if attached options.item ("theme") as s then
|
||||
Result := s
|
||||
elseif dft /= Void then
|
||||
Result := dft
|
||||
else
|
||||
Result := "default"
|
||||
end
|
||||
end
|
||||
|
||||
site_id: READABLE_STRING_8
|
||||
do
|
||||
if attached options.item ("site.id") as s then
|
||||
Result := s
|
||||
else
|
||||
Result := "_EWF_CMS_NO_ID_"
|
||||
end
|
||||
end
|
||||
|
||||
site_name (dft: like site_name): READABLE_STRING_8
|
||||
do
|
||||
if attached options.item ("site.name") as s then
|
||||
Result := s
|
||||
else
|
||||
Result := dft
|
||||
end
|
||||
end
|
||||
|
||||
site_url (dft: like site_url): detachable READABLE_STRING_8
|
||||
do
|
||||
if attached options.item ("site.url") as s then
|
||||
Result := s
|
||||
else
|
||||
Result := dft
|
||||
end
|
||||
if Result /= Void then
|
||||
if Result.is_empty then
|
||||
-- ok
|
||||
elseif not Result.ends_with ("/") then
|
||||
Result := Result + "/"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
site_script_url (dft: like site_script_url): detachable READABLE_STRING_8
|
||||
do
|
||||
if attached options.item ("site.script_url") as s then
|
||||
Result := s
|
||||
else
|
||||
Result := dft
|
||||
end
|
||||
if Result /= Void then
|
||||
if Result.is_empty then
|
||||
elseif not Result.ends_with ("/") then
|
||||
Result := Result + "/"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
site_email (dft: like site_email): READABLE_STRING_8
|
||||
do
|
||||
if attached options.item ("site.email") as s then
|
||||
Result := s
|
||||
else
|
||||
Result := dft
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Change
|
||||
|
||||
get_var_location
|
||||
local
|
||||
utf: UTF_CONVERTER
|
||||
do
|
||||
if attached options.item ("var-dir") as s then
|
||||
create var_location.make_from_string (utf.utf_8_string_8_to_escaped_string_32 (s))
|
||||
else
|
||||
var_location := execution_environment.current_working_path
|
||||
end
|
||||
end
|
||||
|
||||
get_root_location
|
||||
do
|
||||
root_location := layout.www_path
|
||||
end
|
||||
|
||||
get_files_location
|
||||
local
|
||||
utf: UTF_CONVERTER
|
||||
do
|
||||
if attached options.item ("files-dir") as s then
|
||||
create files_location.make_from_string (utf.utf_8_string_8_to_escaped_string_32 (s))
|
||||
else
|
||||
create files_location.make_from_string ("files")
|
||||
end
|
||||
end
|
||||
|
||||
get_themes_location
|
||||
local
|
||||
utf: UTF_CONVERTER
|
||||
do
|
||||
if attached options.item ("themes-dir") as s then
|
||||
create themes_location.make_from_string (utf.utf_8_string_8_to_escaped_string_32 (s))
|
||||
else
|
||||
themes_location := root_location.extended ("themes")
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
import_from_file (fn: READABLE_STRING_GENERAL)
|
||||
do
|
||||
import_from_path (create {PATH}.make_from_string (fn))
|
||||
end
|
||||
|
||||
import_from_path (a_filename: PATH)
|
||||
-- Import ini file content
|
||||
local
|
||||
f: PLAIN_TEXT_FILE
|
||||
l,v: STRING_8
|
||||
p: INTEGER
|
||||
do
|
||||
create f.make_with_path (a_filename)
|
||||
if f.exists and f.is_readable then
|
||||
f.open_read
|
||||
from
|
||||
f.read_line
|
||||
until
|
||||
f.exhausted
|
||||
loop
|
||||
l := f.last_string
|
||||
l.left_adjust
|
||||
if not l.is_empty then
|
||||
if l[1] = '#' then
|
||||
-- commented line
|
||||
else
|
||||
p := l.index_of ('=', 1)
|
||||
if p > 1 then
|
||||
v := l.substring (p + 1, l.count)
|
||||
l.keep_head (p - 1)
|
||||
v.left_adjust
|
||||
v.right_adjust
|
||||
l.right_adjust
|
||||
|
||||
if l.is_case_insensitive_equal ("@include") then
|
||||
import_from_file (resolved_string (v))
|
||||
else
|
||||
set_option (l.as_lower, resolved_string (v))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
f.read_line
|
||||
end
|
||||
f.close
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Environment
|
||||
|
||||
resolved_string (s: READABLE_STRING_8): STRING_32
|
||||
-- Resolved `s' using `options' or else environment variables.
|
||||
local
|
||||
i,n,b,e: INTEGER
|
||||
k: detachable READABLE_STRING_8
|
||||
do
|
||||
from
|
||||
i := 1
|
||||
n := s.count
|
||||
create Result.make (s.count)
|
||||
until
|
||||
i > n
|
||||
loop
|
||||
if i + 1 < n and then s[i] = '$' and then s[i+1] = '{' then
|
||||
b := i + 2
|
||||
e := s.index_of ('}', b) - 1
|
||||
if e > 0 then
|
||||
k := s.substring (b, e)
|
||||
if attached option (k) as v then
|
||||
if attached {READABLE_STRING_32} v as s32 then
|
||||
Result.append (s32)
|
||||
else
|
||||
Result.append (v.out)
|
||||
end
|
||||
i := e + 1
|
||||
elseif attached execution_environment.item (k) as v then
|
||||
Result.append (v)
|
||||
i := e + 1
|
||||
else
|
||||
Result.extend (s[i])
|
||||
end
|
||||
else
|
||||
Result.extend (s[i])
|
||||
end
|
||||
else
|
||||
Result.extend (s[i])
|
||||
end
|
||||
i := i + 1
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
feature -- Implementation
|
||||
|
||||
layout: CMS_LAYOUT
|
||||
-- Cms layout
|
||||
end
|
||||
@@ -1,15 +0,0 @@
|
||||
note
|
||||
description: "Summary description for {CMS_CUSTOM_SETUP}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CMS_CUSTOM_SETUP
|
||||
|
||||
inherit
|
||||
CMS_DEFAULT_SETUP
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
end
|
||||
@@ -1,7 +1,9 @@
|
||||
note
|
||||
description: "Summary description for {CMS_DEFAULT_SETUP}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
description: "[
|
||||
Default CMS_SETUP that can be reused easily, and/or redefined to match specific setup.
|
||||
]"
|
||||
date: "$Date: 2015-01-14 16:13:47 +0100 (mer., 14 janv. 2015) $"
|
||||
revision: "$Revision: 96454 $"
|
||||
|
||||
class
|
||||
CMS_DEFAULT_SETUP
|
||||
@@ -10,6 +12,7 @@ inherit
|
||||
CMS_SETUP
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
@@ -19,27 +22,50 @@ feature {NONE} -- Initialization
|
||||
-- Create a default setup with `a_layout'.
|
||||
do
|
||||
layout := a_layout
|
||||
create configuration.make (layout)
|
||||
create {INI_CONFIG} configuration.make_from_file (layout.cms_config_ini_path)
|
||||
initialize
|
||||
end
|
||||
|
||||
initialize
|
||||
-- Initialize varius cms components.
|
||||
-- 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 := configuration.site_id
|
||||
site_url := configuration.site_url (Void)
|
||||
site_name := configuration.site_name ("EWF::CMS")
|
||||
site_email := configuration.site_email ("webmaster")
|
||||
themes_location := configuration.themes_location
|
||||
theme_name := configuration.theme_name ("default")
|
||||
--| 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")
|
||||
@@ -49,6 +75,12 @@ feature {NONE} -- Initialization
|
||||
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
|
||||
@@ -57,34 +89,58 @@ feature {NONE} -- Initialization
|
||||
-- -- Core
|
||||
-- create {USER_MODULE} m.make (Current)
|
||||
-- m.enable
|
||||
-- modules.extend (m)
|
||||
-- register_module (m)
|
||||
|
||||
-- create {ADMIN_MODULE} m.make (Current)
|
||||
-- m.enable
|
||||
-- modules.extend (m)
|
||||
-- register_module (m)
|
||||
|
||||
create {NODE_MODULE} m.make (Current)
|
||||
m.enable
|
||||
modules.extend (m)
|
||||
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)
|
||||
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)
|
||||
|
||||
Result := (create {CMS_JSON_CONFIGURATION}).is_web_mode (layout.application_config_path)
|
||||
end
|
||||
|
||||
build_auth_engine
|
||||
@@ -97,6 +153,19 @@ feature -- Access
|
||||
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
|
||||
@@ -111,7 +180,7 @@ feature -- Compute location
|
||||
debug ("refactor_fixme")
|
||||
fixme ("Check if we really need it")
|
||||
end
|
||||
-- Check how to get this path from the CMS_THEME information.
|
||||
-- Check how to get this path from the CMS_THEME information.
|
||||
theme_assets_location := theme_location.extended ("assets")
|
||||
end
|
||||
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
note
|
||||
description: "Summary description for {CMS_JSON_CONFIGURATION}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
date: "$Date: 2015-01-14 16:13:47 +0100 (mer., 14 janv. 2015) $"
|
||||
revision: "$Revision: 96454 $"
|
||||
|
||||
class
|
||||
CMS_JSON_CONFIGURATION
|
||||
|
||||
|
||||
inherit
|
||||
|
||||
JSON_CONFIGURATION
|
||||
|
||||
APPLICATION_JSON_CONFIGURATION_HELPER
|
||||
|
||||
feature -- Access
|
||||
|
||||
is_html_mode (a_path: PATH): BOOLEAN
|
||||
@@ -19,29 +18,36 @@ feature -- Access
|
||||
l_parser: JSON_PARSER
|
||||
do
|
||||
if attached json_file_from (a_path) as json_file then
|
||||
l_parser := new_json_parser (json_file)
|
||||
if attached {JSON_OBJECT} l_parser.parse as jv and then l_parser.is_parsed and then
|
||||
attached {JSON_OBJECT} jv.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
|
||||
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)
|
||||
if attached {JSON_OBJECT} l_parser.parse as jv and then l_parser.is_parsed and then
|
||||
attached {JSON_OBJECT} jv.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
|
||||
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
|
||||
|
||||
@@ -7,8 +7,8 @@ note
|
||||
- documentation
|
||||
- themes
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
date: "$Date: 2014-12-18 16:37:11 +0100 (jeu., 18 déc. 2014) $"
|
||||
revision: "$Revision: 96383 $"
|
||||
|
||||
class
|
||||
CMS_LAYOUT
|
||||
@@ -38,7 +38,7 @@ feature -- Access
|
||||
end
|
||||
|
||||
cms_config_ini_path: PATH
|
||||
-- Database Configuration file path.
|
||||
-- CMS Configuration file path.
|
||||
local
|
||||
p: detachable PATH
|
||||
do
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
note
|
||||
description: "Class that enable to set basic configuration, application layout, core modules and themes."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
date: "$Date: 2015-01-14 18:12:03 +0100 (mer., 14 janv. 2015) $"
|
||||
revision: "$Revision: 96456 $"
|
||||
|
||||
deferred class
|
||||
CMS_SETUP
|
||||
|
||||
feature -- Access
|
||||
inherit
|
||||
REFACTORING_HELPER
|
||||
|
||||
configuration: CMS_CONFIGURATION
|
||||
-- cms configuration.
|
||||
feature -- Access
|
||||
|
||||
layout: CMS_LAYOUT
|
||||
-- CMS layout.
|
||||
@@ -24,6 +24,26 @@ feature -- Access
|
||||
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
|
||||
@@ -32,12 +52,15 @@ feature -- Access
|
||||
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
|
||||
-- Email for the site.
|
||||
-- Admin email address for the site.
|
||||
-- Mainly used for internal notification.
|
||||
|
||||
site_url: detachable READABLE_STRING_8
|
||||
-- Optional base url of the site.
|
||||
@@ -46,19 +69,41 @@ feature -- Access: Site
|
||||
-- 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 particular theme.
|
||||
-- Path to a active theme.
|
||||
|
||||
theme_assets_location: PATH
|
||||
-- Path to a particular theme assets folder.
|
||||
-- Path to a active theme assets folder.
|
||||
|
||||
theme_information_location: PATH
|
||||
-- theme informations.
|
||||
-- Active theme informations.
|
||||
do
|
||||
Result := theme_location.extended ("theme.info")
|
||||
end
|
||||
@@ -66,4 +111,61 @@ feature -- Access: Theme
|
||||
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
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
note
|
||||
description: "Summary description for {CMS_HOOK_BLOCK}."
|
||||
description: "[
|
||||
Hook providing a way to alter a block.
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
|
||||
29
library/src/hooks/cms_hook_block_helper.e
Normal file
29
library/src/hooks/cms_hook_block_helper.e
Normal file
@@ -0,0 +1,29 @@
|
||||
note
|
||||
description: "Summary description for {CMS_HOOK_BLOCK_HELPER}."
|
||||
author: ""
|
||||
date: "$Date: 2015-01-14 16:13:47 +0100 (mer., 14 janv. 2015) $"
|
||||
revision: "$Revision: 96454 $"
|
||||
|
||||
deferred class
|
||||
CMS_HOOK_BLOCK_HELPER
|
||||
|
||||
feature -- Factory
|
||||
|
||||
template_block (a_module: CMS_MODULE; a_block_id: READABLE_STRING_8; a_response: CMS_RESPONSE): detachable CMS_SMARTY_TEMPLATE_BLOCK
|
||||
-- Smarty content block for `a_block_id' in the context of `a_module' and `a_response'.
|
||||
local
|
||||
p: detachable PATH
|
||||
do
|
||||
create p.make_from_string ("templates")
|
||||
p := p.extended ("block_").appended (a_block_id).appended_with_extension ("tpl")
|
||||
p := a_response.module_resource_path (a_module, p)
|
||||
if p /= Void then
|
||||
if attached p.entry as e then
|
||||
create Result.make (a_block_id, Void, p.parent, e)
|
||||
else
|
||||
create Result.make (a_block_id, Void, p.parent, p)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,5 +1,5 @@
|
||||
note
|
||||
description: "Summary description for {CMS_BLOCK}."
|
||||
description: "Describe content to be placed inside Regions."
|
||||
date: "$Date: 2014-08-28 08:21:49 -0300 (ju. 28 de ago. de 2014) $"
|
||||
|
||||
deferred class
|
||||
@@ -8,20 +8,30 @@ deferred class
|
||||
feature -- Access
|
||||
|
||||
name: READABLE_STRING_8
|
||||
-- Name identifying Current block.
|
||||
deferred
|
||||
end
|
||||
|
||||
title: detachable READABLE_STRING_32
|
||||
-- Optional title.
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- status report
|
||||
|
||||
is_enabled: BOOLEAN
|
||||
-- Is current block enabled?
|
||||
|
||||
is_raw: BOOLEAN
|
||||
-- Is raw?
|
||||
-- If True, do not get wrapped it with block specific div
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
to_html (a_theme: CMS_THEME): STRING_8
|
||||
-- HTML representation of Current block.
|
||||
deferred
|
||||
end
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
note
|
||||
description: "Summary description for {CMS_CONTENT_BLOCK}."
|
||||
author: ""
|
||||
date: "$Date: 2014-10-30 12:55:33 -0300 (ju. 30 de oct. de 2014) $"
|
||||
revision: "$Revision: 96018 $"
|
||||
description: "CMS_BLOCK implemented with a `content' associated with a specific `format'."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CMS_CONTENT_BLOCK
|
||||
@@ -17,6 +16,8 @@ create
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_name: like name; a_title: like title; a_content: like content; a_format: like format)
|
||||
require
|
||||
a_name_not_blank: not a_name.is_whitespace
|
||||
do
|
||||
is_enabled := True
|
||||
name := a_name
|
||||
@@ -26,6 +27,8 @@ feature {NONE} -- Initialization
|
||||
end
|
||||
|
||||
make_raw (a_name: like name; a_title: like title; a_content: like content; a_format: like format)
|
||||
require
|
||||
a_name_not_blank: not a_name.is_whitespace
|
||||
do
|
||||
make (a_name, a_title, a_content, a_format)
|
||||
set_is_raw (True)
|
||||
@@ -54,6 +57,20 @@ feature -- Element change
|
||||
is_raw := b
|
||||
end
|
||||
|
||||
set_name (n: like name)
|
||||
-- Set `name' to `n'.
|
||||
require
|
||||
not n.is_whitespace
|
||||
do
|
||||
name := n
|
||||
end
|
||||
|
||||
set_title (a_title: like title)
|
||||
-- Set `title' to `a_title'.
|
||||
do
|
||||
title := a_title
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
to_html (a_theme: CMS_THEME): STRING_8
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
note
|
||||
description: "Summary description for {CMS_MENU_BLOCK}."
|
||||
date: "$Date: 2014-08-28 08:21:49 -0300 (ju. 28 de ago. de 2014) $"
|
||||
date: "$Date: 2014-11-14 20:11:17 +0100 (ven., 14 nov. 2014) $"
|
||||
|
||||
class
|
||||
CMS_MENU_BLOCK
|
||||
@@ -29,8 +29,29 @@ feature -- Access
|
||||
|
||||
title: detachable READABLE_STRING_32
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_horizontal: BOOLEAN
|
||||
|
||||
is_raw: BOOLEAN = False
|
||||
-- <Precursor>
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_name (n: like name)
|
||||
-- Set `name' to `n'.
|
||||
require
|
||||
not n.is_whitespace
|
||||
do
|
||||
name := n
|
||||
end
|
||||
|
||||
set_title (a_title: like title)
|
||||
-- Set `title' to `a_title'.
|
||||
do
|
||||
title := a_title
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
to_html (a_theme: CMS_THEME): STRING_8
|
||||
|
||||
195
library/src/kernel/content/cms_smarty_template_block.e
Normal file
195
library/src/kernel/content/cms_smarty_template_block.e
Normal file
@@ -0,0 +1,195 @@
|
||||
note
|
||||
description: "[
|
||||
CMS block with smarty template file content.
|
||||
]"
|
||||
date: "$Date: 2014-12-05 22:39:27 +0100 (ven., 05 déc. 2014) $"
|
||||
revision: "$Revision: 96260 $"
|
||||
|
||||
class
|
||||
CMS_SMARTY_TEMPLATE_BLOCK
|
||||
|
||||
inherit
|
||||
CMS_BLOCK
|
||||
redefine
|
||||
out
|
||||
select
|
||||
out
|
||||
end
|
||||
SHARED_TEMPLATE_CONTEXT
|
||||
rename
|
||||
out as tpl_out
|
||||
end
|
||||
|
||||
create
|
||||
make,
|
||||
make_raw
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_name: like name; a_title: like title; a_template_root_path: PATH; a_template_location: PATH)
|
||||
-- Create Current with `a_name', `a_title', `a_template_location'
|
||||
-- inside root directory `a_template_root_path' for the templates.
|
||||
require
|
||||
a_name_not_blank: not a_name.is_whitespace
|
||||
do
|
||||
is_enabled := True
|
||||
name := a_name
|
||||
title := a_title
|
||||
location := a_template_location
|
||||
template_root_path := a_template_root_path
|
||||
create values.make (0)
|
||||
end
|
||||
|
||||
make_raw (a_name: like name; a_title: like title; a_template_root_path: PATH; a_template_location: PATH)
|
||||
-- Create Current with `a_name', `a_title', `a_template_location'
|
||||
-- inside root directory `a_template_root_path' for the templates.
|
||||
require
|
||||
a_name_not_blank: not a_name.is_whitespace
|
||||
do
|
||||
make (a_name, a_title, a_template_root_path, a_template_location)
|
||||
set_is_raw (True)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
name: READABLE_STRING_8
|
||||
-- <Precursor>
|
||||
|
||||
title: detachable READABLE_STRING_32
|
||||
-- <Precursor>
|
||||
|
||||
location: PATH
|
||||
-- Location of template file.
|
||||
|
||||
template_root_path: PATH
|
||||
-- Root location for templates universe.
|
||||
|
||||
values: STRING_TABLE [detachable ANY]
|
||||
-- Additional value used during template output processing.
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_raw: BOOLEAN
|
||||
-- Is raw?
|
||||
-- If True, do not get wrapped it with block specific div
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_is_raw (b: BOOLEAN)
|
||||
do
|
||||
is_raw := b
|
||||
end
|
||||
|
||||
set_name (n: like name)
|
||||
-- Set `name' to `n'.
|
||||
require
|
||||
not n.is_whitespace
|
||||
do
|
||||
name := n
|
||||
end
|
||||
|
||||
set_title (a_title: like title)
|
||||
-- Set `title' to `a_title'.
|
||||
do
|
||||
title := a_title
|
||||
end
|
||||
|
||||
set_value (v: detachable ANY; k: READABLE_STRING_GENERAL)
|
||||
-- Associate value `v' with key `k'.
|
||||
do
|
||||
values.force (v, k)
|
||||
end
|
||||
|
||||
unset_value (k: READABLE_STRING_GENERAL)
|
||||
-- Remove value indexed by key `k'.
|
||||
do
|
||||
values.remove (k)
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
to_html (a_theme: CMS_THEME): STRING_8
|
||||
-- <Precursor>
|
||||
local
|
||||
p: detachable PATH
|
||||
tpl: detachable TEMPLATE_FILE
|
||||
ut: FILE_UTILITIES
|
||||
n: STRING_32
|
||||
l_table_inspector: detachable STRING_TABLE_OF_STRING_INSPECTOR
|
||||
do
|
||||
-- Process html generation
|
||||
p := location
|
||||
if ut.file_path_exists (template_root_path.extended_path (p)) then
|
||||
n := p.name
|
||||
template_context.set_template_folder (template_root_path)
|
||||
template_context.disable_verbose
|
||||
debug ("cms")
|
||||
template_context.enable_verbose
|
||||
end
|
||||
|
||||
create tpl.make_from_file (n)
|
||||
|
||||
across
|
||||
values as ic
|
||||
loop
|
||||
tpl.add_value (ic.item, ic.key)
|
||||
end
|
||||
|
||||
|
||||
create l_table_inspector.register (({detachable STRING_TABLE [STRING_8]}).name)
|
||||
create l_table_inspector.register (({detachable STRING_TABLE [STRING_32]}).name)
|
||||
create l_table_inspector.register (({detachable STRING_TABLE [READABLE_STRING_8]}).name)
|
||||
create l_table_inspector.register (({detachable STRING_TABLE [READABLE_STRING_32]}).name)
|
||||
tpl.analyze
|
||||
tpl.get_output
|
||||
l_table_inspector.unregister
|
||||
-- l_table32_inspector.unregister
|
||||
|
||||
if attached tpl.output as l_output then
|
||||
Result := l_output
|
||||
else
|
||||
Result := ""
|
||||
debug ("cms")
|
||||
Result := "Template block #" + name
|
||||
end
|
||||
end
|
||||
else
|
||||
Result := ""
|
||||
debug ("cms")
|
||||
Result := "Template block #" + name
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Debug
|
||||
|
||||
out: STRING
|
||||
do
|
||||
create Result.make_from_string (generator)
|
||||
Result.append ("%Nname:")
|
||||
Result.append (name)
|
||||
if attached title as l_title then
|
||||
Result.append ("%N%Ttitle:")
|
||||
Result.append (l_title)
|
||||
end
|
||||
Result.append ("%Nlocation:")
|
||||
Result.append (location.out)
|
||||
Result.append ("%Ntemplate_root_path:")
|
||||
Result.append (template_root_path.out)
|
||||
Result.append ("%NValues: {")
|
||||
from
|
||||
values.start
|
||||
until
|
||||
values.after
|
||||
loop
|
||||
Result.append ("%NKey:")
|
||||
Result.append (values.key_for_iteration.as_string_8)
|
||||
Result.append (" - Value:")
|
||||
if attached values.item_for_iteration as l_item then
|
||||
Result.append (l_item.out)
|
||||
end
|
||||
values.forth
|
||||
end
|
||||
Result.append ("%N}")
|
||||
end
|
||||
end
|
||||
@@ -1,7 +1,7 @@
|
||||
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 $"
|
||||
date: "$Date: 2014-12-18 16:47:20 +0100 (jeu., 18 déc. 2014) $"
|
||||
revision: "$Revision: 96384 $"
|
||||
|
||||
class
|
||||
CMS_DEBUG_MODULE
|
||||
@@ -82,7 +82,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.configuration.configuration_location as l_loc then
|
||||
if attached api.setup.layout.cms_config_ini_path as l_loc then
|
||||
s.append ("<hr/>")
|
||||
append_info_to ("Configuration file", l_loc.name, r, s)
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
note
|
||||
description: "Summary description for {NEW_CONTENT_HANDLER}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
date: "$Date: 2014-12-19 14:17:32 +0100 (ven., 19 déc. 2014) $"
|
||||
revision: "$Revision: 96402 $"
|
||||
|
||||
class
|
||||
NODE_CONTENT_HANDLER
|
||||
@@ -78,7 +78,7 @@ feature -- HTTP Methods
|
||||
do_error (req, res, l_id)
|
||||
end
|
||||
else
|
||||
(create {ERROR_500_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
end
|
||||
else
|
||||
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
|
||||
@@ -96,14 +96,14 @@ feature -- HTTP Methods
|
||||
if l_method.is_case_insensitive_equal ("PUT") then
|
||||
do_put (req, res)
|
||||
else
|
||||
(create {ERROR_500_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
end
|
||||
end
|
||||
else
|
||||
do_error (req, res, l_id)
|
||||
end
|
||||
else
|
||||
(create {ERROR_500_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
end
|
||||
else
|
||||
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
|
||||
@@ -127,7 +127,7 @@ feature -- HTTP Methods
|
||||
do_error (req, res, l_id)
|
||||
end
|
||||
else
|
||||
(create {ERROR_500_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
end
|
||||
else
|
||||
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
note
|
||||
description: "Summary description for {NODE_HANDLER}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
date: "$Date: 2014-12-19 14:17:32 +0100 (ven., 19 déc. 2014) $"
|
||||
revision: "$Revision: 96402 $"
|
||||
|
||||
class
|
||||
NODE_HANDLER
|
||||
@@ -96,7 +96,7 @@ feature -- HTTP Methods
|
||||
elseif l_method.is_case_insensitive_equal ("PUT") then
|
||||
do_put (req, res)
|
||||
else
|
||||
(create {ERROR_500_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
end
|
||||
end
|
||||
else
|
||||
@@ -131,7 +131,7 @@ feature -- HTTP Methods
|
||||
do_error (req, res, l_id)
|
||||
end
|
||||
else
|
||||
(create {ERROR_500_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
end
|
||||
else
|
||||
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
|
||||
@@ -151,7 +151,7 @@ feature -- HTTP Methods
|
||||
do_error (req, res, l_id)
|
||||
end
|
||||
else
|
||||
(create {ERROR_500_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
end
|
||||
else
|
||||
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
note
|
||||
description: "Summary description for {NODE_SUMMARY_HANDLER}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
date: "$Date: 2014-12-19 14:17:32 +0100 (ven., 19 déc. 2014) $"
|
||||
revision: "$Revision: 96402 $"
|
||||
|
||||
class
|
||||
NODE_SUMMARY_HANDLER
|
||||
@@ -77,7 +77,7 @@ feature -- HTTP Methods
|
||||
do_error (req, res, l_id)
|
||||
end
|
||||
else
|
||||
(create {ERROR_500_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
end
|
||||
else
|
||||
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
|
||||
@@ -95,14 +95,14 @@ feature -- HTTP Methods
|
||||
if l_method.is_case_insensitive_equal ("PUT") then
|
||||
do_put (req, res)
|
||||
else
|
||||
(create {ERROR_500_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
end
|
||||
end
|
||||
else
|
||||
do_error (req, res, l_id)
|
||||
end
|
||||
else
|
||||
(create {ERROR_500_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
end
|
||||
else
|
||||
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
|
||||
@@ -125,7 +125,7 @@ feature -- HTTP Methods
|
||||
do_error (req, res, l_id)
|
||||
end
|
||||
else
|
||||
(create {ERROR_500_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
end
|
||||
else
|
||||
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
note
|
||||
description: "Summary description for {NODE_TITLE_HANDLER}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
date: "$Date: 2014-12-19 14:17:32 +0100 (ven., 19 déc. 2014) $"
|
||||
revision: "$Revision: 96402 $"
|
||||
|
||||
class
|
||||
NODE_TITLE_HANDLER
|
||||
@@ -77,7 +77,7 @@ feature -- HTTP Methods
|
||||
do_error (req, res, l_id)
|
||||
end
|
||||
else
|
||||
(create {ERROR_500_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
end
|
||||
else
|
||||
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
|
||||
@@ -94,14 +94,14 @@ feature -- HTTP Methods
|
||||
if l_method.is_case_insensitive_equal ("PUT") then
|
||||
do_put (req, res)
|
||||
else
|
||||
(create {ERROR_500_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
end
|
||||
end
|
||||
else
|
||||
do_error (req, res, l_id)
|
||||
end
|
||||
else
|
||||
(create {ERROR_500_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
end
|
||||
else
|
||||
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
|
||||
@@ -125,7 +125,7 @@ feature -- HTTP Methods
|
||||
do_error (req, res, l_id)
|
||||
end
|
||||
else
|
||||
(create {ERROR_500_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
end
|
||||
else
|
||||
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)
|
||||
|
||||
18
library/src/persistence/cms_storage_builder.e
Normal file
18
library/src/persistence/cms_storage_builder.e
Normal file
@@ -0,0 +1,18 @@
|
||||
note
|
||||
description: "[
|
||||
Objects that ...
|
||||
]"
|
||||
author: "$Author$"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
CMS_STORAGE_BUILDER
|
||||
|
||||
feature -- Factory
|
||||
|
||||
storage (a_setup: CMS_SETUP): detachable CMS_STORAGE
|
||||
deferred
|
||||
end
|
||||
|
||||
end
|
||||
22
library/src/persistence/cms_storage_null_builder.e
Normal file
22
library/src/persistence/cms_storage_null_builder.e
Normal file
@@ -0,0 +1,22 @@
|
||||
note
|
||||
description: "[
|
||||
Objects that ...
|
||||
]"
|
||||
author: "$Author$"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CMS_STORAGE_NULL_BUILDER
|
||||
|
||||
inherit
|
||||
CMS_STORAGE_BUILDER
|
||||
|
||||
feature -- Factory
|
||||
|
||||
storage (a_setup: CMS_SETUP): detachable CMS_STORAGE_NULL
|
||||
do
|
||||
create Result
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,15 +1,13 @@
|
||||
note
|
||||
description: "API for a CMS"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
date: "$Date: 2015-01-14 16:13:47 +0100 (mer., 14 janv. 2015) $"
|
||||
revision: "$Revision: 96454 $"
|
||||
|
||||
class
|
||||
CMS_API
|
||||
|
||||
inherit
|
||||
|
||||
SHARED_ERROR
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
create
|
||||
@@ -23,7 +21,6 @@ feature -- Initialize
|
||||
setup := a_setup
|
||||
create error_handler.make
|
||||
initialize
|
||||
set_successful
|
||||
ensure
|
||||
setup_set: setup = a_setup
|
||||
error_handler_set: not error_handler.has_error
|
||||
@@ -34,49 +31,38 @@ feature -- Initialize
|
||||
|
||||
initialize
|
||||
-- Initialize the persitent layer.
|
||||
local
|
||||
l_database: DATABASE_CONNECTION
|
||||
retried: BOOLEAN
|
||||
l_message: STRING
|
||||
do
|
||||
if not retried then
|
||||
to_implement ("Refactor database setup")
|
||||
if attached (create {JSON_CONFIGURATION}).new_database_configuration (setup.layout.application_config_path) as l_database_config then
|
||||
create {DATABASE_CONNECTION_MYSQL} l_database.login_with_connection_string (l_database_config.connection_string)
|
||||
create {CMS_STORAGE_MYSQL} storage.make (l_database)
|
||||
else
|
||||
create {DATABASE_CONNECTION_NULL} l_database.make_common
|
||||
create {CMS_STORAGE_NULL} storage
|
||||
end
|
||||
to_implement ("Refactor database setup")
|
||||
if attached setup.storage (error_handler) as l_storage then
|
||||
storage := l_storage
|
||||
else
|
||||
to_implement ("Workaround code, persistence layer does not implement yet this kind of error handling.")
|
||||
-- error hanling.
|
||||
create {DATABASE_CONNECTION_NULL} l_database.make_common
|
||||
create {CMS_STORAGE_NULL} storage
|
||||
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
|
||||
error_handler.add_custom_error (0, " Database Connection ", l_message)
|
||||
end
|
||||
rescue
|
||||
retried := True
|
||||
retry
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
feature -- Access: Error
|
||||
|
||||
has_error: BOOLEAN
|
||||
-- Has error?
|
||||
do
|
||||
Result := error_handler.has_error
|
||||
end
|
||||
|
||||
as_string_representation: STRING_32
|
||||
-- String representation of all error(s).
|
||||
do
|
||||
Result := error_handler.as_string_representation
|
||||
end
|
||||
|
||||
feature -- Element Change: Error
|
||||
|
||||
reset
|
||||
-- Reset error handler.
|
||||
do
|
||||
error_handler.reset
|
||||
end
|
||||
|
||||
feature {NONE}-- Error handler implemenations
|
||||
|
||||
error_handler: ERROR_HANDLER
|
||||
-- Error handler.
|
||||
@@ -91,7 +77,7 @@ feature -- Status Report
|
||||
|
||||
feature -- Access: Node
|
||||
|
||||
nodes: LIST[CMS_NODE]
|
||||
nodes: LIST [CMS_NODE]
|
||||
-- List of nodes.
|
||||
do
|
||||
debug ("refactor_fixme")
|
||||
@@ -188,12 +174,43 @@ feature -- Change User
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Layout
|
||||
|
||||
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'.
|
||||
local
|
||||
p, l_path: PATH
|
||||
ut: FILE_UTILITIES
|
||||
do
|
||||
p := setup.layout.config_path.extended ("modules").extended (a_module_name)
|
||||
if a_name = Void then
|
||||
p := p.extended (a_module_name)
|
||||
else
|
||||
p := p.extended (a_name)
|
||||
end
|
||||
l_path := p.appended_with_extension ("json")
|
||||
if ut.file_path_exists (l_path) then
|
||||
create {JSON_CONFIG} Result.make_from_file (l_path)
|
||||
else
|
||||
l_path := p.appended_with_extension ("ini")
|
||||
if ut.file_path_exists (l_path) then
|
||||
create {INI_CONFIG} Result.make_from_file (l_path)
|
||||
end
|
||||
end
|
||||
if Result = Void and a_name /= Void then
|
||||
-- Use sub config from default?
|
||||
if attached {CONFIG_READER} module_configuration (a_module_name, Void) as cfg then
|
||||
Result := cfg.sub_config (a_name)
|
||||
else
|
||||
-- Maybe try to use the global cms.ini ?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implemenataion
|
||||
|
||||
|
||||
storage: CMS_STORAGE
|
||||
-- Persistence storage.
|
||||
-- Persistence storage.
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -45,7 +45,6 @@ feature {NONE} -- Initialization
|
||||
-- Build a CMS service with `a_api'
|
||||
do
|
||||
api := a_api
|
||||
configuration := a_api.setup.configuration
|
||||
initialize
|
||||
ensure
|
||||
api_set: api = a_api
|
||||
@@ -58,27 +57,17 @@ feature {NONE} -- Initialization
|
||||
initialize_users
|
||||
initialize_auth_engine
|
||||
initialize_mailer
|
||||
-- initialize_router
|
||||
-- initialize_filter: expanded here, for void-safety concern.
|
||||
create_filter
|
||||
initialize_router
|
||||
initialize_filter
|
||||
setup_filter
|
||||
end
|
||||
|
||||
initialize_modules
|
||||
-- Intialize modules and keep only enabled modules.
|
||||
local
|
||||
l_module: CMS_MODULE
|
||||
l_available_modules: CMS_MODULE_COLLECTION
|
||||
do
|
||||
log.write_debug (generator + ".initialize_modules")
|
||||
l_available_modules := setup.modules
|
||||
create modules.make (l_available_modules.count)
|
||||
across
|
||||
l_available_modules as ic
|
||||
loop
|
||||
l_module := ic.item
|
||||
if l_module.is_enabled then
|
||||
modules.extend (l_module)
|
||||
end
|
||||
end
|
||||
modules := setup.enabled_modules
|
||||
ensure
|
||||
only_enabled_modules: across modules as ic all ic.item.is_enabled end
|
||||
end
|
||||
@@ -169,6 +158,7 @@ feature -- Execute Filter
|
||||
-- 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)
|
||||
end
|
||||
|
||||
@@ -243,10 +233,6 @@ feature -- Access
|
||||
Result := api.setup
|
||||
end
|
||||
|
||||
configuration: CMS_CONFIGURATION
|
||||
-- CMS configuration.
|
||||
--| Maybe we can compute it (using `setup') instead of using memory.
|
||||
|
||||
modules: CMS_MODULE_COLLECTION
|
||||
-- Configurator of possible modules.
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
note
|
||||
description: "Summary description for {CMS_ERROR_FILTER}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
date: "$Date: 2014-12-19 14:17:32 +0100 (ven., 19 déc. 2014) $"
|
||||
revision: "$Revision: 96402 $"
|
||||
|
||||
class
|
||||
CMS_ERROR_FILTER
|
||||
@@ -20,13 +20,20 @@ feature -- Basic operations
|
||||
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute the filter
|
||||
do
|
||||
if not api.error_handler.has_error then
|
||||
log.write_information (generator + ".execute")
|
||||
fixme ("Check if it's ok to add new fetures CMS_API.has_error:BOOLEAN and CMS_API.error_description.")
|
||||
if not api.has_error then
|
||||
log.write_information (generator + ".execute with req: " + req.debug_output)
|
||||
if attached req.raw_header_data as l_header_data then
|
||||
log.write_debug (generator + ".execute with req header: " + l_header_data)
|
||||
end
|
||||
if attached req.raw_input_data as l_input_data then
|
||||
log.write_debug (generator + ".execute with req input: " + l_input_data)
|
||||
end
|
||||
execute_next (req, res)
|
||||
else
|
||||
log.write_critical (generator + ".execute" + api.error_handler.as_string_representation )
|
||||
(create {ERROR_500_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
api.error_handler.reset
|
||||
log.write_critical (generator + ".execute" + api.as_string_representation )
|
||||
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
api.reset
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
note
|
||||
description: "Summary description for {BAD_REQUEST_ERROR_CMS_RESPONSE}."
|
||||
date: "$Date: 2014-12-19 14:17:32 +0100 (ven., 19 déc. 2014) $"
|
||||
revision: "$Revision: 96402 $"
|
||||
|
||||
class
|
||||
BAD_REQUEST_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}.bad_request)
|
||||
page.register_variable (page.status_code.out, "code")
|
||||
end
|
||||
|
||||
feature -- Execution
|
||||
|
||||
process
|
||||
-- Computed response message.
|
||||
do
|
||||
set_title ("Bad request")
|
||||
set_page_title ("Bad request")
|
||||
set_main_content ("<em>Bad request.</em>")
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,7 +1,7 @@
|
||||
note
|
||||
description: "Generic CMS Response.It builds the content to get process to render the output"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
date: "$Date: 2014-12-15 21:43:38 +0100 (lun., 15 déc. 2014) $"
|
||||
revision: "$Revision: 96346 $"
|
||||
|
||||
deferred class
|
||||
CMS_RESPONSE
|
||||
@@ -36,19 +36,17 @@ feature {NONE} -- Initialization
|
||||
register_hooks
|
||||
local
|
||||
l_module: CMS_MODULE
|
||||
l_available_modules: CMS_MODULE_COLLECTION
|
||||
l_enabled_modules: CMS_MODULE_COLLECTION
|
||||
do
|
||||
l_available_modules := setup.modules
|
||||
l_enabled_modules := setup.enabled_modules
|
||||
across
|
||||
l_available_modules as ic
|
||||
l_enabled_modules as ic
|
||||
loop
|
||||
l_module := ic.item
|
||||
if l_module.is_enabled then
|
||||
if attached {CMS_HOOK_AUTO_REGISTER} l_module as l_auto then
|
||||
l_auto.auto_subscribe_to_hooks (Current)
|
||||
end
|
||||
l_module.register_hooks (Current)
|
||||
if attached {CMS_HOOK_AUTO_REGISTER} l_module as l_auto then
|
||||
l_auto.auto_subscribe_to_hooks (Current)
|
||||
end
|
||||
l_module.register_hooks (Current)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -81,6 +79,37 @@ feature -- Access
|
||||
additional_page_head_lines: detachable LIST [READABLE_STRING_8]
|
||||
-- HTML>head>...extra lines
|
||||
|
||||
feature -- Module
|
||||
|
||||
module_resource_path (a_module: CMS_MODULE; a_resource: PATH): detachable PATH
|
||||
-- Resource path of `a_resource' for module `a_module', if resource exists.
|
||||
local
|
||||
rp: PATH
|
||||
ut: FILE_UTILITIES
|
||||
do
|
||||
rp := module_assets_theme_location (a_module)
|
||||
Result := rp.extended_path (a_resource)
|
||||
if not ut.file_path_exists (Result) then
|
||||
rp := module_assets_location (a_module)
|
||||
Result := rp.extended_path (a_resource)
|
||||
if not ut.file_path_exists (Result) then
|
||||
Result := Void
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
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)
|
||||
end
|
||||
|
||||
module_assets_theme_location (a_module: CMS_MODULE): PATH
|
||||
-- Location for the assets associated with `a_module'.
|
||||
do
|
||||
Result := setup.theme_location.extended ("modules").extended (a_module.name)
|
||||
end
|
||||
|
||||
feature -- URL utilities
|
||||
|
||||
is_front: BOOLEAN
|
||||
@@ -350,12 +379,6 @@ feature -- Blocks
|
||||
add_block (header_block, "header")
|
||||
if attached message_block as m then
|
||||
add_block (m, "content")
|
||||
end
|
||||
-- FIXME: avoid hardcoded html! should be only in theme.
|
||||
add_block (create {CMS_CONTENT_BLOCK}.make_raw ("top_content_anchor", Void, "<a id=%"main-content%"></a>%N", formats.full_html), "content")
|
||||
if attached page_title as l_page_title then
|
||||
-- FIXME: avoid hardcoded html! should be only in theme.
|
||||
add_block (create {CMS_CONTENT_BLOCK}.make_raw ("page_title", Void, "<h1 id=%"page-title%" class=%"title%">"+ l_page_title +"</h1>%N", formats.full_html), "content")
|
||||
end
|
||||
if attached primary_tabs_block as m then
|
||||
add_block (m, "content")
|
||||
@@ -372,11 +395,10 @@ feature -- Blocks
|
||||
add_block (l_block, "first_sidebar")
|
||||
end
|
||||
|
||||
if attached footer_block as l_block then
|
||||
add_block (l_block, "footer")
|
||||
end
|
||||
|
||||
invoke_block
|
||||
debug ("cms")
|
||||
add_block (create {CMS_CONTENT_BLOCK}.make ("made_with", Void, "Made with <a href=%"http://www.eiffel.com/%">EWF</a>", Void), "footer")
|
||||
end
|
||||
end
|
||||
|
||||
primary_menu_block: detachable CMS_MENU_BLOCK
|
||||
@@ -419,7 +441,7 @@ feature -- Blocks
|
||||
s: STRING
|
||||
do
|
||||
create s.make_empty
|
||||
create Result.make ("page_top", Void, s, formats.full_html)
|
||||
create Result.make ("page_top", Void, s, Void)
|
||||
Result.set_is_raw (True)
|
||||
end
|
||||
|
||||
@@ -430,7 +452,7 @@ feature -- Blocks
|
||||
do
|
||||
create s.make_from_string (theme.menu_html (primary_menu, True))
|
||||
create l_hb.make_empty
|
||||
create Result.make ("header", Void, l_hb, formats.full_html)
|
||||
create Result.make ("header", Void, l_hb, Void)
|
||||
Result.set_is_raw (True)
|
||||
end
|
||||
|
||||
@@ -452,7 +474,7 @@ feature -- Blocks
|
||||
message_block: detachable CMS_CONTENT_BLOCK
|
||||
do
|
||||
if attached message as m and then not m.is_empty then
|
||||
create Result.make ("message", Void, "<div id=%"message%">" + m + "</div>", formats.full_html)
|
||||
create Result.make ("message", Void, "<div id=%"message%">" + m + "</div>", Void)
|
||||
Result.set_is_raw (True)
|
||||
end
|
||||
end
|
||||
@@ -469,22 +491,10 @@ feature -- Blocks
|
||||
s := "No Content"
|
||||
end
|
||||
end
|
||||
create Result.make ("content", Void, s, formats.full_html)
|
||||
create Result.make ("content", Void, s, Void)
|
||||
Result.set_is_raw (True)
|
||||
end
|
||||
|
||||
made_with_html: STRING
|
||||
do
|
||||
create Result.make_empty
|
||||
Result.append ("Made with <a href=%"http://www.eiffel.com/%">EWF</a>")
|
||||
end
|
||||
|
||||
footer_block: CMS_CONTENT_BLOCK
|
||||
do
|
||||
create Result.make ("made_with", Void, made_with_html, Void)
|
||||
end
|
||||
|
||||
|
||||
feature -- Hooks
|
||||
|
||||
hook_subscribers: HASH_TABLE [LIST [CMS_HOOK], TYPE [CMS_HOOK]]
|
||||
@@ -722,7 +732,9 @@ feature -- Theme
|
||||
if l_info.engine.is_case_insensitive_equal_general ("smarty") then
|
||||
create {SMARTY_CMS_THEME} theme.make (setup, l_info)
|
||||
else
|
||||
create {DEFAULT_CMS_THEME} theme.make (setup, l_info)
|
||||
create {MISSING_CMS_THEME} theme.make (setup)
|
||||
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
|
||||
end
|
||||
|
||||
@@ -786,6 +798,13 @@ feature -- Generation
|
||||
across
|
||||
reg_ic.item.blocks as ic
|
||||
loop
|
||||
-- if attached {CMS_SMARTY_CONTENT_BLOCK} ic.item as l_tpl_block then
|
||||
-- across
|
||||
-- page.variables as var_ic
|
||||
-- loop
|
||||
-- l_tpl_block.set_value (var_ic.item, var_ic.key)
|
||||
-- end
|
||||
-- end
|
||||
page.add_to_region (theme.block_html (ic.item), reg_ic.item.name)
|
||||
end
|
||||
end
|
||||
@@ -837,6 +856,11 @@ feature -- Generation
|
||||
|
||||
-- Menu...
|
||||
page.register_variable (horizontal_primary_menu_html, "primary_nav")
|
||||
|
||||
-- Page related
|
||||
if attached page_title as l_page_title then
|
||||
page.register_variable (l_page_title, "page_title")
|
||||
end
|
||||
end
|
||||
|
||||
custom_prepare (page: CMS_HTML_PAGE)
|
||||
@@ -886,7 +910,11 @@ feature -- Generation
|
||||
-- Update the active status recursively on `a_comp'.
|
||||
local
|
||||
ln: CMS_LINK
|
||||
l_comp_link: detachable CMS_LOCAL_LINK
|
||||
do
|
||||
if attached {CMS_LOCAL_LINK} a_comp as lnk then
|
||||
l_comp_link := lnk
|
||||
end
|
||||
if attached a_comp.items as l_items then
|
||||
across
|
||||
l_items as ic
|
||||
@@ -898,8 +926,16 @@ feature -- Generation
|
||||
if (ln.is_expanded or ln.is_collapsed) and then attached {CMS_LINK_COMPOSITE} ln as l_comp then
|
||||
recursive_get_active (l_comp, req)
|
||||
end
|
||||
if l_comp_link /= Void then
|
||||
if ln.is_expanded or (not ln.is_expandable and ln.is_active) then
|
||||
l_comp_link.set_expanded (True)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if l_comp_link /= Void and then l_comp_link.is_active then
|
||||
l_comp_link.set_expanded (True)
|
||||
end
|
||||
end
|
||||
|
||||
get_local_link_active_status (a_lnk: CMS_LOCAL_LINK)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
note
|
||||
description: "Summary description for {HOME_CMS_RESPONSE}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
date: "$Date: 2014-12-17 13:14:43 +0100 (mer., 17 déc. 2014) $"
|
||||
revision: "$Revision: 96367 $"
|
||||
|
||||
class
|
||||
HOME_CMS_RESPONSE
|
||||
@@ -21,7 +21,7 @@ feature -- Generation
|
||||
custom_prepare (page: CMS_HTML_PAGE)
|
||||
do
|
||||
Precursor (page)
|
||||
page.register_variable (api.recent_nodes (0, 5), "nodes")
|
||||
-- page.register_variable (api.recent_nodes (0, 5), "nodes")
|
||||
end
|
||||
|
||||
feature -- Execution
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
note
|
||||
description: "Summary description for {ERROR_500_CMS_RESPONSE}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
description: "Summary description for {INTERNAL_SERVER_ERROR_CMS_RESPONSE}."
|
||||
date: "$Date: 2014-12-19 14:17:32 +0100 (ven., 19 déc. 2014) $"
|
||||
revision: "$Revision: 96402 $"
|
||||
|
||||
class
|
||||
ERROR_500_CMS_RESPONSE
|
||||
INTERNAL_SERVER_ERROR_CMS_RESPONSE
|
||||
|
||||
inherit
|
||||
|
||||
@@ -32,6 +32,7 @@ feature -- Execution
|
||||
do
|
||||
set_title ("Internal Server Error")
|
||||
set_page_title (Void)
|
||||
set_main_content ("<em>Internal Server Error</em>")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
note
|
||||
description: "Summary description for {WSF_CMS_PAGE_TEMPLATE}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
description: "[
|
||||
Abstract interface for a CMS Template, as part of the theme design.
|
||||
]"
|
||||
date: "$Date: 2014-11-20 15:03:29 +0100 (jeu., 20 nov. 2014) $"
|
||||
revision: "$Revision: 96138 $"
|
||||
|
||||
deferred class
|
||||
CMS_TEMPLATE
|
||||
@@ -9,18 +11,22 @@ deferred class
|
||||
feature -- Access
|
||||
|
||||
theme: CMS_THEME
|
||||
-- Associated theme.
|
||||
deferred
|
||||
end
|
||||
|
||||
variables: STRING_TABLE [detachable ANY]
|
||||
-- Variables used for Current template rendering.
|
||||
deferred
|
||||
end
|
||||
|
||||
prepare (page: CMS_HTML_PAGE)
|
||||
-- Prepare `page' with current template.
|
||||
deferred
|
||||
end
|
||||
|
||||
to_html (page: CMS_HTML_PAGE): STRING
|
||||
-- HTML rendering for page `page'.
|
||||
deferred
|
||||
end
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
note
|
||||
description: "Summary description for {WSF_CMS_THEME}."
|
||||
description: "Abstract class describing a generic theme"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
@@ -62,12 +62,12 @@ feature -- Conversion
|
||||
debug ("refactor_fixme")
|
||||
fixme ("Refactor HTML code to use the new Bootstrap theme template")
|
||||
end
|
||||
if attached {CMS_CONTENT_BLOCK} a_block as l_content_block and then l_content_block.is_raw then
|
||||
if attached a_block.is_raw then
|
||||
create s.make_empty
|
||||
if attached l_content_block.title as l_title then
|
||||
if attached a_block.title as l_title then
|
||||
s.append ("<div class=%"title%">" + html_encoded (l_title) + "</div>")
|
||||
end
|
||||
s.append (l_content_block.to_html (Current))
|
||||
s.append (a_block.to_html (Current))
|
||||
else
|
||||
create s.make_from_string ("<div class=%"block%" id=%"" + a_block.name + "%">")
|
||||
if attached a_block.title as l_title then
|
||||
@@ -80,6 +80,7 @@ feature -- Conversion
|
||||
end
|
||||
Result := s
|
||||
end
|
||||
|
||||
page_html (page: CMS_HTML_PAGE): STRING_8
|
||||
-- Render `page' as html.
|
||||
deferred
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
note
|
||||
description: "Summary description for {CMS_HTML_TEMPLATE}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
DEFAULT_CMS_HTML_TEMPLATE
|
||||
|
||||
inherit
|
||||
CMS_HTML_TEMPLATE
|
||||
|
||||
DEFAULT_CMS_TEMPLATE
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (t: DEFAULT_CMS_THEME)
|
||||
do
|
||||
theme := t
|
||||
create variables.make (0)
|
||||
end
|
||||
|
||||
variables: STRING_TABLE [detachable ANY]
|
||||
|
||||
feature -- Access
|
||||
|
||||
register (v: STRING_8; k: STRING_8)
|
||||
do
|
||||
variables.force (v, k)
|
||||
end
|
||||
|
||||
theme: DEFAULT_CMS_THEME
|
||||
|
||||
prepare (page: CMS_HTML_PAGE)
|
||||
do
|
||||
variables.make (10)
|
||||
|
||||
across
|
||||
page.variables as ic
|
||||
loop
|
||||
variables.force (ic.item, ic.key)
|
||||
end
|
||||
|
||||
if attached page.title as l_title then
|
||||
variables.force (l_title, "title")
|
||||
variables.force (l_title, "head_title")
|
||||
else
|
||||
variables.force ("", "title")
|
||||
variables.force ("", "head_title")
|
||||
end
|
||||
|
||||
variables.force (page.language, "language")
|
||||
variables.force (page.head_lines_to_string, "head_lines")
|
||||
end
|
||||
|
||||
to_html (page: CMS_HTML_PAGE): STRING
|
||||
do
|
||||
-- Process html generation
|
||||
create Result.make_from_string (template)
|
||||
apply_template_engine (Result)
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
template: STRING
|
||||
once
|
||||
Result := "[
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="$language" lang="$language" version="XHTML+RDFa 1.0" dir="ltr">
|
||||
<head>
|
||||
$head
|
||||
<title>$head_title</title>
|
||||
$styles
|
||||
$scripts
|
||||
$head_lines
|
||||
</head>
|
||||
<body class="$body_classes" $body_attributes>
|
||||
$page_top
|
||||
$page
|
||||
$page_bottom
|
||||
</body>
|
||||
</html>
|
||||
]"
|
||||
end
|
||||
|
||||
|
||||
note
|
||||
copyright: "2011-2014, Jocelyn Fiat, 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
|
||||
@@ -1,102 +0,0 @@
|
||||
note
|
||||
description: "Summary description for {CMS_PAGE_TEMPLATE}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
DEFAULT_CMS_PAGE_TEMPLATE
|
||||
|
||||
inherit
|
||||
CMS_PAGE_TEMPLATE
|
||||
|
||||
DEFAULT_CMS_TEMPLATE
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (t: DEFAULT_CMS_THEME)
|
||||
do
|
||||
theme := t
|
||||
create variables.make (0)
|
||||
end
|
||||
|
||||
variables: STRING_TABLE [detachable ANY]
|
||||
|
||||
feature -- Access
|
||||
|
||||
theme: DEFAULT_CMS_THEME
|
||||
|
||||
prepare (page: CMS_HTML_PAGE)
|
||||
do
|
||||
variables.make (10)
|
||||
|
||||
across
|
||||
page.variables as ic
|
||||
loop
|
||||
variables.force (ic.item, ic.key)
|
||||
end
|
||||
|
||||
if attached page.title as l_title then
|
||||
variables.force (l_title, "title")
|
||||
else
|
||||
variables.force ("", "title")
|
||||
end
|
||||
across
|
||||
theme.regions as r
|
||||
loop
|
||||
variables.force (page.region (r.item), r.item)
|
||||
end
|
||||
end
|
||||
|
||||
to_html (page: CMS_HTML_PAGE): STRING
|
||||
do
|
||||
-- Process html generation
|
||||
create Result.make_from_string (template)
|
||||
apply_template_engine (Result)
|
||||
end
|
||||
|
||||
feature -- Registration
|
||||
|
||||
register (v: STRING_8; k: STRING_8)
|
||||
do
|
||||
variables.force (v, k)
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
template: STRING
|
||||
once
|
||||
Result := "[
|
||||
<div id="page-wrapper">
|
||||
<div id="page">
|
||||
<div id="header">
|
||||
$header
|
||||
</div>
|
||||
<div id="main-wrapper">
|
||||
<div id="main">
|
||||
<div id="first_sidebar" class="sidebar $first_sidebar_css_class">$first_sidebar</div>
|
||||
<div id="content" class="$content_css_class">$content</div>
|
||||
<div id="second_sidebar" class="sidebar $second_sidebar_css_class">$second_sidebar</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="footer">$footer</div>
|
||||
</div>
|
||||
</div>
|
||||
]"
|
||||
end
|
||||
|
||||
|
||||
note
|
||||
copyright: "2011-2014, Jocelyn Fiat, 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
|
||||
@@ -1,100 +0,0 @@
|
||||
note
|
||||
description: "Summary description for {CMS_THEME}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
DEFAULT_CMS_THEME
|
||||
|
||||
inherit
|
||||
CMS_THEME
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_setup: like setup; a_info: like information)
|
||||
do
|
||||
setup := a_setup
|
||||
information := a_info
|
||||
end
|
||||
|
||||
information: CMS_THEME_INFORMATION
|
||||
|
||||
feature -- Access
|
||||
|
||||
name: STRING = "CMS"
|
||||
|
||||
regions: ARRAY [STRING]
|
||||
once
|
||||
Result := <<"header", "content", "footer", "first_sidebar", "second_sidebar">>
|
||||
end
|
||||
|
||||
html_template: DEFAULT_CMS_HTML_TEMPLATE
|
||||
local
|
||||
tpl: like internal_html_template
|
||||
do
|
||||
tpl := internal_html_template
|
||||
if tpl = Void then
|
||||
create tpl.make (Current)
|
||||
internal_html_template := tpl
|
||||
end
|
||||
Result := tpl
|
||||
end
|
||||
|
||||
page_template: DEFAULT_CMS_PAGE_TEMPLATE
|
||||
local
|
||||
tpl: like internal_page_template
|
||||
do
|
||||
tpl := internal_page_template
|
||||
if tpl = Void then
|
||||
create tpl.make (Current)
|
||||
internal_page_template := tpl
|
||||
end
|
||||
Result := tpl
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
prepare (page: CMS_HTML_PAGE)
|
||||
do
|
||||
end
|
||||
|
||||
page_html (page: CMS_HTML_PAGE): STRING_8
|
||||
local
|
||||
l_content: STRING_8
|
||||
do
|
||||
prepare (page)
|
||||
page_template.prepare (page)
|
||||
l_content := page_template.to_html (page)
|
||||
html_template.prepare (page)
|
||||
html_template.register (l_content, "page")
|
||||
Result := html_template.to_html (page)
|
||||
end
|
||||
|
||||
navigation_template: detachable READABLE_STRING_GENERAL
|
||||
-- navigation template name, if any.
|
||||
do
|
||||
end
|
||||
|
||||
feature {NONE} -- Internal
|
||||
|
||||
internal_page_template: detachable like page_template
|
||||
|
||||
internal_html_template: detachable like html_template
|
||||
|
||||
invariant
|
||||
attached internal_page_template as inv_p implies inv_p.theme = Current
|
||||
note
|
||||
copyright: "2011-2014, Jocelyn Fiat, 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
|
||||
48
library/src/theme/missing_theme/missing_cms_template.e
Normal file
48
library/src/theme/missing_theme/missing_cms_template.e
Normal file
@@ -0,0 +1,48 @@
|
||||
note
|
||||
description: "[
|
||||
Template to be used with missing theme.
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
MISSING_CMS_TEMPLATE
|
||||
|
||||
inherit
|
||||
|
||||
CMS_TEMPLATE
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
make (a_theme: MISSING_CMS_THEME)
|
||||
-- Instantiate Current template based on theme `a_theme'.
|
||||
do
|
||||
theme := a_theme
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
theme: MISSING_CMS_THEME
|
||||
-- <Precursor>
|
||||
|
||||
variables: STRING_TABLE [detachable ANY]
|
||||
-- <Precursor>
|
||||
do
|
||||
create Result.make (0)
|
||||
end
|
||||
|
||||
prepare (page: CMS_HTML_PAGE)
|
||||
-- <Precursor>
|
||||
do
|
||||
end
|
||||
|
||||
to_html (page: CMS_HTML_PAGE): STRING
|
||||
-- <Precursor>
|
||||
do
|
||||
Result := " "
|
||||
end
|
||||
|
||||
end
|
||||
48
library/src/theme/missing_theme/missing_cms_theme.e
Normal file
48
library/src/theme/missing_theme/missing_cms_theme.e
Normal file
@@ -0,0 +1,48 @@
|
||||
note
|
||||
description: "[
|
||||
Theme used when expected theme is missing.
|
||||
It is mainly used to report missing theme error.
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
MISSING_CMS_THEME
|
||||
|
||||
inherit
|
||||
|
||||
CMS_THEME
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_setup: like setup)
|
||||
do
|
||||
setup := a_setup
|
||||
ensure
|
||||
setup_set: setup = a_setup
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
name: STRING = "missing theme"
|
||||
|
||||
regions: ARRAY [STRING]
|
||||
do
|
||||
create Result.make_empty
|
||||
end
|
||||
|
||||
page_template: CMS_TEMPLATE
|
||||
-- theme template page.
|
||||
do
|
||||
create {MISSING_CMS_TEMPLATE} Result.make (Current)
|
||||
end
|
||||
|
||||
page_html (page: CMS_HTML_PAGE): STRING_8
|
||||
do
|
||||
to_implement ("Add a better response message, maybe using smarty template")
|
||||
Result := "Service Unavailable"
|
||||
end
|
||||
end
|
||||
@@ -1,7 +1,7 @@
|
||||
note
|
||||
description: "Summary description for {CMS_PAGE_TEMPLATE}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
date: "$Date: 2015-01-14 16:13:47 +0100 (mer., 14 janv. 2015) $"
|
||||
revision: "$Revision: 96454 $"
|
||||
|
||||
class
|
||||
SMARTY_CMS_PAGE_TEMPLATE
|
||||
@@ -75,26 +75,29 @@ feature -- Access
|
||||
debug ("smarty")
|
||||
template_context.enable_verbose
|
||||
end
|
||||
p := template_context.template_folder
|
||||
if p = Void then
|
||||
create p.make_current
|
||||
end
|
||||
|
||||
if attached page.type as l_page_type then
|
||||
create n.make_from_string_general (l_page_type)
|
||||
n.append_character ('-')
|
||||
n.append_string_general (template_name)
|
||||
n.append_string_general (".tpl")
|
||||
if ut.file_path_exists (p.extended (n)) then
|
||||
|
||||
p := template_context.template_file (n)
|
||||
|
||||
if ut.file_path_exists (p) then
|
||||
create tpl.make_from_file (n)
|
||||
end
|
||||
end
|
||||
if tpl = Void then
|
||||
create n.make_from_string_general (template_name)
|
||||
n.append_string_general (".tpl")
|
||||
if ut.file_path_exists (p.extended (n)) then
|
||||
|
||||
p := template_context.template_file (n)
|
||||
if ut.file_path_exists (p) then
|
||||
create tpl.make_from_file (n)
|
||||
end
|
||||
end
|
||||
|
||||
if tpl /= Void then
|
||||
across
|
||||
variables as ic
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
note
|
||||
description: "Summary description for {SMARTY_CMS_THEME}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
description: "Smarty template CMS theme."
|
||||
date: "$Date: 2014-12-05 22:39:27 +0100 (ven., 05 déc. 2014) $"
|
||||
revision: "$Revision: 96260 $"
|
||||
|
||||
class
|
||||
SMARTY_CMS_THEME
|
||||
@@ -55,7 +54,7 @@ feature -- Access
|
||||
i := i + 1
|
||||
end
|
||||
else
|
||||
l_regions := <<"top","header", "content", "footer", "first_sidebar", "second_sidebar","bottom">>
|
||||
l_regions := <<"top","header", "highlighted","help", "content", "footer", "first_sidebar", "second_sidebar", "bottom">>
|
||||
end
|
||||
internaL_regions := l_regions
|
||||
end
|
||||
@@ -102,7 +101,11 @@ feature -- Conversion
|
||||
end
|
||||
end
|
||||
|
||||
create l_table_inspector.register (({detachable STRING_TABLE [STRING]}).name)
|
||||
create l_table_inspector.register (({detachable STRING_TABLE [STRING_8]}).name)
|
||||
create l_table_inspector.register (({detachable STRING_TABLE [STRING_32]}).name)
|
||||
create l_table_inspector.register (({detachable STRING_TABLE [READABLE_STRING_8]}).name)
|
||||
create l_table_inspector.register (({detachable STRING_TABLE [READABLE_STRING_32]}).name)
|
||||
|
||||
page_template.prepare (page)
|
||||
Result := page_template.to_html (page)
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
note
|
||||
description: "Summary description for {STRING_TABLE_OF_STRING_INSPECTOR}."
|
||||
author: ""
|
||||
date: "$Date: 2014-11-06 17:59:12 -0300 (ju. 06 de nov. de 2014) $"
|
||||
revision: "$Revision: 96040 $"
|
||||
date: "$Date: 2014-12-05 22:39:27 +0100 (ven., 05 déc. 2014) $"
|
||||
revision: "$Revision: 96260 $"
|
||||
|
||||
class
|
||||
STRING_TABLE_OF_STRING_INSPECTOR
|
||||
@@ -23,13 +23,22 @@ feature {TEMPLATE_ROUTINES}
|
||||
-- If not handled by this inspector, return Void
|
||||
local
|
||||
l_fn: STRING
|
||||
utf: UTF_CONVERTER
|
||||
do
|
||||
if attached {STRING_TABLE [STRING]} obj as l_regions then
|
||||
if attached {STRING_TABLE [detachable READABLE_STRING_GENERAL]} obj as l_regions then
|
||||
l_fn := field_name.as_lower
|
||||
if l_fn.is_case_insensitive_equal ("count") then
|
||||
Result := cell_of (l_regions.count)
|
||||
elseif attached l_regions.item (l_fn) as v then
|
||||
Result := cell_of (v)
|
||||
if attached {READABLE_STRING_32} v as v32 then
|
||||
if attached v32.is_valid_as_string_8 then
|
||||
Result := cell_of (v.to_string_8)
|
||||
else
|
||||
Result := cell_of (utf.escaped_utf_32_string_to_utf_8_string_8 (v32))
|
||||
end
|
||||
else
|
||||
Result := cell_of (v.to_string_8)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user