Skip to content

Commit f47da8f

Browse files
committed
Add seach rule to find items from a given author
Add a new filter rule to filter feed items by author. "Author" is definedin a broad sense, as it would look for the user, and the rule matches both elements "author" (from RSS2 and Atom) and "creator" (from DC namespace).
1 parent 49174d5 commit f47da8f

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

doc/html/searching_en.html

+12
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,18 @@ <h4>Permanent Searches with Search Folders</h4>
9393
</td></tr>
9494
<!-- ----------------------------------------- -->
9595
<tr><td style="background:#bfb">
96+
<b>Item author does contain</b>
97+
</td><td>
98+
<b>Adds</b> each item whose item author (or creator, acording to the feed) matches the given case insensitive string to the search folder.
99+
</td></tr>
100+
<!-- ----------------------------------------- -->
101+
<tr><td style="background:#fbb">
102+
<b>Item title does not contain</b>
103+
</td><td>
104+
<b>Removes</b> each item whose item author (or creator, acording to the feed) matches the given case insensitive string from the search folder.
105+
</td></tr>
106+
<!-- ----------------------------------------- -->
107+
<tr><td style="background:#bfb">
96108
<b>Item body does contain</b>
97109
</td><td>
98110
<b>Adds</b> each item whose item content matches the given case insensitive string to the search folder.

src/rule.c

+26
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#define ITEM_MATCH_RULE_ID "exact"
3131
#define ITEM_TITLE_MATCH_RULE_ID "exact_title"
3232
#define ITEM_DESC_MATCH_RULE_ID "exact_desc"
33+
#define ITEM_AUTHOR_MATCH_RULE_ID "exact_author"
3334
#define FEED_TITLE_MATCH_RULE_ID "feed_title"
3435
#define FEED_SOURCE_MATCH_RULE_ID "feed_source"
3536
#define PARENT_FOLDER_MATCH_RULE_ID "parent_folder"
@@ -199,6 +200,30 @@ rule_check_item_category (rulePtr rule, itemPtr item)
199200
return FALSE;
200201
}
201202

203+
static gboolean
204+
rule_check_item_author (rulePtr rule, itemPtr item)
205+
{
206+
GSList *iter;
207+
208+
iter = metadata_list_get_values (item->metadata, "author");
209+
while (iter) {
210+
if (rule_strcasecmp ((gchar *)iter->data, rule->valueCaseFolded)) {
211+
return TRUE;
212+
}
213+
iter = g_slist_next (iter);
214+
}
215+
216+
iter = metadata_list_get_values (item->metadata, "creator");
217+
while (iter) {
218+
if (rule_strcasecmp ((gchar *)iter->data, rule->valueCaseFolded)) {
219+
return TRUE;
220+
}
221+
iter = g_slist_next (iter);
222+
}
223+
return FALSE;
224+
}
225+
226+
202227
static gboolean
203228
rule_check_feed_title (rulePtr rule, itemPtr item)
204229
{
@@ -265,6 +290,7 @@ rule_init (void)
265290
rule_info_add (rule_check_item_all, ITEM_MATCH_RULE_ID, _("Item"), _("does contain"), _("does not contain"), TRUE);
266291
rule_info_add (rule_check_item_title, ITEM_TITLE_MATCH_RULE_ID, _("Item title"), _("does contain"), _("does not contain"), TRUE);
267292
rule_info_add (rule_check_item_description, ITEM_DESC_MATCH_RULE_ID, _("Item body"), _("does contain"), _("does not contain"), TRUE);
293+
rule_info_add (rule_check_item_author, ITEM_AUTHOR_MATCH_RULE_ID, _("Item author"), _("does contain"), _("does not contain"), TRUE);
268294
rule_info_add (rule_check_item_is_unread, "unread", _("Read status"), _("is unread"), _("is read"), FALSE);
269295
rule_info_add (rule_check_item_is_flagged, "flagged", _("Flag status"), _("is flagged"), _("is unflagged"), FALSE);
270296
rule_info_add (rule_check_item_has_enc, "enclosure", _("Enclosure"), _("included"), _("not included"), FALSE);

0 commit comments

Comments
 (0)