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:
@@ -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
|
||||
|
||||
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