Updated CMS code.
Separated code to have a lib and an example. Improved design, fixed a few issues related to folder location. This is still experimental and require more work to be really friendly to use.
This commit is contained in:
58
draft/application/cms/src/handler/any_cms_execution.e
Normal file
58
draft/application/cms/src/handler/any_cms_execution.e
Normal file
@@ -0,0 +1,58 @@
|
||||
note
|
||||
description: "[
|
||||
This class implements the web service
|
||||
|
||||
It inherits from WSF_DEFAULT_SERVICE to get default EWF connector ready
|
||||
And from WSF_URI_TEMPLATE_ROUTED_SERVICE to use the router service
|
||||
|
||||
`initialize' can be redefine to provide custom options if needed.
|
||||
]"
|
||||
|
||||
class
|
||||
ANY_CMS_EXECUTION
|
||||
|
||||
inherit
|
||||
CMS_EXECUTION
|
||||
|
||||
create
|
||||
make,
|
||||
make_with_text
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_with_text (req: WSF_REQUEST; res: WSF_RESPONSE; h: like service; t: like text)
|
||||
do
|
||||
make (req, res, h)
|
||||
text := t
|
||||
end
|
||||
|
||||
text: detachable STRING
|
||||
|
||||
feature -- Execution
|
||||
|
||||
process
|
||||
-- Computed response message.
|
||||
local
|
||||
b: STRING_8
|
||||
s: STRING
|
||||
do
|
||||
create b.make_empty
|
||||
if attached text as t then
|
||||
s := request.path_info
|
||||
if attached service.base_url as l_base_url then
|
||||
if s.starts_with (l_base_url) then
|
||||
s.remove_head (l_base_url.count)
|
||||
if s.starts_with ("/") then
|
||||
s.remove_head (1)
|
||||
end
|
||||
end
|
||||
end
|
||||
set_title (s)
|
||||
b.append (t)
|
||||
else
|
||||
set_title ("Page Not Found")
|
||||
end
|
||||
set_main_content (b)
|
||||
end
|
||||
|
||||
end
|
||||
16
draft/application/cms/src/handler/cms_file_system_handler.e
Normal file
16
draft/application/cms/src/handler/cms_file_system_handler.e
Normal file
@@ -0,0 +1,16 @@
|
||||
note
|
||||
description: "Summary description for {CMS_FILE_SYSTEM_HANDLER}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CMS_FILE_SYSTEM_HANDLER
|
||||
|
||||
inherit
|
||||
WSF_FILE_SYSTEM_HANDLER
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
end
|
||||
64
draft/application/cms/src/handler/cms_handler.e
Normal file
64
draft/application/cms/src/handler/cms_handler.e
Normal file
@@ -0,0 +1,64 @@
|
||||
note
|
||||
description: "Summary description for {CMS_HANDLER}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CMS_HANDLER
|
||||
|
||||
inherit
|
||||
WSF_URI_HANDLER
|
||||
rename
|
||||
execute as execute_uri
|
||||
undefine
|
||||
new_mapping
|
||||
end
|
||||
|
||||
WSF_URI_TEMPLATE_HANDLER
|
||||
rename
|
||||
execute as execute_uri_template
|
||||
end
|
||||
|
||||
WSF_STARTS_WITH_HANDLER
|
||||
rename
|
||||
execute as execute_starts_with
|
||||
undefine
|
||||
new_mapping
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (e: like action)
|
||||
do
|
||||
action := e
|
||||
end
|
||||
|
||||
action: PROCEDURE [ANY, TUPLE [req: WSF_REQUEST; res: WSF_RESPONSE]]
|
||||
|
||||
feature -- Execution
|
||||
|
||||
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
action.call ([req, res])
|
||||
end
|
||||
|
||||
execute_uri (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
execute (req, res)
|
||||
end
|
||||
|
||||
execute_uri_template (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
execute_uri (req, res)
|
||||
end
|
||||
|
||||
execute_starts_with (a_start_path: READABLE_STRING_8; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
execute_uri (req, res)
|
||||
end
|
||||
|
||||
end
|
||||
52
draft/application/cms/src/handler/home_cms_execution.e
Normal file
52
draft/application/cms/src/handler/home_cms_execution.e
Normal file
@@ -0,0 +1,52 @@
|
||||
note
|
||||
description: "[
|
||||
]"
|
||||
|
||||
class
|
||||
HOME_CMS_EXECUTION
|
||||
|
||||
inherit
|
||||
CMS_EXECUTION
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Execution
|
||||
|
||||
process
|
||||
-- Computed response message.
|
||||
local
|
||||
-- l_url: READABLE_STRING_8
|
||||
b: STRING_8
|
||||
do
|
||||
set_title ("Home")
|
||||
set_page_title (Void)
|
||||
create b.make_empty
|
||||
if attached service.storage.recent_nodes (1, 10) as l_nodes then
|
||||
across
|
||||
l_nodes as c
|
||||
loop
|
||||
b.append ("<div class=%"node-wrapper%">")
|
||||
b.append (c.item.to_html (theme))
|
||||
b.append ("</div>%N")
|
||||
end
|
||||
end
|
||||
|
||||
-- b.append ("<ul>%N")
|
||||
-- l_url := url ("/", Void)
|
||||
-- b.append ("<li><a href=%"" + l_url + "%">Home</a></li>%N")
|
||||
-- l_url := url ("/info/", Void)
|
||||
-- b.append ("<li><a href=%"" + l_url + "%">EWF Info</a></li>%N")
|
||||
|
||||
-- b.append ("</ul>%N")
|
||||
|
||||
debug ("cms")
|
||||
if attached controller.session as sess then
|
||||
b.append ("<div>Session#" + sess.uuid + "</div>%N")
|
||||
end
|
||||
end
|
||||
|
||||
set_main_content (b)
|
||||
end
|
||||
|
||||
end
|
||||
34
draft/application/cms/src/handler/not_found_cms_execution.e
Normal file
34
draft/application/cms/src/handler/not_found_cms_execution.e
Normal file
@@ -0,0 +1,34 @@
|
||||
note
|
||||
description: "[
|
||||
This class implements the web service
|
||||
|
||||
It inherits from WSF_DEFAULT_SERVICE to get default EWF connector ready
|
||||
And from WSF_URI_TEMPLATE_ROUTED_SERVICE to use the router service
|
||||
|
||||
`initialize' can be redefine to provide custom options if needed.
|
||||
]"
|
||||
|
||||
class
|
||||
NOT_FOUND_CMS_EXECUTION
|
||||
|
||||
inherit
|
||||
CMS_EXECUTION
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Execution
|
||||
|
||||
process
|
||||
-- Computed response message.
|
||||
local
|
||||
b: STRING_8
|
||||
do
|
||||
status_code := {HTTP_STATUS_CODE}.not_found
|
||||
create b.make_empty
|
||||
set_title ("Page Not Found")
|
||||
b.append ("<em>The requested page could not be found.</em>%N")
|
||||
set_main_content (b)
|
||||
end
|
||||
|
||||
end
|
||||
47
draft/application/cms/src/handler/theme_cms_execution.e
Normal file
47
draft/application/cms/src/handler/theme_cms_execution.e
Normal file
@@ -0,0 +1,47 @@
|
||||
note
|
||||
description: "[
|
||||
]"
|
||||
|
||||
class
|
||||
THEME_CMS_EXECUTION
|
||||
|
||||
inherit
|
||||
CMS_EXECUTION
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Execution
|
||||
|
||||
process
|
||||
-- Computed response message.
|
||||
local
|
||||
-- l_url: READABLE_STRING_8
|
||||
b: STRING_8
|
||||
do
|
||||
set_title ("Home")
|
||||
create b.make_empty
|
||||
|
||||
b.append ("<h1>Home</h1>%N")
|
||||
if attached service.storage.recent_nodes (1, 10) as l_nodes then
|
||||
across
|
||||
l_nodes as c
|
||||
loop
|
||||
b.append ("<div class=%"node-wrapper%">")
|
||||
b.append (c.item.to_html (theme))
|
||||
b.append ("</div>%N")
|
||||
end
|
||||
end
|
||||
|
||||
-- b.append ("<ul>%N")
|
||||
-- l_url := url ("/", Void)
|
||||
-- b.append ("<li><a href=%"" + l_url + "%">Home</a></li>%N")
|
||||
-- l_url := url ("/info/", Void)
|
||||
-- b.append ("<li><a href=%"" + l_url + "%">EWF Info</a></li>%N")
|
||||
|
||||
-- b.append ("</ul>%N")
|
||||
|
||||
set_main_content (b)
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user