laserchicken icon indicating copy to clipboard operation
laserchicken copied to clipboard

Entry filters

Open tilboerner opened this issue 12 years ago • 5 comments
trafficstars

Some feeds regularly contain entries that are not very interesting. There should be per-feed filters for entries whose text matches a certain regex. Matches are automatically marked as read and also get a filtered (or filtered-by) attribute set.

Use case from the Github Blog: /is a GitHubber!/, /(?<!Berlin )Drinkup/.

tilboerner avatar Jul 10 '13 10:07 tilboerner

It's nice to have regex, but also more simple filters like: containsAny('foo','bar','baz') or containsAll('bambie','is','dead') would probably be more than enough. Because those filters suck to create using regexes

Or even a little more OO: title.containsAny('foo','bar','baz') and body.containsAll('bambie','is','dead')

devsnd avatar Jul 11 '13 10:07 devsnd

Right, filters like these should also make for better usablility.

That raises the problem of filter UI, though. Any ideas? I'm not too big a fan of radio buttons and comboboxes like

Filter: 
    select[ entry | title | body | ... ] select[has all | has any | startswith | ... ] textfield[   ]

I'd hate using those. How about a mini-Domain Specific Language (if you can call it that) with keywords

  • title,
  • body,
  • and (implied),
  • or,
  • (...),
  • [starts|ends]with(...)?

I'd still like to have regexes, though, because I really want that negative lookbehind assertion there. You never know. :beers:

tilboerner avatar Jul 11 '13 21:07 tilboerner

    filter = ε | expr

    expr = wordlist | op | scope
    wordlist = word (word)*
    word = WORDCHARS+ - <keywords> | '"' MORECHARS+ '"'

    op = and_op | or_op | not_op
    and_op = expr AND expr
    or_op = expr OR expr
    not_op = NOT expr

    scope = blank_scope | named_scope
    blank_scope = "(" expr ")"
    named_scope = [location "."] predicate blank_scope
    location = ENTRY | TITLE | BODY | TEXT
    predicate = CONTAINS | IS | (STARTS|ENDS) WITH

    // whitespace separates tokens but counts as empty
    // syntax errors: treat expression as plaintext or something ><'

Muhahaha! :japanese_ogre: :neckbeard: :heart_eyes_cat:

tilboerner avatar Jul 11 '13 22:07 tilboerner

NO PLEASE MAX! I'M SORRY, I DIDN'T MEAN TO! :gun:

Please don't invent YADSL. Can't you just go with a subset of Ruby commands? In python there's a module called ast, which parses python code for you and gives you the abstract tree syntax. This makes it very easy to restrict the language. There must be an equivalent in ruby.

devsnd avatar Jul 12 '13 10:07 devsnd

Hehehe. Yeah, after writing out that pseudo-grammar I didn't seriously consider doing that anymore. It's the nucular option! :bomb:

Using the Ruby parser like you suggest is a very interesting idea. For later reference, here's a link to look into: http://www.igvita.com/2008/12/11/ruby-ast-for-fun-and-profit/ .

tilboerner avatar Jul 12 '13 10:07 tilboerner