Saltu al enhavo

Vikipedio:Lua/Moduloj/URIutil

El Vikipedio, la libera enciklopedio
Ŝablona programado Diskutoj Lua Testoj Subpaĝoj
Modulo Esperanto English Deutsch

Modulo: Dokumentado

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.


Functions for templates

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.

coreISSN
7 significant digits of a 8-digit or 13-digit ISSN
formatISBN
Segmentation by hyphens; “X” capitalized.
formatISSN
Segmentation by hyphens; “X” capitalized.
  • Optionally: second parameter 8 or 13 for output format; else as got.
isDNBvalid
Is this DNB (also GND, ZDB) identifier formally correct, including check digit?
  • GND have at least 9 digits, not former 8 digits SWD and GKD with check digit separated by hyphen.
If a number with up to 7 digits a check digit separated by hyphen is following, a validation by rules before 2012 is tried.
  • nothing – if invalid
  • number of digits or 2011valid
isDOI
Is this a syntactically correct Digital Object Identifier?
  • number of organisation – yes
  • nothing – if invalid
isEscValid
Are bad percent escapings in attempt?
  • nothing – no complaints
  • string – objected sequence
isGTINvalid
Is this GTIN (EAN) formally correct, including check digit?
  • number of digits
  • nothing – if invalid
GTIN are also ISBN-13, ISSN-13 and perhaps one day AV media.
isISBN
Is this a syntactically correct ISBN?
  • 10 if 10 digits and hyphens; also terminated by xX
  • 13 if 13 digits and hyphens; starting with bookland
  • nothing – else
isISBNvalid
Is this a syntactically correct ISBN, including check digit?
  • 10 or 13yes
  • nothing – no
isISSNvalid
Is this ISSN formally correct, including check digit?
  • 8 or 13yes
  • nichts – no
isLCCN
Is this a syntactically correct LCCN?
  • string – identified, without separators
  • nothing – if invalid
linkDOI
Bracketed external link on DOI resolver
linkISBN
Bracketed external link on Special:Booksources with prefixed keyword ISBN and formatISBN (also when syntactically incorrect)
  • Optionally: second parameter 1 permits invalid check digit.
  • Optionally: link=0 and nbsp=0
linkISSN
Bracketed external link on data base of periodicals with prefixed keyword ISSN and formatISSN (also when syntactically incorrect)
  • Optionally: second parameter 1 permits invalid check digit.
  • Optionally: link=0 and nbsp=0
class="plainlinks-print" won’t be issued.
linkURN
Bracketed external link on URN resolver
For the time being not implemented due lack of universal resolver.
mayDOI
isDOI or empty
  • Number of organisation – yes
  • 0empty
  • nothing – if invalid
mayISBN
isISBN or empty
  • 10 oder 13yes
  • 0 empty
  • nothing – if invalid
mayISSN
isISSNvalid or empty
  • 8 oder 13yes
  • 0empty
  • nothing – if invalid
mayLCCN
isLCCN or empty
  • string – identified, without separators
  • 0empty
  • nothing – if invalid
mayURI
URI in general or empty; no spaces within, isEscValid
  • Optionally: second parameter 1 permits ASCII only (no IRI).
  • nothing – no complaints
  • string – objected sequence
mayURN
Valid URN or empty
  • nothing – no complaints
  • string – objected sequence
plainISBN
Raw ISBN with digits only (or X); 10 or 13 characters.
Appropriate for Wikipedia:BibRecord.
uriDOI
Like linkDOI with prefixed scheme doi:
uriURN
Like linkURN with prefixed scheme urn:
Not yet implemented.

Optional parameters

link=

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.

nbsp=

The functions link* will use non breaking space between prefixed keyword and code; but nbsp=0 requests ASCII spaces.

Markup of bad codes

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;
}

Examples (test page)

A test page illustrates practical use.

Ĝeneralaj atentigoj pri la enplektado de moduloj

Enplektado okazas ĉiam en la formato

{{#invoke: URIutil | Funkcionomo | valoro1 | valoro2 | nomoX=valoro … }}

La parametroj povas esti nomitaj aŭ nenomitaj kiel ĉe ŝablonoj.

Se nekonata signoĉeno venas de ekstere (kiel ŝablonaj parametroj), ĉiam estu laborata kun la formo 1=valoro.

Pliajn informojn vi trovos sur Helpo:Lua.