Module:Find sources/doc explained

This module produces a list of links to search engines to help editors find sources about a given subject. It implements and other similar templates. It is highly extensible; new templates and new link types can be added easily and by any user.

Usage

From wikitext

Usually, from wikitext this module should be used via a template, e.g. . However, it is also possible to use it directly from #invoke, like this:

{}

Alternatively the following can be used, which will convert any title to a search query, with the main portion of the title in quotation marks, and any parenthetical disambiguator outside quotation marks. {}

From Lua

Load the module with the following code:

local mFindSources = require('Module:Find sources')

You can then produce the list of search links like this:

mFindSources._main(template, searchTerms)

Example syntax:

mFindSources._main('Find sources',)

Available templates

The following templates are available for use:

Making new templates

There are two basic ingredients to making a new source-finding template. The first is the template configuration module, and the second is the template invocation on the template page.

Template configuration page

To find the name of the template configuration page, take the page name of your proposed template without the namespace prefix, and add it to the base page of "Module:Find sources/templates/". For example, for, the configuration page is located at . Note that the template must be capitalised exactly as the page name is, otherwise the arguments will not be passed through from the template page to the module.

The template configuration page should look something like this:

return

Once you have created your template configuration page, you need to add the template to in order for it to show up in the table of templates on this documentation page.

Link tables

Link tables are used in the "introLink" and "links" fields of the template configuration. They can contain three fields, "code", "display", and "tooltip". The "code" field is required, and must be one of the link codes listed in the table below. The "display" field is optional, and specifies a custom display value for that link to be used by the template. If the display field is not set, a default value is set by the module. The "tooltip" field is also optional, and specifies a custom tooltip for the link. HTML reserved characters are escaped by the module. If the field is absent, no tooltip is displayed. For the "introLink" field, the default value is the search text entered by the user; for the "links" field, the default value is defined in the link configuration modules.

The following table contains all the available link codes, with descriptions and examples.

Template invocation

The template invocation on the template page itself should look like this:

{}<noinclude> {} </noinclude>

This activates the template code and also provides automatic documentation. template is the name of the template without the namespace prefix, and must be correctly capitalised.

If you want to use custom documentation from a /doc subpage instead of the automatic documentation, use this invocation instead:

{}<noinclude> {} <!-- Categories go on the /doc subpage, and interwikis go on Wikidata. --> </noinclude>

Adding new links

New links are added to . Link codes should be short but descriptive, and should be in lower case. For example, the link code for Google search is "google".

The link configuration page should look something like this:

return

Parameters
ParameterDescription
urlThe url to perform the search. This field takes a parameter $1, which is the URL-encoded search text entered by the user. This field is required.
displayIf a display value is not specified in the template configuration, this value is used instead. This field is required.
separatorThis is used to separate the search terms entered by the user. This is optional, and defaults to "+" (a URL-encoded space).
descriptiona brief description of what the search engine link does. This is used in the template documentation to generate the list of link descriptions, and also to make the descriptions in the table of link codes above. This is optional, but recommended.
notesnotes about the search engine link. These are put in the table of link codes above, but they are not put in the template documentation for individual source-finding templates. This field is optional.tooltip
tooltip

Automatic documentation

Automatic documentation is provided for templates based on this module; the documentation is generated by . The autodoc module uses the following pages:

Template documentation configuration page

This page is located at the "/autodoc" subpage of the template configuration page. It is only used to generate the documentation, not to generate any of the actual template output, so it does not need to be protected. It should look something like this:

return

Configuration

The messages used in this module can be found at and . This can be helpful for translating this module for use in other languages. Note that any template and link configuration used must also be translated.