|Version 9 (modified by txcraig, 5 years ago) (diff)|
Server Side Redirect from a Wiki Page
This plug-in allows one to place a redirect macro at the start of any wiki page which will cause an server side redirect when the wiki page is viewed.
This plug-in is compatible (i.e. can be used) with the client side redirect macro TracRedirect but doesn't depend on it. Because the redirect is caused by the server (using a HTTP redirect request to the browser) it is much faster and less noticeable for the user. The back-link feature of TracRedirect can also be used for server side redirected pages because both generate the same URL attributes.
A protection for 1st (A->A) and 2nd (A->B->A) order redirect loops is implemented, but higher order loops (A->B->C->A, etc.) must be handled by the browser or the user. Firefox 3 handles redirect loops well.
To edit a redirecting wiki page access its URL with ?action=edit appended. To view the page either use ?action=view, which will print the redirect target (if TracRedirect isn't active, which will redirect the wiki using client side code), or ?redirect=no which disables redirection of both the ServerSideRedirectPlugin and TracRedirect plug-in.
Direct after the redirect target is added (or modified) Trac will automatically reload it, as it does with all wiki pages. This plug-in will detect this and not redirect but display the wiki page with the redirect target URL printed to provide feedback about the successful change. However, further visits will trigger the redirect.
This plug-in uses the ExtractUrlPlugin, which must also be install.
If you have any issues, create a new ticket.
Download the zipped source from here.
Enable the plugin in:
[components] tracserversideredirect.* = enabled tracextracturl.* = enabled
You may need to restart your Web server.
To use the plugin place the following trac macro at the begin of the wiki page.
The macro is normally not executed, but the plugin will scan every wiki page for it and execute the redirect before the wiki page is send to the user. However, a fall-back implementation of the macro is provided which displays the redirect target to the user. This message is also shown directly after the redirect macro was added to the wiki page to give the editing user a feedback over the successful change.
Please note that the lower-case version 'redirect' is compatible with the TracRedirect macro, which is not redefined by this plugin if this macro is also enabled. The upper-case version 'Redirect' is always provided by this plugin and will be ignored by TracRedirect.
In addition to a wiki page any other TracLink can also be used:
[[redirect(wiki:OtherWikiPage)]] [[redirect(source:/trunk/file.py)]] [[redirect(http://www.example.com/)]]
[[Redirect(wiki:OtherWikiPage)]] [[Redirect(source:/trunk/file.py)]] [[Redirect(http://www.example.com/)]]
-  by rjollos on 2012-08-04 03:37:28
Fixes #6940, #8680:
- Removed setup_requires statement from setup.py. The listed package is only necessary for installation, not for running setuptools.
- Modified import statement for extract_url since it was not importing correctly.
Tested with Trac 1.0dev-r11167.
-  by martin_s on 2010-08-30 23:57:55
Added encoding meta-comment and declared SVN keywords as unicode to avoid issues with non-english locales.
-  by martin_s on 2010-08-23 13:12:11
Removed outdated variable rev from setup file.