Wikipedia:Lua/Modul/Vorlage:URN/en

aus Wikipedia, der freien Enzyklopädie
Zur Navigation springen Zur Suche springen
Vorlagenprogrammierung Diskussionen Lua Unterseiten
Modul Deutsch English

Modul: Dokumentation

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.
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 or wikidata or ~
{{#invoke:Vorlage:URN|failsafe}} yields 2020-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.

Limited to:

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:
  1. argsF
    table; list with #invoke parameters
    • .errNS might be string or sequence table with number
  2. argsT
    table; list with template transclusion parameters
returns:
  • string with external link or error message
URNtemplate.failsafe( atleast )
Versioning interface
  1. atleast
    optional
    nil or minimum version or wikidata or ~ for synchronisation
returns: Version ID as string or false

Dependencies[Quelltext bearbeiten]

Installation on other WMF projects[Quelltext bearbeiten]

Follow the steps:

  1. Copy module code of Module:Vorlage:URN into your project.
    • Choose any appropriate name for the module.
  2. Register this module at d:Q52365013.
  3. Ensure that Module:URIutil (d:Q19644443) is available for your project.
  4. Module:URIutil/urn (d:Q20950454) is required as well, see URIutil root module.
  5. 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.