Redirect service
- Main
- Configuration
- Local file settings
- JSON profiles
- Modules
- recon
- recon-suggest-entity
- recon-suggest-entity (MW)
- recon-suggest-property
- recon-suggest-type
- recon-suggest-propvalue
- Other
- Additional usage guide
- Implementation notes
- Implementation notes: SMW
- Implementation notes: MW and types
- Redirect service
- TypeaheadSearch
- Future
The extension enables an intermediary special page, Special:ReconRedirect
, that can be used to redirect the user to either a page matching the requested phrase, given it exists, is accessible and meets other requirements, or else to a query page.
MediaWiki uses a similar special page, Special:Search
, to serve as both a central search page as well as a redirect page if the search phrase in the URL string (search
) matches an existing page and if that page offers read access to the user. It is used, for instance, by the main search box in the Vector skin. But what if instead you want to do either of the following, or both?
- send the user to a custom search page on the wiki
- check a semantic property (SMW) if the page should be visited directly
This is where Special:ReconRedirect comes in.
The URL to the special page can be supplied to the TypeaheadSearch widget.
Methods
Profile
Special:ReconRedirect/23234?q=<phrase>
To support those use cases, you can add a section to your profile page, for instance:
"redirectPage": { // Name of the page : "queryPage": "MySearchPage", // Elements of the URL query string : // The search phrase will be automatically assigned to the final parameter. "query": { "foo": "bar", "phrase": "" }, // @todo check if it works with proper booleans "smwcondition": [ { // the semantic property to be checked "smwproperty": "Is published", // The values to be interpreted as true or false "pass": [ "Yes", "true" ], "fail": [ "No", "false" ] } ] }
Without the inline comments, of course.
Custom search page only
You can do without a profile if all you need is a custom query page, with the regular checks in place but without the property-based check.
- Approach 1
- Add the query page as a subpage of
Special:ReconRedirect
. - Add the intended query string. As always, make sure the parameter for the search phrase comes at the end.
Mock example:
Special:ReconRedirect/MyCustomQueryPage?foo=bar&search=Táin<phrase>
- Approach 2
- Add a default query page to
$wgReconDefaultQueryPage
, which will be used if you leave out a subpage. - For the query string, see approach 1
Special:ReconRedirect?foo=bar&search=Táin<phrase>
Development
Examples:
- https://codecs.vanhamel.nl/Special:ReconRedirect/69727?q=Annals%20of%20Clonmacnoise
- https://codecs.vanhamel.nl/Special:ReconRedirect/69727?q=annals
- https://codecs.vanhamel.nl/Special:ReconRedirect/Special:Search?search=Home
- https://codecs.vanhamel.nl/Special:ReconRedirect/Special:Search?search=Somethingthatdoesnotexist
- Using config setting