Fixed implementation of path alias settings.
Now report an error if path is already aliased to another location.
This commit is contained in:
@@ -76,3 +76,9 @@ ul.horizontal li {
|
||||
border-width: 2px 1px 0;
|
||||
padding: 2px 7px 1px;
|
||||
}
|
||||
|
||||
#message li.error {
|
||||
background-color: #f99;
|
||||
border: solid 1px red;
|
||||
padding: 5px 2px 5px 2px;
|
||||
}
|
||||
|
||||
@@ -81,3 +81,8 @@ ul.horizontal {
|
||||
}
|
||||
}
|
||||
}
|
||||
#message li.error {
|
||||
background-color: #f99;
|
||||
border: solid 1px red;
|
||||
padding: 5px 2px 5px 2px;
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ feature -- URL
|
||||
require
|
||||
a_node.has_id
|
||||
do
|
||||
create Result.make (a_node.title, cms_api.path_alias (node_path (a_node)))
|
||||
create Result.make (a_node.title, cms_api.location_alias (node_path (a_node)))
|
||||
end
|
||||
|
||||
node_path (a_node: CMS_NODE): STRING
|
||||
|
||||
@@ -102,7 +102,7 @@ feature -- Forms ...
|
||||
if attached a_node.link as lnk then
|
||||
l_uri := lnk.location
|
||||
else
|
||||
l_uri := percent_encoder.percent_decoded_string (response.api.path_alias (response.node_api.node_path (a_node)))
|
||||
l_uri := percent_encoder.percent_decoded_string (response.api.location_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.")
|
||||
@@ -122,6 +122,9 @@ feature -- Forms ...
|
||||
else
|
||||
-- TODO: implement full path alias validation
|
||||
end
|
||||
if attached a_response.api.location_alias (f_path_alias) as l_aliased_location then
|
||||
fd.report_invalid_field ("path_alias", "Path is already aliazed to location %"" + l_aliased_location + "%" !")
|
||||
end
|
||||
end
|
||||
end(?, response)
|
||||
)
|
||||
|
||||
@@ -305,6 +305,18 @@ feature -- Path aliases
|
||||
storage.unset_path_alias (a_source, a_alias)
|
||||
end
|
||||
|
||||
location_alias (a_source: READABLE_STRING_8): READABLE_STRING_8
|
||||
-- Location alias associated with `a_source' or the source itself.
|
||||
do
|
||||
Result := a_source
|
||||
if attached storage.path_alias (Result) as l_path then
|
||||
Result := l_path
|
||||
if Result.starts_with ("/") then
|
||||
Result := Result.substring (2, Result.count)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
path_alias (a_source: READABLE_STRING_8): READABLE_STRING_8
|
||||
-- Path alias associated with `a_source' or the source itself.
|
||||
do
|
||||
|
||||
Reference in New Issue
Block a user