New contrib repository - Redirect macro extension

Hello,
I would like to add a macro extension that lets you easily include a redirect in a page, and optionally set delay and a notice message for it.

Here is how the macro would look like:

{{redirect location=“Sandbox.TestPage2” delay=“3” visible=“false”/}}

or

{{redirect location=“https://www.w3.org” /}}

For the parameters:
location - The XWiki document reference or URL to redirect to. The URL can be absolute or relative.
delay - expressed in seconds (optional: default is 0)
visible - whether to display a redirect notice box (optional: defaults is “true”)

I suggest we call this extension simply “redirect-macro”.

If it’s OK for everyone, is it possible to create a contrib repository and a jira project?

As per our naming rules I’d recommend naming the repo redirect, with a redirect-macro submodule.

Agreed

I’ll create the repo and jira in a few minutes.

Once you’ve released it, you may want to update https://www.xwiki.org/xwiki/bin/view/FAQ/Adding%20a%20redirect

Some comments:

  • For consistency, i’d use reference and/or page instead of location for the parameter since this is what we use in other macros (include, display, etc).
  • If you want to use the same parameter for both a reference and a URL you could have some problems since in theory a page can be named “http://somedomain”. In this case you may want to use the same strategy than we use for the xwiki/2.1 link syntax, see the explanations at the bottom of https://www.xwiki.org/xwiki/bin/view/Documentation/UserGuide/Features/XWikiSyntax/?syntax=2.1&section=Links (you may even be able to reuse the same code for resolving link references). A simpler option (but maybe less nice for users would be to allow both reference and url parameters for the macro, at least it would less magical).

Note: redirect is using a pretty broad namespace. I’m hesitating with some more restrictive name like page-redirect. However, if I don’t get any negative feedback for redirect in the coming 10mn, I’ll go with it.

Thx

Also you could have a subwiki named “http” and the page named “//somedomain”.

Better use reference, yes (also this field should probably be a org.xwiki.rendering.listener.reference.ResourceReference given its description). page does not make much sense, since it might not be a page at all.

Cool if that exists, didn’t know if we had a resolver for org.xwiki.rendering.listener.reference.ResourceReference. Makes it simple to implement.

Done:

Enjoy
Thx

That’s what we use in the Office Viewer macro (but more importantly, it’s what represent the reference of a link in the XDOM, so it should fit your use case well), for example @ppantiru if you want to take a look.

I will take the feedback/recommendations into account.
Thank you!