Fixed implementation of path alias settings.

Now report an error if path is already aliased to another location.
This commit is contained in:
2015-07-07 17:20:25 +02:00
parent 37729f648a
commit 4c8af3ef66
5 changed files with 28 additions and 2 deletions

View File

@@ -76,3 +76,9 @@ ul.horizontal li {
border-width: 2px 1px 0; border-width: 2px 1px 0;
padding: 2px 7px 1px; padding: 2px 7px 1px;
} }
#message li.error {
background-color: #f99;
border: solid 1px red;
padding: 5px 2px 5px 2px;
}

View File

@@ -81,3 +81,8 @@ ul.horizontal {
} }
} }
} }
#message li.error {
background-color: #f99;
border: solid 1px red;
padding: 5px 2px 5px 2px;
}

View File

@@ -182,7 +182,7 @@ feature -- URL
require require
a_node.has_id a_node.has_id
do 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 end
node_path (a_node: CMS_NODE): STRING node_path (a_node: CMS_NODE): STRING

View File

@@ -102,7 +102,7 @@ feature -- Forms ...
if attached a_node.link as lnk then if attached a_node.link as lnk then
l_uri := lnk.location l_uri := lnk.location
else 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 end
ti.set_text_value (l_uri) 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_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 else
-- TODO: implement full path alias validation -- TODO: implement full path alias validation
end 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
end(?, response) end(?, response)
) )

View File

@@ -305,6 +305,18 @@ feature -- Path aliases
storage.unset_path_alias (a_source, a_alias) storage.unset_path_alias (a_source, a_alias)
end 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 (a_source: READABLE_STRING_8): READABLE_STRING_8
-- Path alias associated with `a_source' or the source itself. -- Path alias associated with `a_source' or the source itself.
do do