tilboerner / laserchicken

RSS reader web application built on Rails
MIT License
20 stars 3 forks source link

Entry filters #6

Open tilboerner opened 11 years ago

tilboerner commented 11 years ago

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/.

devsnd commented 11 years ago

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')

tilboerner commented 11 years ago

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

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

tilboerner commented 11 years ago
    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:

devsnd commented 11 years ago

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.

tilboerner commented 11 years ago

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/ .