Merged CMS based on concurrent EWF (i.e ewf_v1) with blog branch.
This commit is contained in:
@@ -39,17 +39,21 @@ feature {NONE} -- Initialization
|
||||
end
|
||||
|
||||
configure
|
||||
local
|
||||
l_url: like site_url
|
||||
do
|
||||
--| Site id, used to identified a site, this could be set to a uuid, or else
|
||||
site_id := text_item_or_default ("site.id", "_EWF_CMS_NO_ID_")
|
||||
|
||||
-- Site url: optional, but ending with a slash
|
||||
site_url := string_8_item ("site_url")
|
||||
if attached site_url as l_url and then not l_url.is_empty then
|
||||
if l_url[l_url.count] /= '/' then
|
||||
site_url := l_url + "/"
|
||||
l_url := string_8_item ("site_url")
|
||||
if l_url /= Void and then not l_url.is_empty then
|
||||
if l_url [l_url.count] /= '/' then
|
||||
l_url := l_url + "/"
|
||||
end
|
||||
end
|
||||
site_url := l_url
|
||||
|
||||
-- Site name
|
||||
site_name := text_item_or_default ("site.name", "EWF::CMS")
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ feature -- Access: Site
|
||||
-- Mainly used for internal notification.
|
||||
|
||||
site_url: detachable READABLE_STRING_8
|
||||
-- Optional base url of the site.
|
||||
-- Optional url of current CMS site.
|
||||
|
||||
front_page_path: detachable READABLE_STRING_8
|
||||
-- Optional path defining the front page.
|
||||
|
||||
@@ -12,11 +12,12 @@ feature -- Factory
|
||||
template_block (a_module: CMS_MODULE; a_block_id: READABLE_STRING_8; a_response: CMS_RESPONSE): detachable CMS_SMARTY_TEMPLATE_BLOCK
|
||||
-- Smarty content block for `a_block_id' in the context of `a_module' and `a_response'.
|
||||
local
|
||||
res: PATH
|
||||
p: detachable PATH
|
||||
do
|
||||
create p.make_from_string ("templates")
|
||||
p := p.extended ("block_").appended (a_block_id).appended_with_extension ("tpl")
|
||||
p := a_response.module_resource_path (a_module, p)
|
||||
create res.make_from_string ("templates")
|
||||
res := res.extended ("block_").appended (a_block_id).appended_with_extension ("tpl")
|
||||
p := a_response.module_resource_path (a_module, res)
|
||||
if p /= Void then
|
||||
if attached p.entry as e then
|
||||
create Result.make (a_block_id, Void, p.parent, e)
|
||||
|
||||
15
src/kernel/form/cms_lower_upper_pager.e
Normal file
15
src/kernel/form/cms_lower_upper_pager.e
Normal file
@@ -0,0 +1,15 @@
|
||||
note
|
||||
description: "Pager widget for ROC CMS."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CMS_LOWER_UPPER_PAGER
|
||||
|
||||
inherit
|
||||
WSF_WIDGET_PAGER
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
end
|
||||
@@ -39,7 +39,7 @@ feature -- Router
|
||||
setup_router (a_router: WSF_ROUTER; a_api: CMS_API)
|
||||
-- <Precursor>
|
||||
do
|
||||
a_router.handle ("/debug/", create {WSF_URI_TEMPLATE_AGENT_HANDLER}.make (agent handle_debug (a_api, ?, ?)))
|
||||
a_router.handle ("/debug/", create {WSF_URI_TEMPLATE_AGENT_HANDLER}.make (agent handle_debug (a_api, ?, ?)), Void)
|
||||
end
|
||||
|
||||
feature -- Hooks configuration
|
||||
|
||||
88
src/persistence/cms_data_query_parameters.e
Normal file
88
src/persistence/cms_data_query_parameters.e
Normal file
@@ -0,0 +1,88 @@
|
||||
note
|
||||
description: "[
|
||||
Parameters associated with data query.
|
||||
It could be query over http, or storage.
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CMS_DATA_QUERY_PARAMETERS
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_offset: NATURAL_64; a_size: NATURAL)
|
||||
do
|
||||
offset := a_offset
|
||||
size := a_size
|
||||
ensure
|
||||
size_set: size = a_size
|
||||
offset_set: offset = a_offset
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
size: NATURAL assign set_size
|
||||
-- Number of items per page.
|
||||
|
||||
offset: NATURAL_64 assign set_offset
|
||||
-- lower index of `items' pagination.
|
||||
|
||||
order_by: detachable READABLE_STRING_8
|
||||
-- field to order by.
|
||||
|
||||
order_ascending: BOOLEAN
|
||||
-- is ascending ordering?
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_size (a_size: NATURAL)
|
||||
-- Set `size' with `a_size'.
|
||||
do
|
||||
size := a_size
|
||||
ensure
|
||||
size_set: size = a_size
|
||||
end
|
||||
|
||||
set_offset (a_offset: NATURAL_64)
|
||||
-- Set offset with `a_offset'.
|
||||
do
|
||||
offset := a_offset
|
||||
ensure
|
||||
limit_set: offset = a_offset
|
||||
end
|
||||
|
||||
set_ascending_order_by_field (a_field: detachable READABLE_STRING_8)
|
||||
-- Pager with a order_by `a_field' asc.
|
||||
do
|
||||
if a_field /= Void then
|
||||
order_by := a_field
|
||||
order_ascending := True
|
||||
else
|
||||
order_by := Void
|
||||
end
|
||||
ensure
|
||||
order_by_unset: a_field = Void implies order_by = Void
|
||||
order_by_set: a_field /= Void implies attached order_by as l_order_by and then l_order_by.same_string (a_field)
|
||||
asc_true: order_ascending
|
||||
end
|
||||
|
||||
set_descending_order_by_field (a_field: detachable READABLE_STRING_8)
|
||||
-- Pager sorting descending with field `a_field' if set, otherwise remove sorting.
|
||||
do
|
||||
if a_field /= Void then
|
||||
order_by := a_field
|
||||
order_ascending := False
|
||||
else
|
||||
order_by := Void
|
||||
end
|
||||
ensure
|
||||
order_by_unset: a_field = Void implies order_by = Void
|
||||
order_by_set: a_field /= Void implies attached order_by as l_order_by and then l_order_by.same_string (a_field)
|
||||
asc_fasle: not order_ascending
|
||||
end
|
||||
|
||||
end
|
||||
@@ -39,6 +39,13 @@ feature -- Status report
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- Basic operation
|
||||
|
||||
close
|
||||
-- Close/disconnect current storage.
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- Error Handling
|
||||
|
||||
error_handler: ERROR_HANDLER
|
||||
|
||||
@@ -45,6 +45,13 @@ feature -- Status report
|
||||
Result := True
|
||||
end
|
||||
|
||||
feature -- Basic operation
|
||||
|
||||
close
|
||||
-- <Precursor>
|
||||
do
|
||||
end
|
||||
|
||||
feature -- URL aliases
|
||||
|
||||
set_path_alias (a_source: READABLE_STRING_8; a_alias: READABLE_STRING_8)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
note
|
||||
description: "[
|
||||
Objects that ...
|
||||
CMS Storage for core functionalities.
|
||||
]"
|
||||
author: "$Author$"
|
||||
date: "$Date$"
|
||||
|
||||
107
src/persistence/sql/cms_storage_fs_i.e
Normal file
107
src/persistence/sql/cms_storage_fs_i.e
Normal file
@@ -0,0 +1,107 @@
|
||||
note
|
||||
description: "Interface used to implement CMS Storage based on File system."
|
||||
date: "$Date: 2015-02-13 13:08:13 +0100 (ven., 13 févr. 2015) $"
|
||||
revision: "$Revision: 96616 $"
|
||||
|
||||
deferred class
|
||||
CMS_STORAGE_FS_I
|
||||
|
||||
inherit
|
||||
SHARED_LOGGER
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_location: PATH; a_api: CMS_API)
|
||||
do
|
||||
location := a_location
|
||||
api := a_api
|
||||
create error_handler.make
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
api: CMS_API
|
||||
-- Associated CMS api.
|
||||
|
||||
location: PATH
|
||||
-- File system location.
|
||||
|
||||
feature -- Error handler
|
||||
|
||||
error_handler: ERROR_HANDLER
|
||||
-- Error handler.
|
||||
|
||||
has_error: BOOLEAN
|
||||
-- Last operation reported error.
|
||||
do
|
||||
Result := error_handler.has_error
|
||||
end
|
||||
|
||||
reset_error
|
||||
-- Reset errors.
|
||||
do
|
||||
error_handler.reset
|
||||
end
|
||||
|
||||
feature -- Helpers
|
||||
|
||||
save_to_file (a_text: STRING; opt_name: detachable READABLE_STRING_GENERAL)
|
||||
local
|
||||
s: READABLE_STRING_GENERAL
|
||||
now: DATE_TIME
|
||||
fut: WSF_FILE_UTILITIES [RAW_FILE]
|
||||
do
|
||||
create fut
|
||||
if opt_name /= Void then
|
||||
s := opt_name
|
||||
else
|
||||
create now.make_now_utc
|
||||
s := date_to_yyyymmdd_hhmmss_string (now)
|
||||
end
|
||||
if attached fut.new_file (location.extended (s)) as f then
|
||||
f.put_string (a_text)
|
||||
f.close
|
||||
else
|
||||
error_handler.add_custom_error (0, "saving failure", Void)
|
||||
end
|
||||
end
|
||||
|
||||
date_to_yyyymmdd_hhmmss_string (d: DATE_TIME): STRING
|
||||
local
|
||||
i: INTEGER
|
||||
do
|
||||
create Result.make_empty
|
||||
Result.append_integer (d.year)
|
||||
Result.append_character ('-')
|
||||
i := d.month
|
||||
if i < 10 then
|
||||
Result.append_integer (0)
|
||||
end
|
||||
Result.append_integer (i)
|
||||
Result.append_character ('-')
|
||||
i := d.day
|
||||
if i < 10 then
|
||||
Result.append_integer (0)
|
||||
end
|
||||
Result.append_integer (i)
|
||||
Result.append_character ('_')
|
||||
i := d.hour
|
||||
if i < 10 then
|
||||
Result.append_integer (0)
|
||||
end
|
||||
Result.append_integer (i)
|
||||
Result.append_character ('-')
|
||||
i := d.minute
|
||||
if i < 10 then
|
||||
Result.append_integer (0)
|
||||
end
|
||||
Result.append_integer (i)
|
||||
Result.append_character ('-')
|
||||
i := d.second
|
||||
if i < 10 then
|
||||
Result.append_integer (0)
|
||||
end
|
||||
Result.append_integer (i)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -40,6 +40,10 @@ feature -- Initialization
|
||||
|
||||
--| Node
|
||||
-- FIXME: move that initialization to node module
|
||||
-- TODO: should we move the initialization to an
|
||||
--! external configuration file?
|
||||
--! at the moment we only have 1 admin to the whole site.
|
||||
--! is that ok?
|
||||
l_anonymous_role.add_permission ("view any page")
|
||||
a_storage.save_user_role (l_anonymous_role)
|
||||
|
||||
@@ -47,9 +51,11 @@ feature -- Initialization
|
||||
l_authenticated_role.add_permission ("view any page")
|
||||
l_authenticated_role.add_permission ("edit any page")
|
||||
l_authenticated_role.add_permission ("delete page")
|
||||
l_authenticated_role.add_permission ("trash page")
|
||||
l_authenticated_role.add_permission ("view own page")
|
||||
l_authenticated_role.add_permission ("edit own page")
|
||||
l_authenticated_role.add_permission ("delete own page")
|
||||
l_authenticated_role.add_permission ("trash own page")
|
||||
a_storage.save_user_role (l_authenticated_role)
|
||||
|
||||
|
||||
|
||||
@@ -217,6 +217,21 @@ feature -- Access
|
||||
deferred
|
||||
end
|
||||
|
||||
sql_read_natural_64 (a_index: INTEGER): NATURAL_64
|
||||
-- Retrieved value at `a_index' position in `item'.
|
||||
local
|
||||
l_item: like sql_item
|
||||
do
|
||||
l_item := sql_item (a_index)
|
||||
if attached {NATURAL_64} l_item as i then
|
||||
Result := i
|
||||
elseif attached {NATURAL_64_REF} l_item as l_value then
|
||||
Result := l_value.item
|
||||
else
|
||||
Result := sql_read_integer_64 (a_index).to_natural_64
|
||||
end
|
||||
end
|
||||
|
||||
sql_read_integer_64 (a_index: INTEGER): INTEGER_64
|
||||
-- Retrieved value at `a_index' position in `item'.
|
||||
local
|
||||
|
||||
@@ -148,17 +148,15 @@ feature -- Permissions system
|
||||
|
||||
feature -- Query: module
|
||||
|
||||
module (a_type: TYPE [detachable CMS_MODULE]): detachable CMS_MODULE
|
||||
module (a_type: TYPE [CMS_MODULE]): detachable CMS_MODULE
|
||||
-- Enabled module typed `a_type', if any.
|
||||
--| usage: if attached module ({FOO_MODULE}) as mod then ...
|
||||
local
|
||||
t: STRING_8
|
||||
-- t: STRING_8
|
||||
l_type: TYPE [detachable CMS_MODULE]
|
||||
do
|
||||
t := a_type.name
|
||||
if t.starts_with ("!") then
|
||||
t.remove_head (1)
|
||||
end
|
||||
-- t := type_name_without_annotation (a_type)
|
||||
|
||||
across
|
||||
setup.modules as ic
|
||||
until
|
||||
@@ -171,8 +169,12 @@ feature -- Query: module
|
||||
l_type := Result.generating_type
|
||||
if a_type ~ l_type then
|
||||
-- Found
|
||||
elseif t.same_string (l_type.name) then
|
||||
elseif
|
||||
attached a_type.attempt (Result) and then attached l_type.generating_type.attempt (a_type)
|
||||
then
|
||||
-- Found
|
||||
-- elseif t.same_string (type_name_without_annotation (l_type)) then
|
||||
-- -- Found
|
||||
else
|
||||
Result := Void
|
||||
end
|
||||
@@ -185,8 +187,11 @@ feature -- Query: module
|
||||
module_api (a_type: TYPE [CMS_MODULE]): detachable CMS_MODULE_API
|
||||
-- Enabled module API associated with module typed `a_type'.
|
||||
do
|
||||
if attached {CMS_MODULE} module (a_type) as mod then
|
||||
if attached module (a_type) as mod then
|
||||
if mod.is_enabled then
|
||||
if not mod.is_initialized then
|
||||
mod.initialize (Current)
|
||||
end
|
||||
Result := mod.module_api
|
||||
end
|
||||
end
|
||||
@@ -236,9 +241,16 @@ feature -- Query: API
|
||||
|
||||
feature -- Path aliases
|
||||
|
||||
is_valid_path_alias (a_alias: READABLE_STRING_8): BOOLEAN
|
||||
do
|
||||
Result := a_alias.is_empty or else not a_alias.starts_with_general ("/")
|
||||
end
|
||||
|
||||
set_path_alias (a_source, a_alias: READABLE_STRING_8; a_keep_previous: BOOLEAN)
|
||||
-- Set `a_alias' as alias of `a_source',
|
||||
-- and eventually unset previous alias if any.
|
||||
require
|
||||
valid_alias: is_valid_path_alias (a_alias)
|
||||
local
|
||||
l_continue: BOOLEAN
|
||||
do
|
||||
@@ -283,8 +295,8 @@ feature -- Path aliases
|
||||
-- Resolved path for alias `a_alias'.
|
||||
--| the CMS supports aliases for path, and then this function simply returns
|
||||
--| the effective target path/url for this `a_alias'.
|
||||
--| For instance: /articles/2015/may/this-is-an-article can be an alias to /node/123
|
||||
--| This function will return "/node/123".
|
||||
--| For instance: articles/2015/may/this-is-an-article can be an alias to node/123
|
||||
--| This function will return "node/123".
|
||||
--| If the alias is bad (i.e does not alias real path), then this function
|
||||
--| returns the alias itself.
|
||||
do
|
||||
@@ -310,6 +322,41 @@ feature {NONE}-- Implemenation
|
||||
internal_user_api: detachable like user_api
|
||||
-- Cached value for `user_api'.
|
||||
|
||||
type_name_without_annotation (a_type: TYPE [detachable ANY]): STRING
|
||||
-- Type name for `a_type, without any annotation.
|
||||
-- Used by `module' to search by type.
|
||||
local
|
||||
i,j,n: INTEGER
|
||||
c: CHARACTER
|
||||
do
|
||||
create Result.make_from_string (a_type.name)
|
||||
from
|
||||
i := 1
|
||||
n := Result.count
|
||||
until
|
||||
i > n
|
||||
loop
|
||||
c := Result[i]
|
||||
if c = '!' or c = '?' then
|
||||
Result.remove (i)
|
||||
n := n - 1
|
||||
elseif c.is_lower then
|
||||
j := Result.index_of (' ', i + 1)
|
||||
if j > 0 then
|
||||
Result.remove_substring (i, j)
|
||||
n := n - (j - i)
|
||||
end
|
||||
else
|
||||
i := i + 1
|
||||
end
|
||||
end
|
||||
if Result.starts_with ("!") or Result.starts_with ("?") then
|
||||
Result.remove_head (1)
|
||||
elseif Result.starts_with ("detachable ") then
|
||||
Result.remove_head (11)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Environment
|
||||
|
||||
module_configuration (a_module_name: READABLE_STRING_GENERAL; a_name: detachable READABLE_STRING_GENERAL): detachable CONFIG_READER
|
||||
|
||||
@@ -14,4 +14,10 @@ create
|
||||
make,
|
||||
make_from_manifest
|
||||
|
||||
convert
|
||||
make_from_manifest ({ ARRAY [TUPLE [key: STRING; value: detachable ANY]],
|
||||
ARRAY [TUPLE [STRING_8, ARRAY [TUPLE [STRING_8, STRING_32]]]],
|
||||
ARRAY [TUPLE [STRING_8, ARRAY [TUPLE [STRING_8, STRING_8]]]]
|
||||
})
|
||||
|
||||
end
|
||||
|
||||
@@ -6,56 +6,56 @@ note
|
||||
even for a specific handler.
|
||||
]"
|
||||
|
||||
class
|
||||
CMS_SERVICE
|
||||
deferred class
|
||||
CMS_EXECUTION
|
||||
|
||||
inherit
|
||||
WSF_ROUTED_SKELETON_SERVICE
|
||||
rename
|
||||
execute as execute_service
|
||||
WSF_FILTERED_ROUTED_SKELETON_EXECUTION
|
||||
undefine
|
||||
requires_proxy
|
||||
redefine
|
||||
create_router, router,
|
||||
execute_default,
|
||||
create_router,
|
||||
router
|
||||
end
|
||||
|
||||
WSF_FILTERED_SERVICE
|
||||
|
||||
WSF_FILTER
|
||||
rename
|
||||
execute as execute_filter
|
||||
filter_execute,
|
||||
initialize
|
||||
end
|
||||
|
||||
WSF_NO_PROXY_POLICY
|
||||
|
||||
WSF_URI_HELPER_FOR_ROUTED_SERVICE
|
||||
WSF_URI_HELPER_FOR_ROUTED_EXECUTION
|
||||
|
||||
WSF_URI_TEMPLATE_HELPER_FOR_ROUTED_SERVICE
|
||||
WSF_URI_TEMPLATE_HELPER_FOR_ROUTED_EXECUTION
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
SHARED_LOGGER
|
||||
|
||||
create
|
||||
make
|
||||
--create
|
||||
-- make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_setup: CMS_SETUP)
|
||||
initialize
|
||||
-- Build a CMS service with `a_api'
|
||||
local
|
||||
l_setup: CMS_SETUP
|
||||
do
|
||||
create api.make (a_setup)
|
||||
initialize
|
||||
l_setup := initial_cms_setup
|
||||
setup_storage (l_setup)
|
||||
setup_modules (l_setup)
|
||||
create api.make (l_setup)
|
||||
modules := setup.enabled_modules
|
||||
|
||||
initialize_cms
|
||||
Precursor
|
||||
end
|
||||
|
||||
initialize
|
||||
-- Initialize various parts of the CMS service.
|
||||
initialize_cms
|
||||
do
|
||||
initialize_modules
|
||||
initialize_users
|
||||
initialize_mailer
|
||||
write_debug_log (generator + ".initialize_cms")
|
||||
|
||||
-- CMS Initialization
|
||||
|
||||
-- initialize_router
|
||||
-- initialize_filter: expanded here, for void-safety concern.
|
||||
create_filter
|
||||
@@ -71,20 +71,41 @@ feature {NONE} -- Initialization
|
||||
only_enabled_modules: across modules as ic all ic.item.is_enabled end
|
||||
end
|
||||
|
||||
initialize_users
|
||||
-- Initialize users.
|
||||
do
|
||||
feature -- Factory
|
||||
|
||||
initial_cms_setup: CMS_SETUP
|
||||
deferred
|
||||
end
|
||||
|
||||
initialize_mailer
|
||||
-- Initialize mailer engine.
|
||||
feature -- Access
|
||||
|
||||
api: CMS_API
|
||||
-- API service.
|
||||
|
||||
setup: CMS_SETUP
|
||||
-- CMS Setup.
|
||||
do
|
||||
to_implement ("To Implement mailer")
|
||||
Result := api.setup
|
||||
end
|
||||
|
||||
modules: CMS_MODULE_COLLECTION
|
||||
-- Configurator of possible modules.
|
||||
|
||||
feature -- CMS setup
|
||||
|
||||
setup_modules (a_setup: CMS_SETUP)
|
||||
-- Setup additional modules.
|
||||
deferred
|
||||
end
|
||||
|
||||
setup_storage (a_setup: CMS_SETUP)
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- Settings: router
|
||||
|
||||
router: CMS_ROUTER
|
||||
-- <Precursor>
|
||||
|
||||
create_router
|
||||
-- Create `router'.
|
||||
@@ -124,9 +145,9 @@ feature -- Settings: router
|
||||
create l_root_handler.make (api)
|
||||
create l_methods
|
||||
l_methods.enable_get
|
||||
a_router.handle_with_request_methods ("/", l_root_handler, l_methods)
|
||||
a_router.handle_with_request_methods ("", l_root_handler, l_methods)
|
||||
map_uri_agent_with_request_methods ("/favicon.ico", agent handle_favicon, a_router.methods_head_get)
|
||||
a_router.handle ("/", l_root_handler, l_methods)
|
||||
a_router.handle ("", l_root_handler, l_methods)
|
||||
map_uri_agent ("/favicon.ico", agent handle_favicon, a_router.methods_head_get)
|
||||
end
|
||||
|
||||
configure_api_file_handler (a_router: WSF_ROUTER)
|
||||
@@ -137,11 +158,11 @@ feature -- Settings: router
|
||||
|
||||
create fhdl.make_hidden_with_path (setup.theme_assets_location)
|
||||
fhdl.disable_index
|
||||
fhdl.set_not_found_handler (agent (ia_uri: READABLE_STRING_8; ia_req: WSF_REQUEST; ia_res: WSF_RESPONSE)
|
||||
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)
|
||||
a_router.handle_with_request_methods ("/theme/", fhdl, router.methods_GET)
|
||||
a_router.handle ("/theme/", fhdl, router.methods_GET)
|
||||
|
||||
|
||||
create fhdl.make_hidden_with_path (setup.environment.www_path)
|
||||
@@ -150,17 +171,17 @@ feature -- Settings: router
|
||||
do
|
||||
execute_default (ia_req, ia_res)
|
||||
end)
|
||||
a_router.handle_with_request_methods ("/", fhdl, router.methods_GET)
|
||||
a_router.handle ("/", fhdl, router.methods_GET)
|
||||
end
|
||||
|
||||
feature -- Execute Filter
|
||||
|
||||
execute_filter (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
filter_execute (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 ("X-EWF-Server: CMS_v1.0")
|
||||
execute_service (req, res)
|
||||
Precursor (req, res)
|
||||
end
|
||||
|
||||
feature -- Filters
|
||||
@@ -180,10 +201,10 @@ feature -- Filters
|
||||
f.set_next (l_filter)
|
||||
l_filter := f
|
||||
|
||||
-- Error Filter
|
||||
create {CMS_ERROR_FILTER} f.make (api)
|
||||
f.set_next (l_filter)
|
||||
l_filter := f
|
||||
-- -- Error Filter
|
||||
-- create {CMS_ERROR_FILTER} f.make (api)
|
||||
-- f.set_next (l_filter)
|
||||
-- l_filter := f
|
||||
|
||||
-- Include filters from modules
|
||||
l_api := api
|
||||
@@ -223,20 +244,6 @@ feature -- Filters
|
||||
f.set_next (Current)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
api: CMS_API
|
||||
-- API service.
|
||||
|
||||
setup: CMS_SETUP
|
||||
-- CMS setup.
|
||||
do
|
||||
Result := api.setup
|
||||
end
|
||||
|
||||
modules: CMS_MODULE_COLLECTION
|
||||
-- Configurator of possible modules.
|
||||
|
||||
feature -- Execution
|
||||
|
||||
handle_favicon (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
@@ -49,28 +49,32 @@ feature {CMS_API} -- Access: API
|
||||
|
||||
module_api: detachable CMS_MODULE_API
|
||||
-- Eventual module api.
|
||||
require
|
||||
is_initialized: is_initialized
|
||||
do
|
||||
-- No API by default.
|
||||
end
|
||||
|
||||
feature {CMS_API} -- Module management
|
||||
|
||||
is_installed (api: CMS_API): BOOLEAN
|
||||
-- Is Current module installed?
|
||||
do
|
||||
Result := is_enabled
|
||||
-- FIXME: implement proper installation status.
|
||||
Result := attached api.storage.custom_value ("is_initialized", "module-" + name) as v and then v.is_case_insensitive_equal_general ("yes")
|
||||
end
|
||||
|
||||
install (api: CMS_API)
|
||||
require
|
||||
is_not_installed: not is_installed (api)
|
||||
do
|
||||
-- Not Yet Supported
|
||||
api.storage.set_custom_value ("is_initialized", "module-" + name, "yes")
|
||||
end
|
||||
|
||||
uninstall (api: CMS_API)
|
||||
require
|
||||
is_installed: is_installed (api)
|
||||
do
|
||||
-- Not Yet Supported
|
||||
api.storage.set_custom_value ("is_initialized", "module-" + name, "no")
|
||||
end
|
||||
|
||||
feature -- Router
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
note
|
||||
description: "Summary description for {CMS_MODULE_API}."
|
||||
author: ""
|
||||
date: "$Date: 2015-02-13 14:54:27 +0100 (ven., 13 févr. 2015) $"
|
||||
revision: "$Revision: 96620 $"
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
note
|
||||
description: "Summary description for {CMS_MODULE_COLLECTION}."
|
||||
author: ""
|
||||
description: "Collection of CMS modules."
|
||||
date: "$Date: 2015-02-09 22:29:56 +0100 (lun., 09 févr. 2015) $"
|
||||
revision: "$Revision: 96596 $"
|
||||
|
||||
|
||||
@@ -19,15 +19,19 @@ feature -- Basic operations
|
||||
|
||||
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute the filter
|
||||
local
|
||||
utf: UTF_CONVERTER
|
||||
do
|
||||
fixme ("Check if it's ok to add new fetures CMS_API.has_error:BOOLEAN and CMS_API.error_description.")
|
||||
debug ("refactor_fixme")
|
||||
fixme ("Check if it's ok to add new features CMS_API.has_error:BOOLEAN and CMS_API.error_description.")
|
||||
end
|
||||
if not api.has_error then
|
||||
api.logger.put_information (generator + ".execute with req: " + req.debug_output, Void)
|
||||
if attached req.raw_header_data as l_header_data then
|
||||
api.logger.put_debug (generator + ".execute with req header: " + l_header_data, Void)
|
||||
api.logger.put_debug (generator + ".execute with req header: " + utf.escaped_utf_32_string_to_utf_8_string_8 (l_header_data), Void)
|
||||
end
|
||||
if attached req.raw_input_data as l_input_data then
|
||||
api.logger.put_debug (generator + ".execute with req input: " + l_input_data, Void)
|
||||
api.logger.put_debug (generator + ".execute with req input: " + utf.escaped_utf_32_string_to_utf_8_string_8 (l_input_data), Void)
|
||||
end
|
||||
execute_next (req, res)
|
||||
else
|
||||
|
||||
@@ -36,6 +36,18 @@ feature -- Response helpers
|
||||
-- res.send (create {CMS_REDIRECTION_RESPONSE_MESSAGE}.make (a_location))
|
||||
end
|
||||
|
||||
send_bad_request_message (res: WSF_RESPONSE)
|
||||
-- Send via `res' a bad request response.
|
||||
do
|
||||
res.send (create {CMS_CUSTOM_RESPONSE_MESSAGE}.make ({HTTP_STATUS_CODE}.bad_request))
|
||||
end
|
||||
|
||||
send_not_found_message (res: WSF_RESPONSE)
|
||||
-- Send via `res' a bad request response.
|
||||
do
|
||||
res.send (create {CMS_CUSTOM_RESPONSE_MESSAGE}.make ({HTTP_STATUS_CODE}.not_found))
|
||||
end
|
||||
|
||||
send_access_denied_message (res: WSF_RESPONSE)
|
||||
-- Send via `res' an access denied response.
|
||||
do
|
||||
|
||||
@@ -70,14 +70,4 @@ feature -- Media 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
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -13,6 +13,7 @@ inherit
|
||||
feature -- Core
|
||||
|
||||
site_url: READABLE_STRING_8
|
||||
-- Absolute site URL of Current CMS site.
|
||||
deferred
|
||||
end
|
||||
|
||||
|
||||
@@ -31,8 +31,22 @@ feature {WSF_ROUTER_MAPPING} -- Dispatch helper
|
||||
|
||||
path_to_dispatch (req: WSF_REQUEST): READABLE_STRING_8
|
||||
-- Path used by the router, to apply url dispatching of request `req'.
|
||||
local
|
||||
l_path: STRING_8
|
||||
do
|
||||
Result := api.source_of_path_alias (Precursor (req))
|
||||
create l_path.make_from_string (Precursor (req))
|
||||
if not l_path.is_empty and l_path [1] = '/' then
|
||||
l_path.remove_head (1)
|
||||
end
|
||||
Result := api.source_of_path_alias (l_path)
|
||||
if Result.is_empty then
|
||||
Result := "/"
|
||||
elseif Result [1] /= '/' then
|
||||
create l_path.make (Result.count + 1)
|
||||
l_path.append_character ('/')
|
||||
l_path.append (Result)
|
||||
Result := l_path
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -3,8 +3,8 @@ note
|
||||
Generic CMS Response.
|
||||
It builds the content to get process to render the output.
|
||||
]"
|
||||
date: "$Date: 2015-02-16 20:14:19 +0100 (lun., 16 févr. 2015) $"
|
||||
revision: "$Revision: 96643 $"
|
||||
date: "$Date: 2015-05-20 11:48:26 +0200 (mer., 20 mai 2015) $"
|
||||
revision: "$Revision: 97327 $"
|
||||
|
||||
deferred class
|
||||
CMS_RESPONSE
|
||||
@@ -29,6 +29,7 @@ feature {NONE} -- Initialization
|
||||
|
||||
initialize
|
||||
do
|
||||
initialize_site_url
|
||||
get_theme
|
||||
create menu_system.make
|
||||
initialize_block_region_settings
|
||||
@@ -36,6 +37,35 @@ feature {NONE} -- Initialization
|
||||
register_hooks
|
||||
end
|
||||
|
||||
initialize_site_url
|
||||
-- Initialize site and base url.
|
||||
local
|
||||
l_url: detachable STRING_8
|
||||
i,j: INTEGER
|
||||
do
|
||||
--| WARNING: do not use `absolute_url' and `url', since it relies on site_url and base_url.
|
||||
if attached setup.site_url as l_site_url and then not l_site_url.is_empty then
|
||||
create l_url.make_from_string (l_site_url)
|
||||
else
|
||||
l_url := request.absolute_script_url ("/")
|
||||
end
|
||||
check is_not_empty: not l_url.is_empty end
|
||||
if l_url [l_url.count] /= '/' then
|
||||
l_url.append_character ('/')
|
||||
end
|
||||
site_url := l_url
|
||||
i := l_url.substring_index ("://", 1)
|
||||
if i > 0 then
|
||||
j := l_url.index_of ('/', i + 3)
|
||||
if j > 0 then
|
||||
base_url := l_url.substring (j, l_url.count)
|
||||
end
|
||||
end
|
||||
ensure
|
||||
site_url_set: site_url /= Void
|
||||
site_url_ends_with_slash: site_url.ends_with_general ("/")
|
||||
end
|
||||
|
||||
register_hooks
|
||||
local
|
||||
l_module: CMS_MODULE
|
||||
@@ -76,6 +106,15 @@ feature -- Access
|
||||
redirection: detachable READABLE_STRING_8
|
||||
-- Location for eventual redirection.
|
||||
|
||||
location: STRING_8
|
||||
-- Associated cms local location.
|
||||
do
|
||||
create Result.make_from_string (request.percent_encoded_path_info)
|
||||
if not Result.is_empty and then Result[1] = '/' then
|
||||
Result.remove_head (1)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Internationalization (i18n)
|
||||
|
||||
translation (a_text: READABLE_STRING_GENERAL; opts: detachable CMS_API_OPTIONS): STRING_32
|
||||
@@ -121,9 +160,11 @@ feature -- Module
|
||||
rp: PATH
|
||||
ut: FILE_UTILITIES
|
||||
do
|
||||
-- Check first in selected theme folder.
|
||||
rp := module_assets_theme_location (a_module)
|
||||
Result := rp.extended_path (a_resource)
|
||||
if not ut.file_path_exists (Result) then
|
||||
-- And if not found, look into site/modules/$a_module.name/.... folders.
|
||||
rp := module_assets_location (a_module)
|
||||
Result := rp.extended_path (a_resource)
|
||||
if not ut.file_path_exists (Result) then
|
||||
@@ -163,16 +204,13 @@ feature -- URL utilities
|
||||
end
|
||||
end
|
||||
|
||||
site_url: READABLE_STRING_8
|
||||
do
|
||||
Result := absolute_host (request, "")
|
||||
end
|
||||
site_url: IMMUTABLE_STRING_8
|
||||
-- Absolute site url.
|
||||
|
||||
base_url: detachable READABLE_STRING_8
|
||||
base_url: detachable IMMUTABLE_STRING_8
|
||||
-- Base url if any.
|
||||
--| Usually it is Void, but it could be
|
||||
--| /project/demo/
|
||||
--| FIXME: for now, no way to change that. Always at the root "/"
|
||||
|
||||
feature -- Access: CMS
|
||||
|
||||
@@ -183,7 +221,7 @@ feature -- Access: CMS
|
||||
|
||||
front_page_url: READABLE_STRING_8
|
||||
do
|
||||
Result := request.absolute_script_url ("/")
|
||||
Result := absolute_url ("/", Void)
|
||||
end
|
||||
|
||||
values: CMS_VALUE_TABLE
|
||||
@@ -806,9 +844,9 @@ feature -- Theme
|
||||
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)
|
||||
create {SMARTY_CMS_THEME} theme.make (setup, l_info, site_url)
|
||||
else
|
||||
create {MISSING_CMS_THEME} theme.make (setup)
|
||||
create {MISSING_CMS_THEME} theme.make (setup, l_info, site_url)
|
||||
status_code := {HTTP_STATUS_CODE}.service_unavailable
|
||||
to_implement ("Check how to add the Retry-after, http://tools.ietf.org/html/rfc7231#section-6.6.4 and http://tools.ietf.org/html/rfc7231#section-7.1.3")
|
||||
end
|
||||
@@ -834,7 +872,7 @@ feature -- Generation
|
||||
lnk: CMS_LINK
|
||||
do
|
||||
-- Menu
|
||||
create {CMS_LOCAL_LINK} lnk.make ("Home", "/")
|
||||
create {CMS_LOCAL_LINK} lnk.make ("Home", "")
|
||||
lnk.set_weight (-10)
|
||||
add_to_primary_menu (lnk)
|
||||
invoke_menu_system_alter (menu_system)
|
||||
@@ -920,8 +958,8 @@ feature -- Generation
|
||||
end
|
||||
|
||||
-- Variables
|
||||
page.register_variable (request.absolute_script_url (""), "site_url")
|
||||
page.register_variable (request.absolute_script_url (""), "host") -- Same as `site_url'.
|
||||
page.register_variable (absolute_url ("", Void), "site_url")
|
||||
page.register_variable (absolute_url ("", Void), "host") -- Same as `site_url'.
|
||||
page.register_variable (request.is_https, "is_https")
|
||||
if attached current_user_name (request) as l_user then
|
||||
page.register_variable (l_user, "user")
|
||||
@@ -1029,6 +1067,9 @@ feature -- Generation
|
||||
l_is_active: BOOLEAN
|
||||
do
|
||||
create qs.make_from_string (request.percent_encoded_path_info)
|
||||
if qs.starts_with ("/") then
|
||||
qs.remove_head (1)
|
||||
end
|
||||
l_is_active := qs.same_string (a_lnk.location)
|
||||
if not l_is_active then
|
||||
if attached request.query_string as l_query_string and then not l_query_string.is_empty then
|
||||
@@ -1102,8 +1143,8 @@ feature {NONE} -- Execution
|
||||
-- h.put_location (l_location)
|
||||
response.redirect_now (l_location)
|
||||
else
|
||||
-- h.put_location (request.absolute_script_url (l_location))
|
||||
response.redirect_now (request.absolute_script_url (l_location))
|
||||
-- h.put_location (request.absolute_url (l_location, Void))
|
||||
response.redirect_now (absolute_url (l_location, Void))
|
||||
end
|
||||
else
|
||||
h.put_header_object (header)
|
||||
|
||||
@@ -20,7 +20,7 @@ feature -- Generation
|
||||
|
||||
custom_prepare (page: CMS_HTML_PAGE)
|
||||
do
|
||||
page.register_variable (request.absolute_script_url (request.path_info), "request")
|
||||
page.register_variable (absolute_url (request.path_info, Void), "request")
|
||||
page.set_status_code ({HTTP_STATUS_CODE}.bad_request)
|
||||
page.register_variable (page.status_code.out, "code")
|
||||
end
|
||||
|
||||
@@ -20,7 +20,7 @@ feature -- Generation
|
||||
|
||||
custom_prepare (page: CMS_HTML_PAGE)
|
||||
do
|
||||
page.register_variable (request.absolute_script_url (request.path_info), "request")
|
||||
page.register_variable (absolute_url (request.path_info, Void), "request")
|
||||
page.set_status_code ({HTTP_STATUS_CODE}.forbidden)
|
||||
page.register_variable (page.status_code.out, "code")
|
||||
end
|
||||
|
||||
@@ -20,7 +20,7 @@ feature -- Generation
|
||||
|
||||
custom_prepare (page: CMS_HTML_PAGE)
|
||||
do
|
||||
page.register_variable (request.absolute_script_url (request.path_info), "request")
|
||||
page.register_variable (absolute_url (request.path_info, Void), "request")
|
||||
page.set_status_code ({HTTP_STATUS_CODE}.internal_server_error)
|
||||
page.register_variable (page.status_code.out, "code")
|
||||
end
|
||||
|
||||
@@ -20,7 +20,7 @@ feature -- Generation
|
||||
|
||||
custom_prepare (page: CMS_HTML_PAGE)
|
||||
do
|
||||
page.register_variable (request.absolute_script_url (request.path_info), "request")
|
||||
page.register_variable (absolute_url (request.path_info, Void), "request")
|
||||
page.set_status_code ({HTTP_STATUS_CODE}.not_found)
|
||||
page.register_variable (page.status_code.out, "code")
|
||||
end
|
||||
|
||||
@@ -20,7 +20,7 @@ feature -- Generation
|
||||
|
||||
custom_prepare (page: CMS_HTML_PAGE)
|
||||
do
|
||||
page.register_variable (request.absolute_script_url (request.path_info), "request")
|
||||
page.register_variable (absolute_url (request.path_info, Void), "request")
|
||||
page.set_status_code ({HTTP_STATUS_CODE}.not_implemented)
|
||||
page.register_variable (page.status_code.out, "code")
|
||||
end
|
||||
|
||||
64
src/service/response/message/cms_custom_response_message.e
Normal file
64
src/service/response/message/cms_custom_response_message.e
Normal file
@@ -0,0 +1,64 @@
|
||||
note
|
||||
description: "Custom cms response message."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CMS_CUSTOM_RESPONSE_MESSAGE
|
||||
|
||||
inherit
|
||||
CMS_RESPONSE_MESSAGE
|
||||
redefine
|
||||
send_payload_to
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_code: INTEGER)
|
||||
-- Set `status_code' to `a_code'.
|
||||
require
|
||||
a_code_valid: a_code > 0
|
||||
do
|
||||
initialize
|
||||
status_code := a_code
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
payload: detachable READABLE_STRING_8
|
||||
-- Optional payload.
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_status_code (a_code: INTEGER)
|
||||
-- Set `status_code' to `a_code'.
|
||||
require
|
||||
a_code_valid: a_code > 0
|
||||
do
|
||||
status_code := a_code
|
||||
end
|
||||
|
||||
set_payload (s: detachable READABLE_STRING_8)
|
||||
-- Set `payload' to `s'.
|
||||
do
|
||||
if s /= Void then
|
||||
payload := s
|
||||
header.put_content_length (s.count)
|
||||
else
|
||||
end
|
||||
end
|
||||
|
||||
feature {WSF_RESPONSE} -- Output
|
||||
|
||||
send_payload_to (res: WSF_RESPONSE)
|
||||
-- Send payload data to response `res'.
|
||||
do
|
||||
if attached payload as s then
|
||||
res.put_string (s)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
284
src/support/cms_pagination_generator.e
Normal file
284
src/support/cms_pagination_generator.e
Normal file
@@ -0,0 +1,284 @@
|
||||
note
|
||||
description: "Pagination class to generate html pagination links and header summary."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CMS_PAGINATION_GENERATOR
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_resource: READABLE_STRING_8; a_count: NATURAL_64; a_page_size: NATURAL)
|
||||
-- Create an object with a pages of size `a_page_size'.
|
||||
-- If `a_page_size' is zero, use default pagination size.
|
||||
require
|
||||
a_page_size > 0
|
||||
do
|
||||
create resource.make (a_resource)
|
||||
set_page_size (a_page_size)
|
||||
set_upper (a_count)
|
||||
set_current_page_index (1)
|
||||
|
||||
maximum_ith_page_links := 7
|
||||
page_parameter_id := "page"
|
||||
size_parameter_id := "size"
|
||||
set_first_text_id ("<<")
|
||||
set_prev_text_id ("<")
|
||||
set_next_text_id (">")
|
||||
set_last_text_id (">>")
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
resource: URI_TEMPLATE
|
||||
-- Resource associated with current pager.
|
||||
|
||||
page_size: NATURAL
|
||||
-- Number of items per page.
|
||||
|
||||
upper: NATURAL_64
|
||||
-- number of items.
|
||||
-- if zero, no upper limit.
|
||||
|
||||
current_page_index: INTEGER
|
||||
-- Current page index.
|
||||
|
||||
current_page_offset: NATURAL_64
|
||||
-- Lower index - 1 for current page.
|
||||
do
|
||||
if current_page_index > 1 then
|
||||
Result := (current_page_index - 1).to_natural_32 * page_size
|
||||
else
|
||||
Result := 0
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
has_upper_limit: BOOLEAN
|
||||
-- Upper limit known?
|
||||
do
|
||||
Result := upper > 0
|
||||
end
|
||||
|
||||
pages_count: INTEGER
|
||||
-- Number of pages.
|
||||
-- If upper is
|
||||
require
|
||||
has_upper_limit: has_upper_limit
|
||||
do
|
||||
Result := (upper // page_size.as_natural_64).to_integer_32
|
||||
if upper \\ page_size.to_natural_64 > 0 then
|
||||
Result := Result + 1
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Parameters
|
||||
|
||||
page_parameter_id: STRING
|
||||
-- Parameter id for page value.
|
||||
|
||||
size_parameter_id: STRING
|
||||
-- Parameter id for size value.
|
||||
|
||||
maximum_ith_page_links: INTEGER
|
||||
-- Maximum number of numeric ith page link.
|
||||
-- ex: max = 6 gives "1 2 3 4 5 6 ... > >>".
|
||||
|
||||
label_first: IMMUTABLE_STRING_32
|
||||
label_previous: IMMUTABLE_STRING_32
|
||||
label_next: IMMUTABLE_STRING_32
|
||||
label_last: IMMUTABLE_STRING_32
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_page_size (a_size: NATURAL)
|
||||
-- Set `page_size' to `a_size'.
|
||||
do
|
||||
page_size := a_size
|
||||
end
|
||||
|
||||
set_upper (a_upper: NATURAL_64)
|
||||
-- Set pages count, or upper limit `upper' to `a_size'.
|
||||
do
|
||||
upper := a_upper
|
||||
end
|
||||
|
||||
set_current_page_index (a_page_index: like current_page_index)
|
||||
-- Set Current page index to `a_page_index'.
|
||||
do
|
||||
current_page_index := a_page_index
|
||||
end
|
||||
|
||||
set_page_parameter_id (a_id: READABLE_STRING_8)
|
||||
-- Set "page" query parameter to `a_id'.
|
||||
do
|
||||
page_parameter_id := a_id
|
||||
end
|
||||
|
||||
set_size_parameter_id (a_id: READABLE_STRING_8)
|
||||
-- Set "size" query parameter to `a_id'.
|
||||
do
|
||||
size_parameter_id := a_id
|
||||
end
|
||||
|
||||
get_setting_from_request (req: WSF_REQUEST)
|
||||
-- Get various pager related settings from request `req' query paramenters.
|
||||
-- Using `page_parameter_id' and `size_parameter_id' value for parameter names.
|
||||
do
|
||||
-- Size
|
||||
if
|
||||
attached {WSF_STRING} req.query_parameter (size_parameter_id) as l_size and then
|
||||
attached l_size.value as l_value and then
|
||||
l_value.is_natural
|
||||
then
|
||||
set_page_size (l_value.to_natural_32)
|
||||
else
|
||||
-- Keep default size
|
||||
end
|
||||
|
||||
-- Page
|
||||
if
|
||||
attached {WSF_STRING} req.query_parameter (page_parameter_id) as l_page and then
|
||||
l_page.is_integer
|
||||
then
|
||||
set_current_page_index (l_page.integer_value)
|
||||
else
|
||||
set_current_page_index (1)
|
||||
end
|
||||
end
|
||||
|
||||
set_first_text_id (s: READABLE_STRING_GENERAL)
|
||||
-- Set label for "First" link to `s'.
|
||||
-- default: "<<"
|
||||
do
|
||||
create label_first.make_from_string_general (s)
|
||||
end
|
||||
|
||||
set_prev_text_id (s: READABLE_STRING_GENERAL)
|
||||
-- Set label for "Prev" link to `s'.
|
||||
-- default: "<"
|
||||
do
|
||||
create label_previous.make_from_string_general (s)
|
||||
end
|
||||
|
||||
set_next_text_id (s: READABLE_STRING_GENERAL)
|
||||
-- Set label for "Next" link to `s'.
|
||||
-- default: ">"
|
||||
do
|
||||
create label_next.make_from_string_general (s)
|
||||
end
|
||||
|
||||
set_last_text_id (s: READABLE_STRING_GENERAL)
|
||||
-- Set label for "Last" link to `s'.
|
||||
-- default: ">>"
|
||||
do
|
||||
create label_last.make_from_string_general (s)
|
||||
end
|
||||
|
||||
set_maximum_ith_page_links (nb: INTEGER)
|
||||
-- Set `maximum_ith_page_links' to `nb'.
|
||||
do
|
||||
maximum_ith_page_links := nb
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
pagination_links: ARRAYED_LIST [CMS_LOCAL_LINK]
|
||||
-- CMS local links related to Current paginations.
|
||||
local
|
||||
lnk: CMS_LOCAL_LINK
|
||||
tb: HASH_TABLE [detachable ANY, STRING_8]
|
||||
curr, max: INTEGER
|
||||
i,j: INTEGER
|
||||
do
|
||||
create Result.make (maximum_ith_page_links)
|
||||
|
||||
curr := current_page_index
|
||||
if has_upper_limit then
|
||||
max := pages_count
|
||||
else
|
||||
max := curr + page_size.to_integer_32
|
||||
end
|
||||
|
||||
create tb.make (2)
|
||||
tb.force (page_size, size_parameter_id)
|
||||
tb.force (1, page_parameter_id)
|
||||
if curr > 1 then
|
||||
create lnk.make (label_first, resource.expanded_string (tb))
|
||||
Result.force (lnk)
|
||||
end
|
||||
|
||||
if curr > 1 then
|
||||
tb.force (curr - 1, "page")
|
||||
create lnk.make (label_previous, resource.expanded_string (tb))
|
||||
Result.force (lnk)
|
||||
end
|
||||
from
|
||||
if curr >= maximum_ith_page_links // 2 then
|
||||
i := curr - (maximum_ith_page_links // 2)
|
||||
else
|
||||
i := 1
|
||||
end
|
||||
j := 0
|
||||
until
|
||||
j >= maximum_ith_page_links or (has_upper_limit and then i > max)
|
||||
loop
|
||||
tb.force (i, "page")
|
||||
create lnk.make (i.out, resource.expanded_string (tb))
|
||||
lnk.set_is_active (i = curr)
|
||||
Result.force (lnk)
|
||||
j := j + 1
|
||||
i := i + 1
|
||||
end
|
||||
if not has_upper_limit or else i < max then
|
||||
tb.force (i, "page")
|
||||
create lnk.make ("...", resource.expanded_string (tb))
|
||||
Result.force (lnk)
|
||||
end
|
||||
|
||||
if curr < max then
|
||||
tb.force (curr + 1, "page")
|
||||
create lnk.make (label_next, resource.expanded_string (tb))
|
||||
Result.force (lnk)
|
||||
end
|
||||
|
||||
if upper > 0 and curr /= max then
|
||||
tb.force (max, "page")
|
||||
create lnk.make (label_last, resource.expanded_string (tb))
|
||||
Result.force (lnk)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Convertion
|
||||
|
||||
append_to_html (a_response: CMS_RESPONSE; a_output: STRING)
|
||||
-- Append html pager to `a_output' in the context of `a_response'.
|
||||
-- note: First, [Prev], [Next], Last.
|
||||
local
|
||||
lnk: CMS_LOCAL_LINK
|
||||
do
|
||||
a_output.append ("<ul class=%"pagination%">%N")
|
||||
across
|
||||
pagination_links as ic
|
||||
loop
|
||||
lnk := ic.item
|
||||
if lnk.is_active then
|
||||
a_output.append ("<li class=%"active%">")
|
||||
elseif lnk.title.same_string (label_previous) then
|
||||
a_output.append ("<li class=%"previous%">")
|
||||
elseif lnk.title.same_string (label_next) then
|
||||
a_output.append ("<li class=%"next%">")
|
||||
else
|
||||
a_output.append ("<li>")
|
||||
end
|
||||
a_output.append (a_response.link (lnk.title, lnk.location, Void))
|
||||
a_output.append ("</li>")
|
||||
end
|
||||
a_output.append ("</ul>")
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,7 +1,7 @@
|
||||
note
|
||||
description: "Abstract class describing a generic theme"
|
||||
date: "$Date: 2015-02-16 12:52:35 +0100 (lun., 16 févr. 2015) $"
|
||||
revision: "$Revision: 96630 $"
|
||||
date: "$Date: 2015-05-20 11:48:26 +0200 (mer., 20 mai 2015) $"
|
||||
revision: "$Revision: 97327 $"
|
||||
|
||||
deferred class
|
||||
CMS_THEME
|
||||
@@ -9,6 +9,8 @@ deferred class
|
||||
inherit
|
||||
CMS_ENCODERS
|
||||
|
||||
CMS_URL_UTILITIES
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
|
||||
@@ -16,6 +18,12 @@ feature {NONE} -- Access
|
||||
|
||||
setup: CMS_SETUP
|
||||
|
||||
site_url: IMMUTABLE_STRING_8
|
||||
-- Absolute URL for Current CMS site.
|
||||
|
||||
base_url: detachable IMMUTABLE_STRING_8
|
||||
-- Optional base url of current CMS site.
|
||||
|
||||
feature -- Access
|
||||
|
||||
name: STRING
|
||||
@@ -41,6 +49,31 @@ feature -- Status report
|
||||
Result := across regions as ic some a_region_name.is_case_insensitive_equal (ic.item) end
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_site_url (a_url: READABLE_STRING_8)
|
||||
-- Set `site_url' to `a_url'.
|
||||
require
|
||||
a_url.ends_with_general ("/")
|
||||
local
|
||||
i,j: INTEGER
|
||||
do
|
||||
base_url := Void
|
||||
if a_url [a_url.count] = '/' then
|
||||
create site_url.make_from_string (a_url)
|
||||
else
|
||||
create site_url.make_from_string (a_url + "/")
|
||||
end
|
||||
|
||||
i := a_url.substring_index ("://", 1)
|
||||
if i > 0 then
|
||||
j := a_url.index_of ('/', i + 3)
|
||||
if j > 0 then
|
||||
create base_url.make_from_string (a_url.substring (j, a_url.count))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
menu_html (a_menu: CMS_MENU; is_horizontal: BOOLEAN; a_options: detachable CMS_HTML_OPTIONS): STRING_8
|
||||
@@ -133,7 +166,11 @@ feature {NONE} -- Implementation
|
||||
else
|
||||
s.append ("<li class=%""+ cl + "%">")
|
||||
end
|
||||
s.append ("<a href=%"" + (lnk.location) + "%">" + html_encoded (lnk.title) + "</a>")
|
||||
s.append ("<a href=%"")
|
||||
s.append (url (lnk.location, Void))
|
||||
s.append ("%">")
|
||||
s.append (html_encoded (lnk.title))
|
||||
s.append ("</a>")
|
||||
if
|
||||
(lnk.is_expanded or lnk.is_collapsed) and then
|
||||
attached lnk.children as l_children
|
||||
|
||||
@@ -18,15 +18,19 @@ create
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_setup: like setup)
|
||||
make (a_setup: like setup; a_info: like information; abs_site_url: READABLE_STRING_8)
|
||||
do
|
||||
setup := a_setup
|
||||
information := a_info
|
||||
set_site_url (abs_site_url)
|
||||
ensure
|
||||
setup_set: setup = a_setup
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
information: CMS_THEME_INFORMATION
|
||||
|
||||
name: STRING = "missing theme"
|
||||
|
||||
regions: ARRAY [STRING]
|
||||
|
||||
@@ -14,7 +14,7 @@ create
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_setup: like setup; a_info: like information;)
|
||||
make (a_setup: like setup; a_info: like information; abs_site_url: READABLE_STRING_8)
|
||||
do
|
||||
setup := a_setup
|
||||
information := a_info
|
||||
@@ -23,6 +23,7 @@ feature {NONE} -- Initialization
|
||||
else
|
||||
templates_directory := a_setup.theme_location
|
||||
end
|
||||
set_site_url (abs_site_url)
|
||||
ensure
|
||||
setup_set: setup = a_setup
|
||||
information_set: information = a_info
|
||||
|
||||
54
src/theme/wsf/cms_to_wsf_theme.e
Normal file
54
src/theme/wsf/cms_to_wsf_theme.e
Normal file
@@ -0,0 +1,54 @@
|
||||
note
|
||||
description: "Theme from the EWF framework, but dedicated for the CMS."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CMS_TO_WSF_THEME
|
||||
|
||||
inherit
|
||||
WSF_THEME
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (res: CMS_RESPONSE; a_cms_theme: CMS_THEME)
|
||||
do
|
||||
request := res.request
|
||||
cms_theme := a_cms_theme
|
||||
set_response (res)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
request: WSF_REQUEST
|
||||
|
||||
response: CMS_RESPONSE
|
||||
|
||||
cms_theme: CMS_THEME
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_response (a_response: CMS_RESPONSE)
|
||||
-- Set `response' to `a_response'.
|
||||
do
|
||||
response := a_response
|
||||
end
|
||||
|
||||
feature -- Core
|
||||
|
||||
site_url: READABLE_STRING_8
|
||||
-- CMS site url.
|
||||
do
|
||||
Result := response.site_url
|
||||
end
|
||||
|
||||
base_url: detachable READABLE_STRING_8
|
||||
-- Base url if any.
|
||||
do
|
||||
Result := response.base_url
|
||||
end
|
||||
|
||||
end
|
||||
17
src/theme/wsf/wsf_cms_theme.e
Normal file
17
src/theme/wsf/wsf_cms_theme.e
Normal file
@@ -0,0 +1,17 @@
|
||||
note
|
||||
description: "Summary description for {WSF_CMS_THEME}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_CMS_THEME
|
||||
|
||||
obsolete "Use CMS_TO_WSF_THEME [2015-May]"
|
||||
|
||||
inherit
|
||||
CMS_TO_WSF_THEME
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
end
|
||||
30
src/theme/wsf/wsf_null_theme.e
Normal file
30
src/theme/wsf/wsf_null_theme.e
Normal file
@@ -0,0 +1,30 @@
|
||||
note
|
||||
description: " Null theme for void-safety purpose."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_NULL_THEME
|
||||
|
||||
inherit
|
||||
WSF_THEME
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
do
|
||||
end
|
||||
|
||||
feature -- Core
|
||||
|
||||
site_url: STRING = ""
|
||||
|
||||
base_url: detachable READABLE_STRING_8
|
||||
-- Base url if any.
|
||||
do
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user