Implemented feed aggregation filtering based on categories.
This commit is contained in:
@@ -45,6 +45,15 @@ feature -- Access
|
|||||||
description_enabled: BOOLEAN
|
description_enabled: BOOLEAN
|
||||||
-- Display description?
|
-- 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
|
feature -- Element change
|
||||||
|
|
||||||
set_description (a_desc: detachable READABLE_STRING_GENERAL)
|
set_description (a_desc: detachable READABLE_STRING_GENERAL)
|
||||||
@@ -99,6 +108,10 @@ feature -- Element change
|
|||||||
feature -- Status report
|
feature -- Status report
|
||||||
|
|
||||||
is_included (e: FEED_ITEM): BOOLEAN
|
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
|
do
|
||||||
Result := True
|
Result := True
|
||||||
if attached e.categories as e_cats then
|
if attached e.categories as e_cats then
|
||||||
|
|||||||
@@ -113,16 +113,11 @@ feature -- Operation
|
|||||||
|
|
||||||
aggregation_feed (agg: FEED_AGGREGATION): detachable FEED
|
aggregation_feed (agg: FEED_AGGREGATION): detachable FEED
|
||||||
-- Feed from aggregation `agg'.
|
-- Feed from aggregation `agg'.
|
||||||
local
|
|
||||||
fac: FEED_DEFAULT_PARSERS
|
|
||||||
f: detachable FEED
|
|
||||||
do
|
do
|
||||||
create fac
|
|
||||||
across
|
across
|
||||||
agg.locations as ic
|
agg.locations as ic
|
||||||
loop
|
loop
|
||||||
if attached new_http_client_session (ic.item).get ("", Void).body as res then
|
if attached feed (ic.item) as f then
|
||||||
f := fac.feed_from_string (res)
|
|
||||||
if Result /= Void then
|
if Result /= Void then
|
||||||
if f /= Void then
|
if f /= Void then
|
||||||
Result := Result + f
|
Result := Result + f
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
note
|
note
|
||||||
description: "CMS module bringing support for feed aggregation."
|
description: "CMS module bringing support for feed aggregation."
|
||||||
date: "$Date: 2015-02-13 13:08:13 +0100 (ven., 13 févr. 2015) $"
|
date: "$Date$"
|
||||||
revision: "$Revision: 96616 $"
|
revision: "$Revision$"
|
||||||
|
|
||||||
class
|
class
|
||||||
FEED_AGGREGATOR_MODULE
|
FEED_AGGREGATOR_MODULE
|
||||||
@@ -280,6 +280,19 @@ feature -- Hook
|
|||||||
vis.set_footer (s)
|
vis.set_footer (s)
|
||||||
|
|
||||||
if attached l_feed_api.aggregation_feed (l_agg) as l_feed then
|
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)
|
l_feed.accept (vis)
|
||||||
end
|
end
|
||||||
l_cache.put (Result)
|
l_cache.put (Result)
|
||||||
|
|||||||
Reference in New Issue
Block a user