Skip to content

Conditional redirects#34

Open
solewniczak wants to merge 2 commits intosplitbrain:masterfrom
gkrid:master
Open

Conditional redirects#34
solewniczak wants to merge 2 commits intosplitbrain:masterfrom
gkrid:master

Conversation

@solewniczak
Copy link

This pull request introduces an idea of conditional redirects, using a following syntax in a config file:

source destination ? condition | other_destination ? other_condition | else_destination

The code above redirects the user from page "source" to the first page on the list which condition was met. If no condition is met the user is redirected to "else_destination". If no "else_destination" is provided the redirect doesn't trigger. Particularly we can use only one condition:

source destination ? condition

Currently I've implemented two types of conditions:

  • $USER$=name which check if 'name' is currently login user
  • $USER.grps$=group which check if currently login user belongs to 'group'

Of course the list of condition types can be easily extended.

I think that the idea can be useful in many use cases. What do you think about it?

@solewniczak
Copy link
Author

What do you think about this feature? Can you merge it into master?

@splitbrain
Copy link
Owner

I'm not a huge fan of increasing the complexity of this plugin. If we do, it might be worth to see if we could adopt the syntax of something existing that does what we want instead of inventing our own. mod_rewrite comes to mind but might not be a good fit.

With the syntax getting more complex than just source destination I would also want proper unit tests.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants