added CMS widgets demonstration in DEMO_MODULE
This commit is contained in:
@@ -10,6 +10,10 @@ class
|
|||||||
inherit
|
inherit
|
||||||
CMS_MODULE
|
CMS_MODULE
|
||||||
|
|
||||||
|
CMS_HOOK_MENU_ALTER
|
||||||
|
|
||||||
|
CMS_HOOK_AUTO_REGISTER
|
||||||
|
|
||||||
create
|
create
|
||||||
make
|
make
|
||||||
|
|
||||||
@@ -30,19 +34,29 @@ feature {CMS_SERVICE} -- Registration
|
|||||||
register (a_service: CMS_SERVICE)
|
register (a_service: CMS_SERVICE)
|
||||||
do
|
do
|
||||||
service := a_service
|
service := a_service
|
||||||
|
a_service.map_uri_template ("/demo/widget{/args}", agent handle_widget_demo (a_service, ?, ?))
|
||||||
a_service.map_uri_template ("/demo/date/{arg}", agent handle_date_time_demo (a_service, ?, ?))
|
a_service.map_uri_template ("/demo/date/{arg}", agent handle_date_time_demo (a_service, ?, ?))
|
||||||
a_service.map_uri_template ("/demo/format/{arg}", agent handle_format_demo (a_service, ?, ?))
|
a_service.map_uri_template ("/demo/format/{arg}", agent handle_format_demo (a_service, ?, ?))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
menu_alter (a_menu_system: CMS_MENU_SYSTEM; a_execution: CMS_EXECUTION)
|
||||||
|
local
|
||||||
|
lnk: CMS_LOCAL_LINK
|
||||||
|
-- opts: CMS_API_OPTIONS
|
||||||
|
do
|
||||||
|
create lnk.make ("Demo::widget", "/demo/widget/")
|
||||||
|
a_menu_system.management_menu.extend (lnk)
|
||||||
|
end
|
||||||
|
|
||||||
feature -- Hooks
|
feature -- Hooks
|
||||||
|
|
||||||
links: HASH_TABLE [CMS_MODULE_LINK, STRING]
|
links: HASH_TABLE [CMS_MODULE_LINK, STRING]
|
||||||
-- Link indexed by path
|
-- Link indexed by path
|
||||||
local
|
local
|
||||||
-- lnk: CMS_MODULE_LINK
|
lnk: CMS_MODULE_LINK
|
||||||
do
|
do
|
||||||
create Result.make (0)
|
create Result.make (0)
|
||||||
-- create lnk.make ("Date/time demo")
|
create lnk.make ("Date/time demo")
|
||||||
-- lnk.set_callback (agent process_date_time_demo, <<"arg">>)
|
-- lnk.set_callback (agent process_date_time_demo, <<"arg">>)
|
||||||
-- Result["/demo/date/{arg}"] := lnk
|
-- Result["/demo/date/{arg}"] := lnk
|
||||||
end
|
end
|
||||||
@@ -57,4 +71,9 @@ feature -- Hooks
|
|||||||
(create {ANY_CMS_EXECUTION}.make_with_text (req, res, cms, "<h1>Demo::format</h1>")).execute
|
(create {ANY_CMS_EXECUTION}.make_with_text (req, res, cms, "<h1>Demo::format</h1>")).execute
|
||||||
end
|
end
|
||||||
|
|
||||||
|
handle_widget_demo (cms: CMS_SERVICE; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||||
|
do
|
||||||
|
(create {DEMO_WIDGET_CMS_EXECUTION}.make (req, res, cms)).execute
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,97 @@
|
|||||||
|
note
|
||||||
|
description : "Objects that ..."
|
||||||
|
author : "$Author$"
|
||||||
|
date : "$Date$"
|
||||||
|
revision : "$Revision$"
|
||||||
|
|
||||||
|
class
|
||||||
|
DEMO_WIDGET_CMS_EXECUTION
|
||||||
|
|
||||||
|
inherit
|
||||||
|
CMS_EXECUTION
|
||||||
|
|
||||||
|
create
|
||||||
|
make
|
||||||
|
|
||||||
|
feature -- Execution
|
||||||
|
|
||||||
|
process
|
||||||
|
local
|
||||||
|
args: like arguments
|
||||||
|
l_table: like new_table
|
||||||
|
s: STRING
|
||||||
|
do
|
||||||
|
args := arguments
|
||||||
|
if args.is_empty then
|
||||||
|
set_title ("Widgets")
|
||||||
|
set_main_content ("...")
|
||||||
|
else
|
||||||
|
|
||||||
|
end
|
||||||
|
l_table := new_table
|
||||||
|
|
||||||
|
create s.make_empty
|
||||||
|
l_table.append_to_html (theme, s)
|
||||||
|
set_main_content (s)
|
||||||
|
end
|
||||||
|
|
||||||
|
new_table: CMS_WIDGET_TABLE [READABLE_STRING_8]
|
||||||
|
local
|
||||||
|
l_table: CMS_WIDGET_TABLE [READABLE_STRING_8]
|
||||||
|
do
|
||||||
|
create l_table.make
|
||||||
|
l_table.add_css_style ("width: 85%%; border: solid 1px #999; padding: 2px;")
|
||||||
|
|
||||||
|
l_table.set_column_count (3)
|
||||||
|
l_table.column (1).set_title ("First")
|
||||||
|
l_table.column (2).set_title ("Second")
|
||||||
|
l_table.column (3).set_title ("Third")
|
||||||
|
|
||||||
|
l_table.column (1).add_css_style ("width: 20%%")
|
||||||
|
l_table.column (2).add_css_style ("width: 40px")
|
||||||
|
l_table.column (3).add_css_style ("width: 40px")
|
||||||
|
|
||||||
|
l_table.set_data (<<"foo", "bar", "foobar">>)
|
||||||
|
l_table.set_foot_data (<<"abc", "def">>)
|
||||||
|
l_table.set_compute_item_function (agent (d: READABLE_STRING_8): CMS_WIDGET_TABLE_ROW
|
||||||
|
local
|
||||||
|
i: INTEGER
|
||||||
|
w: CMS_WIDGET_TABLE_ITEM
|
||||||
|
do
|
||||||
|
create Result.make (d.count)
|
||||||
|
if d.is_case_insensitive_equal ("bar") then
|
||||||
|
Result.add_css_style ("background-color: #ccf;")
|
||||||
|
end
|
||||||
|
across
|
||||||
|
d as c
|
||||||
|
loop
|
||||||
|
i := i + 1
|
||||||
|
create w.make_with_text (c.item.out)
|
||||||
|
if i = 1 then
|
||||||
|
w.add_css_style ("background-color: #333; color: white; font-weight: bold;")
|
||||||
|
elseif i > 3 then
|
||||||
|
w.add_css_style ("color: red; border: solid 1px red; padding: 3px;")
|
||||||
|
end
|
||||||
|
Result.force (w)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
Result := l_table
|
||||||
|
end
|
||||||
|
|
||||||
|
arguments: ARRAY [READABLE_STRING_32]
|
||||||
|
-- Path parameters arguments related to {/vars}
|
||||||
|
do
|
||||||
|
if
|
||||||
|
attached {WSF_TABLE} request.path_parameter ("args") as lst and then
|
||||||
|
attached lst.as_array_of_string as arr
|
||||||
|
then
|
||||||
|
Result := arr
|
||||||
|
else
|
||||||
|
create Result.make_empty
|
||||||
|
end
|
||||||
|
|
||||||
|
Result.rebase (1)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user