Compare commits
55 Commits
roc_servic
...
minor_chan
| Author | SHA1 | Date | |
|---|---|---|---|
| 76bdbeaa2a | |||
|
|
44a1dd62cb | ||
|
|
1f8be4e37f | ||
|
|
d963fd218b | ||
|
|
8ab4343d5b | ||
|
|
9af6356f0a | ||
|
|
b16048eb18 | ||
| 71734a6dd7 | |||
| 9cd53c7c78 | |||
| a51d0d3c68 | |||
|
|
b3c2879b07 | ||
| e1feee51f9 | |||
|
|
2aaed89417 | ||
|
|
789b26eafa | ||
|
|
a576c38d42 | ||
| a524b80108 | |||
| 48a8ac4a1c | |||
|
|
1d4e9df917 | ||
|
|
2d5c1a5e41 | ||
|
|
fba9b598f9 | ||
| c3d48c47cc | |||
|
|
96ceb2481a | ||
|
|
590bd8fc3a | ||
| 96da59c4cb | |||
| b0930299fc | |||
| abe9de621e | |||
| 241b003542 | |||
|
|
730f6d42a4 | ||
|
|
75d34870fa | ||
|
|
2c130cf882 | ||
|
|
223a5fafdb | ||
|
|
f1b911b6e3 | ||
|
|
b90e3b3df0 | ||
|
|
bafdc085d9 | ||
|
|
b11462105a | ||
|
|
5cb26f0b24 | ||
|
|
3c73202a0d | ||
|
|
8a06dc11ac | ||
|
|
ab76a752d7 | ||
|
|
4b9a692c2c | ||
|
|
b8257e7bf0 | ||
| 4841039d4a | |||
|
|
609d71a0e9 | ||
|
|
8d79447cf8 | ||
|
|
36dc48125c | ||
|
|
d183ab8130 | ||
| 6fc38272fe | |||
| 51e1058409 | |||
|
|
965b0e9f7d | ||
| c94e5391e9 | |||
|
|
b004ac8ae0 | ||
|
|
c3e23e1697 | ||
|
|
3fe166b768 | ||
|
|
a0cb7c0ecc | ||
|
|
e053ffceef |
31
README.md
Normal file
31
README.md
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
Eiffel CMS Library
|
||||
===============
|
||||
|
||||
Eiffel CMS library is build with [EWF](http://eiffelwebframework.github.io/EWF/) and inspired by [Drupal](https://www.drupal.org/).
|
||||
|
||||
The goal of the library is to provide the following features.
|
||||
|
||||
- content type
|
||||
- user management
|
||||
- module design
|
||||
- theme
|
||||
- API
|
||||
|
||||
|
||||
**Directory Structure**
|
||||
|
||||
- library --Library
|
||||
- layout -- application layout library.
|
||||
- model -- domain model library.
|
||||
- persistence -- persistence layer library.
|
||||
- src -- cms source code.
|
||||
- example
|
||||
- demo -- example using the cms library.
|
||||
- doc -- Documentation.
|
||||
|
||||
**Documentation**
|
||||
>[CMS design](https://github.com/EiffelWebFramework/ROC).
|
||||
>[CMS concepts](https://github.com/EiffelWebFramework/ROC).
|
||||
|
||||
|
||||
@@ -9,12 +9,20 @@
|
||||
<library name="crypto" location="$ISE_LIBRARY\unstable\library\text\encryption\crypto\crypto-safe.ecf"/>
|
||||
<library name="http" location="$ISE_LIBRARY\contrib\library\network\protocol\http\http-safe.ecf"/>
|
||||
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json-safe.ecf" readonly="false"/>
|
||||
<library name="layout" location="..\layout\layout.ecf"/>
|
||||
<library name="persistence_mysql" location="..\persistence\implementation\mysql\persistence_mysql.ecf" readonly="false"/>
|
||||
<library name="layout" location=".\library\layout\layout-safe.ecf"/>
|
||||
<library name="model" location=".\library\model\cms_model-safe.ecf" readonly="false"/>
|
||||
<library name="encoder" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\text\encoder\encoder-safe.ecf" readonly="false"/>
|
||||
<library name="text_filter" location="$ISE_LIBRARY\unstable\library\text\text_filter\text_filter-safe.ecf"/>
|
||||
|
||||
<library name="error" location="$ISE_LIBRARY\contrib\library\utility\general\error\error-safe.ecf"/>
|
||||
<library name="http_authorization" location="$ISE_LIBRARY\contrib\library\network\authentication\http_authorization\http_authorization-safe.ecf" readonly="false"/>
|
||||
<library name="persistence_mysql" location=".\library\persistence\implementation\mysql\persistence_mysql-safe.ecf" readonly="false"/>
|
||||
<library name="smarty" location="$ISE_LIBRARY\contrib\library\text\template\smarty\smarty-safe.ecf" readonly="false"/>
|
||||
<library name="wsf" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf-safe.ecf"/>
|
||||
<library name="wsf_extension" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf_extension-safe.ecf" readonly="false"/>
|
||||
<cluster name="src" location=".\src\" recursive="true">
|
||||
<library name="wsf_html" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf_html\wsf_html-safe.ecf" readonly="false"/>
|
||||
<library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/>
|
||||
<cluster name="src" location=".\library\src\" recursive="true">
|
||||
<file_rule>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
<exclude>/CVS$</exclude>
|
||||
@@ -1,32 +0,0 @@
|
||||
note
|
||||
description: "Summary description for {CMS_LAYOUT}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CMS_LAYOUT
|
||||
|
||||
inherit
|
||||
|
||||
APPLICATION_LAYOUT
|
||||
|
||||
create
|
||||
make_default,
|
||||
make_with_path
|
||||
|
||||
|
||||
feature -- Access
|
||||
|
||||
theme_path: PATH
|
||||
-- Directory for templates (HTML, etc).
|
||||
once
|
||||
Result := www_path.extended ("theme")
|
||||
end
|
||||
|
||||
cms_config_ini_path: PATH
|
||||
-- Database Configuration file path.
|
||||
once
|
||||
Result := config_path.extended ("cms.ini")
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,85 +0,0 @@
|
||||
note
|
||||
description: "Summary description for {CMS_SETUP}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
CMS_SETUP
|
||||
|
||||
feature -- Access
|
||||
|
||||
configuration: CMS_CONFIGURATION
|
||||
-- cms configuration.
|
||||
|
||||
layout: CMS_LAYOUT
|
||||
-- CMS layout.
|
||||
|
||||
api_service: CMS_API_SERVICE
|
||||
-- cms api service.
|
||||
|
||||
modules: LIST[CMS_MODULE]
|
||||
-- Possible list of modules.
|
||||
-- |If we remove Modules from setup.
|
||||
-- |we can let the CMS_SERVICE define the basic modules.
|
||||
deferred
|
||||
end
|
||||
|
||||
is_html: BOOLEAN
|
||||
-- api with progresive enhacements css and js, server side rendering.
|
||||
deferred
|
||||
end
|
||||
|
||||
is_web: BOOLEAN
|
||||
-- web: Web Site with progresive enhacements css and js and Ajax calls.
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- Access: Site
|
||||
|
||||
site_id: READABLE_STRING_8
|
||||
|
||||
site_name: READABLE_STRING_32
|
||||
|
||||
site_email: READABLE_STRING_8
|
||||
|
||||
site_url: READABLE_STRING_8
|
||||
|
||||
site_dir: PATH
|
||||
|
||||
site_var_dir: PATH
|
||||
|
||||
files_location: PATH
|
||||
|
||||
feature -- Access:Theme
|
||||
|
||||
themes_location: PATH
|
||||
|
||||
theme_location: PATH
|
||||
|
||||
theme_resource_location: PATH
|
||||
--
|
||||
|
||||
theme_information_location: PATH
|
||||
-- theme informations.
|
||||
do
|
||||
Result := theme_location.extended ("theme.info")
|
||||
end
|
||||
|
||||
theme_name: READABLE_STRING_32
|
||||
-- theme name
|
||||
|
||||
feature -- Compute location
|
||||
|
||||
compute_theme_location
|
||||
do
|
||||
theme_location := themes_location.extended (theme_name)
|
||||
end
|
||||
|
||||
compute_theme_resource_location
|
||||
-- assets (js, css, images, etc)
|
||||
-- Not used at the moment.
|
||||
do
|
||||
theme_resource_location := theme_location
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,48 +0,0 @@
|
||||
note
|
||||
description: "Summary description for {WSF_CMS_MODULE}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
CMS_MODULE
|
||||
|
||||
feature -- Access
|
||||
|
||||
is_enabled: BOOLEAN
|
||||
|
||||
name: STRING
|
||||
|
||||
description: STRING
|
||||
|
||||
package: STRING
|
||||
|
||||
version: STRING
|
||||
|
||||
feature -- Router
|
||||
|
||||
router: WSF_ROUTER
|
||||
-- Router configuration.
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- Settings
|
||||
|
||||
enable
|
||||
do
|
||||
is_enabled := True
|
||||
end
|
||||
|
||||
disable
|
||||
do
|
||||
is_enabled := False
|
||||
end
|
||||
|
||||
feature -- Hooks
|
||||
|
||||
help_text (a_path: STRING): STRING
|
||||
do
|
||||
create Result.make_empty
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
@@ -1,127 +0,0 @@
|
||||
note
|
||||
description: "Summary description for {CMS_MODULE}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
NODE_MODULE
|
||||
|
||||
inherit
|
||||
|
||||
CMS_MODULE
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_config: CMS_SETUP)
|
||||
do
|
||||
name := "node"
|
||||
version := "1.0"
|
||||
description := "Service to manage content based on 'node'"
|
||||
package := "core"
|
||||
config := a_config
|
||||
setup_router
|
||||
enable
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
router: WSF_ROUTER
|
||||
-- Node router.
|
||||
|
||||
config: CMS_SETUP
|
||||
-- Node configuration.
|
||||
|
||||
feature -- Implementation
|
||||
|
||||
setup_router
|
||||
-- Setup `router'.
|
||||
do
|
||||
create router.make (5)
|
||||
configure_api_node
|
||||
configure_api_nodes
|
||||
configure_api_node_title
|
||||
configure_api_node_summary
|
||||
configure_api_node_content
|
||||
end
|
||||
|
||||
feature -- Configure Node Resources Routes
|
||||
|
||||
configure_api_node
|
||||
local
|
||||
l_node_handler: NODE_HANDLER
|
||||
l_methods: WSF_REQUEST_METHODS
|
||||
do
|
||||
create l_node_handler.make (config)
|
||||
create l_methods
|
||||
l_methods.enable_get
|
||||
l_methods.enable_post
|
||||
l_methods.enable_put
|
||||
router.handle_with_request_methods ("/node", l_node_handler, l_methods)
|
||||
|
||||
create l_node_handler.make (config)
|
||||
create l_methods
|
||||
l_methods.enable_get
|
||||
l_methods.enable_post
|
||||
l_methods.enable_put
|
||||
l_methods.enable_delete
|
||||
router.handle_with_request_methods ("/node/{id}", l_node_handler, l_methods)
|
||||
end
|
||||
|
||||
|
||||
configure_api_nodes
|
||||
local
|
||||
l_nodes_handler: NODES_HANDLER
|
||||
l_methods: WSF_REQUEST_METHODS
|
||||
do
|
||||
create l_nodes_handler.make (config)
|
||||
create l_methods
|
||||
l_methods.enable_get
|
||||
router.handle_with_request_methods ("/nodes", l_nodes_handler, l_methods)
|
||||
end
|
||||
|
||||
|
||||
configure_api_node_summary
|
||||
local
|
||||
l_report_handler: NODE_SUMMARY_HANDLER
|
||||
l_methods: WSF_REQUEST_METHODS
|
||||
do
|
||||
create l_report_handler.make (config)
|
||||
create l_methods
|
||||
l_methods.enable_get
|
||||
l_methods.enable_post
|
||||
l_methods.enable_put
|
||||
router.handle_with_request_methods ("/node/{id}/summary", l_report_handler, l_methods)
|
||||
end
|
||||
|
||||
|
||||
configure_api_node_title
|
||||
local
|
||||
l_report_handler: NODE_TITLE_HANDLER
|
||||
l_methods: WSF_REQUEST_METHODS
|
||||
do
|
||||
create l_report_handler.make (config)
|
||||
create l_methods
|
||||
l_methods.enable_get
|
||||
l_methods.enable_post
|
||||
l_methods.enable_put
|
||||
router.handle_with_request_methods ("/node/{id}/title", l_report_handler, l_methods)
|
||||
end
|
||||
|
||||
|
||||
configure_api_node_content
|
||||
local
|
||||
l_report_handler: NODE_CONTENT_HANDLER
|
||||
l_methods: WSF_REQUEST_METHODS
|
||||
do
|
||||
create l_report_handler.make (config)
|
||||
create l_methods
|
||||
l_methods.enable_get
|
||||
l_methods.enable_post
|
||||
l_methods.enable_put
|
||||
router.handle_with_request_methods ("/node/{id}/content", l_report_handler, l_methods)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,127 +0,0 @@
|
||||
note
|
||||
description: "Summary description for {CMS_API_SERVICE}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CMS_API_SERVICE
|
||||
|
||||
inherit
|
||||
|
||||
SHARED_ERROR
|
||||
REFACTORING_HELPER
|
||||
|
||||
|
||||
create make
|
||||
|
||||
|
||||
feature -- Initialize
|
||||
|
||||
make (a_storage: CMS_STORAGE)
|
||||
-- Create the API service with an storege `a_storage'.
|
||||
do
|
||||
storage := a_storage
|
||||
set_successful
|
||||
ensure
|
||||
storage_set: storage = a_storage
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
login_valid (l_auth_login, l_auth_password: READABLE_STRING_32): BOOLEAN
|
||||
local
|
||||
l_security: SECURITY_PROVIDER
|
||||
do
|
||||
Result := storage.is_valid_credential (l_auth_login, l_auth_password)
|
||||
end
|
||||
|
||||
feature -- Access: Node
|
||||
|
||||
nodes: LIST[CMS_NODE]
|
||||
-- List of nodes.
|
||||
do
|
||||
fixme ("Implementation")
|
||||
Result := storage.recent_nodes (0, 10)
|
||||
end
|
||||
|
||||
recent_nodes (a_offset, a_rows: INTEGER): LIST[CMS_NODE]
|
||||
-- List of the `a_rows' most recent nodes starting from `a_offset'.
|
||||
do
|
||||
Result := storage.recent_nodes (a_offset, a_rows)
|
||||
end
|
||||
|
||||
node (a_id: INTEGER_64): detachable CMS_NODE
|
||||
-- Node by ID.
|
||||
do
|
||||
fixme ("Check preconditions")
|
||||
Result := storage.node (a_id)
|
||||
end
|
||||
|
||||
|
||||
feature -- Change: Node
|
||||
|
||||
new_node (a_node: CMS_NODE)
|
||||
-- Add a new node
|
||||
do
|
||||
storage.save_node (a_node)
|
||||
end
|
||||
|
||||
delete_node (a_id: INTEGER_64)
|
||||
do
|
||||
storage.delete_node (a_id)
|
||||
end
|
||||
|
||||
update_node (a_id: like {CMS_USER}.id; a_node: CMS_NODE)
|
||||
do
|
||||
storage.update_node (a_id,a_node)
|
||||
end
|
||||
|
||||
update_node_title (a_id: like {CMS_USER}.id; a_node_id: like {CMS_NODE}.id; a_title: READABLE_STRING_32)
|
||||
do
|
||||
fixme ("Check preconditions")
|
||||
storage.update_node_title (a_id,a_node_id,a_title)
|
||||
end
|
||||
|
||||
update_node_summary (a_id: like {CMS_USER}.id; a_node_id: like {CMS_NODE}.id; a_summary: READABLE_STRING_32)
|
||||
do
|
||||
fixme ("Check preconditions")
|
||||
storage.update_node_summary (a_id,a_node_id, a_summary)
|
||||
end
|
||||
|
||||
update_node_content (a_id: like {CMS_USER}.id; a_node_id: like {CMS_NODE}.id; a_content: READABLE_STRING_32)
|
||||
do
|
||||
fixme ("Check preconditions")
|
||||
storage.update_node_content (a_id,a_node_id, a_content)
|
||||
end
|
||||
|
||||
|
||||
feature -- Access: User
|
||||
|
||||
user_by_name (a_username: READABLE_STRING_32): detachable CMS_USER
|
||||
do
|
||||
Result := storage.user_by_name (a_username)
|
||||
end
|
||||
feature -- Change User
|
||||
|
||||
new_user (a_user: CMS_USER)
|
||||
-- Add a new user `a_user'.
|
||||
do
|
||||
if
|
||||
attached a_user.password as l_password and then
|
||||
attached a_user.email as l_email
|
||||
then
|
||||
storage.save_user (a_user)
|
||||
else
|
||||
fixme ("Add error")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
feature {NONE} -- Implemenataion
|
||||
|
||||
|
||||
storage: CMS_STORAGE
|
||||
-- Persistence storage
|
||||
|
||||
end
|
||||
|
||||
@@ -1,156 +0,0 @@
|
||||
note
|
||||
description: "[
|
||||
This class implements the CMS service
|
||||
|
||||
It could be used to implement the main EWF service, or
|
||||
even for a specific handler.
|
||||
]"
|
||||
|
||||
class
|
||||
CMS_SERVICE
|
||||
|
||||
inherit
|
||||
WSF_ROUTED_SKELETON_SERVICE
|
||||
undefine
|
||||
requires_proxy
|
||||
redefine
|
||||
execute_default
|
||||
end
|
||||
|
||||
WSF_FILTERED_SERVICE
|
||||
|
||||
WSF_FILTER
|
||||
rename
|
||||
execute as execute_filter
|
||||
end
|
||||
|
||||
WSF_NO_PROXY_POLICY
|
||||
|
||||
WSF_URI_HELPER_FOR_ROUTED_SERVICE
|
||||
|
||||
WSF_URI_TEMPLATE_HELPER_FOR_ROUTED_SERVICE
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
SHARED_LOGGER
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_setup: CMS_SETUP)
|
||||
do
|
||||
setup := a_setup
|
||||
configuration := a_setup.configuration
|
||||
modules := a_setup.modules
|
||||
initialize_users
|
||||
initialize_auth_engine
|
||||
initialize_mailer
|
||||
initialize_router
|
||||
initialize_modules
|
||||
end
|
||||
|
||||
|
||||
|
||||
initialize_users
|
||||
do
|
||||
end
|
||||
|
||||
initialize_mailer
|
||||
do
|
||||
to_implement ("To Implement mailer")
|
||||
end
|
||||
|
||||
setup_router
|
||||
do
|
||||
configure_api_root
|
||||
end
|
||||
|
||||
initialize_modules
|
||||
-- Intialize modules, import router definitions
|
||||
-- from enabled modules.
|
||||
do
|
||||
log.write_debug (generator + ".initialize_modules")
|
||||
across
|
||||
modules as m
|
||||
loop
|
||||
if m.item.is_enabled then
|
||||
router.import (m.item.router)
|
||||
end
|
||||
end
|
||||
configure_api_file_handler
|
||||
end
|
||||
|
||||
initialize_auth_engine
|
||||
do
|
||||
to_implement ("To Implement authentication engine")
|
||||
end
|
||||
|
||||
|
||||
configure_api_root
|
||||
local
|
||||
l_root_handler: CMS_ROOT_HANDLER
|
||||
l_methods: WSF_REQUEST_METHODS
|
||||
do
|
||||
log.write_debug (generator + ".configure_api_root")
|
||||
create l_root_handler.make (setup)
|
||||
create l_methods
|
||||
l_methods.enable_get
|
||||
router.handle_with_request_methods ("/", l_root_handler, l_methods)
|
||||
end
|
||||
|
||||
configure_api_file_handler
|
||||
local
|
||||
fhdl: WSF_FILE_SYSTEM_HANDLER
|
||||
do
|
||||
log.write_debug (generator + ".configure_api_file_handler")
|
||||
create fhdl.make_hidden_with_path (setup.layout.www_path)
|
||||
fhdl.disable_index
|
||||
fhdl.set_not_found_handler (agent (ia_uri: READABLE_STRING_8; ia_req: WSF_REQUEST; ia_res: WSF_RESPONSE)
|
||||
do
|
||||
execute_default (ia_req, ia_res)
|
||||
end)
|
||||
router.handle_with_request_methods ("/", fhdl, router.methods_GET)
|
||||
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.
|
||||
|
||||
feature -- Logging
|
||||
|
||||
feature -- Notification
|
||||
|
||||
|
||||
feature -- Execution
|
||||
|
||||
execute_default (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Default request handler if no other are relevant
|
||||
local
|
||||
do
|
||||
fixme ("To Implement")
|
||||
end
|
||||
|
||||
|
||||
note
|
||||
copyright: "2011-2014, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
@@ -1,190 +0,0 @@
|
||||
note
|
||||
description: "Generic CMS Response, place to add HOOKS features as collaborators."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
CMS_RESPONSE
|
||||
|
||||
inherit
|
||||
|
||||
CMS_REQUEST_UTIL
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (req: WSF_REQUEST; res: WSF_RESPONSE; a_setup: like setup; a_template: like template)
|
||||
do
|
||||
status_code := {HTTP_STATUS_CODE}.ok
|
||||
setup := a_setup
|
||||
request := req
|
||||
response := res
|
||||
template := a_template
|
||||
create header.make
|
||||
initialize
|
||||
end
|
||||
|
||||
initialize
|
||||
do
|
||||
get_theme
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
request: WSF_REQUEST
|
||||
|
||||
response: WSF_RESPONSE
|
||||
|
||||
setup: CMS_SETUP
|
||||
-- Current setup
|
||||
|
||||
status_code: INTEGER
|
||||
|
||||
header: WSF_HEADER
|
||||
|
||||
title: detachable READABLE_STRING_32
|
||||
|
||||
page_title: detachable READABLE_STRING_32
|
||||
-- Page title
|
||||
|
||||
main_content: detachable STRING_8
|
||||
|
||||
template: READABLE_STRING_32
|
||||
-- Current template.
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_title (t: like title)
|
||||
do
|
||||
title := t
|
||||
set_page_title (t)
|
||||
end
|
||||
|
||||
set_page_title (t: like page_title)
|
||||
do
|
||||
page_title := t
|
||||
end
|
||||
|
||||
set_main_content (s: like main_content)
|
||||
do
|
||||
main_content := s
|
||||
end
|
||||
|
||||
feature -- Theme
|
||||
|
||||
theme: CMS_THEME
|
||||
-- Current theme
|
||||
|
||||
get_theme
|
||||
local
|
||||
l_info: CMS_THEME_INFORMATION
|
||||
do
|
||||
if attached setup.theme_information_location as fn then
|
||||
create l_info.make (fn)
|
||||
else
|
||||
create l_info.make_default
|
||||
end
|
||||
if l_info.engine.is_case_insensitive_equal_general ("smarty") then
|
||||
create {SMARTY_CMS_THEME} theme.make (setup, l_info, template)
|
||||
else
|
||||
create {DEFAULT_CMS_THEME} theme.make (setup, l_info)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Element Change
|
||||
|
||||
set_status_code (a_status: INTEGER)
|
||||
-- Set `status_code' with `a_status'.
|
||||
note
|
||||
EIS: "src=eiffel:?class=HTTP_STATUS_CODE"
|
||||
do
|
||||
to_implement ("Feature to test if a_status is a valid status code!!!.")
|
||||
status_code := a_status
|
||||
ensure
|
||||
status_code_set: status_code = a_status
|
||||
end
|
||||
|
||||
feature -- Generation
|
||||
|
||||
prepare (page: CMS_HTML_PAGE)
|
||||
do
|
||||
common_prepare (page)
|
||||
custom_prepare (page)
|
||||
end
|
||||
|
||||
common_prepare (page: CMS_HTML_PAGE)
|
||||
do
|
||||
fixme ("Fix generacion common")
|
||||
page.register_variable (request.absolute_script_url (""), "host")
|
||||
page.register_variable (setup.is_web, "web")
|
||||
page.register_variable (setup.is_html, "html")
|
||||
if attached current_user_name (request) as l_user then
|
||||
page.register_variable (l_user, "user")
|
||||
end
|
||||
end
|
||||
|
||||
custom_prepare (page: CMS_HTML_PAGE)
|
||||
do
|
||||
end
|
||||
|
||||
|
||||
feature -- Custom Variables
|
||||
|
||||
variables: detachable STRING_TABLE[ANY]
|
||||
-- Custom variables to feed the templates.
|
||||
|
||||
|
||||
feature -- Element change: Add custom variables.
|
||||
|
||||
add_variable (a_element: ANY; a_key:READABLE_STRING_32)
|
||||
local
|
||||
l_variables: like variables
|
||||
do
|
||||
l_variables := variables
|
||||
if l_variables = Void then
|
||||
create l_variables.make (5)
|
||||
variables := l_variables
|
||||
end
|
||||
l_variables.force (a_element, a_key)
|
||||
end
|
||||
|
||||
|
||||
feature -- Execution
|
||||
|
||||
execute
|
||||
do
|
||||
begin
|
||||
process
|
||||
terminate
|
||||
end
|
||||
|
||||
feature {NONE} -- Execution
|
||||
|
||||
begin
|
||||
do
|
||||
end
|
||||
|
||||
process
|
||||
deferred
|
||||
end
|
||||
|
||||
frozen terminate
|
||||
local
|
||||
cms_page: CMS_HTML_PAGE
|
||||
page: CMS_HTML_PAGE_RESPONSE
|
||||
do
|
||||
create cms_page.make
|
||||
prepare (cms_page)
|
||||
create page.make (theme.page_html (cms_page))
|
||||
page.set_status_code (status_code)
|
||||
response.send (page)
|
||||
on_terminated
|
||||
end
|
||||
|
||||
on_terminated
|
||||
do
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,49 +0,0 @@
|
||||
CMS Hypermedia API and Adaptive Web Design
|
||||
============================================
|
||||
|
||||
|
||||
A content management system is not a simple domain.
|
||||
This example shows how to build a basic Hypermedia API for a CMS using HTML5 and progressive enhacement.
|
||||
The idea is based on an existing [Eiffel CMS] (https://github.com/EiffelWebFramework/cms), the goal is learn the domain and create a new modular CMS.
|
||||
|
||||
Persistence
|
||||
============
|
||||
The current solution uses MySQL and only handle users and nodes concept.
|
||||
|
||||
|
||||
Authentication/Authorization
|
||||
============================
|
||||
Basic Auth.
|
||||
|
||||
|
||||
API features
|
||||
============
|
||||
|
||||
There is no session.
|
||||
|
||||
The root uri:
|
||||
shows Navigation and the possiblity to add a New Node (only for loggedin users).
|
||||
shows a predefined number of nodes the `n' most recent nodes.
|
||||
|
||||
Guest users will be able to list all the nodes and view a particular node.
|
||||
Logged in users.
|
||||
Logged users are able to
|
||||
Add a new node
|
||||
Edit an existing node
|
||||
Edit a node title
|
||||
Edit a node summary
|
||||
Edit a node content
|
||||
Delete a node
|
||||
|
||||
|
||||
Server Modes
|
||||
============
|
||||
|
||||
api: HTML5 API
|
||||
html: api with progresive enhacements css and js, server side rendering.
|
||||
web: api with progresive enhacements css and js and Ajax calls.
|
||||
|
||||
References
|
||||
|
||||
1: http://codeartisan.blogspot.se/2012/07/using-html-as-media-type-for-your-api.html
|
||||
2: https://github.com/gustafnk/combining-html-hypermedia-apis-and-adaptive-web-design
|
||||
@@ -1,24 +0,0 @@
|
||||
note
|
||||
description: "[
|
||||
Effective class for APPLICATION_LAUNCHER_I
|
||||
|
||||
You can put modification in this class
|
||||
]"
|
||||
date: "$Date: 2014-08-08 16:02:11 -0300 (vi., 08 ago. 2014) $"
|
||||
revision: "$Revision: 95593 $"
|
||||
|
||||
class
|
||||
APPLICATION_LAUNCHER
|
||||
|
||||
inherit
|
||||
APPLICATION_LAUNCHER_I
|
||||
|
||||
feature -- Custom
|
||||
|
||||
is_console_output_supported: BOOLEAN
|
||||
do
|
||||
Result := False
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,102 +0,0 @@
|
||||
note
|
||||
description: "[
|
||||
Specific application launcher
|
||||
|
||||
DO NOT EDIT THIS CLASS
|
||||
|
||||
you can customize APPLICATION_LAUNCHER
|
||||
]"
|
||||
date: "$Date: 2014-08-08 16:02:11 -0300 (vi., 08 ago. 2014) $"
|
||||
revision: "$Revision: 95593 $"
|
||||
|
||||
deferred class
|
||||
APPLICATION_LAUNCHER_I
|
||||
|
||||
inherit
|
||||
|
||||
SHARED_EXECUTION_ENVIRONMENT
|
||||
|
||||
feature -- Execution
|
||||
|
||||
launch (a_service: WSF_SERVICE; opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
|
||||
local
|
||||
-- nature: like launcher_nature
|
||||
do
|
||||
-- nature := launcher_nature
|
||||
-- if nature = Void or else nature = nature_nino then
|
||||
-- launch_nino (a_service, opts)
|
||||
-- elseif nature = nature_cgi then
|
||||
-- launch_cgi (a_service, opts)
|
||||
-- elseif nature = nature_libfcgi then
|
||||
launch_libfcgi (a_service, opts)
|
||||
-- else
|
||||
-- -- bye bye
|
||||
-- (create {EXCEPTIONS}).die (-1)
|
||||
-- end
|
||||
end
|
||||
|
||||
feature {NONE} -- Access
|
||||
|
||||
launcher_nature: detachable READABLE_STRING_8
|
||||
-- Initialize the launcher nature
|
||||
-- either cgi, libfcgi, or nino.
|
||||
--| We could extend with more connector if needed.
|
||||
--| and we could use WSF_DEFAULT_SERVICE_LAUNCHER to configure this at compilation time.
|
||||
local
|
||||
p: PATH
|
||||
ext: detachable READABLE_STRING_32
|
||||
do
|
||||
create p.make_from_string (execution_environment.arguments.command_name)
|
||||
if attached p.entry as l_entry then
|
||||
ext := l_entry.extension
|
||||
end
|
||||
if ext /= Void then
|
||||
if ext.same_string (nature_nino) then
|
||||
Result := nature_nino
|
||||
end
|
||||
if ext.same_string (nature_cgi) then
|
||||
Result := nature_cgi
|
||||
end
|
||||
if ext.same_string (nature_libfcgi) or else ext.same_string ("fcgi") then
|
||||
Result := nature_libfcgi
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- nino
|
||||
|
||||
nature_nino: STRING = "nino"
|
||||
|
||||
launch_nino (a_service: WSF_SERVICE; opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
|
||||
local
|
||||
launcher: WSF_NINO_SERVICE_LAUNCHER
|
||||
do
|
||||
create launcher.make_and_launch (a_service, opts)
|
||||
end
|
||||
|
||||
feature {NONE} -- cgi
|
||||
|
||||
nature_cgi: STRING = "cgi"
|
||||
|
||||
launch_cgi (a_service: WSF_SERVICE; opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
|
||||
local
|
||||
launcher: WSF_CGI_SERVICE_LAUNCHER
|
||||
do
|
||||
create launcher.make_and_launch (a_service, opts)
|
||||
end
|
||||
|
||||
feature {NONE} -- libfcgi
|
||||
|
||||
nature_libfcgi: STRING = "libfcgi"
|
||||
|
||||
launch_libfcgi (a_service: WSF_SERVICE; opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
|
||||
local
|
||||
launcher: WSF_LIBFCGI_SERVICE_LAUNCHER
|
||||
do
|
||||
create launcher.make_and_launch (a_service, opts)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
note
|
||||
description: "[
|
||||
Effective class for APPLICATION_LAUNCHER_I
|
||||
|
||||
You can put modification in this class
|
||||
]"
|
||||
date: "$Date: 2014-08-08 16:02:11 -0300 (vi., 08 ago. 2014) $"
|
||||
revision: "$Revision: 95593 $"
|
||||
|
||||
class
|
||||
APPLICATION_LAUNCHER
|
||||
|
||||
inherit
|
||||
APPLICATION_LAUNCHER_I
|
||||
|
||||
SHARED_EXECUTION_ENVIRONMENT
|
||||
|
||||
|
||||
feature -- Status Report
|
||||
|
||||
is_console_output_supported: BOOLEAN
|
||||
do
|
||||
Result := launcher_nature = nature_nino
|
||||
end
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
launcher_nature: detachable READABLE_STRING_8
|
||||
-- Initialize the launcher nature
|
||||
-- either cgi, libfcgi, or nino.
|
||||
--| We could extend with more connector if needed.
|
||||
--| and we could use WSF_DEFAULT_SERVICE_LAUNCHER to configure this at compilation time.
|
||||
local
|
||||
p: PATH
|
||||
ext: detachable READABLE_STRING_32
|
||||
do
|
||||
create p.make_from_string (execution_environment.arguments.command_name)
|
||||
if attached p.entry as l_entry then
|
||||
ext := l_entry.extension
|
||||
end
|
||||
if ext /= Void then
|
||||
if ext.same_string (nature_nino) then
|
||||
Result := nature_nino
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- nino
|
||||
|
||||
nature_nino: STRING = "nino"
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
note
|
||||
description: "[
|
||||
Specific application launcher
|
||||
|
||||
DO NOT EDIT THIS CLASS
|
||||
|
||||
you can customize APPLICATION_LAUNCHER
|
||||
]"
|
||||
date: "$Date: 2014-08-08 16:02:11 -0300 (vi., 08 ago. 2014) $"
|
||||
revision: "$Revision: 95593 $"
|
||||
|
||||
deferred class
|
||||
APPLICATION_LAUNCHER_I
|
||||
|
||||
feature -- Execution
|
||||
|
||||
launch (a_service: WSF_SERVICE; opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
|
||||
local
|
||||
launcher: WSF_SERVICE_LAUNCHER
|
||||
do
|
||||
create {WSF_DEFAULT_SERVICE_LAUNCHER} launcher.make_and_launch (a_service, opts)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-13-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-13-0 http://www.eiffel.com/developers/xml/configuration-1-13-0.xsd" name="api" uuid="8B2873E9-8E2A-4490-8B6C-1122B579FD1D" library_target="api">
|
||||
<target name="common" abstract="true">
|
||||
<file_rule>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
<exclude>/CVS$</exclude>
|
||||
<exclude>/.svn$</exclude>
|
||||
</file_rule>
|
||||
<option warning="true" full_class_checking="false" is_attached_by_default="true" void_safety="all" syntax="transitional">
|
||||
<debug name="esa" enabled="true"/>
|
||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||
</option>
|
||||
<setting name="console_application" value="true"/>
|
||||
<setting name="exception_trace" value="true"/>
|
||||
<setting name="concurrency" value="thread"/>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="conneg" location="$ISE_LIBRARY\contrib\library\network\protocol\content_negotiation\conneg-safe.ecf"/>
|
||||
<library name="crypto" location="$ISE_LIBRARY\unstable\library\text\encryption\crypto\crypto-safe.ecf"/>
|
||||
<library name="persistence_mysql" location="..\..\persistence\implementation\mysql\persistence_mysql.ecf" readonly="false"/>
|
||||
<library name="encoder" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\text\encoder\encoder-safe.ecf"/>
|
||||
<library name="http" location="$ISE_LIBRARY\contrib\library\network\protocol\http\http-safe.ecf"/>
|
||||
<library name="http_authorization" location="$ISE_LIBRARY\contrib\library\network\authentication\http_authorization\http_authorization-safe.ecf" readonly="false"/>
|
||||
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json-safe.ecf" readonly="false"/>
|
||||
<library name="layout" location="..\..\layout\layout.ecf"/>
|
||||
<library name="logging" location="$ISE_LIBRARY\library\runtime\logging\logging-safe.ecf"/>
|
||||
<library name="net" location="$ISE_LIBRARY\library\net\net-safe.ecf"/>
|
||||
<library name="process" location="$ISE_LIBRARY\library\process\process-safe.ecf"/>
|
||||
<library name="smarty" location="$ISE_LIBRARY\contrib\library\text\template\smarty\smarty-safe.ecf" readonly="false"/>
|
||||
<library name="wsf" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf-safe.ecf"/>
|
||||
<library name="wsf_extension" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf_extension-safe.ecf" readonly="false"/>
|
||||
</target>
|
||||
<target name="api_any" extends="common">
|
||||
<root class="ROC_SERVER" feature="make_and_launch"/>
|
||||
<library name="cgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\cgi-safe.ecf"/>
|
||||
<library name="libfcgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\libfcgi-safe.ecf"/>
|
||||
<library name="nino" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\nino-safe.ecf"/>
|
||||
<cluster name="launcher" location=".\launcher\any\" recursive="true"/>
|
||||
<cluster name="src" location=".\src\" recursive="true"/>
|
||||
</target>
|
||||
<target name="api_nino" extends="common">
|
||||
<root class="ROC_SERVER" feature="make_and_launch"/>
|
||||
<library name="default_nino" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\nino-safe.ecf"/>
|
||||
<cluster name="launcher" location=".\launcher\default\" recursive="true"/>
|
||||
<cluster name="src" location=".\src\" recursive="true"/>
|
||||
</target>
|
||||
<target name="api_cgi" extends="common">
|
||||
<root class="ROC_SERVER" feature="make_and_launch"/>
|
||||
<library name="default_cgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\cgi-safe.ecf"/>
|
||||
<cluster name="launcher" location=".\launcher\default\" recursive="true"/>
|
||||
<cluster name="src" location=".\src\" recursive="true"/>
|
||||
</target>
|
||||
<target name="api_libfcgi" extends="common">
|
||||
<root class="ROC_SERVER" feature="make_and_launch"/>
|
||||
<library name="cgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\cgi-safe.ecf"/>
|
||||
<library name="default_libfcgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\libfcgi-safe.ecf"/>
|
||||
<library name="libfcgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\libfcgi-safe.ecf"/>
|
||||
<library name="nino" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\nino-safe.ecf" readonly="false"/>
|
||||
<library name="wgi_nino" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\ewsgi\connectors\nino\nino-safe.ecf"/>
|
||||
<cluster name="launcher" location=".\launcher\any\" recursive="true"/>
|
||||
<cluster name="src" location=".\src\" recursive="true"/>
|
||||
</target>
|
||||
|
||||
<!-- <target name="api_test" extends="common">
|
||||
<root class="APPLICATION_TEST" feature="make"/>
|
||||
<library name="default_nino" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\nino-safe.ecf"/>
|
||||
<library name="ewsgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\ewsgi\ewsgi-safe.ecf" readonly="false">
|
||||
<option>
|
||||
<assertions precondition="true" postcondition="true" check="true" supplier_precondition="true"/>
|
||||
</option>
|
||||
</library>
|
||||
<library name="http_client" location="$ISE_LIBRARY\contrib\library\network\http_client\http_client-safe.ecf"/>
|
||||
<library name="testing" location="$ISE_LIBRARY\library\testing\testing-safe.ecf"/>
|
||||
<library name="thread" location="$ISE_LIBRARY\library\thread\thread-safe.ecf"/>
|
||||
<library name="wgi_nino" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\ewsgi\connectors\nino\nino-safe.ecf"/>
|
||||
<cluster name="launcher" location=".\launcher\default\" recursive="true"/>
|
||||
<cluster name="src" location="src\" recursive="true"/>
|
||||
<cluster name="test" location="test\" recursive="true"/>
|
||||
</target>
|
||||
-->
|
||||
<target name="api" extends="api_nino">
|
||||
</target>
|
||||
</system>
|
||||
@@ -1,27 +0,0 @@
|
||||
<nav id="" class="navbar navbar-default navbar-inverse navbar-fixed-top" role="navigation">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<a class="navbar-brand" href="{$host/}" rel="home">Rest on CMS</a>
|
||||
</div>
|
||||
|
||||
<div class="collapse navbar-collapse" id="navbarCollapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li class="ListOfNodes"><a title="Nodes" href="{$host/}/nodes" rel="node">List of Nodes</a></li>
|
||||
</ul>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
{if isset="$user"}
|
||||
<li><a>{$user/}</a></li>
|
||||
<li><a title="Node" href="{$host/}/node" rel="node">New Node</a></li>
|
||||
<li><a title="Logoff" href="{$host/}/logoff" rel="logoff">Logoff</a></li>
|
||||
{/if}
|
||||
{unless isset="$user"}
|
||||
<li><a title="Login" href="{$host/}/login" rel="login">Login</a></li>
|
||||
<li><a title="Register" href="{$host/}/user" rel="register">Register</a></li>
|
||||
{/unless}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
{if condition="html"}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
{include file="master2/head.tpl"/}
|
||||
</head>
|
||||
<body>
|
||||
{/if}
|
||||
|
||||
|
||||
{unless condition="$web"}
|
||||
<!-- Site Navigation -->
|
||||
{include file="master2/site_navigation.tpl"/}
|
||||
{/unless}
|
||||
|
||||
{if condition="html"}
|
||||
|
||||
<div class="container">
|
||||
<hr>
|
||||
<div class="row">
|
||||
<main class="main">
|
||||
{/if}
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="col-xs-12" itemscope itemtype="http://schema.org/Article">
|
||||
<form class="form-inline well" action="{$host/}/node/{$id/}/summary" method="POST">
|
||||
<input type="hidden" name="method" value="PUT">
|
||||
<fieldset>
|
||||
<legend>Edit Node Summary</legend>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-1">
|
||||
<label> <span itemprop="text">Summary:</span> </label>
|
||||
</div>
|
||||
<div class="col-xs-7">
|
||||
<textarea id="summary" rows="3" cols="80" name="summary" placeholder="Node summary" required>{$summary/}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label>
|
||||
<span> </span>
|
||||
<input type="Submit" value="Send" />
|
||||
</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{if condition="html"}
|
||||
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
|
||||
{if condition="html"}
|
||||
<div id="footer">
|
||||
<footer class="site-footer">
|
||||
{include file="master2/footer.tpl"/}
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
{include file="master2/optional_enhancement_js.tpl"/}
|
||||
|
||||
</body>
|
||||
</html>
|
||||
{/if}
|
||||
@@ -1,70 +0,0 @@
|
||||
{if condition="html"}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
{include file="master2/head.tpl"/}
|
||||
</head>
|
||||
<body>
|
||||
{/if}
|
||||
|
||||
{unless condition="$web"}
|
||||
<!-- Site Navigation -->
|
||||
{include file="master2/site_navigation.tpl"/}
|
||||
{/unless}
|
||||
|
||||
|
||||
{if condition="html"}
|
||||
|
||||
<div class="container">
|
||||
<hr>
|
||||
<div class="row">
|
||||
<main class="main">
|
||||
{/if}
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="col-xs-12" itemscope itemtype="http://schema.org/Article">
|
||||
<form class="form-inline well" action="{$host/}/node/{$id/}/title" method="POST">
|
||||
<input type="hidden" name="method" value="PUT">
|
||||
<fieldset>
|
||||
<legend>Edit Node Title</legend>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-1">
|
||||
<label> <span itemprop="text">Title:</span> </label>
|
||||
</div>
|
||||
<div class="col-xs-7">
|
||||
<input id="title" type="text" name="title" placeholder="Title" required value="{$title/}"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label>
|
||||
<span> </span>
|
||||
<input type="Submit" value="Send" />
|
||||
</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{if condition="html"}
|
||||
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
|
||||
{if condition="html"}
|
||||
<div id="footer">
|
||||
<footer class="site-footer">
|
||||
{include file="master2/footer.tpl"/}
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
{include file="master2/optional_enhancement_js.tpl"/}
|
||||
|
||||
</body>
|
||||
</html>
|
||||
{/if}
|
||||
@@ -1,19 +0,0 @@
|
||||
note
|
||||
description: "Summary description for {ESA_APPLICATION_CONSTANTS}."
|
||||
date: "$Date: 2014-08-20 15:21:15 -0300 (mi., 20 ago. 2014) $"
|
||||
revision: "$Revision: 95678 $"
|
||||
|
||||
class
|
||||
APPLICATION_CONSTANTS
|
||||
|
||||
feature -- Access
|
||||
|
||||
major: INTEGER = 0
|
||||
minor: INTEGER = 1
|
||||
built: STRING = "0001"
|
||||
|
||||
version: STRING
|
||||
do
|
||||
Result := major.out + "." + minor.out + "." + built
|
||||
end
|
||||
end
|
||||
@@ -1,70 +0,0 @@
|
||||
note
|
||||
description: "API configuration factory"
|
||||
date: "$Date: 2014-08-20 15:21:15 -0300 (mi., 20 ago. 2014) $"
|
||||
revision: "$Revision: 95678 $"
|
||||
|
||||
class
|
||||
CONFIGURATION_FACTORY
|
||||
|
||||
inherit
|
||||
|
||||
SHARED_EXECUTION_ENVIRONMENT
|
||||
|
||||
SHARED_ERROR
|
||||
|
||||
feature -- Factory
|
||||
|
||||
roc_config (a_dir: detachable STRING): ROC_CONFIG
|
||||
local
|
||||
l_layout: APPLICATION_LAYOUT
|
||||
l_email_service: ROC_EMAIL_SERVICE
|
||||
l_database: DATABASE_CONNECTION
|
||||
l_api_service: ROC_API_SERVICE
|
||||
l_retried: BOOLEAN
|
||||
do
|
||||
if not l_retried then
|
||||
if attached a_dir then
|
||||
create l_layout.make_with_path (create {PATH}.make_from_string (a_dir))
|
||||
else
|
||||
create l_layout.make_default
|
||||
end
|
||||
log.write_information (generator + ".roc_config " + l_layout.path.name.out)
|
||||
|
||||
create l_email_service.make ((create {JSON_CONFIGURATION}).new_smtp_configuration(l_layout.application_config_path))
|
||||
|
||||
if attached (create {JSON_CONFIGURATION}).new_database_configuration (l_layout.application_config_path) as l_database_config then
|
||||
create {DATABASE_CONNECTION_MYSQL} l_database.login_with_connection_string (l_database_config.connection_string)
|
||||
create l_api_service.make (create {CMS_STORAGE_MYSQL}.make (l_database))
|
||||
create Result.make (l_database, l_api_service, l_email_service, l_layout)
|
||||
if (create {ROC_JSON_CONFIGURATION}).is_web_mode(l_layout.application_config_path) then
|
||||
Result.mark_web
|
||||
elseif (create {ROC_JSON_CONFIGURATION}).is_html_mode(l_layout.application_config_path) then
|
||||
Result.mark_html
|
||||
end
|
||||
set_successful
|
||||
else
|
||||
create {DATABASE_CONNECTION_NULL} l_database.make_common
|
||||
create l_api_service.make (create {CMS_STORAGE_NULL})
|
||||
create Result.make (l_database, l_api_service, l_email_service, l_layout)
|
||||
set_last_error ("Database Connections", generator + ".roc_config")
|
||||
log.write_error (generator + ".roc_config Error database connection" )
|
||||
end
|
||||
else
|
||||
if attached a_dir then
|
||||
create l_layout.make_with_path (create {PATH}.make_from_string (a_dir))
|
||||
else
|
||||
create l_layout.make_default
|
||||
end
|
||||
create l_email_service.make ((create {JSON_CONFIGURATION}).new_smtp_configuration(l_layout.application_config_path))
|
||||
|
||||
create {DATABASE_CONNECTION_NULL} l_database.make_common
|
||||
create l_api_service.make (create {CMS_STORAGE_NULL})
|
||||
create Result.make (l_database, l_api_service, l_email_service, l_layout)
|
||||
end
|
||||
rescue
|
||||
set_last_error_from_exception ("Database Connection execution")
|
||||
log.write_critical (generator + ".roc_config Database Connection execution exceptions")
|
||||
l_retried := True
|
||||
retry
|
||||
end
|
||||
end
|
||||
@@ -1,48 +0,0 @@
|
||||
note
|
||||
description: "Summary description for {ROC_JSON_CONFIGURATION}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
ROC_JSON_CONFIGURATION
|
||||
|
||||
inherit
|
||||
|
||||
JSON_CONFIGURATION
|
||||
|
||||
feature -- Access
|
||||
|
||||
is_html_mode (a_path: PATH): BOOLEAN
|
||||
-- Is the server running on web mode?
|
||||
local
|
||||
l_parser: JSON_PARSER
|
||||
do
|
||||
if attached json_file_from (a_path) as json_file then
|
||||
l_parser := new_json_parser (json_file)
|
||||
if attached {JSON_OBJECT} l_parser.parse as jv and then l_parser.is_parsed and then
|
||||
attached {JSON_OBJECT} jv.item ("server") as l_server and then
|
||||
attached {JSON_STRING} l_server.item ("mode") as l_mode then
|
||||
Result := l_mode.item.is_case_insensitive_equal_general ("html")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
is_web_mode (a_path: PATH): BOOLEAN
|
||||
-- Is the server running on web mode?
|
||||
local
|
||||
l_parser: JSON_PARSER
|
||||
do
|
||||
if attached json_file_from (a_path) as json_file then
|
||||
l_parser := new_json_parser (json_file)
|
||||
if attached {JSON_OBJECT} l_parser.parse as jv and then l_parser.is_parsed and then
|
||||
attached {JSON_OBJECT} jv.item ("server") as l_server and then
|
||||
attached {JSON_STRING} l_server.item ("mode") as l_mode then
|
||||
Result := l_mode.item.is_case_insensitive_equal_general ("web")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
@@ -1,29 +0,0 @@
|
||||
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
|
||||
@@ -1,143 +0,0 @@
|
||||
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
|
||||
@@ -1,76 +0,0 @@
|
||||
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
|
||||
@@ -1,119 +0,0 @@
|
||||
note
|
||||
description: "Abstract API service"
|
||||
date: "$Date: 2014-08-20 15:21:15 -0300 (mi., 20 ago. 2014) $"
|
||||
revision: "$Revision: 95678 $"
|
||||
|
||||
deferred class
|
||||
ROC_ABSTRACT_API
|
||||
|
||||
inherit
|
||||
WSF_ROUTED_SKELETON_SERVICE
|
||||
undefine
|
||||
requires_proxy
|
||||
redefine
|
||||
execute_default
|
||||
end
|
||||
|
||||
WSF_NO_PROXY_POLICY
|
||||
|
||||
WSF_URI_HELPER_FOR_ROUTED_SERVICE
|
||||
|
||||
WSF_URI_TEMPLATE_HELPER_FOR_ROUTED_SERVICE
|
||||
|
||||
SHARED_CONNEG_HELPER
|
||||
|
||||
SHARED_LOGGER
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_esa_config: ROC_CONFIG; a_server: ROC_SERVER)
|
||||
do
|
||||
roc_config := a_esa_config
|
||||
server := a_server
|
||||
initialize_router
|
||||
end
|
||||
|
||||
feature -- ESA
|
||||
|
||||
roc_config: ROC_CONFIG
|
||||
-- Configuration
|
||||
|
||||
server: ROC_SERVER
|
||||
-- Server
|
||||
|
||||
feature -- Router setup
|
||||
|
||||
setup_router
|
||||
-- Setup `router'
|
||||
deferred
|
||||
end
|
||||
|
||||
layout: APPLICATION_LAYOUT
|
||||
do
|
||||
Result := roc_config.layout
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
handle_debug (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
local
|
||||
s: STRING_8
|
||||
h: HTTP_HEADER
|
||||
do
|
||||
if req.is_get_request_method then
|
||||
s := "debug"
|
||||
create h.make_with_count (1)
|
||||
h.put_content_type_text_html
|
||||
h.put_content_length (s.count)
|
||||
res.put_header_lines (h)
|
||||
res.put_string (s)
|
||||
else
|
||||
create s.make (30_000)
|
||||
across
|
||||
req.form_parameters as c
|
||||
loop
|
||||
s.append (c.item.url_encoded_name)
|
||||
s.append ("=")
|
||||
s.append (c.item.string_representation)
|
||||
s.append ("<br/>")
|
||||
end
|
||||
if s.is_empty then
|
||||
req.read_input_data_into (s)
|
||||
end
|
||||
create h.make_with_count (1)
|
||||
h.put_content_type_text_html
|
||||
h.put_content_length (s.count)
|
||||
res.put_header_lines (h)
|
||||
res.put_string (s)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Handler
|
||||
|
||||
not_yet_implemented_uri_template_handler (msg: READABLE_STRING_8): WSF_URI_TEMPLATE_HANDLER
|
||||
do
|
||||
create {WSF_URI_TEMPLATE_AGENT_HANDLER} Result.make (agent not_yet_implemented(?, ?, msg))
|
||||
end
|
||||
|
||||
not_yet_implemented (req: WSF_REQUEST; res: WSF_RESPONSE; msg: detachable READABLE_STRING_8)
|
||||
local
|
||||
m: WSF_NOT_IMPLEMENTED_RESPONSE
|
||||
do
|
||||
create m.make (req)
|
||||
if msg /= Void then
|
||||
m.set_body (msg)
|
||||
end
|
||||
res.send (m)
|
||||
end
|
||||
|
||||
|
||||
feature -- Default Execution
|
||||
|
||||
execute_default (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Dispatch requests without a matching handler.
|
||||
local
|
||||
do
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,87 +0,0 @@
|
||||
note
|
||||
description: "Eiffel Suppor API configuration"
|
||||
date: "$Date: 2014-08-20 15:21:15 -0300 (mi., 20 ago. 2014) $"
|
||||
revision: "$Revision: 95678 $"
|
||||
|
||||
class
|
||||
ROC_CONFIG
|
||||
|
||||
inherit
|
||||
|
||||
SHARED_ERROR
|
||||
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Initialization
|
||||
|
||||
make (a_database: DATABASE_CONNECTION; a_api_service: ROC_API_SERVICE; a_email_service: ROC_EMAIL_SERVICE; a_layout: APPLICATION_LAYOUT )
|
||||
-- Create an object with defaults.
|
||||
do
|
||||
database := a_database
|
||||
api_service := a_api_service
|
||||
email_service := a_email_service
|
||||
layout := a_layout
|
||||
mark_api
|
||||
ensure
|
||||
database_set: database = a_database
|
||||
api_service_set: api_service = a_api_service
|
||||
email_service_set: email_service = a_email_service
|
||||
layout_set: layout = a_layout
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
is_successful: BOOLEAN
|
||||
-- Is the configuration successful?
|
||||
do
|
||||
Result := successful
|
||||
end
|
||||
|
||||
is_api: BOOLEAN
|
||||
-- Is the server running on server mode API
|
||||
|
||||
is_web: BOOLEAN
|
||||
-- Is the server running on server mode API
|
||||
|
||||
is_html: BOOLEAN
|
||||
-- Is the server running on html mode API
|
||||
|
||||
database: DATABASE_CONNECTION
|
||||
-- Database connection.
|
||||
|
||||
api_service: ROC_API_SERVICE
|
||||
-- Support API.
|
||||
|
||||
email_service: ROC_EMAIL_SERVICE
|
||||
-- Email service.
|
||||
|
||||
layout: APPLICATION_LAYOUT
|
||||
-- Api layout.
|
||||
|
||||
mark_api
|
||||
-- Set server mode to api.
|
||||
do
|
||||
is_api := True
|
||||
is_html := False
|
||||
is_web := False
|
||||
end
|
||||
|
||||
mark_web
|
||||
-- Set server mode to web.
|
||||
do
|
||||
is_web := True
|
||||
is_api := False
|
||||
is_html := False
|
||||
end
|
||||
|
||||
mark_html
|
||||
-- Set server mode to web.
|
||||
do
|
||||
is_html := True
|
||||
is_api := False
|
||||
is_web := False
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,210 +0,0 @@
|
||||
note
|
||||
description: "[
|
||||
application service
|
||||
]"
|
||||
date: "$Date: 2014-08-20 15:21:15 -0300 (mi., 20 ago. 2014) $"
|
||||
revision: "$Revision: 95678 $"
|
||||
|
||||
class
|
||||
ROC_SERVER
|
||||
|
||||
inherit
|
||||
|
||||
WSF_LAUNCHABLE_SERVICE
|
||||
rename
|
||||
make_and_launch as make_and_launch_service
|
||||
redefine
|
||||
initialize
|
||||
end
|
||||
|
||||
WSF_FILTERED_SERVICE
|
||||
|
||||
WSF_FILTER
|
||||
rename
|
||||
execute as execute_filter
|
||||
end
|
||||
|
||||
SHARED_EXECUTION_ENVIRONMENT
|
||||
export
|
||||
{NONE} all
|
||||
end
|
||||
|
||||
APPLICATION_CONSTANTS
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
ARGUMENTS
|
||||
|
||||
create
|
||||
make_and_launch
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_and_launch
|
||||
do
|
||||
setup_config
|
||||
create launcher
|
||||
make_and_launch_service
|
||||
end
|
||||
|
||||
initialize
|
||||
-- Initialize current service.
|
||||
do
|
||||
Precursor
|
||||
service_options := create {WSF_SERVICE_LAUNCHER_OPTIONS_FROM_INI}.make_from_file ("roc.ini")
|
||||
initialize_filter
|
||||
end
|
||||
|
||||
feature {NONE} -- Launch operation
|
||||
|
||||
launcher: APPLICATION_LAUNCHER
|
||||
|
||||
launch (a_service: WSF_SERVICE; opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
|
||||
local
|
||||
l_retry: BOOLEAN
|
||||
l_message: STRING
|
||||
do
|
||||
if not l_retry then
|
||||
launcher.launch (a_service, opts)
|
||||
else
|
||||
-- error hanling.
|
||||
create l_message.make (1024)
|
||||
if attached ((create {EXCEPTION_MANAGER}).last_exception) as l_exception then
|
||||
if attached l_exception.description as l_description then
|
||||
l_message.append (l_description.as_string_32)
|
||||
l_message.append ("%N%N")
|
||||
elseif attached l_exception.trace as l_trace then
|
||||
l_message.append (l_trace)
|
||||
l_message.append ("%N%N")
|
||||
else
|
||||
l_message.append (l_exception.out)
|
||||
l_message.append ("%N%N")
|
||||
end
|
||||
else
|
||||
l_message.append ("The application crash without available information")
|
||||
l_message.append ("%N%N")
|
||||
end
|
||||
roc_config.email_service.send_shutdown_email (l_message)
|
||||
roc_config.log.write_emergency (generator + ".launch %N" + l_message)
|
||||
end
|
||||
rescue
|
||||
l_retry := True
|
||||
retry
|
||||
end
|
||||
|
||||
feature {ROC_ABSTRACT_API} -- Services
|
||||
|
||||
api_service: ROC_REST_API
|
||||
-- rest api.
|
||||
local
|
||||
s: like internal_api_service
|
||||
do
|
||||
s := internal_api_service
|
||||
if s = Void then
|
||||
create s.make (roc_config, Current)
|
||||
internal_api_service := s
|
||||
end
|
||||
Result := s
|
||||
end
|
||||
|
||||
feature {NONE} -- Internal
|
||||
|
||||
internal_api_service: detachable like api_service
|
||||
|
||||
feature -- ESA Configuraion
|
||||
|
||||
roc_config: ROC_CONFIG
|
||||
-- Configuration.
|
||||
|
||||
setup_config
|
||||
-- Configure API.
|
||||
local
|
||||
l_configuration_factory: CONFIGURATION_FACTORY
|
||||
do
|
||||
create l_configuration_factory
|
||||
roc_config := l_configuration_factory.roc_config (separate_character_option_value ('d'))
|
||||
if attached l_configuration_factory.last_error as l_error then
|
||||
roc_config.set_last_error_from_handler (l_error)
|
||||
else
|
||||
roc_config.set_successful
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Execute Filter
|
||||
|
||||
execute_filter (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute the filter.
|
||||
do
|
||||
|
||||
res.put_header_line ("Date: " + (create {HTTP_DATE}.make_now_utc).string)
|
||||
|
||||
res.put_header_line ("ROCServer: " + version)
|
||||
api_service.execute (req, res)
|
||||
end
|
||||
|
||||
feature -- Filters
|
||||
|
||||
create_filter
|
||||
-- Create `filter'.
|
||||
local
|
||||
f, l_filter: detachable WSF_FILTER
|
||||
fh: WSF_CUSTOM_HEADER_FILTER
|
||||
do
|
||||
l_filter := Void
|
||||
|
||||
-- Header
|
||||
create fh.make (1)
|
||||
fh.set_next (l_filter)
|
||||
fh.custom_header.put_header ("X-ROCServer: " + version)
|
||||
l_filter := fh
|
||||
|
||||
-- Maintenance
|
||||
create {WSF_MAINTENANCE_FILTER} f
|
||||
f.set_next (l_filter)
|
||||
l_filter := f
|
||||
|
||||
if launcher.is_console_output_supported then
|
||||
-- Logging for nino
|
||||
create {WSF_LOGGING_FILTER} f.make_with_output (io.output)
|
||||
f.set_next (l_filter)
|
||||
l_filter := f
|
||||
end
|
||||
-- CORS Authentication
|
||||
create {CORS_FILTER} f
|
||||
f.set_next (l_filter)
|
||||
l_filter := f
|
||||
|
||||
-- Logger Filter
|
||||
create {LOGGER_FILTER} f.make (roc_config)
|
||||
f.set_next (l_filter)
|
||||
l_filter := f
|
||||
|
||||
-- Error Filter
|
||||
create {ERROR_FILTER} f.make (roc_config)
|
||||
f.set_next (l_filter)
|
||||
l_filter := f
|
||||
|
||||
-- Authentication
|
||||
create {AUTHENTICATION_FILTER} f.make (roc_config)
|
||||
f.set_next (l_filter)
|
||||
l_filter := f
|
||||
|
||||
filter := l_filter
|
||||
end
|
||||
|
||||
setup_filter
|
||||
-- Setup `filter'.
|
||||
local
|
||||
f: WSF_FILTER
|
||||
do
|
||||
from
|
||||
f := filter
|
||||
until
|
||||
not attached f.next as l_next
|
||||
loop
|
||||
f := l_next
|
||||
end
|
||||
f.set_next (Current)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,42 +0,0 @@
|
||||
note
|
||||
description: "Error filter"
|
||||
date: "$Date: 2014-08-08 16:02:11 -0300 (vi., 08 ago. 2014) $"
|
||||
revision: "$Revision: 95593 $"
|
||||
|
||||
class
|
||||
ERROR_FILTER
|
||||
|
||||
inherit
|
||||
WSF_URI_TEMPLATE_HANDLER
|
||||
|
||||
APP_ABSTRACT_HANDLER
|
||||
rename
|
||||
set_esa_config as make
|
||||
end
|
||||
WSF_FILTER
|
||||
|
||||
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute the filter
|
||||
|
||||
do
|
||||
if roc_config.is_successful and then roc_config.api_service.successful then
|
||||
log.write_information (generator + ".execute")
|
||||
execute_next (req, res)
|
||||
else
|
||||
-- send internal server error.
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
note
|
||||
copyright: "2011-2012, Olivier Ligot, Jocelyn Fiat and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
|
||||
end
|
||||
@@ -1,54 +0,0 @@
|
||||
note
|
||||
description: "Logger filter"
|
||||
date: "$Date: 2014-08-08 16:02:11 -0300 (vi., 08 ago. 2014) $"
|
||||
revision: "$Revision: 95593 $"
|
||||
|
||||
class
|
||||
LOGGER_FILTER
|
||||
|
||||
|
||||
inherit
|
||||
WSF_URI_TEMPLATE_HANDLER
|
||||
|
||||
APP_ABSTRACT_HANDLER
|
||||
rename
|
||||
set_esa_config as make
|
||||
end
|
||||
WSF_FILTER
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute the filter.
|
||||
local
|
||||
s: STRING_8
|
||||
do
|
||||
log.write_debug (generator + ".execute")
|
||||
create s.make (2048)
|
||||
if attached req.content_type as l_type then
|
||||
s.append ("[length=")
|
||||
s.append_natural_64 (req.content_length_value)
|
||||
s.append_character (']')
|
||||
s.append_character (' ')
|
||||
s.append (l_type.debug_output)
|
||||
s.append_character ('%N')
|
||||
end
|
||||
|
||||
append_iterable_to ("Path parameters", req.path_parameters, s)
|
||||
append_iterable_to ("Query parameters", req.query_parameters, s)
|
||||
append_iterable_to ("Form parameters", req.form_parameters, s)
|
||||
|
||||
if not s.is_empty then
|
||||
log.write_debug (generator + ".execute" + s)
|
||||
end
|
||||
execute_next (req, res)
|
||||
end
|
||||
|
||||
|
||||
note
|
||||
copyright: "2011-2012, Olivier Ligot, Jocelyn Fiat and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
end
|
||||
@@ -1,48 +0,0 @@
|
||||
note
|
||||
description: "Abstrat Eiffel Support API Handler."
|
||||
date: "$Date: 2014-08-08 16:02:11 -0300 (vi., 08 ago. 2014) $"
|
||||
revision: "$Revision: 95593 $"
|
||||
|
||||
deferred class
|
||||
APP_ABSTRACT_HANDLER
|
||||
|
||||
inherit
|
||||
WSF_HANDLER
|
||||
|
||||
APP_HANDLER
|
||||
|
||||
SHARED_CONNEG_HELPER
|
||||
|
||||
feature -- Change
|
||||
|
||||
set_esa_config (a_esa_config: like roc_config)
|
||||
-- Set `roc_config' to `a_esa_condig'.
|
||||
do
|
||||
roc_config := a_esa_config
|
||||
ensure
|
||||
esa_config_set: roc_config = a_esa_config
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
roc_config: ROC_CONFIG
|
||||
-- Configuration.
|
||||
|
||||
api_service: ROC_API_SERVICE
|
||||
-- api Service.
|
||||
do
|
||||
Result := roc_config.api_service
|
||||
end
|
||||
|
||||
email_service: ROC_EMAIL_SERVICE
|
||||
-- Email Service.
|
||||
do
|
||||
Result := roc_config.email_service
|
||||
end
|
||||
|
||||
is_web: BOOLEAN
|
||||
do
|
||||
Result := roc_config.is_web
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,98 +0,0 @@
|
||||
note
|
||||
description: "Summary description for {ESA_HANDLER}."
|
||||
date: "$Date: 2014-08-20 15:21:15 -0300 (mi., 20 ago. 2014) $"
|
||||
revision: "$Revision: 95678 $"
|
||||
|
||||
class
|
||||
APP_HANDLER
|
||||
|
||||
inherit
|
||||
|
||||
SHARED_LOGGER
|
||||
|
||||
feature -- User
|
||||
|
||||
current_user_name (req: WSF_REQUEST): detachable READABLE_STRING_32
|
||||
-- Current user name or Void in case of Guest users.
|
||||
note
|
||||
EIS: "src=eiffel:?class=AUTHENTICATION_FILTER&feature=execute"
|
||||
do
|
||||
if attached {CMS_USER} current_user (req) as l_user then
|
||||
Result := l_user.name
|
||||
end
|
||||
end
|
||||
|
||||
current_user (req: WSF_REQUEST): detachable CMS_USER
|
||||
-- Current user or Void in case of Guest user.
|
||||
note
|
||||
EIS: "eiffel:?class=AUTHENTICATION_FILTER&feature=execute"
|
||||
do
|
||||
if attached {CMS_USER} req.execution_variable ("user") as l_user then
|
||||
Result := l_user
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Media Type
|
||||
|
||||
current_media_type (req: WSF_REQUEST): detachable READABLE_STRING_32
|
||||
-- Current media type or Void if it's not acceptable.
|
||||
do
|
||||
if attached {STRING} req.execution_variable ("media_type") as l_type then
|
||||
Result := l_type
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Absolute Host
|
||||
|
||||
absolute_host (req: WSF_REQUEST; a_path:STRING): STRING
|
||||
do
|
||||
Result := req.absolute_script_url (a_path)
|
||||
if Result.last_index_of ('/', Result.count) = Result.count then
|
||||
Result.remove_tail (1)
|
||||
end
|
||||
log.write_debug (generator + ".absolute_host " + Result )
|
||||
end
|
||||
|
||||
feature -- Compression
|
||||
|
||||
current_compression (req: WSF_REQUEST): detachable READABLE_STRING_32
|
||||
-- Current compression encoding or Void if it's not acceptable.
|
||||
do
|
||||
if attached {STRING} req.execution_variable ("compression") as l_encoding then
|
||||
Result := l_encoding
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementations
|
||||
|
||||
append_iterable_to (a_title: READABLE_STRING_8; it: detachable ITERABLE [WSF_VALUE]; s: STRING_8)
|
||||
local
|
||||
n: INTEGER
|
||||
do
|
||||
if it /= Void then
|
||||
across it as c loop
|
||||
n := n + 1
|
||||
end
|
||||
if n > 0 then
|
||||
s.append (a_title)
|
||||
s.append_character (':')
|
||||
s.append_character ('%N')
|
||||
across
|
||||
it as c
|
||||
loop
|
||||
s.append (" - ")
|
||||
s.append (c.item.url_encoded_name)
|
||||
s.append_character (' ')
|
||||
s.append_character ('{')
|
||||
s.append (c.item.generating_type)
|
||||
s.append_character ('}')
|
||||
s.append_character ('=')
|
||||
s.append (c.item.debug_output.as_string_8)
|
||||
s.append_character ('%N')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
@@ -1,57 +0,0 @@
|
||||
note
|
||||
description: "Summary description for {NAVIGATION_HANDLER}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
NAVIGATION_HANDLER
|
||||
inherit
|
||||
APP_ABSTRACT_HANDLER
|
||||
rename
|
||||
set_esa_config as make
|
||||
end
|
||||
|
||||
WSF_FILTER
|
||||
|
||||
WSF_URI_HANDLER
|
||||
rename
|
||||
execute as uri_execute,
|
||||
new_mapping as new_uri_mapping
|
||||
end
|
||||
|
||||
WSF_RESOURCE_HANDLER_HELPER
|
||||
redefine
|
||||
do_get
|
||||
end
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- execute
|
||||
|
||||
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute request handler
|
||||
do
|
||||
execute_methods (req, res)
|
||||
execute_next (req, res)
|
||||
end
|
||||
|
||||
uri_execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute request handler
|
||||
do
|
||||
execute_methods (req, res)
|
||||
end
|
||||
|
||||
feature -- HTTP Methods
|
||||
|
||||
do_get (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- <Precursor>
|
||||
local
|
||||
l_page: ROC_RESPONSE
|
||||
do
|
||||
create l_page.make (req, "modules/navigation.tpl")
|
||||
l_page.send_to (res)
|
||||
end
|
||||
end
|
||||
@@ -1,190 +0,0 @@
|
||||
note
|
||||
description: "Summary description for {NEW_CONTENT_HANDLER}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
NODE_CONTENT_HANDLER
|
||||
|
||||
inherit
|
||||
APP_ABSTRACT_HANDLER
|
||||
rename
|
||||
set_esa_config as make
|
||||
end
|
||||
|
||||
WSF_FILTER
|
||||
|
||||
WSF_URI_HANDLER
|
||||
rename
|
||||
execute as uri_execute,
|
||||
new_mapping as new_uri_mapping
|
||||
end
|
||||
|
||||
WSF_URI_TEMPLATE_HANDLER
|
||||
rename
|
||||
execute as uri_template_execute,
|
||||
new_mapping as new_uri_template_mapping
|
||||
select
|
||||
new_uri_template_mapping
|
||||
end
|
||||
|
||||
WSF_RESOURCE_HANDLER_HELPER
|
||||
redefine
|
||||
do_get,
|
||||
do_post,
|
||||
do_put
|
||||
end
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- execute
|
||||
|
||||
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute request handler
|
||||
do
|
||||
execute_methods (req, res)
|
||||
execute_next (req, res)
|
||||
end
|
||||
|
||||
uri_execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute request handler
|
||||
do
|
||||
execute_methods (req, res)
|
||||
end
|
||||
|
||||
uri_template_execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute request handler
|
||||
do
|
||||
execute_methods (req, res)
|
||||
end
|
||||
|
||||
feature -- HTTP Methods
|
||||
|
||||
do_get (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- <Precursor>
|
||||
local
|
||||
l_page: ROC_RESPONSE
|
||||
do
|
||||
if attached current_user_name (req) then
|
||||
-- Existing node
|
||||
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
|
||||
create l_page.make (req, "modules/node_content.tpl")
|
||||
l_page.set_value (l_node.content, "content")
|
||||
l_page.set_value (l_id.value, "id")
|
||||
l_page.set_value (roc_config.is_web, "web")
|
||||
l_page.set_value (roc_config.is_html, "html")
|
||||
l_page.send_to (res)
|
||||
else
|
||||
do_error (req, res, l_id)
|
||||
end
|
||||
else
|
||||
-- Todo extract method
|
||||
create l_page.make (req, "master2/error.tpl")
|
||||
l_page.set_value ("500", "code")
|
||||
l_page.set_value (req.absolute_script_url (req.path_info), "request")
|
||||
l_page.send_to (res)
|
||||
end
|
||||
else
|
||||
(create {ROC_RESPONSE}.make(req,"")).new_response_unauthorized (req, res)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
do_post (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- <Precursor>
|
||||
local
|
||||
u_node: CMS_NODE
|
||||
l_page: ROC_RESPONSE
|
||||
do
|
||||
if attached current_user_name (req) 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 attached {WSF_STRING} req.form_parameter ("method") as l_method then
|
||||
if l_method.is_case_insensitive_equal ("PUT") then
|
||||
do_put (req, res)
|
||||
else
|
||||
create l_page.make (req, "master2/error.tpl")
|
||||
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
|
||||
do_error (req, res, l_id)
|
||||
end
|
||||
else
|
||||
create l_page.make (req, "master2/error.tpl")
|
||||
l_page.set_value ("500", "code")
|
||||
l_page.set_value (req.absolute_script_url (req.path_info), "request")
|
||||
l_page.send_to (res)
|
||||
end
|
||||
else
|
||||
(create {ROC_RESPONSE}.make(req,"")).new_response_unauthorized (req, res)
|
||||
end
|
||||
end
|
||||
|
||||
do_put (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- <Precursor>
|
||||
local
|
||||
u_node: CMS_NODE
|
||||
l_page: ROC_RESPONSE
|
||||
do
|
||||
to_implement ("Check if user has permissions")
|
||||
if attached current_user (req) as l_user 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
|
||||
u_node := extract_data_form (req)
|
||||
u_node.set_id (l_id.integer_value)
|
||||
api_service.update_node_content (l_user.id, u_node.id, u_node.content)
|
||||
(create {ROC_RESPONSE}.make (req, "")).new_response_redirect (req, res, req.absolute_script_url (""))
|
||||
else
|
||||
do_error (req, res, l_id)
|
||||
end
|
||||
else
|
||||
create l_page.make (req, "master2/error.tpl")
|
||||
l_page.set_value ("500", "code")
|
||||
l_page.set_value (req.absolute_script_url (req.path_info), "request")
|
||||
l_page.send_to (res)
|
||||
end
|
||||
else
|
||||
(create {ROC_RESPONSE}.make(req,"")).new_response_unauthorized (req, res)
|
||||
end
|
||||
end
|
||||
feature -- Error
|
||||
|
||||
do_error (req: WSF_REQUEST; res: WSF_RESPONSE; a_id: WSF_STRING)
|
||||
-- Handling error.
|
||||
local
|
||||
l_page: ROC_RESPONSE
|
||||
do
|
||||
create l_page.make (req, "master2/error.tpl")
|
||||
if a_id.is_integer then
|
||||
-- resource not found
|
||||
l_page.set_value ("404", "code")
|
||||
else
|
||||
-- bad request
|
||||
l_page.set_value ("400", "code")
|
||||
end
|
||||
l_page.set_value (req.absolute_script_url (req.path_info), "request")
|
||||
l_page.send_to(res)
|
||||
end
|
||||
|
||||
|
||||
feature -- {NONE} Form data
|
||||
|
||||
|
||||
extract_data_form (req: WSF_REQUEST): CMS_NODE
|
||||
-- Extract request form data and build a object
|
||||
-- Node
|
||||
do
|
||||
create Result.make ("", "", "")
|
||||
if attached {WSF_STRING}req.form_parameter ("content") as l_content then
|
||||
Result.set_content (l_content.value)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,225 +0,0 @@
|
||||
note
|
||||
description: "Summary description for {NODE_HANDLER}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
NODE_HANDLER
|
||||
|
||||
inherit
|
||||
|
||||
APP_ABSTRACT_HANDLER
|
||||
rename
|
||||
set_esa_config as make
|
||||
end
|
||||
|
||||
WSF_FILTER
|
||||
|
||||
WSF_URI_HANDLER
|
||||
rename
|
||||
execute as uri_execute,
|
||||
new_mapping as new_uri_mapping
|
||||
end
|
||||
|
||||
WSF_URI_TEMPLATE_HANDLER
|
||||
rename
|
||||
execute as uri_template_execute,
|
||||
new_mapping as new_uri_template_mapping
|
||||
select
|
||||
new_uri_template_mapping
|
||||
end
|
||||
|
||||
WSF_RESOURCE_HANDLER_HELPER
|
||||
redefine
|
||||
do_get,
|
||||
do_post,
|
||||
do_put,
|
||||
do_delete
|
||||
end
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- execute
|
||||
|
||||
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute request handler
|
||||
do
|
||||
execute_methods (req, res)
|
||||
execute_next (req, res)
|
||||
end
|
||||
|
||||
uri_execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute request handler
|
||||
do
|
||||
execute_methods (req, res)
|
||||
end
|
||||
|
||||
uri_template_execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute request handler
|
||||
do
|
||||
execute_methods (req, res)
|
||||
end
|
||||
|
||||
feature -- HTTP Methods
|
||||
|
||||
do_get (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- <Precursor>
|
||||
local
|
||||
l_page: ROC_RESPONSE
|
||||
do
|
||||
-- Existing node
|
||||
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
|
||||
create l_page.make (req, "modules/node.tpl")
|
||||
l_page.set_value (l_node, "node")
|
||||
l_page.set_value (roc_config.is_web, "web")
|
||||
l_page.set_value (roc_config.is_html, "html")
|
||||
l_page.send_to (res)
|
||||
else
|
||||
do_error (req, res, l_id)
|
||||
end
|
||||
else
|
||||
-- Factory
|
||||
new_node (req, res)
|
||||
end
|
||||
end
|
||||
|
||||
do_post (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- <Precursor>
|
||||
local
|
||||
u_node: CMS_NODE
|
||||
l_page: ROC_RESPONSE
|
||||
do
|
||||
to_implement ("Check user permissions!!!")
|
||||
if attached current_user (req) as l_user 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 attached {WSF_STRING} req.form_parameter ("method") as l_method then
|
||||
if l_method.is_case_insensitive_equal ("DELETE") then
|
||||
do_delete (req, res)
|
||||
elseif l_method.is_case_insensitive_equal ("PUT") then
|
||||
do_put (req, res)
|
||||
else
|
||||
create l_page.make (req, "master2/error.tpl")
|
||||
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
|
||||
do_error (req, res, l_id)
|
||||
end
|
||||
else
|
||||
-- New node
|
||||
u_node := extract_data_form (req)
|
||||
u_node.set_author (l_user)
|
||||
api_service.new_node (u_node)
|
||||
(create {ROC_RESPONSE}.make (req, "")).new_response_redirect (req, res, req.absolute_script_url (""))
|
||||
end
|
||||
else
|
||||
(create {ROC_RESPONSE}.make(req,"")).new_response_unauthorized (req, res)
|
||||
end
|
||||
end
|
||||
|
||||
do_put (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- <Precursor>
|
||||
local
|
||||
u_node: CMS_NODE
|
||||
do
|
||||
|
||||
if attached current_user (req) as l_user 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
|
||||
u_node := extract_data_form (req)
|
||||
u_node.set_id (l_id.integer_value)
|
||||
api_service.update_node (l_user.id,u_node)
|
||||
(create {ROC_RESPONSE}.make (req, "")).new_response_redirect (req, res, req.absolute_script_url (""))
|
||||
else
|
||||
do_error (req, res, l_id)
|
||||
end
|
||||
else
|
||||
-- Internal server error
|
||||
end
|
||||
else
|
||||
(create {ROC_RESPONSE}.make(req,"")).new_response_unauthorized (req, res)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
do_delete (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- <Precursor>
|
||||
do
|
||||
if attached current_user_name (req) 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
|
||||
api_service.delete_node (l_id.integer_value)
|
||||
(create {ROC_RESPONSE}.make (req, "")).new_response_redirect (req, res, req.absolute_script_url (""))
|
||||
else
|
||||
do_error (req, res, l_id)
|
||||
end
|
||||
else
|
||||
-- Internal server error
|
||||
end
|
||||
else
|
||||
(create {ROC_RESPONSE}.make(req,"")).new_response_unauthorized (req, res)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Error
|
||||
|
||||
do_error (req: WSF_REQUEST; res: WSF_RESPONSE; a_id: WSF_STRING)
|
||||
-- Handling error.
|
||||
local
|
||||
l_page: ROC_RESPONSE
|
||||
do
|
||||
create l_page.make (req, "master2/error.tpl")
|
||||
if a_id.is_integer then
|
||||
-- resource not found
|
||||
l_page.set_value ("404", "code")
|
||||
else
|
||||
-- bad request
|
||||
l_page.set_value ("400", "code")
|
||||
end
|
||||
l_page.set_value (req.absolute_script_url (req.path_info), "request")
|
||||
l_page.send_to (res)
|
||||
end
|
||||
|
||||
feature {NONE} -- Node
|
||||
|
||||
new_node (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
local
|
||||
l_page: ROC_RESPONSE
|
||||
do
|
||||
if attached current_user_name (req) then
|
||||
create l_page.make (req, "modules/node.tpl")
|
||||
l_page.set_value (roc_config.is_web, "web")
|
||||
l_page.set_value (roc_config.is_html, "html")
|
||||
|
||||
l_page.send_to (res)
|
||||
else
|
||||
(create {ROC_RESPONSE}.make (req, "")).new_response_unauthorized (req, res)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- {NONE} Form data
|
||||
|
||||
extract_data_form (req: WSF_REQUEST): CMS_NODE
|
||||
-- Extract request form data and build a object
|
||||
-- Node
|
||||
do
|
||||
create Result.make ("", "", "")
|
||||
if attached {WSF_STRING} req.form_parameter ("title") as l_title then
|
||||
Result.set_title (l_title.value)
|
||||
end
|
||||
if attached {WSF_STRING} req.form_parameter ("summary") as l_summary then
|
||||
Result.set_summary (l_summary.value)
|
||||
end
|
||||
if attached {WSF_STRING} req.form_parameter ("content") as l_content then
|
||||
Result.set_content (l_content.value)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,199 +0,0 @@
|
||||
note
|
||||
description: "Summary description for {NODE_SUMMARY_HANDLER}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
NODE_SUMMARY_HANDLER
|
||||
|
||||
inherit
|
||||
APP_ABSTRACT_HANDLER
|
||||
rename
|
||||
set_esa_config as make
|
||||
end
|
||||
|
||||
WSF_FILTER
|
||||
|
||||
WSF_URI_HANDLER
|
||||
rename
|
||||
execute as uri_execute,
|
||||
new_mapping as new_uri_mapping
|
||||
end
|
||||
|
||||
WSF_URI_TEMPLATE_HANDLER
|
||||
rename
|
||||
execute as uri_template_execute,
|
||||
new_mapping as new_uri_template_mapping
|
||||
select
|
||||
new_uri_template_mapping
|
||||
end
|
||||
|
||||
WSF_RESOURCE_HANDLER_HELPER
|
||||
redefine
|
||||
do_get,
|
||||
do_post,
|
||||
do_put
|
||||
end
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- execute
|
||||
|
||||
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute request handler
|
||||
do
|
||||
execute_methods (req, res)
|
||||
execute_next (req, res)
|
||||
end
|
||||
|
||||
uri_execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute request handler
|
||||
do
|
||||
execute_methods (req, res)
|
||||
end
|
||||
|
||||
uri_template_execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute request handler
|
||||
do
|
||||
execute_methods (req, res)
|
||||
end
|
||||
|
||||
feature -- HTTP Methods
|
||||
|
||||
do_get (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- <Precursor>
|
||||
local
|
||||
l_page: ROC_RESPONSE
|
||||
do
|
||||
if attached current_user_name (req) then
|
||||
-- Existing node
|
||||
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
|
||||
create l_page.make (req, "modules/node_summary.tpl")
|
||||
l_page.set_value (l_node.summary, "summary")
|
||||
l_page.set_value (roc_config.is_web, "web")
|
||||
l_page.set_value (roc_config.is_html, "html")
|
||||
l_page.set_value (l_id.value, "id")
|
||||
l_page.send_to (res)
|
||||
else
|
||||
do_error (req, res, l_id)
|
||||
end
|
||||
else
|
||||
create l_page.make (req, "master2/error.tpl")
|
||||
l_page.set_value ("500", "code")
|
||||
l_page.set_value (req.absolute_script_url (req.path_info), "request")
|
||||
l_page.send_to (res)
|
||||
end
|
||||
else
|
||||
(create {ROC_RESPONSE}.make(req,"")).new_response_unauthorized (req, res)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
do_post (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- <Precursor>
|
||||
local
|
||||
u_node: CMS_NODE
|
||||
l_page: ROC_RESPONSE
|
||||
do
|
||||
if attached current_user_name (req) 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 attached {WSF_STRING} req.form_parameter ("method") as l_method then
|
||||
if l_method.is_case_insensitive_equal ("PUT") then
|
||||
do_put (req, res)
|
||||
else
|
||||
create l_page.make (req, "master2/error.tpl")
|
||||
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
|
||||
do_error (req, res, l_id)
|
||||
end
|
||||
else
|
||||
create l_page.make (req, "master2/error.tpl")
|
||||
l_page.set_value ("500", "code")
|
||||
l_page.set_value (req.absolute_script_url (req.path_info), "request")
|
||||
l_page.send_to (res)
|
||||
end
|
||||
else
|
||||
(create {ROC_RESPONSE}.make(req,"")).new_response_unauthorized (req, res)
|
||||
end
|
||||
end
|
||||
|
||||
do_put (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- <Precursor>
|
||||
local
|
||||
u_node: CMS_NODE
|
||||
l_page: ROC_RESPONSE
|
||||
do
|
||||
to_implement ("Check if user has permissions!!!")
|
||||
if attached current_user (req) as l_user 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
|
||||
u_node := extract_data_form (req)
|
||||
u_node.set_id (l_id.integer_value)
|
||||
api_service.update_node_summary (l_user.id,u_node.id, u_node.summary)
|
||||
(create {ROC_RESPONSE}.make (req, "")).new_response_redirect (req, res, req.absolute_script_url (""))
|
||||
else
|
||||
do_error (req, res, l_id)
|
||||
end
|
||||
else
|
||||
create l_page.make (req, "master2/error.tpl")
|
||||
l_page.set_value ("500", "code")
|
||||
l_page.set_value (req.absolute_script_url (req.path_info), "request")
|
||||
l_page.send_to (res)
|
||||
end
|
||||
else
|
||||
(create {ROC_RESPONSE}.make(req,"")).new_response_unauthorized (req, res)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Error
|
||||
|
||||
do_error (req: WSF_REQUEST; res: WSF_RESPONSE; a_id: WSF_STRING)
|
||||
-- Handling error.
|
||||
local
|
||||
l_page: ROC_RESPONSE
|
||||
do
|
||||
create l_page.make (req, "master2/error.tpl")
|
||||
if a_id.is_integer then
|
||||
-- resource not found
|
||||
l_page.set_value ("404", "code")
|
||||
else
|
||||
-- bad request
|
||||
l_page.set_value ("400", "code")
|
||||
end
|
||||
l_page.set_value (req.absolute_script_url (req.path_info), "request")
|
||||
l_page.send_to(res)
|
||||
end
|
||||
|
||||
feature {NONE} -- Node
|
||||
|
||||
new_node (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
local
|
||||
l_page: ROC_RESPONSE
|
||||
do
|
||||
create l_page.make (req, "modules/node.tpl")
|
||||
l_page.send_to (res)
|
||||
end
|
||||
|
||||
feature -- {NONE} Form data
|
||||
|
||||
|
||||
extract_data_form (req: WSF_REQUEST): CMS_NODE
|
||||
-- Extract request form data and build a object
|
||||
-- Node
|
||||
do
|
||||
create Result.make ("", "", "")
|
||||
if attached {WSF_STRING}req.form_parameter ("summary") as l_summary then
|
||||
Result.set_summary (l_summary.value)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,199 +0,0 @@
|
||||
note
|
||||
description: "Summary description for {NODE_TITLE_HANDLER}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
NODE_TITLE_HANDLER
|
||||
|
||||
inherit
|
||||
|
||||
APP_ABSTRACT_HANDLER
|
||||
rename
|
||||
set_esa_config as make
|
||||
end
|
||||
|
||||
WSF_FILTER
|
||||
|
||||
WSF_URI_HANDLER
|
||||
rename
|
||||
execute as uri_execute,
|
||||
new_mapping as new_uri_mapping
|
||||
end
|
||||
|
||||
WSF_URI_TEMPLATE_HANDLER
|
||||
rename
|
||||
execute as uri_template_execute,
|
||||
new_mapping as new_uri_template_mapping
|
||||
select
|
||||
new_uri_template_mapping
|
||||
end
|
||||
|
||||
WSF_RESOURCE_HANDLER_HELPER
|
||||
redefine
|
||||
do_get,
|
||||
do_post,
|
||||
do_put
|
||||
end
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- execute
|
||||
|
||||
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute request handler
|
||||
do
|
||||
execute_methods (req, res)
|
||||
execute_next (req, res)
|
||||
end
|
||||
|
||||
uri_execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute request handler
|
||||
do
|
||||
execute_methods (req, res)
|
||||
end
|
||||
|
||||
uri_template_execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute request handler
|
||||
do
|
||||
execute_methods (req, res)
|
||||
end
|
||||
|
||||
feature -- HTTP Methods
|
||||
|
||||
do_get (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- <Precursor>
|
||||
local
|
||||
l_page: ROC_RESPONSE
|
||||
do
|
||||
if attached current_user_name (req) as l_user then
|
||||
-- Existing node
|
||||
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
|
||||
create l_page.make (req, "modules/node_title.tpl")
|
||||
l_page.set_value (l_node.title, "title")
|
||||
l_page.set_value (l_id.value, "id")
|
||||
l_page.set_value (roc_config.is_web, "web")
|
||||
l_page.set_value (roc_config.is_html, "html")
|
||||
l_page.send_to (res)
|
||||
else
|
||||
do_error (req, res, l_id)
|
||||
end
|
||||
else
|
||||
create l_page.make (req, "master2/error.tpl")
|
||||
l_page.set_value ("500", "code")
|
||||
l_page.set_value (req.absolute_script_url (req.path_info), "request")
|
||||
l_page.send_to (res)
|
||||
end
|
||||
else
|
||||
(create {ROC_RESPONSE}.make(req,"")).new_response_unauthorized (req, res)
|
||||
end
|
||||
end
|
||||
|
||||
do_post (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- <Precursor>
|
||||
local
|
||||
u_node: CMS_NODE
|
||||
l_page: ROC_RESPONSE
|
||||
do
|
||||
if attached current_user_name (req) as l_user 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 attached {WSF_STRING} req.form_parameter ("method") as l_method then
|
||||
if l_method.is_case_insensitive_equal ("PUT") then
|
||||
do_put (req, res)
|
||||
else
|
||||
create l_page.make (req, "master2/error.tpl")
|
||||
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
|
||||
do_error (req, res, l_id)
|
||||
end
|
||||
else
|
||||
create l_page.make (req, "master2/error.tpl")
|
||||
l_page.set_value ("500", "code")
|
||||
l_page.set_value (req.absolute_script_url (req.path_info), "request")
|
||||
l_page.send_to (res)
|
||||
end
|
||||
else
|
||||
(create {ROC_RESPONSE}.make(req,"")).new_response_unauthorized (req, res)
|
||||
end
|
||||
end
|
||||
|
||||
do_put (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- <Precursor>
|
||||
local
|
||||
u_node: CMS_NODE
|
||||
l_page: ROC_RESPONSE
|
||||
do
|
||||
to_implement ("Check if user has permissions")
|
||||
if attached current_user (req) as l_user 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
|
||||
u_node := extract_data_form (req)
|
||||
u_node.set_id (l_id.integer_value)
|
||||
api_service.update_node_title (l_user.id,u_node.id, u_node.title)
|
||||
(create {ROC_RESPONSE}.make (req, "")).new_response_redirect (req, res, req.absolute_script_url (""))
|
||||
else
|
||||
do_error (req, res, l_id)
|
||||
end
|
||||
else
|
||||
create l_page.make (req, "master2/error.tpl")
|
||||
l_page.set_value ("500", "code")
|
||||
l_page.set_value (req.absolute_script_url (req.path_info), "request")
|
||||
l_page.send_to (res)
|
||||
end
|
||||
else
|
||||
(create {ROC_RESPONSE}.make(req,"")).new_response_unauthorized (req, res)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Error
|
||||
|
||||
do_error (req: WSF_REQUEST; res: WSF_RESPONSE; a_id: WSF_STRING)
|
||||
-- Handling error.
|
||||
local
|
||||
l_page: ROC_RESPONSE
|
||||
do
|
||||
create l_page.make (req, "master2/error.tpl")
|
||||
if a_id.is_integer then
|
||||
-- resource not found
|
||||
l_page.set_value ("404", "code")
|
||||
else
|
||||
-- bad request
|
||||
l_page.set_value ("400", "code")
|
||||
end
|
||||
l_page.set_value (req.absolute_script_url (req.path_info), "request")
|
||||
l_page.send_to (res)
|
||||
end
|
||||
|
||||
feature {NONE} -- Node
|
||||
|
||||
new_node (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
local
|
||||
l_page: ROC_RESPONSE
|
||||
do
|
||||
create l_page.make (req, "modules/node.tpl")
|
||||
l_page.send_to (res)
|
||||
end
|
||||
|
||||
feature -- {NONE} Form data
|
||||
|
||||
extract_data_form (req: WSF_REQUEST): CMS_NODE
|
||||
-- Extract request form data and build a object
|
||||
-- Node
|
||||
do
|
||||
create Result.make ("", "", "")
|
||||
if attached {WSF_STRING} req.form_parameter ("title") as l_title then
|
||||
Result.set_title (l_title.value)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,62 +0,0 @@
|
||||
note
|
||||
description: "Summary description for {NODES_HANDLER}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
NODES_HANDLER
|
||||
|
||||
inherit
|
||||
APP_ABSTRACT_HANDLER
|
||||
rename
|
||||
set_esa_config as make
|
||||
end
|
||||
|
||||
WSF_FILTER
|
||||
|
||||
WSF_URI_HANDLER
|
||||
rename
|
||||
execute as uri_execute,
|
||||
new_mapping as new_uri_mapping
|
||||
end
|
||||
|
||||
WSF_RESOURCE_HANDLER_HELPER
|
||||
redefine
|
||||
do_get
|
||||
end
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- execute
|
||||
|
||||
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute request handler
|
||||
do
|
||||
execute_methods (req, res)
|
||||
execute_next (req, res)
|
||||
end
|
||||
|
||||
uri_execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute request handler
|
||||
do
|
||||
execute_methods (req, res)
|
||||
end
|
||||
|
||||
feature -- HTTP Methods
|
||||
|
||||
do_get (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- <Precursor>
|
||||
local
|
||||
l_page: ROC_RESPONSE
|
||||
do
|
||||
|
||||
create l_page.make (req, "modules/nodes.tpl")
|
||||
l_page.set_value (api_service.nodes, "nodes")
|
||||
l_page.set_value (roc_config.is_web, "web")
|
||||
l_page.set_value (roc_config.is_html, "html")
|
||||
l_page.send_to (res)
|
||||
end
|
||||
end
|
||||
@@ -1,63 +0,0 @@
|
||||
note
|
||||
description: "ROOT_HANDLER."
|
||||
date: "$Date: 2014-08-08 16:02:11 -0300 (vi., 08 ago. 2014) $"
|
||||
revision: "$Revision: 95593 $"
|
||||
|
||||
class
|
||||
ROC_ROOT_HANDLER
|
||||
|
||||
inherit
|
||||
APP_ABSTRACT_HANDLER
|
||||
rename
|
||||
set_esa_config as make
|
||||
end
|
||||
|
||||
WSF_FILTER
|
||||
|
||||
WSF_URI_HANDLER
|
||||
rename
|
||||
execute as uri_execute,
|
||||
new_mapping as new_uri_mapping
|
||||
end
|
||||
|
||||
WSF_RESOURCE_HANDLER_HELPER
|
||||
redefine
|
||||
do_get
|
||||
end
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- execute
|
||||
|
||||
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute request handler
|
||||
do
|
||||
execute_methods (req, res)
|
||||
execute_next (req, res)
|
||||
end
|
||||
|
||||
uri_execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute request handler
|
||||
do
|
||||
execute_methods (req, res)
|
||||
end
|
||||
|
||||
feature -- HTTP Methods
|
||||
|
||||
do_get (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- <Precursor>
|
||||
local
|
||||
l_page: ROC_RESPONSE
|
||||
do
|
||||
|
||||
create l_page.make (req, "layout2.tpl")
|
||||
l_page.set_value (api_service.recent_nodes (0,5), "nodes")
|
||||
l_page.set_value (is_web, "web")
|
||||
l_page.set_value (roc_config.is_html, "html")
|
||||
l_page.send_to (res)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,163 +0,0 @@
|
||||
note
|
||||
description: "Summary description for {USER_HANDLER}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
USER_HANDLER
|
||||
|
||||
inherit
|
||||
|
||||
APP_ABSTRACT_HANDLER
|
||||
rename
|
||||
set_esa_config as make
|
||||
end
|
||||
|
||||
WSF_FILTER
|
||||
|
||||
WSF_URI_HANDLER
|
||||
rename
|
||||
execute as uri_execute,
|
||||
new_mapping as new_uri_mapping
|
||||
end
|
||||
|
||||
WSF_URI_TEMPLATE_HANDLER
|
||||
rename
|
||||
execute as uri_template_execute,
|
||||
new_mapping as new_uri_template_mapping
|
||||
select
|
||||
new_uri_template_mapping
|
||||
end
|
||||
|
||||
WSF_RESOURCE_HANDLER_HELPER
|
||||
redefine
|
||||
do_get,
|
||||
do_post,
|
||||
do_put,
|
||||
do_delete
|
||||
end
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- execute
|
||||
|
||||
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute request handler
|
||||
do
|
||||
execute_methods (req, res)
|
||||
execute_next (req, res)
|
||||
end
|
||||
|
||||
uri_execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute request handler
|
||||
do
|
||||
execute_methods (req, res)
|
||||
end
|
||||
|
||||
uri_template_execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute request handler
|
||||
do
|
||||
execute_methods (req, res)
|
||||
end
|
||||
|
||||
feature -- HTTP Methods
|
||||
|
||||
do_get (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- <Precursor>
|
||||
local
|
||||
l_page: ROC_RESPONSE
|
||||
do
|
||||
-- Existing node
|
||||
create l_page.make (req, "modules/register.tpl")
|
||||
l_page.set_value (roc_config.is_web, "web")
|
||||
l_page.set_value (roc_config.is_html, "html")
|
||||
l_page.send_to (res)
|
||||
end
|
||||
|
||||
do_post (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- <Precursor>
|
||||
local
|
||||
u_node: CMS_NODE
|
||||
l_page: ROC_RESPONSE
|
||||
do
|
||||
-- New user
|
||||
api_service.new_user (extract_data_form (req))
|
||||
if api_service.successful then
|
||||
(create {ROC_RESPONSE}.make (req, "")).new_response_redirect (req, res, req.absolute_script_url (""))
|
||||
else
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
do_put (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- <Precursor>
|
||||
local
|
||||
u_node: CMS_NODE
|
||||
do
|
||||
end
|
||||
|
||||
do_delete (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- <Precursor>
|
||||
do
|
||||
end
|
||||
|
||||
feature -- Error
|
||||
|
||||
do_error (req: WSF_REQUEST; res: WSF_RESPONSE; a_id: WSF_STRING)
|
||||
-- Handling error.
|
||||
local
|
||||
l_page: ROC_RESPONSE
|
||||
do
|
||||
create l_page.make (req, "master2/error.tpl")
|
||||
if a_id.is_integer then
|
||||
-- resource not found
|
||||
l_page.set_value ("404", "code")
|
||||
else
|
||||
-- bad request
|
||||
l_page.set_value ("400", "code")
|
||||
end
|
||||
l_page.set_value (req.absolute_script_url (req.path_info), "request")
|
||||
l_page.send_to (res)
|
||||
end
|
||||
|
||||
feature {NONE} -- Node
|
||||
|
||||
new_node (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
local
|
||||
l_page: ROC_RESPONSE
|
||||
do
|
||||
if attached current_user_name (req) then
|
||||
create l_page.make (req, "modules/node.tpl")
|
||||
l_page.send_to (res)
|
||||
else
|
||||
(create {ROC_RESPONSE}.make (req, "")).new_response_unauthorized (req, res)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- {NONE} Form data
|
||||
|
||||
extract_data_form (req: WSF_REQUEST): CMS_USER
|
||||
-- Extract request form data and build a object
|
||||
-- user
|
||||
do
|
||||
create Result.make ("")
|
||||
if attached {WSF_STRING} req.form_parameter ("username") as l_username then
|
||||
Result.set_name (l_username)
|
||||
end
|
||||
if
|
||||
attached {WSF_STRING} req.form_parameter ("password") as l_password and then
|
||||
attached {WSF_STRING} req.form_parameter ("check_password") as l_check_password and then
|
||||
l_password.value.is_case_insensitive_equal (l_check_password.value)
|
||||
then
|
||||
Result.set_password (l_password)
|
||||
end
|
||||
if attached {WSF_STRING} req.form_parameter ("email") as l_email then
|
||||
Result.set_email (l_email)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,126 +0,0 @@
|
||||
note
|
||||
description: "API Service facade to the underlying business logic"
|
||||
date: "$Date: 2014-08-20 15:21:15 -0300 (mi., 20 ago. 2014) $"
|
||||
revision: "$Revision: 95678 $"
|
||||
|
||||
class
|
||||
ROC_API_SERVICE
|
||||
|
||||
inherit
|
||||
|
||||
SHARED_ERROR
|
||||
REFACTORING_HELPER
|
||||
|
||||
|
||||
create make
|
||||
|
||||
|
||||
feature -- Initialize
|
||||
|
||||
make (a_storage: CMS_STORAGE)
|
||||
-- Create the API service with an storege `a_storage'.
|
||||
do
|
||||
storage := a_storage
|
||||
set_successful
|
||||
ensure
|
||||
storage_set: storage = a_storage
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
login_valid (l_auth_login, l_auth_password: READABLE_STRING_32): BOOLEAN
|
||||
local
|
||||
l_security: SECURITY_PROVIDER
|
||||
do
|
||||
Result := storage.is_valid_credential (l_auth_login, l_auth_password)
|
||||
end
|
||||
|
||||
feature -- Access: Node
|
||||
|
||||
nodes: LIST[CMS_NODE]
|
||||
-- List of nodes.
|
||||
do
|
||||
fixme ("Implementation")
|
||||
Result := storage.recent_nodes (0, 10)
|
||||
end
|
||||
|
||||
recent_nodes (a_offset, a_rows: INTEGER): LIST[CMS_NODE]
|
||||
-- List of the `a_rows' most recent nodes starting from `a_offset'.
|
||||
do
|
||||
Result := storage.recent_nodes (a_offset, a_rows)
|
||||
end
|
||||
|
||||
node (a_id: INTEGER_64): detachable CMS_NODE
|
||||
-- Node by ID.
|
||||
do
|
||||
fixme ("Check preconditions")
|
||||
Result := storage.node (a_id)
|
||||
end
|
||||
|
||||
|
||||
feature -- Change: Node
|
||||
|
||||
new_node (a_node: CMS_NODE)
|
||||
-- Add a new node
|
||||
do
|
||||
storage.save_node (a_node)
|
||||
end
|
||||
|
||||
delete_node (a_id: INTEGER_64)
|
||||
do
|
||||
storage.delete_node (a_id)
|
||||
end
|
||||
|
||||
update_node (a_id: like {CMS_USER}.id; a_node: CMS_NODE)
|
||||
do
|
||||
storage.update_node (a_id,a_node)
|
||||
end
|
||||
|
||||
update_node_title (a_id: like {CMS_USER}.id; a_node_id: like {CMS_NODE}.id; a_title: READABLE_STRING_32)
|
||||
do
|
||||
fixme ("Check preconditions")
|
||||
storage.update_node_title (a_id,a_node_id,a_title)
|
||||
end
|
||||
|
||||
update_node_summary (a_id: like {CMS_USER}.id; a_node_id: like {CMS_NODE}.id; a_summary: READABLE_STRING_32)
|
||||
do
|
||||
fixme ("Check preconditions")
|
||||
storage.update_node_summary (a_id,a_node_id, a_summary)
|
||||
end
|
||||
|
||||
update_node_content (a_id: like {CMS_USER}.id; a_node_id: like {CMS_NODE}.id; a_content: READABLE_STRING_32)
|
||||
do
|
||||
fixme ("Check preconditions")
|
||||
storage.update_node_content (a_id,a_node_id, a_content)
|
||||
end
|
||||
|
||||
|
||||
feature -- Access: User
|
||||
|
||||
user_by_name (a_username: READABLE_STRING_32): detachable CMS_USER
|
||||
do
|
||||
Result := storage.user_by_name (a_username)
|
||||
end
|
||||
feature -- Change User
|
||||
|
||||
new_user (a_user: CMS_USER)
|
||||
-- Add a new user `a_user'.
|
||||
do
|
||||
if
|
||||
attached a_user.password as l_password and then
|
||||
attached a_user.email as l_email
|
||||
then
|
||||
storage.save_user (a_user)
|
||||
else
|
||||
fixme ("Add error")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
feature {NONE} -- Implemenataion
|
||||
|
||||
|
||||
storage: CMS_STORAGE
|
||||
-- Persistence storage
|
||||
|
||||
end
|
||||
@@ -1,127 +0,0 @@
|
||||
note
|
||||
description: "Provides email access"
|
||||
date: "$Date: 2014-08-20 15:21:15 -0300 (mi., 20 ago. 2014) $"
|
||||
revision: "$Revision: 95678 $"
|
||||
|
||||
class
|
||||
ROC_EMAIL_SERVICE
|
||||
|
||||
inherit
|
||||
|
||||
SHARED_ERROR
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_smtp_server: READABLE_STRING_32)
|
||||
-- Create an instance of {ESA_EMAIL_SERVICE} with an smtp_server `a_smtp_server'.
|
||||
-- Using "noreplies@eiffel.com" as admin email.
|
||||
local
|
||||
l_address_factory: INET_ADDRESS_FACTORY
|
||||
do
|
||||
-- Get local host name needed in creation of SMTP_PROTOCOL.
|
||||
create l_address_factory
|
||||
create smtp_protocol.make (a_smtp_server, l_address_factory.create_localhost.host_name)
|
||||
set_successful
|
||||
end
|
||||
|
||||
admin_email: IMMUTABLE_STRING_8
|
||||
-- Administrator email.
|
||||
once
|
||||
Result := "noreplies@eiffel.com"
|
||||
end
|
||||
|
||||
webmaster_email: IMMUTABLE_STRING_8
|
||||
-- Webmaster email.
|
||||
once
|
||||
Result := "webmaster@eiffel.com"
|
||||
end
|
||||
|
||||
smtp_protocol: SMTP_PROTOCOL
|
||||
-- SMTP protocol.
|
||||
|
||||
feature -- Basic Operations
|
||||
|
||||
send_template_email (a_to, a_token, a_host: STRING)
|
||||
-- Send successful registration message containing activation code `a_token' to `a_to'.
|
||||
require
|
||||
attached_to: a_to /= Void
|
||||
attached_token: a_token /= Void
|
||||
attached_host: a_host /= Void
|
||||
local
|
||||
l_content: STRING
|
||||
l_url: URL_ENCODER
|
||||
l_path: PATH
|
||||
l_html: HTML_ENCODER
|
||||
l_email: EMAIL
|
||||
do
|
||||
if successful then
|
||||
log.write_information (generator + ".send_post_registration_email to [" + a_to + "]" )
|
||||
create l_path.make_current
|
||||
create l_url
|
||||
create l_html
|
||||
create l_content.make (1024)
|
||||
l_content.append ("Thank you for registering at CMS.%N%NTo complete your registration, please click on this link to activate your account:%N%N")
|
||||
l_content.append (a_host)
|
||||
l_content.append ("/activation?code=")
|
||||
l_content.append (l_url.encoded_string (a_token))
|
||||
l_content.append ("&email=")
|
||||
l_content.append (l_url.encoded_string (a_to))
|
||||
l_content.append ("%N%NOnce there, please enter the following information and then click the Activate Account, button.%N%N")
|
||||
l_content.append ("Your e-mail: ")
|
||||
l_content.append (l_html.encoded_string (a_to))
|
||||
l_content.append ("%N%NYour activation code: ")
|
||||
l_content.append (l_html.encoded_string(a_token))
|
||||
l_content.append ("%N%NThank you for joining us.%N%N CMS team.")
|
||||
l_content.append (Disclaimer)
|
||||
-- Create our message.
|
||||
create l_email.make_with_entry (admin_email, a_to)
|
||||
l_email.set_message (l_content)
|
||||
l_email.add_header_entry ({EMAIL_CONSTANTS}.H_subject, "CMS Site: Account Activation")
|
||||
send_email (l_email)
|
||||
end
|
||||
end
|
||||
|
||||
send_shutdown_email (a_message: READABLE_STRING_GENERAL)
|
||||
-- Send email shutdown cause by an unexpected condition.
|
||||
local
|
||||
l_email: EMAIL
|
||||
l_content: STRING
|
||||
do
|
||||
create l_email.make_with_entry (admin_email, webmaster_email)
|
||||
create l_content.make (2048)
|
||||
l_content.append (a_message.as_string_32)
|
||||
l_email.set_message (l_content)
|
||||
l_email.add_header_entry ({EMAIL_CONSTANTS}.H_subject, "ROC API exception")
|
||||
send_email (l_email)
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
send_email (a_email: EMAIL)
|
||||
-- Send the email represented by `a_email'.
|
||||
local
|
||||
l_retried: BOOLEAN
|
||||
do
|
||||
if not l_retried then
|
||||
log.write_information (generator + ".send_email Process send email.")
|
||||
smtp_protocol.initiate_protocol
|
||||
smtp_protocol.transfer (a_email)
|
||||
smtp_protocol.close_protocol
|
||||
log.write_information (generator + ".send_email Email sent.")
|
||||
set_successful
|
||||
else
|
||||
log.write_error (generator + ".send_email Email not send" + last_error_message )
|
||||
end
|
||||
rescue
|
||||
set_last_error_from_exception (generator + ".send_email")
|
||||
l_retried := True
|
||||
retry
|
||||
end
|
||||
|
||||
Disclaimer: STRING = "This email is generated automatically, and the address is not monitored for responses. If you try contacting us by using %"reply%", you will not receive an answer."
|
||||
-- Email not monitored disclaimer.
|
||||
|
||||
end
|
||||
@@ -1,185 +0,0 @@
|
||||
note
|
||||
description: "[
|
||||
REST API configuration
|
||||
We manage URI and Uri templates using Routers. They are used to delegate calls (to the corresponing handlers) based on a URI template.
|
||||
We define a Rooter and attach handlers to it.
|
||||
]"
|
||||
date: "$Date: 2014-08-08 16:02:11 -0300 (vi., 08 ago. 2014) $"
|
||||
revision: "$Revision: 95593 $"
|
||||
|
||||
class
|
||||
ROC_REST_API
|
||||
|
||||
inherit
|
||||
|
||||
ROC_ABSTRACT_API
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Initialization
|
||||
|
||||
setup_router
|
||||
-- Setup `router'.
|
||||
local
|
||||
fhdl: WSF_FILE_SYSTEM_HANDLER
|
||||
do
|
||||
configure_api_root
|
||||
configure_api_node
|
||||
configure_api_navigation
|
||||
configure_api_login
|
||||
configure_api_nodes
|
||||
configure_api_node_title
|
||||
configure_api_node_summary
|
||||
configure_api_node_content
|
||||
configure_api_logoff
|
||||
configure_api_register
|
||||
|
||||
|
||||
create fhdl.make_hidden_with_path (layout.www_path)
|
||||
fhdl.disable_index
|
||||
fhdl.set_not_found_handler (agent (ia_uri: READABLE_STRING_8; ia_req: WSF_REQUEST; ia_res: WSF_RESPONSE)
|
||||
do
|
||||
execute_default (ia_req, ia_res)
|
||||
end)
|
||||
router.handle_with_request_methods ("/", fhdl, router.methods_GET)
|
||||
end
|
||||
|
||||
feature -- Configure Resources Routes
|
||||
|
||||
configure_api_root
|
||||
local
|
||||
l_root_handler:ROC_ROOT_HANDLER
|
||||
l_methods: WSF_REQUEST_METHODS
|
||||
do
|
||||
create l_root_handler.make (roc_config)
|
||||
create l_methods
|
||||
l_methods.enable_get
|
||||
router.handle_with_request_methods ("/", l_root_handler, l_methods)
|
||||
end
|
||||
|
||||
configure_api_node
|
||||
local
|
||||
l_report_handler: NODE_HANDLER
|
||||
l_methods: WSF_REQUEST_METHODS
|
||||
do
|
||||
create l_report_handler.make (roc_config)
|
||||
create l_methods
|
||||
l_methods.enable_get
|
||||
l_methods.enable_post
|
||||
l_methods.enable_put
|
||||
router.handle_with_request_methods ("/node", l_report_handler, l_methods)
|
||||
|
||||
create l_report_handler.make (roc_config)
|
||||
create l_methods
|
||||
l_methods.enable_get
|
||||
l_methods.enable_post
|
||||
l_methods.enable_put
|
||||
l_methods.enable_delete
|
||||
router.handle_with_request_methods ("/node/{id}", l_report_handler, l_methods)
|
||||
end
|
||||
|
||||
configure_api_navigation
|
||||
local
|
||||
l_report_handler: NAVIGATION_HANDLER
|
||||
l_methods: WSF_REQUEST_METHODS
|
||||
do
|
||||
create l_report_handler.make (roc_config)
|
||||
create l_methods
|
||||
l_methods.enable_get
|
||||
router.handle_with_request_methods ("/navigation", l_report_handler, l_methods)
|
||||
end
|
||||
|
||||
configure_api_login
|
||||
local
|
||||
l_report_handler: ROC_LOGIN_HANDLER
|
||||
l_methods: WSF_REQUEST_METHODS
|
||||
do
|
||||
create l_report_handler.make (roc_config)
|
||||
create l_methods
|
||||
l_methods.enable_get
|
||||
router.handle_with_request_methods ("/login", l_report_handler, l_methods)
|
||||
end
|
||||
|
||||
configure_api_logoff
|
||||
local
|
||||
l_report_handler: ROC_LOGOFF_HANDLER
|
||||
l_methods: WSF_REQUEST_METHODS
|
||||
do
|
||||
create l_report_handler.make (roc_config)
|
||||
create l_methods
|
||||
l_methods.enable_get
|
||||
router.handle_with_request_methods ("/logoff", l_report_handler, l_methods)
|
||||
end
|
||||
|
||||
|
||||
configure_api_nodes
|
||||
local
|
||||
l_report_handler: NODES_HANDLER
|
||||
l_methods: WSF_REQUEST_METHODS
|
||||
do
|
||||
create l_report_handler.make (roc_config)
|
||||
create l_methods
|
||||
l_methods.enable_get
|
||||
router.handle_with_request_methods ("/nodes", l_report_handler, l_methods)
|
||||
end
|
||||
|
||||
|
||||
configure_api_node_summary
|
||||
local
|
||||
l_report_handler: NODE_SUMMARY_HANDLER
|
||||
l_methods: WSF_REQUEST_METHODS
|
||||
do
|
||||
create l_report_handler.make (roc_config)
|
||||
create l_methods
|
||||
l_methods.enable_get
|
||||
l_methods.enable_post
|
||||
l_methods.enable_put
|
||||
router.handle_with_request_methods ("/node/{id}/summary", l_report_handler, l_methods)
|
||||
end
|
||||
|
||||
|
||||
configure_api_node_title
|
||||
local
|
||||
l_report_handler: NODE_TITLE_HANDLER
|
||||
l_methods: WSF_REQUEST_METHODS
|
||||
do
|
||||
create l_report_handler.make (roc_config)
|
||||
create l_methods
|
||||
l_methods.enable_get
|
||||
l_methods.enable_post
|
||||
l_methods.enable_put
|
||||
router.handle_with_request_methods ("/node/{id}/title", l_report_handler, l_methods)
|
||||
end
|
||||
|
||||
|
||||
configure_api_node_content
|
||||
local
|
||||
l_report_handler: NODE_CONTENT_HANDLER
|
||||
l_methods: WSF_REQUEST_METHODS
|
||||
do
|
||||
create l_report_handler.make (roc_config)
|
||||
create l_methods
|
||||
l_methods.enable_get
|
||||
l_methods.enable_post
|
||||
l_methods.enable_put
|
||||
router.handle_with_request_methods ("/node/{id}/content", l_report_handler, l_methods)
|
||||
end
|
||||
|
||||
|
||||
configure_api_register
|
||||
local
|
||||
l_report_handler: USER_HANDLER
|
||||
l_methods: WSF_REQUEST_METHODS
|
||||
do
|
||||
create l_report_handler.make (roc_config)
|
||||
create l_methods
|
||||
l_methods.enable_get
|
||||
l_methods.enable_post
|
||||
l_methods.enable_put
|
||||
router.handle_with_request_methods ("/user", l_report_handler, l_methods)
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
@@ -1,48 +0,0 @@
|
||||
note
|
||||
description: "Conneg Helper"
|
||||
date: "$Date: 2014-08-08 16:02:11 -0300 (vi., 08 ago. 2014) $"
|
||||
revision: "$Revision: 95593 $"
|
||||
|
||||
class
|
||||
SHARED_CONNEG_HELPER
|
||||
|
||||
|
||||
feature -- Access
|
||||
|
||||
conneg (req: WSF_REQUEST): SERVER_CONTENT_NEGOTIATION
|
||||
-- Content negotiatior for all requests.
|
||||
once
|
||||
create Result.make ({HTTP_MIME_TYPES}.text_html, "en", "UTF-8", "identity")
|
||||
end
|
||||
|
||||
mime_types_supported (req: WSF_REQUEST): LIST [STRING]
|
||||
-- All values for Accept header that `Current' can serve.
|
||||
do
|
||||
create {ARRAYED_LIST [STRING]} Result.make_from_array (<<{HTTP_MIME_TYPES}.text_html, "application/vnd.collection+json">>)
|
||||
Result.compare_objects
|
||||
ensure
|
||||
mime_types_supported_includes_default: Result.has (conneg (req).default_media_type)
|
||||
end
|
||||
|
||||
media_type_variants (req: WSF_REQUEST): HTTP_ACCEPT_MEDIA_TYPE_VARIANTS
|
||||
-- Media type negotiation.
|
||||
do
|
||||
Result := conneg (req).media_type_preference (mime_types_supported (req), req.http_accept)
|
||||
end
|
||||
|
||||
compression_supported (req: WSF_REQUEST): LIST [STRING]
|
||||
-- All values for Accept-Encofing header that `Current' can serve.
|
||||
do
|
||||
create {ARRAYED_LIST [STRING]} Result.make_from_array (<<"identity","deflate">>)
|
||||
Result.compare_objects
|
||||
ensure
|
||||
compression_supported_includes_default: Result.has (conneg (req).default_encoding)
|
||||
end
|
||||
|
||||
compression_variants (req: WSF_REQUEST): HTTP_ACCEPT_ENCODING_VARIANTS
|
||||
-- Compression negotiation.
|
||||
do
|
||||
Result := conneg (req).encoding_preference (compression_supported (req), req.http_accept_encoding)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,58 +0,0 @@
|
||||
note
|
||||
description: "Provide input validation"
|
||||
date: "$Date: 2014-08-08 16:02:11 -0300 (vi., 08 ago. 2014) $"
|
||||
revision: "$Revision: 95593 $"
|
||||
|
||||
deferred class
|
||||
ROC_INPUT_VALIDATOR
|
||||
|
||||
feature -- Basic Operations
|
||||
|
||||
input_from (a_request: ITERABLE [WSF_VALUE])
|
||||
-- Update current object using parameters extracted from QUERY_STRING.
|
||||
-- If there are errors they are set to the errors parameter.
|
||||
do
|
||||
if attached {STRING_TABLE[WSF_VALUE]} a_request as l_table_request then
|
||||
validate (l_table_request)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Validation
|
||||
|
||||
validate (a_request: STRING_TABLE [WSF_VALUE])
|
||||
-- Validate input for control `a_request'.
|
||||
deferred
|
||||
end
|
||||
|
||||
|
||||
feature -- Access
|
||||
|
||||
acceptable_query_parameters: ARRAY[STRING]
|
||||
-- The parameters are optionals, more parameters is a bad request, the order is not important.
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- Errors
|
||||
|
||||
errors: STRING_TABLE[READABLE_STRING_32]
|
||||
-- Hash table with errors and descriptions.
|
||||
|
||||
has_error: BOOLEAN
|
||||
-- Has errors the last request?
|
||||
do
|
||||
Result := not errors.is_empty
|
||||
end
|
||||
|
||||
error_message: STRING
|
||||
-- String representation.
|
||||
do
|
||||
create Result.make_empty
|
||||
across errors as c loop
|
||||
Result.append (c.item)
|
||||
Result.append ("%N")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
end -- class EFA_INPUT_VALIDATOR
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-13-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-13-0 http://www.eiffel.com/developers/xml/configuration-1-13-0.xsd" name="roc_api" uuid="3643E657-BCBE-46AA-931B-71EAEA877A18" library_target="roc_api">
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-13-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-13-0 http://www.eiffel.com/developers/xml/configuration-1-13-0.xsd" name="demo" uuid="3643E657-BCBE-46AA-931B-71EAEA877A18" library_target="demo">
|
||||
<target name="common" abstract="true">
|
||||
<file_rule>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
@@ -9,17 +9,14 @@
|
||||
<option warning="true" full_class_checking="false" is_attached_by_default="true" void_safety="transitional" syntax="transitional">
|
||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||
</option>
|
||||
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
|
||||
<library name="layout" location="..\..\layout\layout.ecf"/>
|
||||
<library name="cms" location="..\..\cms-safe.ecf" readonly="false"/>
|
||||
<library name="cms_demo_module" location="modules\demo\cms_demo_module-safe.ecf" readonly="false"/>
|
||||
<library name="layout" location="..\..\library\layout\layout-safe.ecf" readonly="false"/>
|
||||
<library name="wsf" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf-safe.ecf"/>
|
||||
<library name="wsf_extension" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf_extension-safe.ecf" readonly="false"/>
|
||||
|
||||
|
||||
<library name="cms" location="..\..\cms\cms.ecf" readonly="false"/>
|
||||
<library name="wsf_extension" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf_extension-safe.ecf" readonly="false"/>
|
||||
</target>
|
||||
<target name="roc_api_any" extends="common">
|
||||
<target name="demo_any" extends="common">
|
||||
<root class="EWF_ROC_SERVER" feature="make_and_launch"/>
|
||||
<library name="cgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\cgi-safe.ecf"/>
|
||||
<library name="libfcgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\libfcgi-safe.ecf"/>
|
||||
@@ -27,24 +24,24 @@
|
||||
<cluster name="launcher" location=".\launcher\any\" recursive="true"/>
|
||||
<cluster name="src" location=".\src\" recursive="true"/>
|
||||
</target>
|
||||
<target name="roc_api_nino" extends="common">
|
||||
<target name="demo_nino" extends="common">
|
||||
<root class="EWF_ROC_SERVER" feature="make_and_launch"/>
|
||||
<library name="default_nino" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\nino-safe.ecf"/>
|
||||
<cluster name="launcher" location=".\launcher\default\" recursive="true"/>
|
||||
<cluster name="src" location=".\src\" recursive="true"/>
|
||||
</target>
|
||||
<target name="roc_api_cgi" extends="common">
|
||||
<target name="demo_cgi" extends="common">
|
||||
<root class="EWF_ROC_SERVER" feature="make_and_launch"/>
|
||||
<library name="default_cgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\cgi-safe.ecf"/>
|
||||
<cluster name="launcher" location=".\launcher\default\" recursive="true"/>
|
||||
<cluster name="src" location=".\src\" recursive="true"/>
|
||||
</target>
|
||||
<target name="roc_api_libfcgi" extends="common">
|
||||
<target name="demo_libfcgi" extends="common">
|
||||
<root class="EWF_ROC_SERVER" feature="make_and_launch"/>
|
||||
<library name="default_libfcgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\libfcgi-safe.ecf"/>
|
||||
<cluster name="launcher" location=".\launcher\default\" recursive="true"/>
|
||||
<cluster name="src" location=".\src\" recursive="true"/>
|
||||
</target>
|
||||
<target name="roc_api" extends="roc_api_nino">
|
||||
<target name="demo" extends="demo_nino">
|
||||
</target>
|
||||
</system>
|
||||
@@ -1,2 +1,2 @@
|
||||
port=8088
|
||||
port=8099
|
||||
#verbose=true
|
||||
24
examples/demo/modules/demo/cms_demo_module-safe.ecf
Normal file
24
examples/demo/modules/demo/cms_demo_module-safe.ecf
Normal file
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-13-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-13-0 http://www.eiffel.com/developers/xml/configuration-1-13-0.xsd" name="cms_demo_module" uuid="4BB59A54-2544-4C10-BFA6-01D12E541A30" library_target="cms_demo_module">
|
||||
<target name="cms_demo_module">
|
||||
<root all_classes="true"/>
|
||||
<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="transitional" syntax="standard">
|
||||
</option>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="base_extension" location="$ISE_LIBRARY\library\base_extension\base_extension-safe.ecf"/>
|
||||
<library name="cms" location="..\..\..\..\cms-safe.ecf" readonly="false"/>
|
||||
<library name="cms_model" location="..\..\..\..\library\model\cms_model-safe.ecf" readonly="false"/>
|
||||
<library name="http" location="$ISE_LIBRARY\contrib\library\network\protocol\http\http-safe.ecf"/>
|
||||
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json-safe.ecf" readonly="false"/>
|
||||
<library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/>
|
||||
<library name="wsf" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf-safe.ecf"/>
|
||||
<library name="wsf_encoder" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\text\encoder\encoder-safe.ecf"/>
|
||||
<cluster name="src" location=".\" recursive="true"/>
|
||||
</target>
|
||||
</system>
|
||||
|
||||
139
examples/demo/modules/demo/cms_demo_module.e
Normal file
139
examples/demo/modules/demo/cms_demo_module.e
Normal file
@@ -0,0 +1,139 @@
|
||||
note
|
||||
description: "Summary description for {CMS_DEMO_MODULE}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CMS_DEMO_MODULE
|
||||
|
||||
inherit
|
||||
CMS_MODULE
|
||||
redefine
|
||||
register_hooks
|
||||
end
|
||||
|
||||
CMS_HOOK_MENU_SYSTEM_ALTER
|
||||
|
||||
CMS_HOOK_BLOCK
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
do
|
||||
name := "Demo module"
|
||||
version := "1.0"
|
||||
description := "Service to demonstrate and test cms system"
|
||||
package := "demo"
|
||||
end
|
||||
|
||||
feature -- Access: router
|
||||
|
||||
router (a_api: CMS_API): WSF_ROUTER
|
||||
-- Node router.
|
||||
do
|
||||
create Result.make (2)
|
||||
|
||||
map_uri_template_agent (Result, "/demo/", agent handle_demo (?,?,a_api))
|
||||
map_uri_template_agent (Result, "/demo/{id}", agent handle_demo_entry (?,?,a_api))
|
||||
end
|
||||
|
||||
feature -- Hooks
|
||||
|
||||
register_hooks (a_response: CMS_RESPONSE)
|
||||
do
|
||||
a_response.subscribe_to_menu_system_alter_hook (Current)
|
||||
a_response.subscribe_to_block_hook (Current)
|
||||
end
|
||||
|
||||
block_list: ITERABLE [like {CMS_BLOCK}.name]
|
||||
do
|
||||
Result := <<"demo-info">>
|
||||
end
|
||||
|
||||
get_block_view (a_block_id: READABLE_STRING_8; a_response: CMS_RESPONSE)
|
||||
local
|
||||
-- b: CMS_CONTENT_BLOCK
|
||||
mb: CMS_MENU_BLOCK
|
||||
m: CMS_MENU
|
||||
lnk: CMS_LOCAL_LINK
|
||||
do
|
||||
if a_block_id.is_case_insensitive_equal_general ("demo-info") then
|
||||
if a_response.request.request_uri.starts_with ("/demo/") then
|
||||
create m.make_with_title (a_block_id, "Demo", 2)
|
||||
create lnk.make ("/demo/abc", a_response.url ("/demo/abc", Void))
|
||||
m.extend (lnk)
|
||||
create lnk.make ("/demo/123", a_response.url ("/demo/123", Void))
|
||||
m.extend (lnk)
|
||||
create mb.make (m)
|
||||
a_response.add_block (mb, "sidebar_second")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
menu_system_alter (a_menu_system: CMS_MENU_SYSTEM; a_response: CMS_RESPONSE)
|
||||
local
|
||||
lnk: CMS_LOCAL_LINK
|
||||
-- perms: detachable ARRAYED_LIST [READABLE_STRING_8]
|
||||
do
|
||||
create lnk.make ("Demo", "/demo/")
|
||||
a_menu_system.primary_menu.extend (lnk)
|
||||
end
|
||||
|
||||
feature -- Handler
|
||||
|
||||
handle_demo,
|
||||
handle_demo_entry (req: WSF_REQUEST; res: WSF_RESPONSE; a_api: CMS_API)
|
||||
local
|
||||
r: NOT_IMPLEMENTED_ERROR_CMS_RESPONSE
|
||||
do
|
||||
create r.make (req, res, a_api)
|
||||
r.set_main_content ("NODE module does not yet implement %"" + req.path_info + "%" ...")
|
||||
r.add_error_message ("NODE Module: not yet implemented")
|
||||
r.execute
|
||||
end
|
||||
|
||||
feature -- Mapping helper: uri template
|
||||
|
||||
map_uri_template (a_router: WSF_ROUTER; a_tpl: STRING; h: WSF_URI_TEMPLATE_HANDLER)
|
||||
-- Map `h' as handler for `a_tpl'
|
||||
require
|
||||
a_tpl_attached: a_tpl /= Void
|
||||
h_attached: h /= Void
|
||||
do
|
||||
map_uri_template_with_request_methods (a_router, a_tpl, h, Void)
|
||||
end
|
||||
|
||||
map_uri_template_with_request_methods (a_router: WSF_ROUTER; a_tpl: READABLE_STRING_8; h: WSF_URI_TEMPLATE_HANDLER; rqst_methods: detachable WSF_REQUEST_METHODS)
|
||||
-- Map `h' as handler for `a_tpl' for request methods `rqst_methods'.
|
||||
require
|
||||
a_tpl_attached: a_tpl /= Void
|
||||
h_attached: h /= Void
|
||||
do
|
||||
a_router.map_with_request_methods (create {WSF_URI_TEMPLATE_MAPPING}.make (a_tpl, h), rqst_methods)
|
||||
end
|
||||
|
||||
feature -- Mapping helper: uri template agent
|
||||
|
||||
map_uri_template_agent (a_router: WSF_ROUTER; a_tpl: READABLE_STRING_8; proc: PROCEDURE [ANY, TUPLE [req: WSF_REQUEST; res: WSF_RESPONSE]])
|
||||
-- Map `proc' as handler for `a_tpl'
|
||||
require
|
||||
a_tpl_attached: a_tpl /= Void
|
||||
proc_attached: proc /= Void
|
||||
do
|
||||
map_uri_template_agent_with_request_methods (a_router, a_tpl, proc, Void)
|
||||
end
|
||||
|
||||
map_uri_template_agent_with_request_methods (a_router: WSF_ROUTER; a_tpl: READABLE_STRING_8; proc: PROCEDURE [ANY, TUPLE [req: WSF_REQUEST; res: WSF_RESPONSE]]; rqst_methods: detachable WSF_REQUEST_METHODS)
|
||||
-- Map `proc' as handler for `a_tpl' for request methods `rqst_methods'.
|
||||
require
|
||||
a_tpl_attached: a_tpl /= Void
|
||||
proc_attached: proc /= Void
|
||||
do
|
||||
map_uri_template_with_request_methods (a_router, a_tpl, create {WSF_URI_TEMPLATE_AGENT_HANDLER}.make (proc), rqst_methods)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -3,4 +3,4 @@ site.name=EWF Web CMS
|
||||
site.email=your@email.com
|
||||
var-dir=var
|
||||
files-dir=files
|
||||
theme=api
|
||||
theme=bootstrap
|
||||
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
@@ -8,10 +8,6 @@
|
||||
<!-- Site Navigation -->
|
||||
{include file="master2/site_navigation.tpl"/}
|
||||
|
||||
<!--<header class="main-navi">
|
||||
{include file="master2/header.tpl"/}
|
||||
</header> -->
|
||||
|
||||
<div class="container">
|
||||
<hr>
|
||||
<div class="row">
|
||||
@@ -12,10 +12,10 @@
|
||||
{if isset="$user"}
|
||||
<li><a>{$user/}</a></li>
|
||||
<li><a title="Node" href="{$host/}/node" rel="node">New Node</a></li>
|
||||
<li><a title="Logoff" href="{$host/}/logoff" rel="logoff">Logoff</a></li>
|
||||
<li><a title="Logoff" href="{$host/}/basic_auth_logoff" rel="logoff">Logoff</a></li>
|
||||
{/if}
|
||||
{unless isset="$user"}
|
||||
<li><a title="Login" href="{$host/}/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>
|
||||
{/unless}
|
||||
</ul>
|
||||
@@ -89,7 +89,7 @@
|
||||
<div class="row">
|
||||
<div class="col-xs-1">
|
||||
{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}
|
||||
{unless isset="$node"}
|
||||
<label> <span itemprop="description">Summary:</span></label>
|
||||
@@ -33,7 +33,7 @@
|
||||
<label> <span itemprop="text">Content:</span> </label>
|
||||
</div>
|
||||
<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>
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
<label> <span itemprop="text">Summary:</span> </label>
|
||||
</div>
|
||||
<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>
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
<label> <span itemprop="text">Title:</span> </label>
|
||||
</div>
|
||||
<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>
|
||||
|
||||
BIN
examples/demo/site/www/themes/bootstrap.7z
Normal file
BIN
examples/demo/site/www/themes/bootstrap.7z
Normal file
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
<div class='navbar navbar-inverse'>
|
||||
<div class='navbar-inner nav-collapse' style="height: auto;">
|
||||
<ul class="nav">
|
||||
{$header_block/}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
84
examples/demo/site/www/themes/bootstrap/page.tpl
Normal file
84
examples/demo/site/www/themes/bootstrap/page.tpl
Normal file
@@ -0,0 +1,84 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>ROC- Layout with defualt Regions</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css">
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
</style>
|
||||
|
||||
<!-- Latest compiled and minified CSS -->
|
||||
|
||||
<!-- Optional theme -->
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap-theme.min.css">
|
||||
|
||||
<!-- Latest compiled and minified JavaScript -->
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
|
||||
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<head>
|
||||
<title>{$head_title/}</title>
|
||||
</head>
|
||||
<body>
|
||||
<!-- Page Top -->
|
||||
{if isset="$region_top"}
|
||||
{$region_top/}
|
||||
{/if}
|
||||
<!-- Body -->
|
||||
<div class='container-fluid'>
|
||||
|
||||
<!-- Page Header -->
|
||||
<div id="header">
|
||||
{if isset="$page.primary_nav"}
|
||||
{$page.primary_nav/}
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<!-- General Page Content -->
|
||||
<div id='content' class='row-fluid'>
|
||||
<!-- Left Sidebar sidebar_first -->
|
||||
{unless empty="$page.region_sidebar_first"}
|
||||
<div style="float: left;">
|
||||
{$page.region_sidebar_first/}
|
||||
</div>
|
||||
{/unless}
|
||||
|
||||
|
||||
<!-- Highlighted, Help, Content -->
|
||||
<div class='span8 main'>
|
||||
<!-- Highlighted Section -->
|
||||
{$page.region_highlighted/}
|
||||
|
||||
<!-- Help Section -->
|
||||
{$page.region_help/}
|
||||
|
||||
<!-- Main Content Section -->
|
||||
{unless empty="$page_title"}<h1 class="page-title">{$page_title/}</h1>{/unless}
|
||||
{$page.region_content/}
|
||||
</div>
|
||||
|
||||
<!-- Right Sidebar sidebar_second-->
|
||||
{unless empty="$page.region_sidebar_second"}
|
||||
<div style="float: right;">
|
||||
{$page.region_sidebar_second/}
|
||||
</div>
|
||||
{/unless}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--Page footer -->
|
||||
{$page.region_footer/}
|
||||
|
||||
<!-- Page Bottom -->
|
||||
{$page.region_bottom/}
|
||||
</body>
|
||||
<script type="text/javascript">
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
108
examples/demo/site/www/themes/bootstrap/roc_template -2.html
Normal file
108
examples/demo/site/www/themes/bootstrap/roc_template -2.html
Normal file
@@ -0,0 +1,108 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>ROC- Layout with defualt Regions</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet">
|
||||
<style type="text/css">
|
||||
|
||||
</style>
|
||||
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
|
||||
<script src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<head>
|
||||
<title>ROC CMS - A responsive layout</title>
|
||||
</head>
|
||||
<body>
|
||||
<!-- Page Top -->
|
||||
<!-- Page Header -->
|
||||
<div class='container-fluid'>
|
||||
<h1>ROC Layout with Defaul Regions</h1>
|
||||
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="https://www2.eiffel.com/beta" itemprop="home" rel="home">Eiffel Support Site</a>
|
||||
</div>
|
||||
<div class="navbar-collapse collapse" itemscope="itemscope" itemtype="https://www2.eiffel.com/beta/profile/esa_api.xml#report" >
|
||||
<ul class="nav navbar-nav navbar-left">
|
||||
<li><a href="https://www2.eiffel.com/beta/reports" class="active" itemprop="all" rel="all">Reports</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
|
||||
|
||||
<li><a href="https://www2.eiffel.com/beta/register" itemprop="register" rel="register">Register</a></li>
|
||||
|
||||
|
||||
|
||||
|
||||
<!--<li><a class="login pull-right" data-toggle="modal" data-target="#myModalSignIn">Sign In</a></li> <! Custome Modal -->
|
||||
<li id="login_pe" ><a href="https://www2.eiffel.com/beta/login" itemprop="login" rel="login">Sign In</a></li> <!-- Custome Modal -->
|
||||
|
||||
</ul>
|
||||
<!--form class="navbar-form navbar-right">
|
||||
<input type="text" class="form-control" placeholder="Search..."/>
|
||||
</form -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div id='content' class='row-fluid'>
|
||||
<!-- Highlighted-->
|
||||
|
||||
|
||||
<!-- Left Side Bard sidebar_first -->
|
||||
<div class='span2 sidebar'>
|
||||
<h3>Left Sidebar</h3>
|
||||
<ul class="nav nav-tabs nav-stacked">
|
||||
<li><a href='#'>Another Link 1</a></li>
|
||||
<li><a href='#'>Another Link 2</a></li>
|
||||
<li><a href='#'>Another Link 3</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<!-- Highlighted, Help, Content -->
|
||||
<div class='span8 main'>
|
||||
<h1>Highlighted Section</h1>
|
||||
<h2>Help Section</h2>
|
||||
|
||||
<h2>Main Content Section</h2>
|
||||
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum.<p>
|
||||
|
||||
<p>Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem. Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius. Claritas est etiam processus dynamicus, qui sequitur mutationem consuetudium lectorum. Mirum est notare quam littera gothica, quam nunc putamus parum claram, anteposuerit litterarum formas humanitatis per seacula quarta decima et quinta decima. Eodem modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in futurum.</p>
|
||||
</div>
|
||||
|
||||
<!-- Left Side Bard sidebar_second-->
|
||||
<div class='span2 sidebar'>
|
||||
<h3>Right Sidebar</h3>
|
||||
<ul class="nav nav-tabs nav-stacked">
|
||||
<li><a href='#'>Another Link 1</a></li>
|
||||
<li><a href='#'>Another Link 2</a></li>
|
||||
<li><a href='#'>Another Link 3</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--Page footer -->
|
||||
<div id="footer">
|
||||
<small>
|
||||
<center>
|
||||
<p class="text-muted"><a href="#" target="_blank" class="info">ROC Documentation </a>
|
||||
<a href="http://www.eiffel.com/company/contact/" target="_blank" class="info">Questions? Comments? Let us know! </a></p>
|
||||
<p>© Copyright 2014 Eiffel Software -- <a href="#" target="_blank" class="info">Privacy Policy</a>
|
||||
</center>
|
||||
</small>
|
||||
</div>
|
||||
|
||||
<!-- Page Bottom -->
|
||||
</body>
|
||||
<script type="text/javascript">
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
135
examples/demo/site/www/themes/bootstrap/roc_template.html
Normal file
135
examples/demo/site/www/themes/bootstrap/roc_template.html
Normal file
@@ -0,0 +1,135 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>ROC- Layout with defualt Regions</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css">
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
</style>
|
||||
|
||||
<!-- Latest compiled and minified CSS -->
|
||||
|
||||
<!-- Optional theme -->
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap-theme.min.css">
|
||||
|
||||
<!-- Latest compiled and minified JavaScript -->
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
|
||||
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<head>
|
||||
<title>ROC CMS - A responsive layout</title>
|
||||
</head>
|
||||
<body>
|
||||
<!-- Page Top -->
|
||||
<!-- Page Header -->
|
||||
<!-- <div class='container-fluid'>
|
||||
<div class="container-fluid">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> <span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button> <a class="navbar-brand" href="#">Eiffel ROC</a>
|
||||
</div>
|
||||
<ul class="nav navbar-nav navbar-left">
|
||||
<li> <a href="#about">Home</a>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li> <a href="#about">About</a>
|
||||
</li>
|
||||
<li> <a href="#services">Service</a>
|
||||
</li>
|
||||
<li> <a href="#portfolio" class="">Portfolio</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
-->
|
||||
<div class="container-fluid">
|
||||
<div class="navbar navbar-default" role="navigation">
|
||||
<div class="container-fluid">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="https://www2.eiffel.com/beta" itemprop="home" rel="home">Eiffel Support Site</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse" itemscope="itemscope" itemtype="https://www2.eiffel.com/beta/profile/esa_api.xml#report" >
|
||||
<ul class="nav navbar-nav navbar-left">
|
||||
<li><a href="https://www2.eiffel.com/beta/reports" class="active" itemprop="all" rel="all">Reports</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
|
||||
|
||||
<li><a href="https://www2.eiffel.com/beta/register" itemprop="register" rel="register">Register</a></li>
|
||||
<li id="login_pe" ><a href="https://www2.eiffel.com/beta/login" itemprop="login" rel="login">Sign In</a></li> <!-- Custome Modal -->
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div id='content' class='row-fluid'>
|
||||
<!-- Highlighted-->
|
||||
|
||||
|
||||
<!-- Left Side Bard sidebar_first -->
|
||||
<div class="sidebar col-sm-2 col-md-2">
|
||||
<h3>Left Sidebar</h3>
|
||||
<ul class="nav nav-tabs nav-stacked">
|
||||
<li><a href="#">Another Link 1</a></li>
|
||||
<li><a href="#">Another Link 2</a></li>
|
||||
<li><a href="#">Another Link 3</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<!-- Highlighted, Help, Content -->
|
||||
<div class="main col-sm-8 col-md-8">
|
||||
<h1>Highlighted Section</h1>
|
||||
<h2>Help Section</h2>
|
||||
|
||||
<h2>Main Content Section</h2>
|
||||
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum.<p>
|
||||
|
||||
<p>Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem. Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius. Claritas est etiam processus dynamicus, qui sequitur mutationem consuetudium lectorum. Mirum est notare quam littera gothica, quam nunc putamus parum claram, anteposuerit litterarum formas humanitatis per seacula quarta decima et quinta decima. Eodem modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in futurum.</p>
|
||||
</div>
|
||||
|
||||
<!-- Left Side Bard sidebar_second-->
|
||||
|
||||
<div class="sidebar col-sm-2 col-md-2">
|
||||
<h3>Right Sidebar</h3>
|
||||
<ul class="nav nav-tabs nav-stacked">
|
||||
<li><a href="#">Another Link 1</a></li>
|
||||
<li><a href="#">Another Link 2</a></li>
|
||||
<li><a href="#">Another Link 3</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--Page footer -->
|
||||
<div id="footer">
|
||||
<small>
|
||||
<center>
|
||||
<p class="text-muted"><a href="#" target="_blank" class="info">ROC Documentation </a>
|
||||
<a href="http://www.eiffel.com/company/contact/" target="_blank" class="info">Questions? Comments? Let us know! </a></p>
|
||||
<p>© Copyright 2014 Eiffel Software -- <a href="#" target="_blank" class="info">Privacy Policy</a>
|
||||
</center>
|
||||
</small>
|
||||
</div>
|
||||
|
||||
<!-- Page Bottom -->
|
||||
</body>
|
||||
<script type="text/javascript">
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
14
examples/demo/site/www/themes/bootstrap/theme.info
Normal file
14
examples/demo/site/www/themes/bootstrap/theme.info
Normal file
@@ -0,0 +1,14 @@
|
||||
name=bootstrap
|
||||
engine=smarty
|
||||
author=jvelilla
|
||||
version=0.1
|
||||
regions[page_top] = Top
|
||||
regions[header] = Header
|
||||
regions[content] = Content
|
||||
regions[highlighted] = Highlighted
|
||||
regions[help] = Help
|
||||
regions[footer] = Footer
|
||||
regions[first_sidebar] = first sidebar
|
||||
regions[second_sidebar] = second sidebar
|
||||
regions[page_bottom] = Bottom
|
||||
navigation=default_nav
|
||||
@@ -0,0 +1 @@
|
||||
<h2>Help Section</h2>
|
||||
@@ -0,0 +1 @@
|
||||
<h1>Highlighted Section</h1>
|
||||
@@ -0,0 +1,8 @@
|
||||
<div class='span2 sidebar'>
|
||||
<h3>Left Sidebar</h3>
|
||||
<ul class="nav nav-tabs nav-stacked">
|
||||
<li><a href='#'>Another Link 1</a></li>
|
||||
<li><a href='#'>Another Link 2</a></li>
|
||||
<li><a href='#'>Another Link 3</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -0,0 +1,4 @@
|
||||
<h2>Main Content Section</h2>
|
||||
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum.<p>
|
||||
|
||||
<p>Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem. Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius. Claritas est etiam processus dynamicus, qui sequitur mutationem consuetudium lectorum. Mirum est notare quam littera gothica, quam nunc putamus parum claram, anteposuerit litterarum formas humanitatis per seacula quarta decima et quinta decima. Eodem modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in futurum.</p>
|
||||
@@ -0,0 +1,9 @@
|
||||
<div id="footer">
|
||||
<small>
|
||||
<center>
|
||||
<p class="text-muted"><a href="#" target="_blank" class="info">ROC Documentation </a>
|
||||
<a href="http://www.eiffel.com/company/contact/" target="_blank" class="info">Questions? Comments? Let us know! </a></p>
|
||||
<p>© Copyright 2014 Eiffel Software -- <a href="#" target="_blank" class="info">Privacy Policy</a>
|
||||
</center>
|
||||
</small>
|
||||
</div>
|
||||
34
examples/demo/site/www/themes/bootstrap/tpl/page_header.tpl
Normal file
34
examples/demo/site/www/themes/bootstrap/tpl/page_header.tpl
Normal file
@@ -0,0 +1,34 @@
|
||||
<div class="navbar navbar-default" role="navigation">
|
||||
<div class="container-fluid">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="{$site_url/}" itemprop="home" rel="home">{unless isset="$site_name"}Eiffel CMS{/unless}{if isset="$site_name"}{$site_name/}{/if}</a>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse">
|
||||
|
||||
{if isset="$primary_nav"}
|
||||
<ul class="nav navbar-nav navbar-left">
|
||||
{foreach item="item" from="$primary_nav.items"}
|
||||
<!-- TODO check if a menu item is active or not -->
|
||||
<li class="active"><a href="{$item.location/}">{$item.title/}</a></li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
{/if}
|
||||
|
||||
{if isset="$secondary_nav"}
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
{foreach item="item" from="$secondary_nav.items"}
|
||||
<!-- TODO check if a menu item is active or not -->
|
||||
<li class="active"><a href="{$item.location/}">{$item.title/}</a></li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
28
examples/demo/site/www/themes/bootstrap/tpl/page_header2.tpl
Normal file
28
examples/demo/site/www/themes/bootstrap/tpl/page_header2.tpl
Normal file
@@ -0,0 +1,28 @@
|
||||
{if isset="$default_nav"}
|
||||
<div class="navbar navbar-default" role="navigation">
|
||||
<div class="container-fluid">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="${site_url/}" itemprop="home" rel="home">{$page_title/}</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse">
|
||||
{/if}
|
||||
|
||||
{if isset="$primary_nav"}
|
||||
{$primary_nav/}
|
||||
{/if}
|
||||
|
||||
{if isset="$secondary_nav"}
|
||||
{$secondary_nav/}
|
||||
{/if}
|
||||
|
||||
{if isset="$default_nav"}
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
@@ -0,0 +1,6 @@
|
||||
<ul class="nav navbar-nav navbar-left">
|
||||
{foreach item="item" from="$menu.items"}
|
||||
<!-- TODO check if a menu item is active or not -->
|
||||
<li class="active"><a href="{$item.location/}">{$item.title/}</a></li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
@@ -0,0 +1,8 @@
|
||||
<div class='span2 sidebar'>
|
||||
<h3>Right Sidebar</h3>
|
||||
<ul class="nav nav-tabs nav-stacked">
|
||||
<li><a href='#'>Another Link 1</a></li>
|
||||
<li><a href='#'>Another Link 2</a></li>
|
||||
<li><a href='#'>Another Link 3</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -0,0 +1,7 @@
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
{foreach item="item" from="$menu.items"}
|
||||
<!-- TODO check if a menu item is active or not -->
|
||||
<li class="active"><a href="{$item.location/}">{$item.title/}</a></li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user