Wikipedia:Lua/Modul/Vorlage:URN/en
aus Wikipedia, der freien Enzyklopädie
Vorlage:URN
– module to generate fully titled external links on resources in URN system by {{URN}}.
Functions for templates
[Quelltext bearbeiten ]- f
- Format.
- Parameters of template transclusion; all but 1 optional:
- 1
-
- Complete specifier
- (obsolete:) namespace-ID before colon, if 2 provided:
nbn
- mandatory
- 2
- Obsolete migration mode from pre-Lua era in dewiki.
- Specifier after colon, if 1 is provided as
nbn
namespace.
- Specifier after colon, if 1 is provided as
- resolver
- Alternative resolver
- Configuration in: Module:URIutil/urn
- fragment
- Link target in generated URL; not part of URN itself
- demo
1
– suppress any fading out of error messages, e.g. in manual context; also do not generate maintenance categories
- Parameters of
#invoke
for project specific adaption; all optional:- errCat
- Title of a maintenance category in case of invalid parameter value etc.
- errClasses
- Classes to be adjoined to error messages, like
error
(always provided) - errHide
1
– hide error messages by default- errNS
- Space separated list of wiki namespace numbers which limit maintenance category.
- Default: Throw errCat in all namespaces.
- Returns: external link or error message, e.g. as
class="error"
. - failsafe
- Version ID (local):
2020年01月18日
- Optional parameter:
1
– Minimum version orwikidata
or~
{{#invoke:Vorlage:URN|failsafe}}
yields2020年01月18日
- With a parameter as ISO date it is compared whether the current module satisfies this version or later.
{{#invoke:Vorlage:URN|failsafe|2001年01月01日}}
returns: »2020年01月18日
«{{#invoke:Vorlage:URN|failsafe|2099年01月01日}}
returns: »« – (empty), if minimal version condition not matched- If keyword is
wikidata
, result is version ID registered on Wikidata (2020年01月18日
) or local if not found there. - If keyword is
~
, result is empty if local and Wikidata version are the same: ().
- Returns:
- Empty, if minimal version condition not matched, or
~
and local version is synchronized. - Version ID if no parameter, or if
wikidata
, or local if not found there, or not synchronized.
- Empty, if minimal version condition not matched, or
Usage
[Quelltext bearbeiten ]Limited to:
- Template:URN or similar
Functions for Lua modules (API)
[Quelltext bearbeiten ]The functions described above can be used by other modules, but are supposed for development and management purposes only. The URIutil library functions are a better solution for productive rendering.
local lucky, URNtemplate = pcall( require, "Module:Vorlage:URN" ) if type( URNtemplate ) ~= "table" then -- In the event of errors, URNtemplate is an error message. return "<span class=\"error\">" .. URNtemplate .. "</span>" end
Subsequently there are available:
- URNtemplate.test( argsF, argsT )
- Development interface
- Parameters as for f:
- argsF
table; list with #invoke parameters- .errNS might be string or sequence table with number
- argsT
table; list with template transclusion parameters
- argsF
- returns:
- string with external link or error message
- URNtemplate.failsafe( atleast )
- Versioning interface
- atleast
optional
nil or minimum version orwikidata
or~
for synchronisation
- atleast
- returns: Version ID as string or
false
Dependencies
[Quelltext bearbeiten ]- Module:URIutil
- Module:TemplUtl (recommended)
Installation on other WMF projects
[Quelltext bearbeiten ]Follow the steps:
- Copy module code of
Module:Vorlage:URN
into your project.- Choose any appropriate name for the module.
- Register this module at d:Q52365013.
- Ensure that
Module:URIutil
(d:Q19644443) is available for your project.- If not yet, provide a copy according to installation guide.
- Module:URIutil/urn (d:Q20950454) is required as well, see URIutil root module.
- It is recommended to provide
Module:TemplUtl
(d:Q52364930) for improved error handling; see installation guide.
Internationalisation
[Quelltext bearbeiten ]There are built-in error messages, currently available in English and German.
- Some few other languages might be incorporated into upstream code.
- For larger number of translations another global multilingual might be implemented.
- That depends on global proliferation.