Moved library/src to src
This commit is contained in:
258
src/service/cms_api.e
Normal file
258
src/service/cms_api.e
Normal file
@@ -0,0 +1,258 @@
|
||||
note
|
||||
description: "API for a CMS"
|
||||
date: "$Date: 2015-01-27 19:15:02 +0100 (mar., 27 janv. 2015) $"
|
||||
revision: "$Revision: 96542 $"
|
||||
|
||||
class
|
||||
CMS_API
|
||||
|
||||
inherit
|
||||
ANY
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
SHARED_HTML_ENCODER
|
||||
export
|
||||
{NONE} all
|
||||
end
|
||||
|
||||
SHARED_WSF_PERCENT_ENCODER
|
||||
export
|
||||
{NONE} all
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Initialize
|
||||
|
||||
make (a_setup: CMS_SETUP)
|
||||
-- Create the API service with a setup `a_setup'
|
||||
do
|
||||
setup := a_setup
|
||||
create error_handler.make
|
||||
initialize
|
||||
ensure
|
||||
setup_set: setup = a_setup
|
||||
error_handler_set: not error_handler.has_error
|
||||
end
|
||||
|
||||
setup: CMS_SETUP
|
||||
-- CMS setup.
|
||||
|
||||
initialize
|
||||
-- Initialize the persitent layer.
|
||||
do
|
||||
to_implement ("Refactor database setup")
|
||||
if attached setup.storage (error_handler) as l_storage then
|
||||
storage := l_storage
|
||||
else
|
||||
create {CMS_STORAGE_NULL} storage
|
||||
end
|
||||
end
|
||||
|
||||
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.
|
||||
|
||||
feature -- Status Report
|
||||
|
||||
is_valid_credential (a_auth_login, a_auth_password: READABLE_STRING_32): BOOLEAN
|
||||
-- Is the credentials `a_auth_login' and `a_auth_password' valid?
|
||||
do
|
||||
Result := storage.is_valid_credential (a_auth_login, a_auth_password)
|
||||
end
|
||||
|
||||
feature -- Access: Node
|
||||
|
||||
nodes_count: INTEGER_64
|
||||
do
|
||||
Result := storage.nodes_count
|
||||
end
|
||||
|
||||
nodes: LIST [CMS_NODE]
|
||||
-- List of nodes.
|
||||
do
|
||||
Result := storage.nodes
|
||||
end
|
||||
|
||||
recent_nodes (a_offset, a_rows: INTEGER): LIST [CMS_NODE]
|
||||
-- List of the `a_rows' most recent nodes starting from `a_offset'.
|
||||
do
|
||||
Result := storage.recent_nodes (a_offset, a_rows)
|
||||
end
|
||||
|
||||
node (a_id: INTEGER_64): detachable CMS_NODE
|
||||
-- Node by ID.
|
||||
do
|
||||
debug ("refactor_fixme")
|
||||
fixme ("Check preconditions")
|
||||
end
|
||||
Result := storage.node_by_id (a_id)
|
||||
end
|
||||
|
||||
feature -- Change: Node
|
||||
|
||||
new_node (a_node: CMS_NODE)
|
||||
-- Add a new node `a_node'
|
||||
require
|
||||
no_id: not a_node.has_id
|
||||
do
|
||||
storage.new_node (a_node)
|
||||
end
|
||||
|
||||
delete_node (a_node: CMS_NODE)
|
||||
-- Delete `a_node'.
|
||||
do
|
||||
if a_node.has_id then
|
||||
storage.delete_node (a_node)
|
||||
end
|
||||
end
|
||||
|
||||
update_node (a_node: CMS_NODE)
|
||||
-- Update node `a_node' data.
|
||||
do
|
||||
storage.update_node (a_node)
|
||||
end
|
||||
|
||||
update_node_title (a_user_id: like {CMS_USER}.id; a_node_id: like {CMS_NODE}.id; a_title: READABLE_STRING_32)
|
||||
-- Update node title, with user identified by `a_id', with node id `a_node_id' and a new title `a_title'.
|
||||
do
|
||||
debug ("refactor_fixme")
|
||||
fixme ("Check preconditions")
|
||||
end
|
||||
storage.update_node_title (a_user_id, a_node_id, a_title)
|
||||
end
|
||||
|
||||
update_node_summary (a_user_id: like {CMS_USER}.id; a_node_id: like {CMS_NODE}.id; a_summary: READABLE_STRING_32)
|
||||
-- Update node summary, with user identified by `a_user_id', with node id `a_node_id' and a new summary `a_summary'.
|
||||
do
|
||||
debug ("refactor_fixme")
|
||||
fixme ("Check preconditions")
|
||||
end
|
||||
storage.update_node_summary (a_user_id, a_node_id, a_summary)
|
||||
end
|
||||
|
||||
update_node_content (a_user_id: like {CMS_USER}.id; a_node_id: like {CMS_NODE}.id; a_content: READABLE_STRING_32)
|
||||
-- Update node content, with user identified by `a_user_id', with node id `a_node_id' and a new content `a_content'.
|
||||
do
|
||||
debug ("refactor_fixme")
|
||||
fixme ("Check preconditions")
|
||||
end
|
||||
storage.update_node_content (a_user_id, a_node_id, a_content)
|
||||
end
|
||||
|
||||
|
||||
feature -- Access: User
|
||||
|
||||
user_by_name (a_username: READABLE_STRING_32): detachable CMS_USER
|
||||
-- User by name `a_user_name', if any.
|
||||
do
|
||||
Result := storage.user_by_name (a_username)
|
||||
end
|
||||
|
||||
feature -- Change User
|
||||
|
||||
new_user (a_user: CMS_USER)
|
||||
-- Add a new user `a_user'.
|
||||
require
|
||||
no_id: not a_user.has_id
|
||||
no_hashed_password: a_user.hashed_password = Void
|
||||
do
|
||||
if
|
||||
attached a_user.password as l_password and then
|
||||
attached a_user.email as l_email
|
||||
then
|
||||
storage.new_user (a_user)
|
||||
else
|
||||
debug ("refactor_fixme")
|
||||
fixme ("Add error")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
update_user (a_user: CMS_USER)
|
||||
-- Update user `a_user'.
|
||||
require
|
||||
has_id: a_user.has_id
|
||||
do
|
||||
storage.update_user (a_user)
|
||||
end
|
||||
|
||||
feature -- Helpers
|
||||
|
||||
html_encoded (a_string: READABLE_STRING_GENERAL): STRING_8
|
||||
-- `a_string' encoded for html output.
|
||||
do
|
||||
Result := html_encoder.general_encoded_string (a_string)
|
||||
end
|
||||
|
||||
percent_encoded (a_string: READABLE_STRING_GENERAL): STRING_8
|
||||
-- `a_string' encoded with percent encoding, mainly used for url.
|
||||
do
|
||||
Result := percent_encoder.percent_encoded_string (a_string)
|
||||
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.
|
||||
|
||||
end
|
||||
|
||||
17
src/service/cms_api_options.e
Normal file
17
src/service/cms_api_options.e
Normal file
@@ -0,0 +1,17 @@
|
||||
note
|
||||
description: "Summary description for {CMS_API_OPTIONS}."
|
||||
author: ""
|
||||
date: "$Date: 2014-11-13 16:23:47 +0100 (jeu., 13 nov. 2014) $"
|
||||
revision: "$Revision: 96085 $"
|
||||
|
||||
class
|
||||
CMS_API_OPTIONS
|
||||
|
||||
inherit
|
||||
WSF_API_OPTIONS
|
||||
|
||||
create
|
||||
make,
|
||||
make_from_manifest
|
||||
|
||||
end
|
||||
58
src/service/cms_request_util.e
Normal file
58
src/service/cms_request_util.e
Normal file
@@ -0,0 +1,58 @@
|
||||
note
|
||||
description: "Summary description for {CMS_REQUEST_UTIL}."
|
||||
author: ""
|
||||
date: "$Date: 2014-11-13 16:23:47 +0100 (jeu., 13 nov. 2014) $"
|
||||
revision: "$Revision: 96085 $"
|
||||
|
||||
deferred class
|
||||
CMS_REQUEST_UTIL
|
||||
|
||||
inherit
|
||||
|
||||
CMS_ENCODERS
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
feature -- User
|
||||
|
||||
current_user_name (req: WSF_REQUEST): detachable READABLE_STRING_32
|
||||
-- Current user name or Void in case of Guest users.
|
||||
note
|
||||
EIS: "src=eiffel:?class=AUTHENTICATION_FILTER&feature=execute"
|
||||
do
|
||||
if attached {CMS_USER} current_user (req) as l_user then
|
||||
Result := l_user.name
|
||||
end
|
||||
end
|
||||
|
||||
current_user (req: WSF_REQUEST): detachable CMS_USER
|
||||
-- Current user or Void in case of Guest user.
|
||||
note
|
||||
EIS: "eiffel:?class=AUTHENTICATION_FILTER&feature=execute"
|
||||
do
|
||||
if attached {CMS_USER} req.execution_variable ("user") as l_user then
|
||||
Result := l_user
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Media Type
|
||||
|
||||
current_media_type (req: WSF_REQUEST): detachable READABLE_STRING_32
|
||||
-- Current media type or Void if it's not acceptable.
|
||||
do
|
||||
if attached {STRING} req.execution_variable ("media_type") as l_type then
|
||||
Result := l_type
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Absolute Host
|
||||
|
||||
absolute_host (req: WSF_REQUEST; a_path:STRING): STRING
|
||||
do
|
||||
Result := req.absolute_script_url (a_path)
|
||||
if Result.last_index_of ('/', Result.count) = Result.count then
|
||||
Result.remove_tail (1)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
261
src/service/cms_service.e
Normal file
261
src/service/cms_service.e
Normal file
@@ -0,0 +1,261 @@
|
||||
note
|
||||
description: "[
|
||||
This class implements the CMS service
|
||||
|
||||
It could be used to implement the main EWF service, or
|
||||
even for a specific handler.
|
||||
]"
|
||||
|
||||
class
|
||||
CMS_SERVICE
|
||||
|
||||
inherit
|
||||
WSF_ROUTED_SKELETON_SERVICE
|
||||
rename
|
||||
execute as execute_service
|
||||
undefine
|
||||
requires_proxy
|
||||
redefine
|
||||
execute_default
|
||||
end
|
||||
|
||||
WSF_FILTERED_SERVICE
|
||||
|
||||
WSF_FILTER
|
||||
rename
|
||||
execute as execute_filter
|
||||
end
|
||||
|
||||
WSF_NO_PROXY_POLICY
|
||||
|
||||
WSF_URI_HELPER_FOR_ROUTED_SERVICE
|
||||
|
||||
WSF_URI_TEMPLATE_HELPER_FOR_ROUTED_SERVICE
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
SHARED_LOGGER
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_api: CMS_API)
|
||||
-- Build a CMS service with `a_api'
|
||||
do
|
||||
api := a_api
|
||||
initialize
|
||||
ensure
|
||||
api_set: api = a_api
|
||||
end
|
||||
|
||||
initialize
|
||||
-- Initialize various parts of the CMS service.
|
||||
do
|
||||
initialize_modules
|
||||
initialize_users
|
||||
initialize_auth_engine
|
||||
initialize_mailer
|
||||
-- initialize_router
|
||||
-- initialize_filter: expanded here, for void-safety concern.
|
||||
create_filter
|
||||
initialize_router
|
||||
setup_filter
|
||||
end
|
||||
|
||||
initialize_modules
|
||||
-- Intialize modules and keep only enabled modules.
|
||||
do
|
||||
modules := setup.enabled_modules
|
||||
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
|
||||
|
||||
initialize_auth_engine
|
||||
do
|
||||
to_implement ("To Implement authentication engine")
|
||||
end
|
||||
|
||||
feature -- Settings: router
|
||||
|
||||
setup_router
|
||||
-- <Precursor>
|
||||
local
|
||||
l_module: CMS_MODULE
|
||||
l_api: like api
|
||||
l_router: like router
|
||||
do
|
||||
log.write_debug (generator + ".setup_router")
|
||||
-- Configure root of api handler.
|
||||
|
||||
l_router := router
|
||||
configure_api_root (l_router)
|
||||
|
||||
-- Include routes from modules.
|
||||
l_api := api
|
||||
across
|
||||
modules as ic
|
||||
loop
|
||||
l_module := ic.item
|
||||
l_router.import (l_module.router (l_api))
|
||||
end
|
||||
-- Configure files handler.
|
||||
configure_api_file_handler (l_router)
|
||||
end
|
||||
|
||||
configure_api_root (a_router: WSF_ROUTER)
|
||||
local
|
||||
l_root_handler: CMS_ROOT_HANDLER
|
||||
l_methods: WSF_REQUEST_METHODS
|
||||
do
|
||||
log.write_debug (generator + ".configure_api_root")
|
||||
create l_root_handler.make (api)
|
||||
create l_methods
|
||||
l_methods.enable_get
|
||||
a_router.handle_with_request_methods ("/", l_root_handler, l_methods)
|
||||
a_router.handle_with_request_methods ("", l_root_handler, l_methods)
|
||||
end
|
||||
|
||||
configure_api_file_handler (a_router: WSF_ROUTER)
|
||||
local
|
||||
fhdl: WSF_FILE_SYSTEM_HANDLER
|
||||
do
|
||||
log.write_debug (generator + ".configure_api_file_handler")
|
||||
|
||||
create fhdl.make_hidden_with_path (setup.theme_assets_location)
|
||||
fhdl.disable_index
|
||||
fhdl.set_not_found_handler (agent (ia_uri: READABLE_STRING_8; ia_req: WSF_REQUEST; ia_res: WSF_RESPONSE)
|
||||
do
|
||||
execute_default (ia_req, ia_res)
|
||||
end)
|
||||
a_router.handle_with_request_methods ("/theme/", fhdl, router.methods_GET)
|
||||
|
||||
|
||||
create fhdl.make_hidden_with_path (setup.layout.www_path)
|
||||
fhdl.disable_index
|
||||
fhdl.set_not_found_handler (agent (ia_uri: READABLE_STRING_8; ia_req: WSF_REQUEST; ia_res: WSF_RESPONSE)
|
||||
do
|
||||
execute_default (ia_req, ia_res)
|
||||
end)
|
||||
a_router.handle_with_request_methods ("/", fhdl, router.methods_GET)
|
||||
end
|
||||
|
||||
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)
|
||||
res.put_header_line ("X-EWF-Server: CMS_v1.0")
|
||||
execute_service (req, res)
|
||||
end
|
||||
|
||||
feature -- Filters
|
||||
|
||||
create_filter
|
||||
-- Create `filter'.
|
||||
local
|
||||
f, l_filter: detachable WSF_FILTER
|
||||
l_module: CMS_MODULE
|
||||
l_api: like api
|
||||
do
|
||||
log.write_debug (generator + ".create_filter")
|
||||
l_filter := Void
|
||||
|
||||
-- Maintenance
|
||||
create {WSF_MAINTENANCE_FILTER} f
|
||||
f.set_next (l_filter)
|
||||
l_filter := f
|
||||
|
||||
-- Error Filter
|
||||
create {CMS_ERROR_FILTER} f.make (api)
|
||||
f.set_next (l_filter)
|
||||
l_filter := f
|
||||
|
||||
-- Include filters from modules
|
||||
l_api := api
|
||||
across
|
||||
modules as ic
|
||||
loop
|
||||
l_module := ic.item
|
||||
if
|
||||
l_module.is_enabled and then
|
||||
attached l_module.filters (l_api) 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
|
||||
|
||||
filter := l_filter
|
||||
end
|
||||
|
||||
setup_filter
|
||||
-- Setup `filter'.
|
||||
local
|
||||
f: WSF_FILTER
|
||||
do
|
||||
log.write_debug (generator + ".setup_filter")
|
||||
|
||||
from
|
||||
f := filter
|
||||
until
|
||||
not attached f.next as l_next
|
||||
loop
|
||||
f := l_next
|
||||
end
|
||||
f.set_next (Current)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
api: CMS_API
|
||||
-- API service.
|
||||
|
||||
setup: CMS_SETUP
|
||||
-- CMS setup.
|
||||
do
|
||||
Result := api.setup
|
||||
end
|
||||
|
||||
modules: CMS_MODULE_COLLECTION
|
||||
-- Configurator of possible modules.
|
||||
|
||||
feature -- Execution
|
||||
|
||||
execute_default (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Default request handler if no other are relevant
|
||||
local
|
||||
r: NOT_FOUND_ERROR_CMS_RESPONSE
|
||||
do
|
||||
to_implement ("Default response for CMS_SERVICE")
|
||||
create r.make (req, res, api)
|
||||
r.execute
|
||||
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
|
||||
129
src/service/cms_url_utilities.e
Normal file
129
src/service/cms_url_utilities.e
Normal file
@@ -0,0 +1,129 @@
|
||||
note
|
||||
description: "Summary description for {CMS_URL_UTILITIES}."
|
||||
author: ""
|
||||
date: "$Date: 2014-11-13 16:23:47 +0100 (jeu., 13 nov. 2014) $"
|
||||
revision: "$Revision: 96085 $"
|
||||
|
||||
deferred class
|
||||
CMS_URL_UTILITIES
|
||||
|
||||
inherit
|
||||
CMS_REQUEST_UTIL
|
||||
|
||||
feature -- Core
|
||||
|
||||
site_url: READABLE_STRING_8
|
||||
deferred
|
||||
end
|
||||
|
||||
base_url: detachable READABLE_STRING_8
|
||||
-- Base url if any.
|
||||
deferred
|
||||
end
|
||||
|
||||
based_path (p: STRING): STRING
|
||||
-- Path `p' in the context of the `base_url'
|
||||
do
|
||||
if attached base_url as l_base_url then
|
||||
create Result.make_from_string (l_base_url)
|
||||
if p.is_empty then
|
||||
else
|
||||
if p[1] = '/' then
|
||||
Result.append (p.substring (2, p.count))
|
||||
else
|
||||
Result.append (p)
|
||||
end
|
||||
end
|
||||
else
|
||||
Result := p
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Url
|
||||
|
||||
absolute_url (a_path: STRING; opts: detachable CMS_API_OPTIONS): STRING
|
||||
local
|
||||
l_opts: detachable CMS_API_OPTIONS
|
||||
do
|
||||
l_opts := opts
|
||||
if l_opts = Void then
|
||||
create l_opts.make (1)
|
||||
end
|
||||
l_opts.force (True, "absolute")
|
||||
Result := url (a_path, l_opts)
|
||||
end
|
||||
|
||||
url (a_path: READABLE_STRING_8; opts: detachable CMS_API_OPTIONS): STRING
|
||||
-- URL for path `a_path' and optional parameters from `opts'.
|
||||
--| Options `opts' could be
|
||||
--| - absolute: True|False => return absolute url
|
||||
--| - query: string => append "?query"
|
||||
--| - fragment: string => append "#fragment"
|
||||
local
|
||||
q,f: detachable STRING_8
|
||||
l_abs: BOOLEAN
|
||||
do
|
||||
l_abs := False
|
||||
|
||||
if opts /= Void then
|
||||
l_abs := opts.boolean_item ("absolute", l_abs)
|
||||
if attached opts.item ("query") as l_query then
|
||||
if attached {READABLE_STRING_8} l_query as s_value then
|
||||
q := s_value
|
||||
elseif attached {ITERABLE [TUPLE [key, value: READABLE_STRING_GENERAL]]} l_query as lst then
|
||||
create q.make_empty
|
||||
across
|
||||
lst as c
|
||||
loop
|
||||
if q.is_empty then
|
||||
else
|
||||
q.append_character ('&')
|
||||
end
|
||||
q.append (url_encoded (c.item.key))
|
||||
q.append_character ('=')
|
||||
q.append (url_encoded (c.item.value))
|
||||
end
|
||||
end
|
||||
end
|
||||
if attached opts.string_item ("fragment") as s_frag then
|
||||
f := s_frag
|
||||
end
|
||||
end
|
||||
if l_abs then
|
||||
if a_path.substring_index ("://", 1) = 0 then
|
||||
create Result.make_from_string (site_url)
|
||||
if a_path.is_empty then
|
||||
elseif Result.ends_with ("/") then
|
||||
if a_path[1] = '/' then
|
||||
Result.append_string (a_path.substring (2, a_path.count))
|
||||
else
|
||||
Result.append_string (a_path)
|
||||
end
|
||||
else
|
||||
if a_path[1] = '/' then
|
||||
Result.append_string (a_path)
|
||||
else
|
||||
Result.append_character ('/')
|
||||
Result.append_string (a_path)
|
||||
end
|
||||
end
|
||||
else
|
||||
Result := a_path
|
||||
end
|
||||
else
|
||||
Result := based_path (a_path)
|
||||
end
|
||||
if q /= Void then
|
||||
Result.append ("?" + q)
|
||||
end
|
||||
if f /= Void then
|
||||
Result.append ("#" + f)
|
||||
end
|
||||
end
|
||||
|
||||
checked_url (a_url: READABLE_STRING_8): READABLE_STRING_8
|
||||
do
|
||||
Result := a_url
|
||||
end
|
||||
|
||||
end
|
||||
40
src/service/filter/cms_error_filter.e
Normal file
40
src/service/filter/cms_error_filter.e
Normal file
@@ -0,0 +1,40 @@
|
||||
note
|
||||
description: "Summary description for {CMS_ERROR_FILTER}."
|
||||
date: "$Date: 2014-12-19 14:17:32 +0100 (ven., 19 déc. 2014) $"
|
||||
revision: "$Revision: 96402 $"
|
||||
|
||||
class
|
||||
CMS_ERROR_FILTER
|
||||
|
||||
inherit
|
||||
|
||||
WSF_URI_TEMPLATE_HANDLER
|
||||
CMS_HANDLER
|
||||
WSF_FILTER
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute the filter
|
||||
do
|
||||
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.as_string_representation )
|
||||
(create {INTERNAL_SERVER_ERROR_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
api.reset
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
38
src/service/handler/cms_handler.e
Normal file
38
src/service/handler/cms_handler.e
Normal file
@@ -0,0 +1,38 @@
|
||||
note
|
||||
description: "Summary description for {CMS_HANDLER}."
|
||||
author: ""
|
||||
date: "$Date: 2014-11-13 16:23:47 +0100 (jeu., 13 nov. 2014) $"
|
||||
revision: "$Revision: 96085 $"
|
||||
|
||||
deferred class
|
||||
CMS_HANDLER
|
||||
|
||||
inherit
|
||||
|
||||
WSF_HANDLER
|
||||
|
||||
CMS_REQUEST_UTIL
|
||||
|
||||
SHARED_LOGGER
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_api: CMS_API)
|
||||
do
|
||||
api := a_api
|
||||
end
|
||||
|
||||
feature -- Setup
|
||||
|
||||
setup: CMS_SETUP
|
||||
do
|
||||
Result := api.setup
|
||||
end
|
||||
|
||||
feature -- API Service
|
||||
|
||||
api: CMS_API
|
||||
|
||||
end
|
||||
54
src/service/handler/cms_root_handler.e
Normal file
54
src/service/handler/cms_root_handler.e
Normal file
@@ -0,0 +1,54 @@
|
||||
note
|
||||
description: "Summary description for {CMS_ROOT_HANDLER}."
|
||||
date: "$Date: 2014-11-13 16:23:47 +0100 (jeu., 13 nov. 2014) $"
|
||||
revision: "$Revision: 96085 $"
|
||||
|
||||
class
|
||||
CMS_ROOT_HANDLER
|
||||
|
||||
inherit
|
||||
|
||||
CMS_HANDLER
|
||||
|
||||
WSF_FILTER
|
||||
|
||||
WSF_URI_HANDLER
|
||||
rename
|
||||
execute as uri_execute,
|
||||
new_mapping as new_uri_mapping
|
||||
end
|
||||
|
||||
WSF_RESOURCE_HANDLER_HELPER
|
||||
redefine
|
||||
do_get
|
||||
end
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- execute
|
||||
|
||||
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute request handler
|
||||
do
|
||||
execute_methods (req, res)
|
||||
execute_next (req, res)
|
||||
end
|
||||
|
||||
uri_execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute request handler
|
||||
do
|
||||
execute_methods (req, res)
|
||||
end
|
||||
|
||||
feature -- HTTP Methods
|
||||
|
||||
do_get (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- <Precursor>
|
||||
do
|
||||
(create {HOME_CMS_RESPONSE}.make (req, res, api)).execute
|
||||
end
|
||||
|
||||
end
|
||||
38
src/service/response/bad_request_error_cms_response.e
Normal file
38
src/service/response/bad_request_error_cms_response.e
Normal file
@@ -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
|
||||
61
src/service/response/cms_generic_response.e
Normal file
61
src/service/response/cms_generic_response.e
Normal file
@@ -0,0 +1,61 @@
|
||||
note
|
||||
description: "Summary description for {CMS_GENERIC_RESPONSE}."
|
||||
date: "$Date: 2014-11-13 16:23:47 +0100 (jeu., 13 nov. 2014) $"
|
||||
revision: "$Revision: 96085 $"
|
||||
|
||||
class
|
||||
CMS_GENERIC_RESPONSE
|
||||
|
||||
feature -- Responses
|
||||
|
||||
new_response_redirect (req: WSF_REQUEST; res: WSF_RESPONSE; a_location: READABLE_STRING_32)
|
||||
-- Redirect to `a_location'
|
||||
local
|
||||
h: HTTP_HEADER
|
||||
do
|
||||
create h.make
|
||||
h.put_content_type_text_html
|
||||
h.put_current_date
|
||||
h.put_location (a_location)
|
||||
res.set_status_code ({HTTP_STATUS_CODE}.see_other)
|
||||
res.put_header_text (h.string)
|
||||
end
|
||||
|
||||
new_response_authenticate (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Handle authenticate.
|
||||
local
|
||||
h: HTTP_HEADER
|
||||
do
|
||||
create h.make
|
||||
h.put_content_type_text_html
|
||||
h.put_current_date
|
||||
h.put_header_key_value ({HTTP_HEADER_NAMES}.header_www_authenticate, "Basic realm=%"CMSRoc-User%"")
|
||||
res.set_status_code ({HTTP_STATUS_CODE}.unauthorized)
|
||||
res.put_header_text (h.string)
|
||||
end
|
||||
|
||||
new_response_denied (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Handle access denied.
|
||||
local
|
||||
h: HTTP_HEADER
|
||||
do
|
||||
create h.make
|
||||
h.put_content_type_text_html
|
||||
h.put_current_date
|
||||
res.set_status_code ({HTTP_STATUS_CODE}.unauthorized)
|
||||
res.put_header_text (h.string)
|
||||
end
|
||||
|
||||
new_response_unauthorized (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Handle not authorized.
|
||||
local
|
||||
h: HTTP_HEADER
|
||||
do
|
||||
create h.make
|
||||
h.put_content_type_text_html
|
||||
h.put_current_date
|
||||
res.set_status_code ({HTTP_STATUS_CODE}.forbidden)
|
||||
res.put_header_text (h.string)
|
||||
end
|
||||
|
||||
end
|
||||
1024
src/service/response/cms_response.e
Normal file
1024
src/service/response/cms_response.e
Normal file
File diff suppressed because it is too large
Load Diff
37
src/service/response/generic_view_cms_response.e
Normal file
37
src/service/response/generic_view_cms_response.e
Normal file
@@ -0,0 +1,37 @@
|
||||
note
|
||||
description: "Summary description for {NODE_VIEW_CMS_RESPONSE}."
|
||||
date: "$Date: 2014-11-13 16:23:47 +0100 (jeu., 13 nov. 2014) $"
|
||||
revision: "$Revision: 96085 $"
|
||||
|
||||
class
|
||||
GENERIC_VIEW_CMS_RESPONSE
|
||||
|
||||
inherit
|
||||
|
||||
CMS_RESPONSE
|
||||
redefine
|
||||
custom_prepare
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Generation
|
||||
|
||||
custom_prepare (page: CMS_HTML_PAGE)
|
||||
do
|
||||
if attached variables as l_variables then
|
||||
across l_variables as c loop page.register_variable (c.item, c.key) end
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Execution
|
||||
|
||||
process
|
||||
-- Computed response message.
|
||||
do
|
||||
-- set_title ("CMS")
|
||||
-- set_page_title (Void)
|
||||
end
|
||||
end
|
||||
|
||||
36
src/service/response/home_cms_response.e
Normal file
36
src/service/response/home_cms_response.e
Normal file
@@ -0,0 +1,36 @@
|
||||
note
|
||||
description: "Summary description for {HOME_CMS_RESPONSE}."
|
||||
date: "$Date: 2014-12-17 13:14:43 +0100 (mer., 17 déc. 2014) $"
|
||||
revision: "$Revision: 96367 $"
|
||||
|
||||
class
|
||||
HOME_CMS_RESPONSE
|
||||
|
||||
inherit
|
||||
|
||||
CMS_RESPONSE
|
||||
redefine
|
||||
custom_prepare
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Generation
|
||||
|
||||
custom_prepare (page: CMS_HTML_PAGE)
|
||||
do
|
||||
Precursor (page)
|
||||
-- page.register_variable (api.recent_nodes (0, 5), "nodes")
|
||||
end
|
||||
|
||||
feature -- Execution
|
||||
|
||||
process
|
||||
-- Computed response message.
|
||||
do
|
||||
set_title (Void)
|
||||
set_page_title (Void)
|
||||
end
|
||||
end
|
||||
|
||||
38
src/service/response/internal_server_error_cms_response.e
Normal file
38
src/service/response/internal_server_error_cms_response.e
Normal file
@@ -0,0 +1,38 @@
|
||||
note
|
||||
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
|
||||
INTERNAL_SERVER_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}.internal_server_error)
|
||||
page.register_variable (page.status_code.out, "code")
|
||||
end
|
||||
|
||||
feature -- Execution
|
||||
|
||||
process
|
||||
-- Computed response message.
|
||||
do
|
||||
set_title ("Internal Server Error")
|
||||
set_page_title (Void)
|
||||
set_main_content ("<em>Internal Server Error</em>")
|
||||
end
|
||||
end
|
||||
|
||||
38
src/service/response/not_found_error_cms_response.e
Normal file
38
src/service/response/not_found_error_cms_response.e
Normal file
@@ -0,0 +1,38 @@
|
||||
note
|
||||
description: "Summary description for {NOT_FOUND_ERROR_CMS_RESPONSE}."
|
||||
date: "$Date: 2014-11-13 19:34:00 +0100 (jeu., 13 nov. 2014) $"
|
||||
revision: "$Revision: 96086 $"
|
||||
|
||||
class
|
||||
NOT_FOUND_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}.not_found)
|
||||
page.register_variable (page.status_code.out, "code")
|
||||
end
|
||||
|
||||
feature -- Execution
|
||||
|
||||
process
|
||||
-- Computed response message.
|
||||
do
|
||||
set_title ("Not Found")
|
||||
set_page_title ("Not Found")
|
||||
set_main_content ("<em>The requested page could not be found.</em>")
|
||||
end
|
||||
end
|
||||
|
||||
40
src/service/response/not_implemented_error_cms_response.e
Normal file
40
src/service/response/not_implemented_error_cms_response.e
Normal file
@@ -0,0 +1,40 @@
|
||||
note
|
||||
description: "Summary description for {NOT_IMPLEMENTED_ERROR_CMS_RESPONSE}."
|
||||
date: "$Date: 2015-01-27 19:15:02 +0100 (mar., 27 janv. 2015) $"
|
||||
revision: "$Revision: 96542 $"
|
||||
|
||||
class
|
||||
NOT_IMPLEMENTED_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}.not_implemented)
|
||||
page.register_variable (page.status_code.out, "code")
|
||||
end
|
||||
|
||||
feature -- Execution
|
||||
|
||||
process
|
||||
-- Computed response message.
|
||||
do
|
||||
set_title ("Not Implemented")
|
||||
set_page_title (Void)
|
||||
if main_content = Void then
|
||||
set_main_content (request.percent_encoded_path_info + " is not implemented!")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user