diff --git a/modules/feed_aggregator/feed_aggregation.e b/modules/feed_aggregator/feed_aggregation.e index 52500c6..439a96f 100644 --- a/modules/feed_aggregator/feed_aggregation.e +++ b/modules/feed_aggregator/feed_aggregation.e @@ -40,7 +40,11 @@ feature -- Access included_categories: detachable LIST [READABLE_STRING_32] -- Optional categories to filter. - -- If Void, include any. + -- If Void, include any, or consider the `included_categories_per_feed'. + + included_categories_per_feed: detachable STRING_TABLE [detachable LIST [READABLE_STRING_32]] + -- Optional categories to filter per feed location.. + -- If Void, include any or consider the `included_categories'. description_enabled: BOOLEAN -- Display description? @@ -54,6 +58,14 @@ feature -- Status report Result := attached included_categories as cats and then not cats.is_empty end + has_category_filter_for_location (a_location: READABLE_STRING_GENERAL): BOOLEAN + -- Is there any category filtering for `a_location'? + do + Result := attached included_categories_per_feed as cats_per_location and then + attached cats_per_location.item (a_location) as cats and then + not cats.is_empty + end + feature -- Element change set_description (a_desc: detachable READABLE_STRING_GENERAL) @@ -86,6 +98,7 @@ feature -- Element change reset_categories do included_categories := Void + included_categories_per_feed := Void end include_category (a_cat: READABLE_STRING_GENERAL) @@ -105,6 +118,29 @@ feature -- Element change end end + include_category_per_feed (a_cat: READABLE_STRING_GENERAL; a_feed_location: READABLE_STRING_8) + local + tb: like included_categories_per_feed + lst: like included_categories + s32: STRING_32 + do + tb := included_categories_per_feed + if tb = Void then + create tb.make_caseless (1) + included_categories_per_feed := tb + end + lst := tb.item (a_feed_location) + if lst = Void then + create {ARRAYED_LIST [READABLE_STRING_32]} lst.make (1) + lst.compare_objects + tb.force (lst, a_feed_location) + end + s32 := a_cat.to_string_32 + if not lst.has (s32) then + lst.force (s32) + end + end + feature -- Status report is_included (e: FEED_ITEM): BOOLEAN @@ -125,4 +161,24 @@ feature -- Status report end end + is_included_for_location (e: FEED_ITEM; a_location: READABLE_STRING_GENERAL): BOOLEAN + -- Is `e' included in feed related to `a_location'? + -- note that if `e' has no category, it is included by default, + -- even if `included_categories_per_feed' is defined for `a_location'. + do + Result := True + if attached e.categories as e_cats then + if + attached included_categories_per_feed as tb and then + attached tb.item (a_location) as lst + then + Result := across lst as ic some + across e_cats as e_ic some + e_ic.item.same_string (ic.item) + end + end + end + end + end + end