Updated CMS libary:

Initial Basic Authentication Node with filters.
Updated ROC API to use the new module.
This commit is contained in:
jvelilla
2014-10-02 20:52:14 -03:00
parent a0cb7c0ecc
commit 3fe166b768
17 changed files with 41 additions and 41 deletions

View File

@@ -62,7 +62,7 @@ feature -- Configure Node Resources Routes
create l_bal_handler.make (config) create l_bal_handler.make (config)
create l_methods create l_methods
l_methods.enable_get l_methods.enable_get
router.handle_with_request_methods ("/basic_auth/login", l_bal_handler, l_methods) router.handle_with_request_methods ("/basic_auth_login", l_bal_handler, l_methods)
end end
configure_api_logoff configure_api_logoff
@@ -73,7 +73,7 @@ feature -- Configure Node Resources Routes
create l_bal_handler.make (config) create l_bal_handler.make (config)
create l_methods create l_methods
l_methods.enable_get l_methods.enable_get
router.handle_with_request_methods ("/basic_auth/logoff", l_bal_handler, l_methods) router.handle_with_request_methods ("/basic_auth_logoff", l_bal_handler, l_methods)
end end
end end

View File

@@ -52,7 +52,7 @@ feature -- HTTP Methods
do do
log.write_information(generator + ".do_get Processing basic auth login") log.write_information(generator + ".do_get Processing basic auth login")
if attached {STRING_32} current_user_name (req) as l_user then if attached {STRING_32} current_user_name (req) as l_user then
(create {CMS_GENERIC_RESPONSE}).new_response_redirect (req, res, req.absolute_script_url("")) (create {CMS_GENERIC_RESPONSE}).new_response_redirect (req, res, req.absolute_script_url("/"))
else else
(create {CMS_GENERIC_RESPONSE}).new_response_authenticate (req, res) (create {CMS_GENERIC_RESPONSE}).new_response_authenticate (req, res)
end end

View File

@@ -71,7 +71,7 @@ feature -- HTTP Methods
if attached {WSF_STRING} req.path_parameter ("id") as l_id then if attached {WSF_STRING} req.path_parameter ("id") as l_id then
if l_id.is_integer and then attached {CMS_NODE} api_service.node (l_id.integer_value) as l_node then if l_id.is_integer and then attached {CMS_NODE} api_service.node (l_id.integer_value) as l_node then
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, setup, "modules/node_content") create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, setup, "modules/node_content")
l_page.add_variable (l_node.content, "content") l_page.add_variable (l_node.content, "node_content")
l_page.add_variable (l_id.value, "id") l_page.add_variable (l_id.value, "id")
l_page.execute l_page.execute
else else

View File

@@ -70,8 +70,8 @@ feature -- HTTP Methods
if attached {WSF_STRING} req.path_parameter ("id") as l_id then if attached {WSF_STRING} req.path_parameter ("id") as l_id then
if l_id.is_integer and then attached {CMS_NODE} api_service.node (l_id.integer_value) as l_node then if l_id.is_integer and then attached {CMS_NODE} api_service.node (l_id.integer_value) as l_node then
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, setup, "modules/node_summary") create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, setup, "modules/node_summary")
l_page.add_variable (l_node.summary, "summary")
l_page.add_variable (l_id.value, "id") l_page.add_variable (l_id.value, "id")
l_page.add_variable (l_node.summary, "node_summary")
l_page.execute l_page.execute
else else
do_error (req, res, l_id) do_error (req, res, l_id)

View File

@@ -70,20 +70,14 @@ feature -- HTTP Methods
if attached {WSF_STRING} req.path_parameter ("id") as l_id then if attached {WSF_STRING} req.path_parameter ("id") as l_id then
if l_id.is_integer and then attached {CMS_NODE} api_service.node (l_id.integer_value) as l_node then if l_id.is_integer and then attached {CMS_NODE} api_service.node (l_id.integer_value) as l_node then
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, setup, "modules/node_title") create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, setup, "modules/node_title")
l_page.add_variable (setup.is_html, "html") l_page.add_variable (l_node.title, "node_title")
l_page.add_variable (setup.is_web, "web")
l_page.add_variable (l_node.title, "title")
l_page.add_variable (l_id.value, "id") l_page.add_variable (l_id.value, "id")
l_page.execute l_page.execute
else else
do_error (req, res, l_id) do_error (req, res, l_id)
end end
else else
to_implement ("Check how to implement API error") (create {ERROR_500_CMS_RESPONSE}.make (req, res, setup, "master2/error")).execute
-- create l_page.make (req, "master2/error")
-- l_page.set_value ("500", "code")
-- l_page.set_value (req.absolute_script_url (req.path_info), "request")
-- l_page.send_to (res)
end end
else else
(create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res) (create {CMS_GENERIC_RESPONSE}).new_response_unauthorized (req, res)

View File

@@ -19,6 +19,7 @@ inherit
execute_default execute_default
end end
WSF_FILTERED_SERVICE WSF_FILTERED_SERVICE
WSF_FILTER WSF_FILTER
@@ -120,23 +121,6 @@ feature {NONE} -- Initialization
router.handle_with_request_methods ("/", fhdl, router.methods_GET) router.handle_with_request_methods ("/", fhdl, router.methods_GET)
end end
feature -- Access
setup: CMS_SETUP
-- CMS setup.
configuration: CMS_CONFIGURATION
-- 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.
feature -- Execute Filter feature -- Execute Filter
execute_filter (req: WSF_REQUEST; res: WSF_RESPONSE) execute_filter (req: WSF_REQUEST; res: WSF_RESPONSE)
@@ -186,6 +170,23 @@ feature -- Filters
f.set_next (Current) f.set_next (Current)
end end
feature -- Access
setup: CMS_SETUP
-- CMS setup.
configuration: CMS_CONFIGURATION
-- 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.
feature -- Execution feature -- Execution
execute_default (req: WSF_REQUEST; res: WSF_RESPONSE) execute_default (req: WSF_REQUEST; res: WSF_RESPONSE)

View File

@@ -9,6 +9,8 @@ deferred class
inherit inherit
WSF_HANDLER
CMS_REQUEST_UTIL CMS_REQUEST_UTIL
SHARED_LOGGER SHARED_LOGGER

View File

@@ -178,6 +178,8 @@ feature {NONE} -- Execution
prepare (cms_page) prepare (cms_page)
create page.make (theme.page_html (cms_page)) create page.make (theme.page_html (cms_page))
page.set_status_code (status_code) page.set_status_code (status_code)
page.header.put_content_length (page.html.count)
page.header.put_current_date
response.send (page) response.send (page)
on_terminated on_terminated
end end

View File

@@ -30,8 +30,8 @@ feature -- Execution
process process
-- Computed response message. -- Computed response message.
do do
set_title ("CMS") -- set_title ("CMS")
set_page_title (Void) -- set_page_title (Void)
end end
end end

View File

@@ -42,10 +42,10 @@ feature -- Access
end end
if attached page.title as l_title then if attached page.title as l_title then
variables.force (l_title, "title") variables.force (l_title, "page_title")
variables.force (l_title, "head_title") variables.force (l_title, "head_title")
else else
variables.force ("", "title") variables.force ("", "page_title")
variables.force ("", "head_title") variables.force ("", "head_title")
end end

View File

@@ -1,2 +1,2 @@
port=8088 port=8099
#verbose=true #verbose=true

View File

@@ -12,10 +12,10 @@
{if isset="$user"} {if isset="$user"}
<li><a>{$user/}</a></li> <li><a>{$user/}</a></li>
<li><a title="Node" href="{$host/}/node" rel="node">New Node</a></li> <li><a title="Node" href="{$host/}/node" rel="node">New Node</a></li>
<li><a title="Logoff" href="{$host/}/basic_auth/logoff" rel="logoff">Logoff</a></li> <li><a title="Logoff" href="{$host/}/basic_auth_logoff" rel="logoff">Logoff</a></li>
{/if} {/if}
{unless isset="$user"} {unless isset="$user"}
<li><a title="Login" href="{$host/}/basic_auth/login" rel="login">Login</a></li> <li><a title="Login" href="{$host/}/basic_auth_login" rel="login">Login</a></li>
<li><a title="Register" href="{$host/}/user" rel="register">Register</a></li> <li><a title="Register" href="{$host/}/user" rel="register">Register</a></li>
{/unless} {/unless}
</ul> </ul>

View File

@@ -89,7 +89,7 @@
<div class="row"> <div class="row">
<div class="col-xs-1"> <div class="col-xs-1">
{if isset="$node"} {if isset="$node"}
<label> <span itemprop="description"><a href="{$host/}/node/{$node.id/}/content" rel="node">Summary:</a></span></label> <label> <span itemprop="description"><a href="{$host/}/node/{$node.id/}/summary" rel="node">Summary:</a></span></label>
{/if} {/if}
{unless isset="$node"} {unless isset="$node"}
<label> <span itemprop="description">Summary:</span></label> <label> <span itemprop="description">Summary:</span></label>

View File

@@ -33,7 +33,7 @@
<label> <span itemprop="text">Content:</span> </label> <label> <span itemprop="text">Content:</span> </label>
</div> </div>
<div class="col-xs-7"> <div class="col-xs-7">
<textarea id="content" rows="25" cols="100" class="form-control" name="content" placeholder="Node content" required>{$content/}</textarea> <textarea id="content" rows="25" cols="100" class="form-control" name="content" placeholder="Node content" required>{$node_content/}</textarea>
</div> </div>
</div> </div>

View File

@@ -33,7 +33,7 @@
<label> <span itemprop="text">Summary:</span> </label> <label> <span itemprop="text">Summary:</span> </label>
</div> </div>
<div class="col-xs-7"> <div class="col-xs-7">
<textarea id="summary" rows="3" cols="80" name="summary" placeholder="Node summary" required>{$summary/}</textarea> <textarea id="summary" rows="3" cols="80" name="summary" placeholder="Node summary" required>{$node_summary/}</textarea>
</div> </div>
</div> </div>

View File

@@ -33,7 +33,7 @@
<label> <span itemprop="text">Title:</span> </label> <label> <span itemprop="text">Title:</span> </label>
</div> </div>
<div class="col-xs-7"> <div class="col-xs-7">
<input id="title" type="text" name="title" placeholder="Title" required value="{$title/}"/> <input id="title" type="text" name="title" placeholder="Title" required value="{$node_title/}"/>
</div> </div>
</div> </div>

View File

@@ -15,6 +15,7 @@ inherit
redefine redefine
initialize initialize
end end
WSF_SERVICE WSF_SERVICE
redefine redefine
execute execute