| Vorlagenprogrammierung | Diskussionen | Lua | Test | Unterseiten | |||
| Modul | Deutsch | English
|
Modul: | Dokumentation | |||
URIutil – Module with functions for strings in context of resource identifiers. This is not targeting for the subset, which is a locator formed as URL (see URLutil). In fact unique key codes for any kind of documents are covered: DOI, ISBN, ISSN, URN; furthermore some national and other codes like LCCN, GTIN/EAN, DNB, GND, ZDB, assigned by public institutions.
All functions expect exactly one unnamed parameter (which should be provided to get a meaningful answer). Whitespace ahead and after content is ignored.
The return value is an empty string (“nothing”), if the parameter value does not fulfil the expectations. If there is a result or the query condition is true, at least one visible character will be returned. The result does not begin or end with a space.
2011 – valid10 if 10 digits and hyphens; also terminated by xX13 if 13 digits and hyphens; starting with bookland10 or 13 – yes8 or 13 – yesformatISBN (also when syntactically incorrect)
formatISSN (also when syntactically incorrect)
class="plainlinks-print" won’t be issued.isDOI or empty
0 – emptyisISBN or empty
10 oder 13 – yes0 emptyisISSNvalid or empty
8 oder 13 – yes0 – emptyisLCCN or empty
0 – empty1 permits ASCII only (no IRI).formatISSN (also when syntactically incorrect)
1 permits invalid check digit.class="plainlinks-print" won’t be issued.linkDOI with prefixed scheme doi:
link=0 – without linking doi: on Digital Object Identifier like doi:linkURN with prefixed scheme urn:The Failsafe interface is heading for version management of globally distributed Lua modules. It enables modules equipped with this interface to
The Failsafe interface is present both at template level and for direct Lua access.
The functions in detail are (not all supported yet completely by every library):
| Value | Result | current |
|---|---|---|
nothingfalse
|
local version ID | »2024-08-05« |
| Minimal version | version ID required at least date in ISO format It will be compared whether the current local implementation matches this version or later.
|
|
wikidata
|
version ID of global upstream
|
»2024-08-05« |
item
|
ID of the Wikidata item
|
Q19644443
|
~
|
Corresponding version ID locally and registered at Wikidata
|
»« |
@
|
Is the current (module) page linked correctly with Wikidata item?
|
|
The return value is in template programming empty or under Lua false, otherwis a non-empty string as described.
| ||
The functions link* and uri* link the prefixed keyword/scheme to the assumed enzyclopedic article. The parameter value may specify an alternative page name; or link=0 would suppress linking.
The functions link* will use non breaking space between prefixed keyword and code; but nbsp=0 requests ASCII spaces.
The functions link* and uri* assign class="invalid-ISBN" etc. to invalid codes. This might be utilized by users or gadgets for markup, e.g. a red box around the code.
.invalid-ISBN,
.invalid-ISSN {
border: solid 2px #FF0000;
}
A test page illustrates practical use.
All functions described above can be used by other modules:[1]
local lucky, URIutil = pcall( require, "Modul:URIutil" )
if type( URIutil ) == "table" then
URIutil = URIutil()
else
-- failure; URLutil is the error message
return "<span class=\"error\">" .. URIutil .. "</span>"
end
Subsequently there are available:
"wikidata" or ~ keywordThe input parameters are:
attempt – string with codeOptional:
achieve – number 8 or 13 for output format; else as got.allow – true permit invalid check digit.abbr – true or string will link prefixed abbreviation ISBN/ISSN.adhere – true use instead of ASCII space.ascii – true permit ASCII only (no IRI).If succeeding, most functions return a string, the URIutil.is*() a number or string; on failure always false.
General library; no limitations.
Follow the steps:
Module:URIutil into your project.
URIutil./config and populate according to your needs.Create a /config sub module of your root module for mw.loadData() access and return a table with the following components (strings):
$1 current ISSN will replace that placeholder, otherwise appended.$1 current PMID will replace that placeholder, otherwise appended."-"."-"."-"."-".URIutil = URIutil()URIutil = URIutil.URIutil()Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.