merge
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
site.name=EWF Web CMS
|
||||
#site.base_url=/demo
|
||||
site.email=your@email.com
|
||||
root-dir=../www
|
||||
var-dir=var
|
||||
files-dir=files
|
||||
themes-dir=${root-dir}/themes
|
||||
#theme=test
|
||||
@@ -1,23 +0,0 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-10-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-10-0 http://www.eiffel.com/developers/xml/configuration-1-10-0.xsd" name="demo" uuid="402ED70E-9A85-4501-8730-7B211EB32E6B" library_target="demo">
|
||||
<target name="demo">
|
||||
<root class="WEB_CMS" feature="make_and_launch"/>
|
||||
<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>
|
||||
<setting name="concurrency" value="none"/>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="cms" location="..\cms-safe.ecf" readonly="false"/>
|
||||
<library name="default_nino" location="..\..\..\..\library\server\wsf\default\nino-safe.ecf"/>
|
||||
<library name="http" location="..\..\..\..\library\network\protocol\http\http-safe.ecf" readonly="false"/>
|
||||
<library name="nino" location="..\..\..\..\library\server\ewsgi\connectors\nino\nino-safe.ecf"/>
|
||||
<library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/>
|
||||
<library name="wsf_html" location="..\..\..\..\library\server\wsf_html\wsf_html-safe.ecf" readonly="false"/>
|
||||
<library name="wsf" location="..\..\..\..\library\server\wsf\wsf-safe.ecf" readonly="false"/>
|
||||
<cluster name="src" location=".\src\" recursive="true"/>
|
||||
</target>
|
||||
</system>
|
||||
@@ -1,4 +0,0 @@
|
||||
# For nino connector, use port 9999
|
||||
port=9090
|
||||
|
||||
#verbose=true
|
||||
@@ -1,82 +0,0 @@
|
||||
note
|
||||
description: "Summary description for {CMS_MODULE}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
DEMO_MODULE
|
||||
|
||||
inherit
|
||||
CMS_MODULE
|
||||
redefine
|
||||
links
|
||||
end
|
||||
|
||||
CMS_HOOK_MENU_ALTER
|
||||
|
||||
CMS_HOOK_AUTO_REGISTER
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
do
|
||||
name := "demo"
|
||||
version := "1.0"
|
||||
description := "demo"
|
||||
package := "misc"
|
||||
end
|
||||
|
||||
feature {CMS_SERVICE} -- Registration
|
||||
|
||||
service: detachable CMS_SERVICE
|
||||
|
||||
register (a_service: CMS_SERVICE)
|
||||
do
|
||||
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/format/{arg}", agent handle_format_demo (a_service, ?, ?))
|
||||
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
|
||||
|
||||
links: HASH_TABLE [CMS_MODULE_LINK, STRING]
|
||||
-- Link indexed by path
|
||||
local
|
||||
lnk: CMS_MODULE_LINK
|
||||
do
|
||||
Result := Precursor
|
||||
create lnk.make ("Date/time demo")
|
||||
-- lnk.set_callback (agent process_date_time_demo, <<"arg">>)
|
||||
-- Result["/demo/date/{arg}"] := lnk
|
||||
end
|
||||
|
||||
handle_date_time_demo (cms: CMS_SERVICE; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
(create {ANY_CMS_EXECUTION}.make_with_text (req, res, cms, "<h1>Demo::date/time</h1>")).execute
|
||||
end
|
||||
|
||||
handle_format_demo (cms: CMS_SERVICE; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
(create {ANY_CMS_EXECUTION}.make_with_text (req, res, cms, "<h1>Demo::format</h1>")).execute
|
||||
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
|
||||
@@ -1,97 +0,0 @@
|
||||
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: WSF_WIDGET_AGENT_TABLE [READABLE_STRING_8]
|
||||
local
|
||||
l_table: WSF_WIDGET_AGENT_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): WSF_WIDGET_TABLE_ROW
|
||||
local
|
||||
i: INTEGER
|
||||
w: WSF_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
|
||||
@@ -1,33 +0,0 @@
|
||||
note
|
||||
description: "Summary description for {SHUTDOWN_CMS_EXECUTION}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
SHUTDOWN_CMS_EXECUTION
|
||||
|
||||
inherit
|
||||
CMS_EXECUTION
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Execution
|
||||
|
||||
process
|
||||
local
|
||||
b: STRING
|
||||
do
|
||||
create b.make_empty
|
||||
set_title ("Shutting down the service ...")
|
||||
if has_permission ("admin shutdown") then
|
||||
if attached {WGI_NINO_CONNECTOR} request.wgi_connector as nino then
|
||||
nino.server.shutdown_server
|
||||
end
|
||||
else
|
||||
b.append ("Access denied")
|
||||
end
|
||||
set_main_content (b)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,69 +0,0 @@
|
||||
note
|
||||
description: "Summary description for {SHUTDOWN_MODULE}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
SHUTDOWN_MODULE
|
||||
|
||||
inherit
|
||||
CMS_MODULE
|
||||
redefine
|
||||
permissions
|
||||
end
|
||||
|
||||
CMS_HOOK_MENU_ALTER
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
do
|
||||
name := "shutdown"
|
||||
version := "1.0"
|
||||
description := "Shutdown the service if this is EWF Nino or FCGI"
|
||||
package := "server"
|
||||
end
|
||||
|
||||
feature {CMS_SERVICE} -- Registration
|
||||
|
||||
service: detachable CMS_SERVICE
|
||||
|
||||
register (a_service: CMS_SERVICE)
|
||||
do
|
||||
a_service.map_uri ("/admin/shutdown/", agent handle_shutdown)
|
||||
|
||||
a_service.add_menu_alter_hook (Current)
|
||||
service := a_service
|
||||
end
|
||||
|
||||
feature -- Hooks
|
||||
|
||||
permissions (a_service: CMS_SERVICE): LIST [CMS_PERMISSION]
|
||||
do
|
||||
Result := Precursor (a_service)
|
||||
Result.extend ("shutdown")
|
||||
end
|
||||
|
||||
menu_alter (a_menu_system: CMS_MENU_SYSTEM; a_execution: CMS_EXECUTION)
|
||||
local
|
||||
lnk: CMS_LOCAL_LINK
|
||||
do
|
||||
create lnk.make ("Shutdown", "/admin/shutdown/")
|
||||
lnk.set_permission_arguments (<<"shutdown">>)
|
||||
a_menu_system.management_menu.extend (lnk)
|
||||
end
|
||||
|
||||
handle_shutdown (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
if attached service as l_service then
|
||||
(create {SHUTDOWN_CMS_EXECUTION}.make (req, res, l_service)).execute ;
|
||||
else
|
||||
res.set_status_code ({HTTP_STATUS_CODE}.expectation_failed)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,135 +0,0 @@
|
||||
note
|
||||
description: "[
|
||||
This class implements the Demo of WEB CMS service
|
||||
|
||||
]"
|
||||
|
||||
class
|
||||
WEB_CMS
|
||||
|
||||
inherit
|
||||
WSF_DEFAULT_SERVICE
|
||||
redefine
|
||||
initialize
|
||||
end
|
||||
|
||||
create
|
||||
make_and_launch
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
initialize
|
||||
local
|
||||
args: ARGUMENTS
|
||||
cfg: detachable STRING
|
||||
i,n: INTEGER
|
||||
do
|
||||
--| Arguments
|
||||
create args
|
||||
from
|
||||
i := 1
|
||||
n := args.argument_count
|
||||
until
|
||||
i > n or cfg /= Void
|
||||
loop
|
||||
if attached args.argument (i) as s then
|
||||
if s.same_string ("--config") or s.same_string ("-c") then
|
||||
if i < n then
|
||||
cfg := args.argument (i + 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
i := i + 1
|
||||
end
|
||||
if cfg = Void then
|
||||
if file_exists ("cms.ini") then
|
||||
cfg := "cms.ini"
|
||||
end
|
||||
end
|
||||
|
||||
--| EWF settings
|
||||
service_options := create {WSF_SERVICE_LAUNCHER_OPTIONS_FROM_INI}.make_from_file ("ewf.ini")
|
||||
Precursor
|
||||
|
||||
--| CMS initialization
|
||||
launch_cms (cms_setup (cfg))
|
||||
end
|
||||
|
||||
cms_setup (a_cfg_fn: detachable READABLE_STRING_8): CMS_CUSTOM_SETUP
|
||||
do
|
||||
if a_cfg_fn /= Void then
|
||||
create Result.make_from_file (a_cfg_fn)
|
||||
else
|
||||
create Result -- Default
|
||||
end
|
||||
setup_modules (Result)
|
||||
setup_storage (Result)
|
||||
end
|
||||
|
||||
launch_cms (a_setup: CMS_SETUP)
|
||||
local
|
||||
cms: CMS_SERVICE
|
||||
do
|
||||
create cms.make (a_setup)
|
||||
on_launched (cms)
|
||||
cms_service := cms
|
||||
end
|
||||
|
||||
feature -- Execution
|
||||
|
||||
cms_service: CMS_SERVICE
|
||||
|
||||
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
cms_service.execute (req, res)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
setup_modules (a_setup: CMS_SETUP)
|
||||
local
|
||||
m: CMS_MODULE
|
||||
do
|
||||
create {DEMO_MODULE} m.make
|
||||
m.enable
|
||||
a_setup.add_module (m)
|
||||
|
||||
create {SHUTDOWN_MODULE} m.make
|
||||
m.enable
|
||||
a_setup.add_module (m)
|
||||
|
||||
create {DEBUG_MODULE} m.make
|
||||
m.enable
|
||||
a_setup.add_module (m)
|
||||
|
||||
create {OPENID_MODULE} m.make
|
||||
m.enable
|
||||
a_setup.add_module (m)
|
||||
end
|
||||
|
||||
setup_storage (a_setup: CMS_SETUP)
|
||||
do
|
||||
|
||||
end
|
||||
|
||||
feature -- Event
|
||||
|
||||
on_launched (cms: CMS_SERVICE)
|
||||
local
|
||||
e: CMS_EMAIL
|
||||
do
|
||||
create e.make (cms.site_email, cms.site_email, "[" + cms.site_name + "] launched...", "The site [" + cms.site_name + "] was launched at " + (create {DATE_TIME}.make_now_utc).out + " UTC.")
|
||||
cms.mailer.safe_process_email (e)
|
||||
end
|
||||
|
||||
feature -- Helper
|
||||
|
||||
file_exists (fn: STRING): BOOLEAN
|
||||
local
|
||||
f: RAW_FILE
|
||||
do
|
||||
create f.make (fn)
|
||||
Result := f.exists and then f.is_readable
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user