Skip to content
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

FEATURE REQUEST: logical operators when specifying tags and exclude myself #2

Open
pitrson opened this issue Jul 14, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@pitrson
Copy link
Collaborator

pitrson commented Jul 14, 2024

Hello there,

first of all - many thanks for your work! Your plugin is really amazing and it is the only one available which was (almost) able to fulfill my needs :-). Now when it comes to my feature request I'm missing few important (IMHO) functionalities:

Exclude myself from the generated links

  • it would be nice to have an option to exclude the page where the pagelist is called, from the list of generated links, something like:
    -myself, or even to have it like that by default and only include if specified. I was missing this even in Confluence :)

Add logical operators for tags in pagelist

Current state:
{ pagelist 100 tag1 tag2}

  • this generates links for pages where either tag1 or tag2 is set. But to me this should only generate links for pages where both of the tags are set.

My idea would be something like this:

  • generate list of links for pages with any of the tags tag1, tag2, tag3:
    (tag1 or tag2 or tag3)
  • generate list of links only for pages with both tag1, and tag2 set:
    (tag1 and tag2)
  • ability to combine multiple cases like:
    ((tag1 and/or tag3) and/or (tag1 and/or tag2)) and (not tag4)

Many thanks again! Let me please know if any help or testing is needed.

Cheers

@alanpt
Copy link
Owner

alanpt commented Jul 15, 2024

Hi Pitrson!

That first point was a problem for me too the other day.

The second one how about this:

{pagelist tag1 tag2} for any pages with either of those tags (Current)
{pagelist tag1 -tag2} for pages with tag1 but not if it also is tagged with tag2 (Current)
`{pagelist +tag1 +tag2} for pages tagged with both those tags (New)

Thanks for the offer of help. I don't have the time right now to do these changes unfortunatly. Maybe in a few weeks?

@alanpt alanpt self-assigned this Jul 15, 2024
@alanpt alanpt added the enhancement New feature or request label Jul 15, 2024
@pitrson
Copy link
Collaborator Author

pitrson commented Sep 28, 2024

Hi @alanpt

I was checking the code today and I've seen that the '+tag' is already implemented.

        any_tags = {tag for tag in tags_to_filter if not tag.startswith('+') and not tag.startswith('-')}
        all_tags = {tag.lstrip('+') for tag in tags_to_filter if tag.startswith('+')}
        exclude_tags = {tag.lstrip('-') for tag in tags_to_filter if tag.startswith('-')}

        any_match = any(tag in page_tags for tag in any_tags) if any_tags else True
        all_match = all(tag in page_tags for tag in all_tags)
        exclude_match = not any(tag in page_tags for tag in exclude_tags)

        return any_match and all_match and exclude_match

It works sufficiently for my needs (for now ^^). I will submit a PR which reflects this in the README and makes sure that it doesn't generate link for "myself" and include few minor fixes I came across.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants