Module:External links/conf/Sports/doc

MyWikiBiz, Author Your Legacy — Wednesday December 25, 2024
Jump to navigationJump to search

This is the documentation page for Module:External links/conf/Sports

Module "External links/conf/Sports/doc" contains configuration used by Module:External links

There are a number of rows in the variable configured_claims that describe which Wikidata properties should be used to create external links in articles. These rows are structured as follows:

<syntaxhighlight lang="lua" inline>{ prop='Pnnnn', message="$3 [$2 $1] <description>", short="[$2 <text>]", langcode='aa', url="...", url_f=<function>, regex="...", genitive=<boolean>, track=<boolean> },</syntaxhighlight>

Where the following is the case:

  • prop – The property name to process.
    • Pnnnn – If this is a "P" followed by a number (Pnnnn), it is assumed that this is a Property number on Wikidata to be checked. Eg. P345 which is then the number for IMDB links. If this exists for the article, an external link for this property will potentially appear.
    • SLaaaa – If it consists of "SL" followed by an interwiki name, e.g. SLspecieswiki, it will attempt to retrieve the name of the corresponding article on the second wiki, with spaces underlined.
    • If there is another property name, this is treated as a purely local definition and needs to get the value / identifier from the name of the module. See example below.
  • message – The text to be displayed in the article. It has two special values: $1 and $2. These two will be replaced with the following:
    • $1 – Replaced with the article name. See also genitive below.
    • $2 – Replaced with the raw URL of the external link. Eg. http://www.imdb.com/title/tt0085255/
    • $3 – Replaced with a language code. Eg. Template:In lang for Norwegian language (no). See langcode.
    • $4 – Replaced by the value itself.
    • $5 – Replaced by a URI formatted version of the value itself.
  • short – A short version of the text to be displayed. It has two special values: $1 and $2. These two will be replaced similarly to the message above.
  • langcode – Enter the language code for the site. This is used to make an indication of the language of the site. If a P-value is entered here, the module will look for this P-value as a qualifier under P305 (the language of the work). Currently only P407 is supported here.
  • url_f – Here you can enter a formatting function for the URLs to be called. This is only the name of the function (which must be defined locally above configured_claims in this module. The function will be called with one variable which is the identifier that comes from Wikidata or locally and a completed raw URL is expected back. Example: <syntaxhighlight lang="lua" inline>url_f=imdb_formatter</syntaxhighlight>. This feature is the first priority when choosing between multiple options.
  • url – Here you can enter the URL to be called. Example: <syntaxhighlight lang="lua" inline>url="http://www.imdb.com/tt/$1"</syntaxhighlight>. This string is second priority when choosing between multiple options. This one has a special value: $1 which will be replaced with the following:
    • $1 – Replaced with the identifier that comes from Wikidata or locally.
  • regex – Here you can enter a regexp string that will be used to verify that the identifier that comes from Wikidata or locally has the correct format. Example: <syntaxhighlight lang="lua" inline>regex="tt\\d+"</syntaxhighlight>. If defined, the identifier must pass this test first. If there are relevant regexp strings on Wikidata, they will be checked as well, but after that.
  • genitive – This is a variable that determines whether to use genitive in the article name that replaces $1 (see above). This can be either <syntaxhighlight lang="lua" inline>true</syntaxhighlight> or <syntaxhighlight lang="lua" inline>false</syntaxhighlight>.
  • track – This is a variable that determines whether to use this property to include the article in a category. The category is controlled by the definition further down (['tracking-cat-found-data'] or ['tracking-cat-found-local']). This can be either <syntaxhighlight lang="lua" inline>true</syntaxhighlight> or <syntaxhighlight lang="lua" inline>false</syntaxhighlight>.

See also the definition of the maximum number of links that will appear in the articles in the limits variable as <syntaxhighlight lang="lua" inline>['links-shown'] = 10</syntaxhighlight>

Examples

message / short

Entering the following line in Module:External links/conf/Sports:

<syntaxhighlight lang="lua">{ prop='P1469', message='[$2 $1] at FIFA', short='[$2 FIFA]', langcode='en' },</syntaxhighlight>

Would display as one of the following in Antonio Cabrini:

{{#invoke:External links|getLinks|conf=Sports}}
Antonio Cabrini at FIFA
{{#invoke:External links|getLinks|conf=Sports|short=1}}
FIFA

genitive

Entering the following line in Module:External links/conf/Sports:

<syntaxhighlight lang="lua">{ prop='P1469', message='[$2 $1 player profile] at FIFA', langcode='en', genitive=true },</syntaxhighlight>

Would display as the following in Antonio Cabrini:

{{#invoke:External links|getLinks|conf=Sports}}
Antonio Cabrini's player profile at FIFA

langcode

Entering the following line in Module:External links/conf/Sports:

<syntaxhighlight lang="lua">{ prop='P3446', message='[$2 $1] at the Italian Athletics Federation$3', langcode='it' },</syntaxhighlight>

Would display as the following in Dorando Pietri:

{{#invoke:External links|getLinks|conf=Sports}}
Dorando Pietri at the Italian Athletics Federation Template:In lang

locally defined ID with regex

Entering the following line in Module:External links/conf/Sports:

<syntaxhighlight lang="lua">{ prop='dbwrestling', message="[$2 $1] at the International Wrestling Database", langcode='en', url='https://www.iat.uni-leipzig.de/datenbanken/dbwrestling/daten.php?spid=$1', regex='[A-F0-9]+' },</syntaxhighlight>

Would display the following in John-Olav Einemo:

{{#invoke:External links |getLinks |conf=Sports |dbwrestling=B777A635A94B435AB78C5413C14BE233}}
John-Olav Einemo at the International Wrestling Database

Does not display a link if the ID does not match the regex:

{{#invoke:External links |getLinks |conf=Sports |dbwrestling=NonValidID}}

See also