Merge pull request #3 from jocelyn/jfiat_roc_auth
Various design changes
This commit is contained in:
@@ -16,8 +16,6 @@ feature {NONE} -- Initialization
|
||||
|
||||
make (a_layout: CMS_LAYOUT)
|
||||
-- Initialize `Current'.
|
||||
local
|
||||
p: PATH
|
||||
do
|
||||
layout := a_layout
|
||||
create options.make_equal (10)
|
||||
@@ -169,8 +167,6 @@ feature -- Change
|
||||
end
|
||||
|
||||
get_root_location
|
||||
local
|
||||
utf: UTF_CONVERTER
|
||||
do
|
||||
root_location := layout.www_path
|
||||
end
|
||||
|
||||
@@ -11,4 +11,5 @@ inherit
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
end
|
||||
|
||||
@@ -12,13 +12,28 @@ inherit
|
||||
REFACTORING_HELPER
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_layout: CMS_LAYOUT)
|
||||
do
|
||||
layout := a_layout
|
||||
create configuration.make (layout)
|
||||
initialize
|
||||
end
|
||||
|
||||
initialize
|
||||
do
|
||||
configure
|
||||
create modules.make (3)
|
||||
build_api_service
|
||||
build_mailer
|
||||
|
||||
initialize_modules
|
||||
end
|
||||
|
||||
configure
|
||||
do
|
||||
site_id := configuration.site_id
|
||||
site_url := configuration.site_url ("")
|
||||
site_name := configuration.site_name ("EWF::CMS")
|
||||
@@ -31,23 +46,35 @@ feature {NONE} -- Initialization
|
||||
|
||||
compute_theme_location
|
||||
compute_theme_resource_location
|
||||
|
||||
initialize
|
||||
end
|
||||
|
||||
|
||||
initialize
|
||||
initialize_modules
|
||||
local
|
||||
m: CMS_MODULE
|
||||
do
|
||||
build_api_service
|
||||
build_auth_engine
|
||||
build_mailer
|
||||
build_modules
|
||||
-- -- Core
|
||||
-- create {USER_MODULE} m.make (Current)
|
||||
-- m.enable
|
||||
-- modules.extend (m)
|
||||
|
||||
-- create {ADMIN_MODULE} m.make (Current)
|
||||
-- m.enable
|
||||
-- modules.extend (m)
|
||||
|
||||
|
||||
create {BASIC_AUTH_MODULE} m.make (Current)
|
||||
m.enable
|
||||
modules.extend (m)
|
||||
|
||||
create {NODE_MODULE} m.make (Current)
|
||||
m.enable
|
||||
modules.extend (m)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
modules: ARRAYED_LIST [CMS_MODULE]
|
||||
-- List of possible modules
|
||||
modules: CMS_MODULE_COLLECTION
|
||||
-- <Precursor>
|
||||
|
||||
is_html: BOOLEAN
|
||||
-- <Precursor>
|
||||
@@ -63,37 +90,8 @@ feature -- Access
|
||||
|
||||
end
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
build_modules
|
||||
-- Core modules. (User, Admin, Node)
|
||||
-- At the moment only node is supported.
|
||||
local
|
||||
m: CMS_MODULE
|
||||
do
|
||||
create modules.make (3)
|
||||
|
||||
-- -- Core
|
||||
-- create {USER_MODULE} m.make
|
||||
-- m.enable
|
||||
-- modules.extend (m)
|
||||
|
||||
-- create {ADMIN_MODULE} m.make
|
||||
-- m.enable
|
||||
-- modules.extend (m)
|
||||
|
||||
create {NODE_MODULE} m.make (Current)
|
||||
m.enable
|
||||
modules.extend (m)
|
||||
|
||||
create {BASIC_AUTH_MODULE} m.make (Current)
|
||||
m.enable
|
||||
modules.extend (m)
|
||||
end
|
||||
|
||||
build_api_service
|
||||
local
|
||||
dn: PATH
|
||||
l_database: DATABASE_CONNECTION
|
||||
do
|
||||
to_implement ("Refactor database setup")
|
||||
@@ -116,12 +114,18 @@ feature {NONE} -- Initialization
|
||||
to_implement ("Not implemented mailer")
|
||||
end
|
||||
|
||||
feature -- Change
|
||||
feature -- Compute location
|
||||
|
||||
add_module (m: CMS_MODULE)
|
||||
-- Add a module `m' to the list of modules `modules'.
|
||||
compute_theme_location
|
||||
do
|
||||
modules.force (m)
|
||||
theme_location := themes_location.extended (theme_name)
|
||||
end
|
||||
|
||||
compute_theme_resource_location
|
||||
-- assets (js, css, images, etc)
|
||||
-- Not used at the moment.
|
||||
do
|
||||
theme_resource_location := theme_location
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -19,14 +19,34 @@ feature -- Access
|
||||
|
||||
theme_path: PATH
|
||||
-- Directory for templates (HTML, etc).
|
||||
once
|
||||
Result := www_path.extended ("theme")
|
||||
local
|
||||
p: detachable PATH
|
||||
do
|
||||
p := internal_theme_path
|
||||
if p = Void then
|
||||
p := www_path.extended ("theme")
|
||||
internal_theme_path := p
|
||||
end
|
||||
Result := p
|
||||
end
|
||||
|
||||
cms_config_ini_path: PATH
|
||||
-- Database Configuration file path.
|
||||
once
|
||||
Result := config_path.extended ("cms.ini")
|
||||
local
|
||||
p: detachable PATH
|
||||
do
|
||||
p := internal_cms_config_ini_path
|
||||
if p = Void then
|
||||
p := config_path.extended ("cms.ini")
|
||||
internal_cms_config_ini_path := p
|
||||
end
|
||||
Result := p
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
internal_theme_path: detachable like theme_path
|
||||
|
||||
internal_cms_config_ini_path: detachable like cms_config_ini_path
|
||||
|
||||
end
|
||||
|
||||
@@ -9,28 +9,26 @@ deferred class
|
||||
feature -- Access
|
||||
|
||||
configuration: CMS_CONFIGURATION
|
||||
-- cms configuration.
|
||||
-- cms configuration.
|
||||
|
||||
layout: CMS_LAYOUT
|
||||
-- CMS layout.
|
||||
-- CMS layout.
|
||||
|
||||
api_service: CMS_API_SERVICE
|
||||
-- cms api service.
|
||||
|
||||
modules: LIST[CMS_MODULE]
|
||||
-- Possible list of modules.
|
||||
-- |If we remove Modules from setup.
|
||||
-- |we can let the CMS_SERVICE define the basic modules.
|
||||
deferred
|
||||
end
|
||||
-- cms api service.
|
||||
|
||||
is_html: BOOLEAN
|
||||
-- api with progresive enhacements css and js, server side rendering.
|
||||
-- api with progressive enhancements css and js, server side rendering.
|
||||
deferred
|
||||
end
|
||||
|
||||
is_web: BOOLEAN
|
||||
-- web: Web Site with progresive enhacements css and js and Ajax calls.
|
||||
-- web: Web Site with progressive enhancements css and js and Ajax calls.
|
||||
deferred
|
||||
end
|
||||
|
||||
modules: CMS_MODULE_COLLECTION
|
||||
-- List of available modules.
|
||||
deferred
|
||||
end
|
||||
|
||||
@@ -50,14 +48,14 @@ feature -- Access: Site
|
||||
|
||||
files_location: PATH
|
||||
|
||||
feature -- Access:Theme
|
||||
feature -- Access: Theme
|
||||
|
||||
themes_location: PATH
|
||||
|
||||
theme_location: PATH
|
||||
|
||||
theme_resource_location: PATH
|
||||
--
|
||||
--
|
||||
|
||||
theme_information_location: PATH
|
||||
-- theme informations.
|
||||
@@ -66,20 +64,6 @@ feature -- Access:Theme
|
||||
end
|
||||
|
||||
theme_name: READABLE_STRING_32
|
||||
-- theme name
|
||||
|
||||
feature -- Compute location
|
||||
|
||||
compute_theme_location
|
||||
do
|
||||
theme_location := themes_location.extended (theme_name)
|
||||
end
|
||||
|
||||
compute_theme_resource_location
|
||||
-- assets (js, css, images, etc)
|
||||
-- Not used at the moment.
|
||||
do
|
||||
theme_resource_location := theme_location
|
||||
end
|
||||
-- theme name
|
||||
|
||||
end
|
||||
|
||||
@@ -9,6 +9,9 @@ class
|
||||
inherit
|
||||
|
||||
CMS_MODULE
|
||||
redefine
|
||||
filters
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
@@ -22,39 +25,34 @@ feature {NONE} -- Initialization
|
||||
description := "Service to manage basic authentication"
|
||||
package := "core"
|
||||
config := a_config
|
||||
setup_router
|
||||
setup_filter
|
||||
enable
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
router: WSF_ROUTER
|
||||
-- Node router.
|
||||
|
||||
config: CMS_SETUP
|
||||
-- Node configuration.
|
||||
|
||||
feature -- Implementation
|
||||
feature -- Access: router
|
||||
|
||||
setup_router
|
||||
-- Setup `router'.
|
||||
router: WSF_ROUTER
|
||||
-- Node router.
|
||||
do
|
||||
create router.make (2)
|
||||
configure_api_login
|
||||
configure_api_logoff
|
||||
create Result.make (2)
|
||||
configure_api_login (Result)
|
||||
configure_api_logoff (Result)
|
||||
end
|
||||
|
||||
setup_filter
|
||||
-- Setup `filter'.
|
||||
feature -- Access: filter
|
||||
|
||||
filters: detachable LIST [WSF_FILTER]
|
||||
-- Possibly list of Filter's module.
|
||||
do
|
||||
add_filter (create {CORS_FILTER})
|
||||
add_filter (create {BASIC_AUTH_FILTER}.make (config))
|
||||
create {ARRAYED_LIST [WSF_FILTER]} Result.make (2)
|
||||
Result.extend (create {CORS_FILTER})
|
||||
Result.extend (create {BASIC_AUTH_FILTER}.make (config))
|
||||
end
|
||||
|
||||
feature -- Configure Node Resources Routes
|
||||
feature {NONE} -- Implementation: routes
|
||||
|
||||
configure_api_login
|
||||
configure_api_login (a_router: WSF_ROUTER)
|
||||
local
|
||||
l_bal_handler: BASIC_AUTH_LOGIN_HANDLER
|
||||
l_methods: WSF_REQUEST_METHODS
|
||||
@@ -62,10 +60,10 @@ feature -- Configure Node Resources Routes
|
||||
create l_bal_handler.make (config)
|
||||
create l_methods
|
||||
l_methods.enable_get
|
||||
router.handle_with_request_methods ("/basic_auth_login", l_bal_handler, l_methods)
|
||||
a_router.handle_with_request_methods ("/basic_auth_login", l_bal_handler, l_methods)
|
||||
end
|
||||
|
||||
configure_api_logoff
|
||||
configure_api_logoff (a_router: WSF_ROUTER)
|
||||
local
|
||||
l_bal_handler: BASIC_AUTH_LOGOFF_HANDLER
|
||||
l_methods: WSF_REQUEST_METHODS
|
||||
@@ -73,7 +71,7 @@ feature -- Configure Node Resources Routes
|
||||
create l_bal_handler.make (config)
|
||||
create l_methods
|
||||
l_methods.enable_get
|
||||
router.handle_with_request_methods ("/basic_auth_logoff", l_bal_handler, l_methods)
|
||||
a_router.handle_with_request_methods ("/basic_auth_logoff", l_bal_handler, l_methods)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -31,7 +31,7 @@ feature -- Basic operations
|
||||
-- A valid user
|
||||
if (attached l_auth.type as l_auth_type and then l_auth_type.is_case_insensitive_equal_general ("basic")) and then
|
||||
attached l_auth.login as l_auth_login and then attached l_auth.password as l_auth_password then
|
||||
if api_service.login_valid (l_auth_login, l_auth_password) then
|
||||
if api_service.is_valid_credential (l_auth_login, l_auth_password) then
|
||||
if attached api_service.user_by_name (l_auth_login) as l_user then
|
||||
req.set_execution_variable ("user", l_user)
|
||||
execute_next (req, res)
|
||||
|
||||
@@ -22,27 +22,18 @@ feature -- Router
|
||||
|
||||
router: WSF_ROUTER
|
||||
-- Router configuration.
|
||||
require
|
||||
is_enabled: is_enabled
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- Filter
|
||||
|
||||
filters: detachable LIST[WSF_FILTER]
|
||||
-- Possibly list of Filter's module.
|
||||
|
||||
feature -- Element Change: Filter
|
||||
|
||||
add_filter (a_filter: WSF_FILTER)
|
||||
-- Add a filter `a_filter' to the list of module filters `filters'.
|
||||
local
|
||||
l_filters: like filters
|
||||
filters: detachable LIST [WSF_FILTER]
|
||||
-- Optional list of filter for Current module.
|
||||
require
|
||||
is_enabled: is_enabled
|
||||
do
|
||||
l_filters := filters
|
||||
if l_filters = Void then
|
||||
create {ARRAYED_LIST[WSF_FILTER]}l_filters.make (1)
|
||||
filters := l_filters
|
||||
end
|
||||
l_filters.force (a_filter)
|
||||
end
|
||||
|
||||
feature -- Settings
|
||||
|
||||
64
cms/src/modules/cms_module_collection.e
Normal file
64
cms/src/modules/cms_module_collection.e
Normal file
@@ -0,0 +1,64 @@
|
||||
note
|
||||
description: "Summary description for {CMS_MODULE_COLLECTION}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CMS_MODULE_COLLECTION
|
||||
|
||||
inherit
|
||||
ITERABLE [CMS_MODULE]
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (nb: INTEGER)
|
||||
do
|
||||
create modules.make (nb)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
new_cursor: INDEXABLE_ITERATION_CURSOR [CMS_MODULE]
|
||||
-- <Precursor>
|
||||
do
|
||||
Result := modules.new_cursor
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
has (a_module: CMS_MODULE): BOOLEAN
|
||||
-- Has `a_module'?
|
||||
do
|
||||
Result := modules.has (a_module)
|
||||
end
|
||||
|
||||
count: INTEGER
|
||||
-- Number of modules.
|
||||
do
|
||||
Result := modules.count
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
extend (a_module: CMS_MODULE)
|
||||
-- Add module
|
||||
do
|
||||
modules.force (a_module)
|
||||
end
|
||||
|
||||
remove (a_module: CMS_MODULE)
|
||||
-- Remove module
|
||||
do
|
||||
modules.prune_all (a_module)
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
modules: ARRAYED_LIST [CMS_MODULE]
|
||||
-- List of available modules.
|
||||
|
||||
end
|
||||
@@ -1,5 +1,5 @@
|
||||
note
|
||||
description: "Summary description for {CMS_MODULE}."
|
||||
description: "CMS module that bring support for NODE management."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
@@ -16,40 +16,34 @@ create
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_config: CMS_SETUP)
|
||||
-- Create Current module, disabled by default.
|
||||
do
|
||||
name := "node"
|
||||
version := "1.0"
|
||||
description := "Service to manage content based on 'node'"
|
||||
package := "core"
|
||||
config := a_config
|
||||
setup_router
|
||||
enable
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
router: WSF_ROUTER
|
||||
-- Node router.
|
||||
|
||||
config: CMS_SETUP
|
||||
-- Node configuration.
|
||||
-- Node configuration.
|
||||
|
||||
feature -- Implementation
|
||||
feature -- Access: router
|
||||
|
||||
setup_router
|
||||
-- Setup `router'.
|
||||
router: WSF_ROUTER
|
||||
-- Node router.
|
||||
do
|
||||
create router.make (5)
|
||||
configure_api_node
|
||||
configure_api_nodes
|
||||
configure_api_node_title
|
||||
configure_api_node_summary
|
||||
configure_api_node_content
|
||||
create Result.make (5)
|
||||
configure_api_node (Result)
|
||||
configure_api_nodes (Result)
|
||||
configure_api_node_title (Result)
|
||||
configure_api_node_summary (Result)
|
||||
configure_api_node_content (Result)
|
||||
end
|
||||
|
||||
feature -- Configure Node Resources Routes
|
||||
feature {NONE} -- Implementation: routes
|
||||
|
||||
configure_api_node
|
||||
configure_api_node (a_router: WSF_ROUTER)
|
||||
local
|
||||
l_node_handler: NODE_HANDLER
|
||||
l_methods: WSF_REQUEST_METHODS
|
||||
@@ -59,7 +53,7 @@ feature -- Configure Node Resources Routes
|
||||
l_methods.enable_get
|
||||
l_methods.enable_post
|
||||
l_methods.enable_put
|
||||
router.handle_with_request_methods ("/node", l_node_handler, l_methods)
|
||||
a_router.handle_with_request_methods ("/node", l_node_handler, l_methods)
|
||||
|
||||
create l_node_handler.make (config)
|
||||
create l_methods
|
||||
@@ -67,11 +61,10 @@ feature -- Configure Node Resources Routes
|
||||
l_methods.enable_post
|
||||
l_methods.enable_put
|
||||
l_methods.enable_delete
|
||||
router.handle_with_request_methods ("/node/{id}", l_node_handler, l_methods)
|
||||
a_router.handle_with_request_methods ("/node/{id}", l_node_handler, l_methods)
|
||||
end
|
||||
|
||||
|
||||
configure_api_nodes
|
||||
configure_api_nodes (a_router: WSF_ROUTER)
|
||||
local
|
||||
l_nodes_handler: NODES_HANDLER
|
||||
l_methods: WSF_REQUEST_METHODS
|
||||
@@ -79,11 +72,10 @@ feature -- Configure Node Resources Routes
|
||||
create l_nodes_handler.make (config)
|
||||
create l_methods
|
||||
l_methods.enable_get
|
||||
router.handle_with_request_methods ("/nodes", l_nodes_handler, l_methods)
|
||||
a_router.handle_with_request_methods ("/nodes", l_nodes_handler, l_methods)
|
||||
end
|
||||
|
||||
|
||||
configure_api_node_summary
|
||||
configure_api_node_summary (a_router: WSF_ROUTER)
|
||||
local
|
||||
l_report_handler: NODE_SUMMARY_HANDLER
|
||||
l_methods: WSF_REQUEST_METHODS
|
||||
@@ -93,11 +85,11 @@ feature -- Configure Node Resources Routes
|
||||
l_methods.enable_get
|
||||
l_methods.enable_post
|
||||
l_methods.enable_put
|
||||
router.handle_with_request_methods ("/node/{id}/summary", l_report_handler, l_methods)
|
||||
a_router.handle_with_request_methods ("/node/{id}/summary", l_report_handler, l_methods)
|
||||
end
|
||||
|
||||
|
||||
configure_api_node_title
|
||||
configure_api_node_title (a_router: WSF_ROUTER)
|
||||
local
|
||||
l_report_handler: NODE_TITLE_HANDLER
|
||||
l_methods: WSF_REQUEST_METHODS
|
||||
@@ -107,11 +99,10 @@ feature -- Configure Node Resources Routes
|
||||
l_methods.enable_get
|
||||
l_methods.enable_post
|
||||
l_methods.enable_put
|
||||
router.handle_with_request_methods ("/node/{id}/title", l_report_handler, l_methods)
|
||||
a_router.handle_with_request_methods ("/node/{id}/title", l_report_handler, l_methods)
|
||||
end
|
||||
|
||||
|
||||
configure_api_node_content
|
||||
configure_api_node_content (a_router: WSF_ROUTER)
|
||||
local
|
||||
l_report_handler: NODE_CONTENT_HANDLER
|
||||
l_methods: WSF_REQUEST_METHODS
|
||||
@@ -121,7 +112,7 @@ feature -- Configure Node Resources Routes
|
||||
l_methods.enable_get
|
||||
l_methods.enable_post
|
||||
l_methods.enable_put
|
||||
router.handle_with_request_methods ("/node/{id}/content", l_report_handler, l_methods)
|
||||
a_router.handle_with_request_methods ("/node/{id}/content", l_report_handler, l_methods)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -12,8 +12,8 @@ inherit
|
||||
REFACTORING_HELPER
|
||||
|
||||
|
||||
create make
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Initialize
|
||||
|
||||
@@ -28,7 +28,7 @@ feature -- Initialize
|
||||
|
||||
feature -- Access
|
||||
|
||||
login_valid (l_auth_login, l_auth_password: READABLE_STRING_32): BOOLEAN
|
||||
is_valid_credential (l_auth_login, l_auth_password: READABLE_STRING_32): BOOLEAN
|
||||
local
|
||||
l_security: SECURITY_PROVIDER
|
||||
do
|
||||
@@ -57,7 +57,6 @@ feature -- Access: Node
|
||||
Result := storage.node (a_id)
|
||||
end
|
||||
|
||||
|
||||
feature -- Change: Node
|
||||
|
||||
new_node (a_node: CMS_NODE)
|
||||
|
||||
@@ -42,56 +42,82 @@ create
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_setup: CMS_SETUP)
|
||||
-- Build a CMS service with `a_setup' configuration.
|
||||
do
|
||||
setup := a_setup
|
||||
configuration := a_setup.configuration
|
||||
modules := a_setup.modules
|
||||
create {ARRAYED_LIST[WSF_FILTER]} filters.make (0)
|
||||
initialize
|
||||
end
|
||||
|
||||
initialize
|
||||
-- Initialize various parts of the CMS service.
|
||||
do
|
||||
initialize_modules
|
||||
initialize_users
|
||||
initialize_auth_engine
|
||||
initialize_mailer
|
||||
initialize_router
|
||||
initialize_modules
|
||||
initialize_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
|
||||
ensure
|
||||
only_enabled_modules: across modules as ic all ic.item.is_enabled end
|
||||
end
|
||||
|
||||
initialize_users
|
||||
-- Initialize users.
|
||||
do
|
||||
end
|
||||
|
||||
initialize_mailer
|
||||
-- Initialize mailer engine.
|
||||
do
|
||||
to_implement ("To Implement mailer")
|
||||
end
|
||||
|
||||
setup_router
|
||||
do
|
||||
configure_api_root
|
||||
end
|
||||
|
||||
initialize_modules
|
||||
-- Intialize modules, import router definitions
|
||||
-- from enabled modules.
|
||||
do
|
||||
log.write_debug (generator + ".initialize_modules")
|
||||
across
|
||||
modules as m
|
||||
loop
|
||||
if m.item.is_enabled then
|
||||
router.import (m.item.router)
|
||||
end
|
||||
if attached m.item.filters as l_m_filters then
|
||||
filters.append (l_m_filters)
|
||||
end
|
||||
end
|
||||
configure_api_file_handler
|
||||
end
|
||||
|
||||
initialize_auth_engine
|
||||
do
|
||||
to_implement ("To Implement authentication engine")
|
||||
end
|
||||
|
||||
feature -- Settings: router
|
||||
|
||||
setup_router
|
||||
-- <Precursor>
|
||||
local
|
||||
l_module: CMS_MODULE
|
||||
do
|
||||
log.write_debug (generator + ".setup_router")
|
||||
-- Configure root of api handler.
|
||||
configure_api_root
|
||||
|
||||
-- Include routes from modules.
|
||||
across
|
||||
modules as ic
|
||||
loop
|
||||
l_module := ic.item
|
||||
router.import (l_module.router)
|
||||
end
|
||||
-- Configure files handler.
|
||||
configure_api_file_handler
|
||||
end
|
||||
|
||||
configure_api_root
|
||||
local
|
||||
@@ -125,7 +151,6 @@ feature -- Execute Filter
|
||||
execute_filter (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute the filter.
|
||||
do
|
||||
|
||||
res.put_header_line ("Date: " + (create {HTTP_DATE}.make_now_utc).string)
|
||||
execute_service (req, res)
|
||||
end
|
||||
@@ -136,18 +161,29 @@ feature -- Filters
|
||||
-- Create `filter'.
|
||||
local
|
||||
f, l_filter: detachable WSF_FILTER
|
||||
fh: WSF_CUSTOM_HEADER_FILTER
|
||||
l_module: CMS_MODULE
|
||||
do
|
||||
log.write_debug (generator + ".create_filter")
|
||||
l_filter := Void
|
||||
-- Maintenance
|
||||
create {WSF_MAINTENANCE_FILTER} f
|
||||
f.set_next (l_filter)
|
||||
l_filter := f
|
||||
|
||||
if attached filters as l_filters then
|
||||
across l_filters as c loop
|
||||
c.item.set_next (l_filter)
|
||||
l_filter := c.item
|
||||
-- Include filters from modules
|
||||
across
|
||||
modules as ic
|
||||
loop
|
||||
l_module := ic.item
|
||||
if
|
||||
l_module.is_enabled and then
|
||||
attached l_module.filters as l_m_filters
|
||||
then
|
||||
across l_m_filters as f_ic loop
|
||||
f := f_ic.item
|
||||
f.set_next (l_filter)
|
||||
l_filter := f
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -159,6 +195,8 @@ feature -- Filters
|
||||
local
|
||||
f: WSF_FILTER
|
||||
do
|
||||
log.write_debug (generator + ".setup_filter")
|
||||
|
||||
from
|
||||
f := filter
|
||||
until
|
||||
@@ -173,29 +211,23 @@ feature -- Filters
|
||||
feature -- Access
|
||||
|
||||
setup: CMS_SETUP
|
||||
-- CMS setup.
|
||||
-- CMS setup.
|
||||
|
||||
configuration: CMS_CONFIGURATION
|
||||
-- CMS configuration.
|
||||
-- | Maybe we can compute it (using `setup') instead of using memory.
|
||||
-- CMS configuration.
|
||||
--| Maybe we can compute it (using `setup') instead of using memory.
|
||||
|
||||
modules: LIST [CMS_MODULE]
|
||||
-- List of possible modules.
|
||||
-- | Maybe we can compute it (using `setup') instead of using memory.
|
||||
|
||||
filters: LIST[WSF_FILTER]
|
||||
-- List of possible filters.
|
||||
modules: CMS_MODULE_COLLECTION
|
||||
-- Configurator of possible modules.
|
||||
|
||||
feature -- Execution
|
||||
|
||||
execute_default (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Default request handler if no other are relevant
|
||||
local
|
||||
do
|
||||
fixme ("To Implement")
|
||||
end
|
||||
|
||||
|
||||
note
|
||||
copyright: "2011-2014, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
|
||||
@@ -45,19 +45,25 @@ feature -- Access
|
||||
local
|
||||
i: INTEGER
|
||||
utf: UTF_CONVERTER
|
||||
once
|
||||
if attached information.regions as tb and then not tb.is_empty then
|
||||
i := 1
|
||||
create Result.make_filled ("", i, i + tb.count - 1)
|
||||
across
|
||||
tb as ic
|
||||
loop
|
||||
Result.force (utf.utf_32_string_to_utf_8_string_8 (ic.key), i) -- NOTE: UTF-8 encoded !
|
||||
i := i + 1
|
||||
l_regions: like internal_regions
|
||||
do
|
||||
l_regions := internal_regions
|
||||
if l_regions = Void then
|
||||
if attached information.regions as tb and then not tb.is_empty then
|
||||
i := 1
|
||||
create l_regions.make_filled ("", i, i + tb.count - 1)
|
||||
across
|
||||
tb as ic
|
||||
loop
|
||||
l_regions.force (utf.utf_32_string_to_utf_8_string_8 (ic.key), i) -- NOTE: UTF-8 encoded !
|
||||
i := i + 1
|
||||
end
|
||||
else
|
||||
l_regions := <<"header", "content", "footer", "first_sidebar", "second_sidebar">>
|
||||
end
|
||||
else
|
||||
Result := <<"header", "content", "footer", "first_sidebar", "second_sidebar">>
|
||||
internaL_regions := l_regions
|
||||
end
|
||||
Result := l_regions
|
||||
end
|
||||
|
||||
page_template: SMARTY_CMS_PAGE_TEMPLATE
|
||||
@@ -87,6 +93,8 @@ feature -- Conversion
|
||||
|
||||
feature {NONE} -- Internal
|
||||
|
||||
internal_regions: detachable like regions
|
||||
|
||||
internal_page_template: detachable like page_template
|
||||
|
||||
invariant
|
||||
|
||||
@@ -9,15 +9,11 @@
|
||||
<option warning="true" full_class_checking="false" is_attached_by_default="true" void_safety="transitional" 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="layout" location="..\..\layout\layout.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="cms" location="..\..\cms\cms.ecf" readonly="false"/>
|
||||
<library name="layout" location="..\..\layout\layout.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"/>
|
||||
</target>
|
||||
<target name="roc_api_any" extends="common">
|
||||
<root class="EWF_ROC_SERVER" feature="make_and_launch"/>
|
||||
|
||||
@@ -43,7 +43,7 @@ feature {NONE} -- Initialization
|
||||
do
|
||||
Precursor
|
||||
service_options := create {WSF_SERVICE_LAUNCHER_OPTIONS_FROM_INI}.make_from_file ("roc.ini")
|
||||
launch_cms (cms_setup)
|
||||
initialize_cms (cms_setup)
|
||||
end
|
||||
|
||||
feature -- Service
|
||||
@@ -111,15 +111,18 @@ feature -- CMS Initialization
|
||||
create layout.make_default
|
||||
end
|
||||
create Result.make (layout)
|
||||
setup_modules (Result)
|
||||
setup_storage (Result)
|
||||
end
|
||||
|
||||
launch_cms (a_setup: CMS_SETUP)
|
||||
initialize_cms (a_setup: CMS_SETUP)
|
||||
local
|
||||
cms: CMS_SERVICE
|
||||
l_modules: CMS_MODULE_COLLECTION
|
||||
do
|
||||
log.write_debug (generator + ".launch_cms")
|
||||
log.write_debug (generator + ".initialize_cms")
|
||||
|
||||
setup_modules (a_setup)
|
||||
|
||||
create cms.make (a_setup)
|
||||
cms_service := cms
|
||||
end
|
||||
@@ -127,14 +130,18 @@ feature -- CMS Initialization
|
||||
feature -- CMS setup
|
||||
|
||||
setup_modules (a_setup: CMS_SETUP)
|
||||
-- Setup modules to be added to the CMS ecosystem.
|
||||
-- Setup additional modules.
|
||||
local
|
||||
m: CMS_MODULE
|
||||
do
|
||||
to_implement ("To implement custom modules")
|
||||
create {NODE_MODULE} m.make (a_setup)
|
||||
m.enable
|
||||
a_setup.modules.extend (m)
|
||||
end
|
||||
|
||||
setup_storage (a_setup: CMS_SETUP)
|
||||
do
|
||||
|
||||
to_implement ("To implement custom storage")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -36,45 +36,118 @@ feature -- Access: internal
|
||||
|
||||
config_path: PATH
|
||||
-- Configuration file path.
|
||||
once
|
||||
Result := path.extended ("config")
|
||||
local
|
||||
p: detachable PATH
|
||||
do
|
||||
p := internal_config_path
|
||||
if p = Void then
|
||||
p := path.extended ("config")
|
||||
internal_config_path := p
|
||||
end
|
||||
Result := p
|
||||
end
|
||||
|
||||
application_config_path: PATH
|
||||
-- Database Configuration file path.
|
||||
once
|
||||
Result := config_path.extended ("application_configuration.json")
|
||||
local
|
||||
p: detachable PATH
|
||||
do
|
||||
p := internal_application_config_path
|
||||
if p = Void then
|
||||
p := config_path.extended ("application_configuration.json")
|
||||
internal_application_config_path := p
|
||||
end
|
||||
Result := p
|
||||
end
|
||||
|
||||
logs_path: PATH
|
||||
-- Directory for logs.
|
||||
once
|
||||
Result := path.extended ("logs")
|
||||
local
|
||||
p: detachable PATH
|
||||
do
|
||||
p := internal_logs_path
|
||||
if p = Void then
|
||||
p := path.extended ("logs")
|
||||
internal_logs_path := p
|
||||
end
|
||||
Result := p
|
||||
end
|
||||
|
||||
documentation_path: PATH
|
||||
-- Directory for API documentation.
|
||||
once
|
||||
Result := path.extended ("doc")
|
||||
local
|
||||
p: detachable PATH
|
||||
do
|
||||
p := internal_documentation_path
|
||||
if p = Void then
|
||||
p := path.extended ("doc")
|
||||
internal_documentation_path := p
|
||||
end
|
||||
Result := p
|
||||
end
|
||||
|
||||
www_path: PATH
|
||||
-- Directory for www.
|
||||
once
|
||||
Result := path.extended ("www")
|
||||
local
|
||||
p: detachable PATH
|
||||
do
|
||||
p := internal_www_path
|
||||
if p = Void then
|
||||
p := path.extended ("www")
|
||||
internal_www_path := p
|
||||
end
|
||||
Result := p
|
||||
end
|
||||
|
||||
assets_path: PATH
|
||||
-- Directory for public assets.
|
||||
-- css, images, js.
|
||||
once
|
||||
Result := path.extended ("www").extended ("assets")
|
||||
local
|
||||
p: detachable PATH
|
||||
do
|
||||
p := internal_assets_path
|
||||
if p = Void then
|
||||
p := www_path.extended ("assets")
|
||||
internal_assets_path := p
|
||||
end
|
||||
Result := p
|
||||
end
|
||||
|
||||
template_path: PATH
|
||||
-- Directory for templates (HTML, etc).
|
||||
once
|
||||
Result := www_path.extended ("template")
|
||||
local
|
||||
p: detachable PATH
|
||||
do
|
||||
p := internal_template_path
|
||||
if p = Void then
|
||||
p := www_path.extended ("template")
|
||||
internal_template_path := p
|
||||
end
|
||||
Result := p
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
internal_config_path: detachable like config_path
|
||||
-- Configuration file path.
|
||||
|
||||
internal_application_config_path: detachable like application_config_path
|
||||
-- Database Configuration file path.
|
||||
|
||||
internal_logs_path: detachable like logs_path
|
||||
-- Directory for logs.
|
||||
|
||||
internal_documentation_path: detachable like documentation_path
|
||||
-- Directory for API documentation.
|
||||
|
||||
internal_www_path: detachable like www_path
|
||||
-- Directory for www.
|
||||
|
||||
internal_assets_path: detachable like assets_path
|
||||
-- Directory for public assets.
|
||||
-- css, images, js.
|
||||
|
||||
internal_template_path: detachable like template_path
|
||||
-- Directory for templates (HTML, etc).
|
||||
|
||||
end
|
||||
|
||||
@@ -80,7 +80,7 @@ feature -- Cursor
|
||||
|
||||
feature -- Action
|
||||
|
||||
action: FUNCTION [ANY, detachable TUPLE [], G]
|
||||
action: FUNCTION [ANY, detachable TUPLE, G]
|
||||
-- Agent to create a new item of type G.
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
Reference in New Issue
Block a user