Added FEED + FEED operator to merge two feeds.
Added FEED sorting routine. Added FEED_ITEM.link: detachable FEED_LINK that represents the main feed link. Comments.
This commit is contained in:
@@ -88,12 +88,47 @@ feature -- Element change
|
||||
end
|
||||
end
|
||||
|
||||
add_item (a_item: FEED_ITEM)
|
||||
extend (a_item: FEED_ITEM)
|
||||
-- Add item `a_item' to feed `items'.
|
||||
do
|
||||
items.force (a_item)
|
||||
end
|
||||
|
||||
extended alias "+" (a_feed: FEED): FEED
|
||||
-- New feed object made from Current merged with a_feed.
|
||||
local
|
||||
l_title: STRING_32
|
||||
do
|
||||
create l_title.make (title.count + a_feed.title.count)
|
||||
l_title.append_character ('(')
|
||||
l_title.append (title)
|
||||
l_title.append_character (')')
|
||||
l_title.append_character ('+')
|
||||
l_title.append_character ('(')
|
||||
l_title.append (a_feed.title)
|
||||
l_title.append_character (')')
|
||||
create Result.make (l_title)
|
||||
Result.items.append (items)
|
||||
across
|
||||
a_feed.items as ic
|
||||
loop
|
||||
-- FIXME jfiat [2015/10/07] : check there is no duplication! (same id, or link, ...)
|
||||
Result.extend (ic.item)
|
||||
end
|
||||
Result.sort
|
||||
end
|
||||
|
||||
sort
|
||||
-- Sort `items', (recent first).
|
||||
local
|
||||
s: QUICK_SORTER [FEED_ITEM]
|
||||
comp: COMPARABLE_COMPARATOR [FEED_ITEM]
|
||||
do
|
||||
create comp
|
||||
create s.make (comp)
|
||||
s.reverse_sort (items)
|
||||
end
|
||||
|
||||
feature -- Visitor
|
||||
|
||||
accept (vis: FEED_VISITOR)
|
||||
|
||||
@@ -61,6 +61,21 @@ feature -- Access
|
||||
date: detachable DATE_TIME
|
||||
-- Publishing date.
|
||||
|
||||
link: detachable FEED_LINK
|
||||
-- Main link for the entry, if any.
|
||||
do
|
||||
if attached links as l_links then
|
||||
Result := l_links.item ("")
|
||||
across
|
||||
l_links as ic
|
||||
until
|
||||
Result /= Void
|
||||
loop
|
||||
Result := ic.item
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
links: STRING_TABLE [FEED_LINK]
|
||||
-- Url indexed by relation
|
||||
|
||||
|
||||
Reference in New Issue
Block a user