Vorlagenprogrammierung Diskussionen Lua Unterseiten
Modul Deutsch English

Modul: Dokumentation

JSTOR – Module for generation of formatted external links to resources in JSTOR system.

Functions for templates

Bearbeiten
f
Format resource link
Parameters from template transclusion; all optional (but need to result in an identifier):
1
Identifier: article ID, ISSN etc.
mandatory
show
Link title
default: generated from ID
suite
Archive type
  • stable – stable article ID (default)
  • journals – ISSN
demo
1 – suppress all hiding of error messages, e.g. in context of documentations; also do not issue any maintenance category.
Parameters with #invoke for project specific adaption; all optional:
errCat
Title of a maintenance category on invalid parameter value etc.
errClasses
Classes, to be assigned to error messages, like error
errHide
1 – hide error messages by default
errNS
Space separated list of namespace numbers where to use errCat
default: all pages, all namespaces, if errCat defined
showArticle
Page name for JSTOR explanation link target – default: JSTOR
empty value: do not link explanation
Returns: links and perhaps error messages with class="error".
failsafe
Version management

The Failsafe interface is heading for version management of globally distributed Lua modules. It enables modules equipped with this interface to

  • ensure, that a library module required by a template or another module available as local copy does support certain functionality, or complain if not.
  • administrate global updating and linking of module codes via Wikidata.

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):

Parameter
Value Result current
nothing
false
local version ID »2024-09-22«
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.

  • empty, if minimal version not achieved
  • 2001-01-01 → »2024-09-22«
  • 2099-01-01 → »«
wikidata version ID of global upstream
  • version ID at Wikidata
  • local, if not found there
»2024-09-22«
item ID of the Wikidata item
  • empty if not defined
Q71782977
~ Corresponding version ID locally and registered at Wikidata
  • empty, if up to date
  • version ID at Wikidata, if not equal
»«
@ Is the current (module) page linked correctly with Wikidata item?
  • empty, if linked to the item which is supposed
  • Iitem ID, if not
The return value is in template programming empty or under Lua false, otherwis a non-empty string as described.

Functions for Lua modules (API)

Bearbeiten

Some of the functions as dokumented above can be used by other modules per require():

local lucky, JSTOR = pcall( require, "Module:JSTOR" )
if type( JSTOR ) == "table" then
    JSTOR = JSTOR()
else
    -- failure; JSTOR is the error message
    return "<span class=\"error\">" .. JSTOR .. "</span>"
end

Then there is available:

JSTOR.feasible( article, area, auxilary )
Check code, normalize
  1. article
    string, with JSTOR ID
  2. area
    string, with with "stable", "journals", or false
  3. auxilary
    table, URIutil library, or false
Returns: string with improved ID, or false
JSTOR.format( article, area, appear, auxilary )
Analyze code, create URL, format like f
  1. article
    string, with JSTOR ID
  2. area
    string, with with "stable", "journals", or false
  3. appear
    string, with link title, or false
  4. auxilary
    table, URIutil library, or false
Returns: string with links and error messages
JSTOR.failsafe( atleast )
Version management
Returns: string oder false

If the interface is not initialized, one more function might be used:

  • p.main( argsF, argsT )
    Invocation
    1. argsF
      table, with #invoke parameters, or false
    2. argsT
      table, with template parameters, or false
    Returns: string with formatting etc.

Dependencies

Bearbeiten