Implemented feed aggregation filtering based on categories.
This commit is contained in:
@@ -45,6 +45,15 @@ feature -- Access
|
||||
description_enabled: BOOLEAN
|
||||
-- Display description?
|
||||
|
||||
feature -- Status report
|
||||
|
||||
has_category_filter: BOOLEAN
|
||||
-- Is there any category filtering?
|
||||
-- i.e via `included_categories'
|
||||
do
|
||||
Result := attached included_categories as cats and then not cats.is_empty
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_description (a_desc: detachable READABLE_STRING_GENERAL)
|
||||
@@ -99,6 +108,10 @@ feature -- Element change
|
||||
feature -- Status report
|
||||
|
||||
is_included (e: FEED_ITEM): BOOLEAN
|
||||
-- Is `e' included in final aggregation?
|
||||
-- i.e: related to `included_categories'
|
||||
-- note that if `e' has no category, it is included by default,
|
||||
-- even if `included_categories' is defined.
|
||||
do
|
||||
Result := True
|
||||
if attached e.categories as e_cats then
|
||||
|
||||
@@ -113,16 +113,11 @@ feature -- Operation
|
||||
|
||||
aggregation_feed (agg: FEED_AGGREGATION): detachable FEED
|
||||
-- Feed from aggregation `agg'.
|
||||
local
|
||||
fac: FEED_DEFAULT_PARSERS
|
||||
f: detachable FEED
|
||||
do
|
||||
create fac
|
||||
across
|
||||
agg.locations as ic
|
||||
loop
|
||||
if attached new_http_client_session (ic.item).get ("", Void).body as res then
|
||||
f := fac.feed_from_string (res)
|
||||
if attached feed (ic.item) as f then
|
||||
if Result /= Void then
|
||||
if f /= Void then
|
||||
Result := Result + f
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
note
|
||||
description: "CMS module bringing support for feed aggregation."
|
||||
date: "$Date: 2015-02-13 13:08:13 +0100 (ven., 13 févr. 2015) $"
|
||||
revision: "$Revision: 96616 $"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
FEED_AGGREGATOR_MODULE
|
||||
@@ -280,6 +280,19 @@ feature -- Hook
|
||||
vis.set_footer (s)
|
||||
|
||||
if attached l_feed_api.aggregation_feed (l_agg) as l_feed then
|
||||
if l_agg.has_category_filter and attached l_feed.items as lst then
|
||||
from
|
||||
lst.start
|
||||
until
|
||||
lst.after
|
||||
loop
|
||||
if not l_agg.is_included (lst.item_for_iteration) then
|
||||
lst.remove
|
||||
else
|
||||
lst.forth
|
||||
end
|
||||
end
|
||||
end
|
||||
l_feed.accept (vis)
|
||||
end
|
||||
l_cache.put (Result)
|
||||
|
||||
Reference in New Issue
Block a user