Motivation
When the
view script needs to yield redirect, the
viewfile script also needs to yield redirect.
Description and Documentation
Introducing a hook to
viewFileRedirectHandler of plugins in
TWiki::UI::View::viewfile()
Here are some use cases.
Many webs migrated to a different server
Not only topic view URLs but also attachment URLs might be linked from outside.
Those URLs of migrated webs should be redirected to the new URLs.
If a good number of webs are migrated to the same site, handling redirection by a plugin is easier than otherwise.
One of federated sites temporarily loses a disk
This may sound weird but it did happen.
One of federated sites temporarily lost one of its disks for maintenance.
The TWiki site itself was working but could not be fully functional.
So during the maintenance, it needed to redirect topic and attachment view to another federated site.
For that, both view and viewfile script access needs to be redirected.
Examples
=pod
---++ viewFileRedirectHandler($session, $web, $topic, $fileName)
* =$session= - the current TWiki session
* =$web= - the name of the web in the current CGI query
* =$topic= - the name of the topic in the current CGI query
* =$fileName= - the name of the file in the current CGI query
This handler is called by the viewfile script at the beginning.
As its name suggests, this handler provides a way to redirect a viewfile request
to some other URL.
This handler returns 1 if it did =$session->redirect(...)=.
It returns 0 otherwise.
The plug-in dispatcher calls =viewRedirectHandler()= of enabled plug-ins until
one plug-in's returns 1 or the handlers are exhausted.
*Since:* TWiki::Plugins::VERSION = '6.02'
=cut
Impact
Implementation
--
Contributors:
Hideyo Imazu - 2014-10-23
Discussion
Looks good. What is the use case?
--
Peter Thoeny - 2014-10-23
I put two use cases above.
--
Hideyo Imazu - 2014-10-24
On question. When does $TWiki::Plugins::VERSION change? Release time? If so, viewFileRedirectHandler is since 6.01 or 6.1 or what?
--
Hideyo Imazu - 2014-10-24
Last time we did at release time. We can anticipate the next number and increase ahead of time (and fix later if it jumps to a major number.)
--
Peter Thoeny - 2014-10-24
OK. Thank you for your reply.
--
Hideyo Imazu - 2014-10-25