Added support for base_url (i.e the CMS can be hosted on the root, or sub folder).
Local paths are relative to cms site url (i.e no starting slash). Favor CMS_RESPONSE.absolute_url and url .. instead of using directly WSF_REQUEST.absolute_script_url and script_url. Handled unicode truncation issue for logger. Code cleaning.
This commit is contained in:
@@ -101,7 +101,7 @@ feature -- Hooks
|
||||
local
|
||||
lnk: CMS_LOCAL_LINK
|
||||
do
|
||||
create lnk.make ("Blogs", "/blogs/")
|
||||
create lnk.make ("Blogs", "blogs/")
|
||||
a_menu_system.primary_menu.extend (lnk)
|
||||
end
|
||||
|
||||
|
||||
@@ -110,9 +110,9 @@ feature -- Hooks
|
||||
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))
|
||||
create lnk.make ("demo: abc", "demo/abc")
|
||||
m.extend (lnk)
|
||||
create lnk.make ("/demo/123", a_response.url ("/demo/123", Void))
|
||||
create lnk.make ("demo: 123", "demo/123")
|
||||
m.extend (lnk)
|
||||
create mb.make (m)
|
||||
a_response.add_block (mb, "sidebar_second")
|
||||
@@ -125,7 +125,7 @@ feature -- Hooks
|
||||
lnk: CMS_LOCAL_LINK
|
||||
-- perms: detachable ARRAYED_LIST [READABLE_STRING_8]
|
||||
do
|
||||
create lnk.make ("Demo", "/demo/")
|
||||
create lnk.make ("Demo", "demo/")
|
||||
a_menu_system.primary_menu.extend (lnk)
|
||||
end
|
||||
|
||||
@@ -137,8 +137,8 @@ feature -- Handler
|
||||
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.set_main_content ("DEMO module does not yet implement %"" + req.path_info + "%" ...")
|
||||
r.add_error_message ("DEMO Module: not yet implemented")
|
||||
r.execute
|
||||
end
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ CREATE TABLE "logs"(
|
||||
CREATE TABLE "custom_values"(
|
||||
"type" VARCHAR(255) NOT NULL,
|
||||
"name" VARCHAR(255) NOT NULL,
|
||||
"value" VARCHAR(255) NOT NULL
|
||||
"value" TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE "path_aliases"(
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
BEGIN;
|
||||
|
||||
CREATE TABLE "nodes"(
|
||||
"nid" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL CHECK("nid">=0),
|
||||
CREATE TABLE "nodes" (
|
||||
"nid" INTEGER NOT NULL CHECK("nid" > 0) PRIMARY KEY AUTOINCREMENT UNIQUE,
|
||||
"revision" INTEGER,
|
||||
"type" TEXT NOT NULL,
|
||||
"title" VARCHAR(255) NOT NULL,
|
||||
"summary" TEXT,
|
||||
"content" MEDIUMTEXT NOT NULL,
|
||||
"format" VARCHAR(255),
|
||||
"content" TEXT NOT NULL,
|
||||
"format" VARCHAR(128),
|
||||
"author" INTEGER,
|
||||
"publish" DATETIME,
|
||||
"created" DATETIME NOT NULL,
|
||||
|
||||
@@ -25,8 +25,10 @@ create
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_title: detachable like title; a_location: like location)
|
||||
make (a_title: detachable READABLE_STRING_GENERAL; a_location: like location)
|
||||
-- Create current local link with optional title `a_title' and location `a_location'.
|
||||
require
|
||||
is_valid_local_location_argument: not a_location.starts_with_general ("/")
|
||||
do
|
||||
location := a_location
|
||||
set_title (a_title)
|
||||
@@ -71,13 +73,13 @@ feature -- Status report
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_title (a_title: detachable like title)
|
||||
set_title (a_title: detachable READABLE_STRING_GENERAL)
|
||||
-- Set `title' to `a_title' or `location'.
|
||||
do
|
||||
if a_title /= Void then
|
||||
title := a_title
|
||||
title := a_title.as_string_32
|
||||
else
|
||||
title := location
|
||||
title := location.as_string_32
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -109,9 +109,9 @@ feature -- Hooks
|
||||
lnk: CMS_LOCAL_LINK
|
||||
do
|
||||
if attached a_response.current_user (a_response.request) as u then
|
||||
create lnk.make (u.name + " (Logout)", "/basic_auth_logoff?destination=" + a_response.request.request_uri)
|
||||
create lnk.make (u.name + " (Logout)", "basic_auth_logoff?destination=" + a_response.request.request_uri)
|
||||
else
|
||||
create lnk.make ("Login", "/basic_auth_login?destination=" + a_response.request.request_uri)
|
||||
create lnk.make ("Login", "basic_auth_login?destination=" + a_response.request.request_uri)
|
||||
end
|
||||
-- if not a_menu_system.primary_menu.has (lnk) then
|
||||
lnk.set_weight (99)
|
||||
|
||||
@@ -22,11 +22,12 @@ feature -- Basic operations
|
||||
-- Execute the filter.
|
||||
local
|
||||
l_auth: HTTP_AUTHORIZATION
|
||||
utf: UTF_CONVERTER
|
||||
do
|
||||
api.logger.put_debug (generator + ".execute ", Void)
|
||||
create l_auth.make (req.http_authorization)
|
||||
if attached req.raw_header_data as l_raw_data then
|
||||
api.logger.put_debug (generator + ".execute " + l_raw_data, Void)
|
||||
api.logger.put_debug (generator + ".execute " + utf.escaped_utf_32_string_to_utf_8_string_8 (l_raw_data), Void)
|
||||
end
|
||||
-- A valid user
|
||||
if
|
||||
|
||||
@@ -170,9 +170,9 @@ feature -- URL
|
||||
-- or URI of path for selection of new content possibilities if ct is Void.
|
||||
do
|
||||
if ct /= Void then
|
||||
Result := "/node/add/" + ct.name
|
||||
Result := "node/add/" + ct.name
|
||||
else
|
||||
Result := "/node/"
|
||||
Result := "node/"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -190,13 +190,13 @@ feature -- URL
|
||||
require
|
||||
a_node.has_id
|
||||
do
|
||||
Result := "/node/" + a_node.id.out
|
||||
Result := "node/" + a_node.id.out
|
||||
end
|
||||
|
||||
nodes_path: STRING
|
||||
-- URI path for list of nodes.
|
||||
do
|
||||
Result := "/nodes"
|
||||
Result := "nodes"
|
||||
end
|
||||
|
||||
feature -- Access: Node
|
||||
|
||||
@@ -9,6 +9,8 @@ deferred class
|
||||
inherit
|
||||
CMS_NODE_TYPE_WEBFORM_MANAGER_I [G]
|
||||
|
||||
SHARED_WSF_PERCENT_ENCODER
|
||||
|
||||
feature -- Forms ...
|
||||
|
||||
populate_form (response: NODE_RESPONSE; f: CMS_FORM; a_node: detachable CMS_NODE)
|
||||
@@ -18,6 +20,7 @@ feature -- Forms ...
|
||||
ta: WSF_FORM_TEXTAREA
|
||||
tselect: WSF_FORM_SELECT
|
||||
opt: WSF_FORM_SELECT_OPTION
|
||||
l_uri: detachable READABLE_STRING_8
|
||||
do
|
||||
create ti.make ("title")
|
||||
ti.set_label ("Title")
|
||||
@@ -66,16 +69,37 @@ feature -- Forms ...
|
||||
|
||||
f.extend (fset)
|
||||
|
||||
-- Path aliase
|
||||
-- Path alias
|
||||
create ti.make ("path_alias")
|
||||
ti.set_label ("Path")
|
||||
ti.set_size (70)
|
||||
if a_node /= Void and then a_node.has_id then
|
||||
if attached a_node.link as lnk then
|
||||
ti.set_text_value (lnk.location)
|
||||
l_uri := lnk.location
|
||||
else
|
||||
ti.set_text_value (response.api.path_alias (response.node_api.node_path (a_node)))
|
||||
l_uri := percent_encoder.percent_decoded_string (response.api.path_alias (response.node_api.node_path (a_node)))
|
||||
end
|
||||
ti.set_text_value (l_uri)
|
||||
ti.set_description ("Optionally specify an alternative URL path by which this content can be accessed. For example, type 'about' when writing an about page. Use a relative path or the URL alias won't work.")
|
||||
ti.set_validation_action (agent (fd: WSF_FORM_DATA; a_response: CMS_RESPONSE)
|
||||
do
|
||||
if
|
||||
attached fd.string_item ("path_alias") as f_path_alias
|
||||
then
|
||||
if a_response.api.is_valid_path_alias (f_path_alias) then
|
||||
-- Ok.
|
||||
elseif f_path_alias.is_empty then
|
||||
-- Ok
|
||||
elseif f_path_alias.starts_with_general ("/") then
|
||||
fd.report_invalid_field ("path_alias", "Path alias should not start with a slash '/' .")
|
||||
elseif f_path_alias.has_substring ("://") then
|
||||
fd.report_invalid_field ("path_alias", "Path alias should not be absolute url .")
|
||||
else
|
||||
-- TODO: implement full path alias validation
|
||||
end
|
||||
end
|
||||
end(?, response)
|
||||
)
|
||||
end
|
||||
if
|
||||
attached f.fields_by_name ("title") as l_title_fields and then
|
||||
@@ -180,7 +204,7 @@ feature -- Output
|
||||
node_api := a_response.node_api
|
||||
|
||||
a_response.add_variable (a_node, "node")
|
||||
create lnk.make (a_response.translation ("View", Void), a_response.node_local_link (a_node).location)
|
||||
lnk := a_response.node_local_link (a_node, a_response.translation ("View", Void))
|
||||
lnk.set_weight (1)
|
||||
a_response.add_to_primary_tabs (lnk)
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ feature {NONE} -- Initialization
|
||||
initialize
|
||||
do
|
||||
Precursor
|
||||
create {WSF_CMS_THEME} wsf_theme.make (Current, theme)
|
||||
create {CMS_TO_WSF_THEME} wsf_theme.make (Current, theme)
|
||||
end
|
||||
|
||||
wsf_theme: WSF_THEME
|
||||
@@ -62,9 +62,9 @@ feature -- Execution
|
||||
fd := f.last_data
|
||||
end
|
||||
if l_node.has_id then
|
||||
add_to_menu (create {CMS_LOCAL_LINK}.make (translation ("View", Void), node_url (l_node)), primary_tabs)
|
||||
add_to_menu (create {CMS_LOCAL_LINK}.make (translation ("Edit", Void), "/node/" + l_node.id.out + "/edit"), primary_tabs)
|
||||
add_to_menu (create {CMS_LOCAL_LINK}.make ("Delete", "/node/" + l_node.id.out + "/delete"), primary_tabs)
|
||||
add_to_menu (node_local_link (l_node, translation ("View", Void)), primary_tabs)
|
||||
add_to_menu (create {CMS_LOCAL_LINK}.make (translation ("Edit", Void), node_api.node_path (l_node) + "/edit"), primary_tabs)
|
||||
add_to_menu (create {CMS_LOCAL_LINK}.make ("Delete", node_api.node_path (l_node) + "/delete"), primary_tabs)
|
||||
end
|
||||
|
||||
if attached redirection as l_location then
|
||||
@@ -86,9 +86,9 @@ feature -- Execution
|
||||
fd := f.last_data
|
||||
end
|
||||
if l_node.has_id then
|
||||
add_to_menu (create {CMS_LOCAL_LINK}.make (translation ("View", Void), node_url (l_node)), primary_tabs)
|
||||
add_to_menu (create {CMS_LOCAL_LINK}.make (translation ("Edit", Void), "/node/" + l_node.id.out + "/edit"), primary_tabs)
|
||||
add_to_menu (create {CMS_LOCAL_LINK}.make ("Delete", "/node/" + l_node.id.out + "/delete"), primary_tabs)
|
||||
add_to_menu (node_local_link (l_node, translation ("View", Void)), primary_tabs)
|
||||
add_to_menu (create {CMS_LOCAL_LINK}.make (translation ("Edit", Void), node_api.node_path (l_node) + "/edit"), primary_tabs)
|
||||
add_to_menu (create {CMS_LOCAL_LINK}.make ("Delete", node_api.node_path (l_node) + "/delete"), primary_tabs)
|
||||
end
|
||||
|
||||
if attached redirection as l_location then
|
||||
@@ -110,8 +110,8 @@ feature -- Execution
|
||||
fd := f.last_data
|
||||
end
|
||||
if l_node.has_id then
|
||||
add_to_menu (create {CMS_LOCAL_LINK}.make (translation ("View", Void), node_url (l_node)), primary_tabs)
|
||||
add_to_menu (create {CMS_LOCAL_LINK}.make ("Trash", "/node/" + l_node.id.out + "/trash"), primary_tabs)
|
||||
add_to_menu (node_local_link (l_node, translation ("View", Void)), primary_tabs)
|
||||
add_to_menu (create {CMS_LOCAL_LINK}.make ("Trash", node_api.node_path (l_node) + "/Trash"), primary_tabs)
|
||||
end
|
||||
|
||||
if attached redirection as l_location then
|
||||
@@ -148,8 +148,8 @@ feature -- Execution
|
||||
set_title ("Edit " + html_encoded (l_type.title) + " #" + l_node.id.out)
|
||||
|
||||
if l_node.has_id then
|
||||
add_to_menu (create {CMS_LOCAL_LINK}.make (translation ("View", Void), node_url (l_node)), primary_tabs)
|
||||
add_to_menu (create {CMS_LOCAL_LINK}.make (translation ("Edit", Void), "/node/" + l_node.id.out + "/edit"), primary_tabs)
|
||||
add_to_menu (node_local_link (l_node, translation ("View", Void)), primary_tabs)
|
||||
add_to_menu (create {CMS_LOCAL_LINK}.make (translation ("Edit", Void), node_api.node_path (l_node) + "/edit"), primary_tabs)
|
||||
end
|
||||
|
||||
f.append_to_html (wsf_theme, b)
|
||||
@@ -173,7 +173,7 @@ feature -- Execution
|
||||
attached ic.item as l_node_type and then
|
||||
has_permissions (<<"create any", "create " + l_node_type.name>>)
|
||||
then
|
||||
b.append ("<li>" + link (l_node_type.name, "/node/add/" + l_node_type.name, Void))
|
||||
b.append ("<li>" + link (l_node_type.name, "node/add/" + l_node_type.name, Void))
|
||||
if attached l_node_type.description as d then
|
||||
b.append ("<div class=%"description%">" + d + "</div>")
|
||||
end
|
||||
@@ -219,6 +219,7 @@ feature -- Form
|
||||
l_preview: BOOLEAN
|
||||
l_node: detachable CMS_NODE
|
||||
s: STRING
|
||||
l_path_alias: detachable READABLE_STRING_8
|
||||
do
|
||||
l_preview := attached {WSF_STRING} fd.item ("op") as l_op and then l_op.same_string ("Preview")
|
||||
if not l_preview then
|
||||
@@ -250,20 +251,29 @@ feature -- Form
|
||||
end
|
||||
node_api.save_node (l_node)
|
||||
if attached current_user (request) as u then
|
||||
api.log ("node", "User %"" + user_html_link (u) + "%" " + s + " node " + link (a_type.name +" #" + l_node.id.out, "/node/" + l_node.id.out , Void), 0, node_local_link (l_node))
|
||||
api.log ("node",
|
||||
"User %"" + user_html_link (u) + "%" " + s + " node " + node_html_link (l_node, a_type.name + " #" + l_node.id.out),
|
||||
0, node_local_link (l_node, Void)
|
||||
)
|
||||
else
|
||||
api.log ("node", "Anonymous " + s + " node " + a_type.name +" #" + l_node.id.out, 0, node_local_link (l_node))
|
||||
api.log ("node", "Anonymous " + s + " node " + a_type.name +" #" + l_node.id.out, 0, node_local_link (l_node, Void))
|
||||
end
|
||||
add_success_message ("Node #" + l_node.id.out + " saved.")
|
||||
|
||||
if attached fd.string_item ("path_alias") as l_path_alias then
|
||||
if
|
||||
attached fd.string_item ("path_alias") as f_path_alias and then
|
||||
not f_path_alias.is_empty
|
||||
then
|
||||
l_path_alias := percent_encoder.partial_encoded_string (f_path_alias, <<'/'>>)
|
||||
-- Path alias, are always from the root of the cms.
|
||||
api.set_path_alias (node_api.node_path (l_node), l_path_alias, False)
|
||||
l_node.set_link (create {CMS_LOCAL_LINK}.make (l_node.title, l_path_alias))
|
||||
else
|
||||
l_node.set_link (node_api.node_link (l_node))
|
||||
end
|
||||
|
||||
set_redirection (node_url (l_node))
|
||||
if attached l_node.link as lnk then
|
||||
set_redirection (lnk.location)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -367,8 +377,6 @@ feature -- Form
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
populate_form (a_content_type: CMS_NODE_TYPE [CMS_NODE]; a_form: WSF_FORM; a_node: detachable CMS_NODE)
|
||||
-- Fill the web form `a_form' with data from `a_node' if set,
|
||||
-- and apply this to content type `a_content_type'.
|
||||
|
||||
@@ -53,30 +53,45 @@ feature -- Helpers
|
||||
|
||||
feature -- Helpers: cms link
|
||||
|
||||
user_local_link (u: CMS_USER): CMS_LOCAL_LINK
|
||||
user_local_link (u: CMS_USER; a_opt_title: detachable READABLE_STRING_GENERAL): CMS_LOCAL_LINK
|
||||
do
|
||||
if a_opt_title /= Void then
|
||||
create Result.make (a_opt_title, user_url (u))
|
||||
else
|
||||
create Result.make (u.name, user_url (u))
|
||||
end
|
||||
end
|
||||
|
||||
node_local_link (n: CMS_NODE): CMS_LOCAL_LINK
|
||||
node_local_link (n: CMS_NODE; a_opt_title: detachable READABLE_STRING_GENERAL): CMS_LOCAL_LINK
|
||||
do
|
||||
if attached n.link as lnk then
|
||||
Result := lnk
|
||||
else
|
||||
Result := node_api.node_link (n)
|
||||
end
|
||||
if a_opt_title /= Void and then not Result.title.same_string_general (a_opt_title) then
|
||||
create Result.make (a_opt_title, Result.location)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Helpers: html link
|
||||
|
||||
user_html_link (u: CMS_USER): like link
|
||||
do
|
||||
Result := link (u.name, "/user/" + u.id.out, Void)
|
||||
Result := link (u.name, "user/" + u.id.out, Void)
|
||||
end
|
||||
|
||||
node_html_link (n: CMS_NODE): like link
|
||||
node_html_link (n: CMS_NODE; a_opt_title: detachable READABLE_STRING_GENERAL): like link
|
||||
local
|
||||
l_title: detachable READABLE_STRING_GENERAL
|
||||
do
|
||||
Result := link (n.title, "/node/" + n.id.out, Void)
|
||||
if a_opt_title /= Void then
|
||||
l_title := a_opt_title
|
||||
else
|
||||
l_title := n.title
|
||||
end
|
||||
Result := link (l_title, node_api.node_path (n), Void)
|
||||
|
||||
end
|
||||
|
||||
feature -- Helpers: URL
|
||||
@@ -85,7 +100,7 @@ feature -- Helpers: URL
|
||||
require
|
||||
u_with_id: u.has_id
|
||||
do
|
||||
Result := url ("/user/" + u.id.out, Void)
|
||||
Result := url ("user/" + u.id.out, Void)
|
||||
end
|
||||
|
||||
node_url (n: CMS_NODE): like url
|
||||
|
||||
@@ -27,7 +27,7 @@ feature {NONE} -- Initialization
|
||||
initialize
|
||||
do
|
||||
Precursor
|
||||
create {WSF_CMS_THEME} wsf_theme.make (Current, theme)
|
||||
create {CMS_TO_WSF_THEME} wsf_theme.make (Current, theme)
|
||||
end
|
||||
|
||||
wsf_theme: WSF_THEME
|
||||
|
||||
@@ -183,13 +183,13 @@ feature -- Hooks
|
||||
lnk: CMS_LOCAL_LINK
|
||||
-- perms: detachable ARRAYED_LIST [READABLE_STRING_8]
|
||||
do
|
||||
create lnk.make ("List of nodes", a_response.url ("/nodes", Void))
|
||||
create lnk.make ("List of nodes", "nodes")
|
||||
a_menu_system.primary_menu.extend (lnk)
|
||||
|
||||
create lnk.make ("Trash nodes", a_response.url ("/trash", Void))
|
||||
create lnk.make ("Trash", a_response.url ("trash", Void))
|
||||
a_menu_system.primary_menu.extend (lnk)
|
||||
|
||||
create lnk.make ("Create ..", a_response.url ("/node/", Void))
|
||||
create lnk.make ("Create ..", a_response.url ("node/", Void))
|
||||
a_menu_system.primary_menu.extend (lnk)
|
||||
end
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
note
|
||||
description: "[
|
||||
Objects that ...
|
||||
CMS Storage for core functionalities.
|
||||
]"
|
||||
author: "$Author$"
|
||||
date: "$Date$"
|
||||
|
||||
@@ -234,9 +234,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
|
||||
@@ -281,8 +288,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
|
||||
|
||||
@@ -19,15 +19,17 @@ 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.")
|
||||
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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,27 @@ feature {NONE} -- Initialization
|
||||
register_hooks
|
||||
end
|
||||
|
||||
initialize_site_url
|
||||
-- Initialize site and base url.
|
||||
local
|
||||
l_url: detachable READABLE_STRING_8
|
||||
i,j: INTEGER
|
||||
do
|
||||
--| WARNING: do not use `absolute_url' and `url', since it relies on site_url and base_url.
|
||||
l_url := setup.site_url
|
||||
if l_url = Void then
|
||||
l_url := request.absolute_script_url ("/")
|
||||
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
|
||||
end
|
||||
|
||||
register_hooks
|
||||
local
|
||||
l_module: CMS_MODULE
|
||||
@@ -164,15 +186,12 @@ feature -- URL utilities
|
||||
end
|
||||
|
||||
site_url: READABLE_STRING_8
|
||||
do
|
||||
Result := absolute_host (request, "")
|
||||
end
|
||||
-- Absolute site url.
|
||||
|
||||
base_url: detachable READABLE_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 +202,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 +825,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 +853,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 +939,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")
|
||||
@@ -1102,8 +1121,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
|
||||
|
||||
@@ -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: READABLE_STRING_8 assign set_site_url
|
||||
-- Absolute URL for Current CMS site.
|
||||
|
||||
base_url: detachable READABLE_STRING_8
|
||||
-- Optional base url of current CMS site.
|
||||
|
||||
feature -- Access
|
||||
|
||||
name: STRING
|
||||
@@ -41,6 +49,30 @@ 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
|
||||
site_url := a_url
|
||||
else
|
||||
site_url := a_url + "/"
|
||||
end
|
||||
i := a_url.substring_index ("://", 1)
|
||||
if i > 0 then
|
||||
j := a_url.index_of ('/', i + 3)
|
||||
if j > 0 then
|
||||
base_url := 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 +165,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
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
note
|
||||
description: "Summary description for {WSF_CMS_THEME}."
|
||||
description: "Theme from the EWF framework, but dedicated for the CMS."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_CMS_THEME
|
||||
CMS_TO_WSF_THEME
|
||||
|
||||
inherit
|
||||
WSF_THEME
|
||||
@@ -25,13 +25,14 @@ feature -- Access
|
||||
|
||||
request: WSF_REQUEST
|
||||
|
||||
response: detachable CMS_RESPONSE
|
||||
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
|
||||
@@ -39,20 +40,15 @@ feature -- Element change
|
||||
feature -- Core
|
||||
|
||||
site_url: READABLE_STRING_8
|
||||
-- CMS site url.
|
||||
do
|
||||
if attached response as r then
|
||||
Result := r.site_url
|
||||
else
|
||||
Result := request.absolute_script_url ("")
|
||||
end
|
||||
Result := response.site_url
|
||||
end
|
||||
|
||||
base_url: detachable READABLE_STRING_8
|
||||
-- Base url if any.
|
||||
do
|
||||
if attached response as r then
|
||||
Result := r.base_url
|
||||
end
|
||||
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
|
||||
Reference in New Issue
Block a user