Initial CMS API commmit.

This commit is contained in:
jvelilla
2014-10-01 12:17:39 -03:00
parent 588827b495
commit 27a11f2eea
170 changed files with 12459 additions and 14 deletions

View File

@@ -0,0 +1,29 @@
note
description: "Template shared common features to all the templates"
date: "$Date: 2014-08-08 16:02:11 -0300 (vi., 08 ago. 2014) $"
revision: "$Revision: 95593 $"
deferred class
TEMPLATE_SHARED
inherit
ROC_TEMPLATE_PAGE
feature --
add_host (a_host: READABLE_STRING_GENERAL)
-- Add value `a_host' to `host'
do
template.add_value (a_host, "host")
end
add_user (a_user: detachable ANY)
-- Add value `a_host' to `host'
do
if attached a_user then
template.add_value (a_user,"user")
end
end
end

View File

@@ -0,0 +1,143 @@
note
description: "Summary description for {ROC_RESPONSE}."
date: "$Date$"
revision: "$Revision$"
class
ROC_RESPONSE
inherit
APP_HANDLER
TEMPLATE_SHARED
create
make
feature {NONE} -- Initialization
make (a_request: WSF_REQUEST; a_template: READABLE_STRING_32)
do
request := a_request
-- Set template to HTML
set_template_folder (html_path)
-- Build Common Template
set_template_file_name (a_template)
-- Process the current tempate.
set_value (a_request.absolute_script_url (""), "host")
if attached current_user_name (request) as l_user then
set_value (l_user, "user")
end
end
feature -- Access
request: WSF_REQUEST
feature -- Access
values: STRING_TABLE [detachable ANY]
do
Result := template.values
end
value (a_key: READABLE_STRING_GENERAL): detachable ANY
do
Result := template.values.item (a_key)
end
feature -- Element change
set_value (a_value: detachable ANY; a_key: READABLE_STRING_GENERAL)
do
template.add_value (a_value, a_key)
end
feature -- Output
send_to (res: WSF_RESPONSE)
do
process
if attached representation as l_output then
new_response (res, l_output, {HTTP_STATUS_CODE}.ok)
end
end
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 forbidden.
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=%"CMS-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 forbidden.
local
h: HTTP_HEADER
do
process
create h.make
if attached representation as l_output then
h.put_content_length (l_output.count)
end
h.put_content_type_text_html
h.put_current_date
res.set_status_code ({HTTP_STATUS_CODE}.unauthorized)
res.put_header_text (h.string)
if attached representation as l_output then
res.put_string (l_output)
end
end
new_response_unauthorized (req: WSF_REQUEST; res: WSF_RESPONSE)
local
h: HTTP_HEADER
output: STRING
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
feature {NONE} -- Implemenation
new_response (res: WSF_RESPONSE; output: STRING; status_code: INTEGER)
local
h: HTTP_HEADER
do
create h.make
h.put_content_type_text_html
h.put_content_length (output.count)
h.put_current_date
res.set_status_code (status_code)
res.put_header_text (h.string)
res.put_string (output)
end
end

View File

@@ -0,0 +1,76 @@
note
description: "Abstract template class"
date: "$Date: 2014-08-20 15:21:15 -0300 (mi., 20 ago. 2014) $"
revision: "$Revision: 95678 $"
deferred class
ROC_TEMPLATE_PAGE
inherit
SHARED_TEMPLATE_CONTEXT
SHARED_LOGGER
ARGUMENTS
feature -- Status
representation: detachable STRING
-- String representation, if any.
set_template_folder (v: PATH)
-- Set template folder to `v'.
do
template_context.set_template_folder (v)
end
set_template_file_name (v: STRING)
-- Set `template' to `v'.
do
create template.make_from_file (v)
end
set_template (v: like template)
-- Set `template' to `v'.
do
template := v
end
template: TEMPLATE_FILE
layout: APPLICATION_LAYOUT
local
l_env: EXECUTION_ENVIRONMENT
once
create l_env
if attached separate_character_option_value ('d') as l_dir then
create Result.make_with_path (create {PATH}.make_from_string (l_dir))
else
create Result.make_default
end
end
html_path: PATH
-- Html template paths.
do
Result := layout.template_path.extended ("html")
end
feature -- Process
process
-- Process the current template.
do
template_context.enable_verbose
template.analyze
template.get_output
if attached template.output as l_output then
representation := l_output
debug
log.write_debug (generator + ".make " + l_output)
end
end
end
end