Patch: more control over filtering
Chris Dolan
chris at chrisdolan.net
Wed Apr 19 23:54:02 EST 2006
[Note: I originally posted this patch to the list in January, but
looking at the archives, it appears to have been lost. Spam filter
error perhaps?]
Currently, planet allows positive or negative regex matches on the
title and content fields via the "filter" and "exclude" directives.
Attached is a patch (against jdub at perkypants.org--projects/planet--
devel--1.0--patch-20) that offers more control over the fields you
can filter on. For example, I'd like to say:
filter = language =~ /^en/
author =~ /Chris/
exclude = title =~ /foo/
any =~ /spam/
The syntax allows line continuations to permit more than one filter.
Note that the "=~" and the "/" delimeters trigger the new syntax. If
they aren't found, then the old syntax is assumed (that is, the whole
value is a regexp that applies to content and title). The possible
keywords are any of the properties of the NewsItem class, namely: any
(which means just title+content right now), title, link, summary,
content, author, category, etc.
The complete syntax is:
keyword := [a-z]+
pattern := *
match := keyword \s* =~ \s* /pattern/ | pattern
filter := match ( \n \s* match )*
Chris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: filter.patch
Type: application/octet-stream
Size: 5443 bytes
Desc: not available
Url : http://lists.waugh.id.au/archives/devel/attachments/20060419/a58586a4/filter.obj
-------------- next part --------------
P.S. the NewsItem class currently does not support the "language"
property, which is used in the example above. This appears to be an
oversight. If it existed, I would use it to filter multi-lingual
blog feeds to show just the posts that I can read. I'd be thrilled
if someone else would improve NewsItem to support <dc:language> tags
in <item> entries, as shown in this example RSS: http://glazman.org/
weblog/dotclear/rss.php
--
Chris Dolan, Software Developer, http://www.chrisdolan.net/
Public key: http://www.chrisdolan.net/public.key
vCard: http://www.chrisdolan.net/ChrisDolan.vcf
Planet: http://www.chrisdolan.net/planet/
Arch repository: chris at chrisdolan.net--2004
Arch mirror: http://www.chrisdolan.net/arch/
--
devel mailing list
devel at lists.planetplanet.org
http://lists.planetplanet.org/mailman/listinfo/devel
More information about the devel
mailing list