Added default path alias for node.
Fixed set path alias, when alias already exists in the history.
This commit is contained in:
@@ -367,6 +367,85 @@ feature -- Change: Node
|
||||
error_handler.append (node_storage.error_handler)
|
||||
end
|
||||
|
||||
feature -- path_alias suggestion
|
||||
|
||||
path_alias_uri_suggestion (a_node: detachable CMS_NODE; a_content_type: CMS_CONTENT_TYPE): STRING
|
||||
local
|
||||
dt: DATE_TIME
|
||||
uri: URI
|
||||
do
|
||||
create uri.make_from_string ("/")
|
||||
uri.add_unencoded_path_segment (a_content_type.name)
|
||||
if a_node /= Void then
|
||||
dt := a_node.creation_date
|
||||
else
|
||||
create dt.make_now_utc
|
||||
end
|
||||
if attached cms_api.user as u and then not cms_api.user_api.is_admin_user (u) then
|
||||
uri.add_unencoded_path_segment (cms_api.user_api.user_display_name (u))
|
||||
end
|
||||
uri.add_unencoded_path_segment (dt.year.out)
|
||||
if dt.month <= 9 then
|
||||
uri.add_unencoded_path_segment ("0" + dt.month.out)
|
||||
else
|
||||
uri.add_unencoded_path_segment (dt.month.out)
|
||||
end
|
||||
if a_node /= Void and then attached a_node.title as l_title then
|
||||
uri.add_unencoded_path_segment (safe_path_alias_uri_segment_text (l_title))
|
||||
else
|
||||
uri.add_unencoded_path_segment ("")
|
||||
end
|
||||
|
||||
Result := uri.string
|
||||
end
|
||||
|
||||
safe_path_alias_uri_segment_text (s: READABLE_STRING_GENERAL): STRING_32
|
||||
local
|
||||
i,n: INTEGER
|
||||
c, prev: CHARACTER_32
|
||||
l_words: ITERABLE [READABLE_STRING_GENERAL]
|
||||
w: STRING_32
|
||||
do
|
||||
l_words := << "a", "an", "as", "at", "before", "but", "by", "for", "from", "is", "in", "into", "like", "of", "off", "on", "onto", "per", "since", "than", "the", "this", "that", "to", "up", "via", "with" >>
|
||||
from
|
||||
i := 1
|
||||
n := s.count
|
||||
create Result.make (n)
|
||||
create w.make_empty
|
||||
until
|
||||
i > n
|
||||
loop
|
||||
c := s[i].as_lower
|
||||
if c.is_alpha_numeric then
|
||||
w.append_character (c)
|
||||
prev := c
|
||||
else
|
||||
if w.is_empty then
|
||||
-- Ignore
|
||||
else
|
||||
if across l_words as ic some w.same_string_general (ic.item) end then
|
||||
-- Ignore
|
||||
w.wipe_out
|
||||
else
|
||||
if not Result.is_empty then
|
||||
Result.append_character ('-')
|
||||
end
|
||||
Result.append (w)
|
||||
w.wipe_out
|
||||
end
|
||||
end
|
||||
end
|
||||
i := i + 1
|
||||
end
|
||||
if not w.is_empty then
|
||||
if not Result.is_empty then
|
||||
Result.append_character ('-')
|
||||
end
|
||||
Result.append (w)
|
||||
w.wipe_out
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Node status
|
||||
|
||||
Not_published: INTEGER = 0
|
||||
|
||||
Reference in New Issue
Block a user