Skip to content

feat: Global Block & Keep filters #2677

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Jul 3, 2024

Conversation

privatmamtora
Copy link
Contributor

@privatmamtora privatmamtora commented Jun 4, 2024

Do you follow the guidelines?

Added new feature to enable Global Keep & Block Rules.
Advantages

  • Users can keep and maintain a single set of rules that would apply to all feeds.
  • Rules are strict to a specific field name specified and doesn't require the user to figure out if there are conflicts.
  • Rules can be kept simple if user is having a difficulty managing their rules

Format: FieldName(RegEx)~FieldName(RegEx)~...

FieldName options: Title, URL, CommentsURL, Content, Author, Tags

Addresses: #1326 , #1654 , #1953 , #2583 (maybe)

@privatmamtora privatmamtora changed the title New Feature: Global Block & Keep filters feat: Global Block & Keep filters Jun 4, 2024
@fguillot
Copy link
Member

Format: FieldName(RegEx)~FieldName(RegEx)~...

FieldName options: Title, URL, CommentsURL, Content, Author, Tags

From a user perspective, I'm wondering if ~ is the right choice for rule separator. Would not be better to have one rule per line in a textarea?

The syntax could be simplified:

EntryURL=(?i)example
Title=(?i)Test

instead of

URL((?i)example)~Title((?i)Test)

I would make the field names explicit to avoid possible confusions: URL -> EntryURL.

@privatmamtora
Copy link
Contributor Author

Ok will make the following changes:

  1. Use a text area, 1 rule per-line
    a. Eliminates the ~ separator
    b. Makes it easier to modify and review rules
  2. Use = to separate FieldName and rules
  3. I'll change the field names to the following:
    • EntryTitle
    • EntryURL
    • EntryCommentsURL
    • EntryContent
    • EntryAuthor
    • EntryTag

@privatmamtora
Copy link
Contributor Author

privatmamtora commented Jun 19, 2024

Completed making the changes @fguillot

Copy link
Member

@fguillot fguillot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would trim the trailing line feeds and empty lines when fetching the form values. Otherwise, the end-user might get this validation error:

Invalid Block rule: rule #2 is missing a valid field name (Options: 'EntryTitle', 'EntryURL', 'EntryCommentsURL', 'EntryContent', 'EntryAuthor', 'EntryTag')

@privatmamtora
Copy link
Contributor Author

privatmamtora commented Jun 29, 2024

I would trim the trailing line feeds and empty lines when fetching the form values. Otherwise, the end-user might get this validation error:

Invalid Block rule: rule #2 is missing a valid field name (Options: 'EntryTitle', 'EntryURL', 'EntryCommentsURL', 'EntryContent', 'EntryAuthor', 'EntryTag')

Actually that was the intention, no blank lines allowed. Allows for easily referring to a specific rule# (rule #2 = line number #2)

I guess removing the last line feeds can make it a little more user friendly, excuse any remaining trailing lines

@fguillot Any suggestions on how to remove only blank lines from the end of the textarea string.
If the last line with a rule ends in spaces, that space must be kept as it could be part of the regex rule.

PS: Figured it out with a regex

@privatmamtora
Copy link
Contributor Author

@fguillot Updated form to sanitize spaces and newlines after a valid keep/block rule

@privatmamtora privatmamtora requested a review from fguillot July 2, 2024 22:20
@fguillot fguillot linked an issue Jul 3, 2024 that may be closed by this pull request
1 task
@fguillot fguillot merged commit 1a81866 into miniflux:main Jul 3, 2024
16 checks passed
@@ -213,14 +213,14 @@ func validateMediaPlaybackRate(mediaPlaybackRate float64) *locale.LocalizedError

func isValidFilterRules(filterEntryRules string, filterType string) *locale.LocalizedError {
// Valid Format: FieldName(RegEx)~FieldName(RegEx)~...
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this comment be updated?

906b2f1#diff-f3574e6be1fa37431084a6f395c2eca7e9b97578b4f91d0ceb6ad32ee0d03b39L218-R218

- rules := strings.Split(filterEntryRules, "~")
+ rules := strings.Split(filterEntryRules, "\n")

Copy link
Contributor Author

@privatmamtora privatmamtora Jul 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, will update.
I also had a dream last night about '\r\n' from windows.
Need to sanitize the string further.
Updating now

Copy link
Contributor Author

@privatmamtora privatmamtora Jul 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, sent a new pull request #2726

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Block rules based off of other elements (not just title). Feature request: Block Rules for article body FR: Global block/keep rules
3 participants