モジュール:Auteur
提供: ひつじ小屋別館2代目
documentation view / edit
- This module generate a header box for Author pages in french Wikisource, replacing Modèle:Auteur.
- First in french, then in other languages.
- It uses Module:Multilingual_Arguments and Module:Unitest_Scribunto
Module:Auteur[編集]
Lua エラー 2064 行目: invalid capture index
-- This module draw a header of Author page in wikisource
-- it is called by templates {{Author... or {{Auteur...
--[[
-- MediaWiki 1.21wmf9 (070f4b4). 14/02/13
-- MediaWiki 1.21wmf9 (afbf386). 15/02/13 test2
-- MediaWiki 1.21wmf9 (afbf386). 15/02/13 test2
-- MediaWiki 1.21wmf10 (edeb4e1) 18/02/13 test2
-- https://gerrit.wikimedia.org/r/#/c/49601/
-- Patch Set 1 - 96615c97b03bbfacb27e749a1d42971429d76852 (gitweb)
3.25 Scribunto
6 days ago Brad JorschMake our loader work like Lua's built-in loaders 15-6=9/2/13
git #5584810 - Make our loader work like Lua's built-in loaders
https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/extensions/Scribunto.git;a=commit;h=5584810c2d69602b33297821dd7467742722980f
https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/extensions/Scribunto.git;a=commit;h=fddf05c0566aca35bc10b0b8fa4abed8668b7134
git #8d02895 - Create wmf/1.21wmf9 branch and update .gitreview
2013-01-31 Brad JorschLua library support functions
git #4c69b13 - Lua library support functions
git #0a8a07d - Fix package.loaded and other cleanups
--]]
--[[
editing code UTF-16 (MacRoman ?)
Exemple tous paramètres :
{{Auteur |c=:|options=fr test params
|nom=Hugo|prénom=Victor|prénomGall= Arthur
|cle=Hugo Victor|initiale=H
|image=Victor Hugo.jpg |description=écrivain français
|texte=vie |categorie=Auteurs |lien=du |liaison=de l'
|texteNaissance=a |categorieNaissance=Auteurs
|incertitudeNaissance= vers |lienNaissance=du |liaisonNaissance=en
|anneeNaissance= 1802 |siecleNaissance= 19
|texteDeces=a |categorieDeces=Auteurs
|incertitudeDeces= après |lienDeces= du |liaisonDeces=en
|anneeDeces= 1885 |siecleDeces= 19
|droits=non |pseudo=Monsieur Legrand
|genre=Romanciers/Poètes/Auteurs de théatre
|langue=français |pays=France/Italie/Grèce
|metier=Académiciens/Personnalités politiqp.md_dataues
|prix=Prix Nobel de littérature
|VIAF=34452139|NLA=35096649|BNF=cb11888266r|SELIBR=34648|PND=11850133X|LCCN=n/50/23101
|border=0
}}
* Init of unit tests. test_list = table
* Begin of unit tests :
* 1 Site tested : mw.uri.fullUrl = //fr.wikisource.org/wiki/Module:Auteur.
* 2 Environment : Mediawiki 1.21wmf10 (d6c6dba) version UTC 2013-03-01 21:53:59.
* 3 Runtime and spaces : server UTC 2013-03-04 01:09:22, namespace=Modèle module_space=Module, template_space=Modèle viewErrors=true.
* 4 frame.args Error : frame.args.lastname = "error". The OK value was "OK" = frame:getParent().args.lastname.
* 5 sub table write Test OK : sub table write OK. / / / result OKOK ; exec_ok=true ; value_ok=true ; var_tested=td.C.X ; value_before=xx ; value_after=okvalue ; A=aa ; Y=yy .
* 6 Is Scribunto complete ? Error : Scribunto is not complete. / / / ; math=table ; os=table ; package=table ; string=table ; table=table ; mw=table ; frame=table ; mw.language=table ; mw.message=nil ; mw.site=table ; mw.title=nil ; mw.uri=table ; mw.ustring=table .
* End of unit tests. Statistic count : Nerr=2 / Ntests=6
-- local MW = require "Module:mw"
--]]
-- Variables et fonctions de base utiles partout
local catView = "" -- = ":" to display a category to document it rather than truly categorize
local doc_args_import_all -- Documentation des arguments dés leur lecture
-- Options de maitrise du fonctionnement de ce module
local local_options = " " -- options normales venant du modèle, normal options from template
-- options=fr params docavant doc-min docmax docdef docnotice doc-apres docligne
-- local debug_options = " " -- pas d'options de debug du module par edit
local debug_options = " unitest debug erreurs params docavant no-box no-cat doc-min doc-max doc-notice doc-def docligne not-ices tra-ck " -- options de debug du module par edit
local option = function(key, opt)
-- if option("nocat") then cat = "" end
-- Si le mot cle key est parmi les mots options, repondre true
-- Chercher dans local_options et ( opt ou debug_options )
-- Options de documentation : docmin docmax docnotice docdef docligne docavant docapres params
-- Autres options : en es fr unitest notices nobox nocat track
-- Veiller à toujours séparer les mots par des espaces
-- On peut désactiver les options en supprimant les mots clés ou en les coupant.
-- Les identifiants de langues permettent de forcer certaines langues.
-- Les erreurs n'apparaissent que dans les espaces de noms Modèle ou Module.
if type(key) ~= "string" then return false end
local options = " " .. local_options .. " "
if type(opt) == "string"
then options = options .. opt .. " " -- options du modèle et de l'appel si définies
else options = options .. debug_options .. " " end -- options du modèle et de debug sinon
key = " " .. key .. " " -- chercher les mots clefs exacts et non ceux inclus dans un autre mot
local n = string.find(options, key)
-- si le mot cle est parmi les mots options, repondre true
return ( nil ~= n )
end -- local option = function(key, opt)
local options_change = function(old, new, chg)
-- local_options = options_change(local_options, Argts.argv("options", tr), "init")
-- local_options = options_change(local_options, debug_options, "test")
if chg == nil then
-- if type(old) == "string" then
return old
else
-- if type(new) == "string" then
return new
end
return ""
end -- local options_change = function(chg, old, new)
local trc = "<br/>* Modele:Auteur trace "
local trck_on = false
local trck = function(x)
if trck_on then trc = trc .. tostring(x) end
end
local table_iterator = function(t) -- iterator to use all elements of a table, one by one
-- for noticeN in table_iterator(notices_properties) do
-- modele : function list_iter (t)
if type(t) ~= "table" then return { }, 0 ,0 end
local i = 0
local n = table.getn(t)
return function ()
i = i + 1
n = table.getn(t)
if t[i] ~= nil then return t[i], i ,n end
end
end
local toUTF8 = function(t)
-- convertir un simple texte en UTF8 pour URL
-- text = "Bibliothèque d'autorité (Suède)"
-- wptx = "Biblioth%%C3%%A8que%%20d%%27autorit%%C3%%A9%%20%%28Su%%C3%%A8de%%29"
if type(t) ~= "string" then t = "" end
t = string.gsub(t, "%s", "%%20")
t = string.gsub(t, "'", "%%27")
t = string.gsub(t, "%(", "%%28")
t = string.gsub(t, "%)", "%%29")
t = string.gsub(t, "é", "%%C3%%A9")
t = string.gsub(t, "è", "%%C3%%A8")
return t
end
--[[
* GESTION DES PARAMETRES DU MODELE, MANAGING PARAMETERS OF THE TEMPLATE
*
* La gestion des paramètres permet de :
* * Lire et mémoriser tous des paramètres fournis par le modèle (voir arg_input arg_memorize)
* * S'adapter à la langue du wiki ou une autre (voir arg_lang)
* * Lire ou modifier simplement la valeur mémorisée chaque fois que nécessaire, indépendamment de la langue (voir argv arg_memorize)
* * Lister les paramètres, tous(docmax), ou ceux définis(docdef), ou selon la spécialisation (docmin, doc1 à doc3)
* * Aider à documenter le modèle selon divers aspects, types, usages ...
* * Lire d'abord tous les paramètres définis, puis calculer les interactions des noms, prénoms, et autres.
* * Développer la vérification des paramètres, de leurs valeurs, de leurs interdépendances.
* Une table args_known décrit les paramètres, leurs types, leurs valeurs et leurs appelations dans diverses langues.
* Les types sont ctr = controle, dat = donnée, ntc = notice, opt = options, syn = synonyme, prg = géré uniquement par le programme
* Les langues sont : en = anglais, es = espagnol, fr = français et il est facile d'en ajouter.
* L'objet Argts, tables et fonctions, est développé ici pour être déplacée dans un module indépendant et partagé.
* Le 2013-01-27, l'objet Argts est prévue pour fonctionner comme une classe, avec héritage et fonction New, mais n'est pas encore validée.
--]]
--[[
{{Auteur |options=fr par-ams docavant doc-min docmax docdef docnotice doc-apres docligne
|c=x:|border=0
| nom = Rimbaud | prénom = Arthur | cle = Rimbaud | prénomGall= Arthur
| description = Poète français très connu.
| naissance = 1854 | deces = 1891 | image = Carjat Arthur Rimbaud 1872 n2.jpg
| droits = 70 | initiale = R | wikipedia = Arthur Rimbaud
| wikiquote = Arthur Rimbaud | commons = Arthur Rimbaud | commonscat =
|texte=vie |categorie=Auteurs |lien=du |liaison=de l'
|texteNaissance=a |categorieNaissance=Auteurs
|incertitudeNaissance= vers |lienNaissance=du |liaisonNaissance=en
|anneeNaissance= 1802 |siecleNaissance= 19
|texteDeces=a |categorieDeces=Auteurs
|incertitudeDeces= après |lienDeces= du |liaisonDeces=en
|anneeDeces= 1885 |siecleDeces= 19
|droits=non |pseudo=Monsieur Legrand
|genre=Romanciers/Poètes/Auteurs de théâtre |langue=français |pays=France/Italie/Grèce
|metier=Académiciens/Personnalités politiques |prix=Nobel de littérature
|VIAF=34452139 |NLA=35096649 |BNF=cb11888266r |SELIBR=34648 |PND=11850133X |LCCN=n/50/23101
|ARC=34452139 |ISBN=123456789 |OCLC=1b5g6t7e |SWD=11/224/488 |ARCitem=Robert/Alain/Paul
|WORLDCATch=Andrea/Mickel |ARCid=34-452-139
}}
--]]
-- local TradArgs = require "Module:Multilingual_Arguments"
--[ [ -- Module:Multilingual_Arguments start
local Trad = { } -- Traductions des textes locaux, sur le modèle de ProofreadPage.i18n.php $messages = array();
Trad['qqq'] = {
-- qqq is a description of each text or peculiarities.
-- qqq es una descripción de cada texto o peculiaridades.
-- qqq est une description de chaque texte, ou de ses particularités.
-- Arguments from frame:getParent()
c = 'c',
options = 'options',
lastname = 'lastname',
initiale = 'initiale',
familyname = 'familyname',
firstname = 'firstname',
pseudonym = 'pseudonym',
title = 'title',
Galliname = 'lastname',
sex = 'sex',
sortkey = 'sortkey',
image = 'image',
birthyear = 'birthyear',
birth = 'birth',
birthcentury = 'birthcentury',
birthuncertain = 'birthuncertain',
deathyear = 'deathyear',
death = 'death',
deathcentury = 'deathcentury',
deathuncertain = 'deathuncertain',
description = 'description',
occupation = 'occupation',
genre = 'genre',
language = 'language',
country = 'country',
prize = 'prize',
rights = 'rights',
wikipedia = 'wikipedia',
wikiquote = 'wikiquote',
commons = 'commons',
commonscat = 'commonscat',
namespace = 'space',
category = 'category',
catspace = 'catspace',
-- Scans and Notices
author_Scans = 'Scans qqq',
author_Notices = 'Notices qqq',
author_cat_birth_year = 'Notices qqq',
author_cat_birth_secular = 'Notices qqq',
author_cat_birth_epoch = 'Notices qqq',
-- Error messages
err_internal_argument_unknown = ' Internal error : the internal argument _X1X_ is unknown in args_import_all. Report the error to improve the model.',
err_value_re_defined = ' Error : the value of the argument _X1X_ is already defined. Choose only one argument and value.',
err_value_missing = " Error : This argument is required but absent : _X1X_. Should define it.",
err_none_value = " Erreur : Error : No argument has been defined.",
err_internal_notice_wsid = "Internal error: the internal argument <b>_X1X_</b> is unknown in the records.",
}
-- Trad['en'] = {
-- This repair a Lua bug : Trad[arg_lang]["options"] = value give an error
Trad.en = {
-- Arguments from frame:getParent()
c = 'c',
options = 'options',
lastname = 'lastname',
initiale = 'initiale',
familyname = 'familyname',
firstname = 'firstname',
pseudonym = 'pseudonym',
title = 'title',
Galliname = 'lastname',
sex = 'sex',
sortkey = 'sortkey',
image = 'image',
birthyear = 'birthyear',
birth = 'birth',
birthcentury = 'birthcentury',
birthuncertain = 'birthuncertain',
deathyear = 'deathyear',
death = 'death',
deathcentury = 'deathcentury',
deathuncertain = 'deathuncertain',
description = 'description',
occupation = 'occupation',
genre = 'genre',
language = 'language',
country = 'country',
prize = 'prize',
rights = 'rights',
wikipedia = 'wikipedia',
wikiquote = 'wikiquote',
commons = 'commons',
commonscat = 'commonscat',
namespace = 'space',
category = 'Category',
catspace = 'catspace',
-- Scans and Notices
author_Scans = 'Scans in',
author_Notices = 'Notices',
author_cat_birth_year = 'Birth in _year_',
author_cat_birth_secular = 'Birth in _secular_ secular',
author_cat_birth_epoch = 'Birth in _epoch_',
-- Error messages
err_error_list_head = "Error while displaying this template :",
err_internal_argument_unknown = 'Error: parameter "<b>_X1X_</b>" is unknown in this template. Check the name or flag this gap.',
err_value_re_defined = "Error : the value of the argument <b>_X1X_</b> is already defined. Choose only one argument and value.",
err_value_missing = "Error : This argument is required but absent : <b>_X1X_</b>. Should define it.",
err_none_value = "Erreur : Error : No argument has been defined.",
err_internal_notice_wsid = "Internal Error: Report that the internal argument <b>_X1X_</b> is unknown in the records.",
}
-- Trad['es'] = {
-- This repair a Lua bug : Trad[arg_lang]["options"] = value give an error
Trad.es = {
-- Arguments from frame:getParent()
c = 'c',
options = 'options',
lastname = 'nombre',
initiale = 'initiale',
familyname = 'primernombre',
firstname = 'apellido',
pseudonym = 'apodo',
title = 'título',
Galliname = 'apellidoGalli',
sex = 'sexo',
sortkey = 'especie clave',
image = 'imagen',
birthyear = 'año de nacimiento',
birth = 'nacimiento',
birthcentury = 'siglo de nacimiento',
birthuncertain = 'nacimiento incierto',
deathyear = 'año de la muerte',
death = 'muerte',
deathcentury = 'siglo de la muerte',
deathuncertain = 'muerte incierto',
description = 'descripción',
occupation = 'profesión',
genre = 'tipo',
language = 'lengua',
country = 'país',
prize = 'premio',
rights = 'derechos',
wikipedia = 'wikipedia',
wikiquote = 'wikiquote',
commons = 'commons',
commonscat = 'commonscat',
namespace = 'espacio',
category = 'Categoría',
catspace = 'catespacio',
-- Scans and Notices
author_Scans = 'Escanea en',
author_Notices = 'Avisos',
author_cat_birth_year = 'Naissance en _year_',
author_cat_birth_secular = 'Naissance au _secular_ siècle',
author_cat_birth_epoch = 'Birth in _epoch_',
-- Los mensajes de error
err_error_list_head = "Error mientras se muestra este modelo :",
err_internal_argument_unknown = 'Error: El parámetro "<b>_X1X_</b>" es desconocido en este modelo. Compruebe el nombre o marca esta brecha.',
err_value_re_defined = "Error : el valor del argumento <b>_X1X_</b> ya se ha definido. Elige uno sólo argumento y valor.",
err_value_missing = "Error : Este argumento es necesario pero ausente : <b>_X1X_</b>. Debe definir.",
err_none_value = "Error : Ningún argumento ha sido definido.",
err_internal_notice_wsid = "Error interno: Informe que el argumento interno <b>_X1X_</b> es desconocida en los registros.",
}
-- Trad['fr'] = {
-- This repair a Lua bug : Trad[arg_lang]["options"] = value give an error
Trad.fr = {
-- Arguments from frame:getParent()
c = 'c',
options = 'options',
lastname = 'nom',
initiale = 'initiale',
familyname = 'nomfamille',
firstname = 'prénom',
pseudonym = 'pseudo',
title = 'titre',
Galliname = 'prénomGall',
sex = 'sexe',
sortkey = 'cle',
image = 'image',
birthyear = 'anneeNaissance',
birth = 'naissance',
birthcentury = 'siecleNaissance',
birthuncertain = 'incertitudeNaissance',
deathyear = 'anneeDeces',
death = 'deces',
deathcentury = 'siecleNaissance',
deathuncertain = 'incertitudeDeces',
description = 'description',
occupation = 'metier',
genre = 'genre',
language = 'langue',
country = 'pays',
prize = 'prix',
rights = 'droits',
wikipedia = 'wikipedia',
wikiquote = 'wikiquote',
commons = 'commons',
commonscat = 'commonscat',
namespace = 'espace',
category = 'Category',
catspace = 'catspace',
-- Scans and Notices
author_Scans = 'Scans sur',
author_Notices = 'Notices',
author_cat_birth_year = 'Naissance en _year_',
author_cat_birth_secular = 'Naissance au _secular_ siècle',
author_cat_birth_epoch = 'Birth in _epoch_',
-- Messages d'erreur
err_error_list_head = 'Erreurs ou remarques sur les paramètres de ce modèle :',
err_internal_argument_unknown = 'Erreur : ce paramètre "<b>_X1X_</b>" est inconnu dans ce modèle. Vérifier ce nom ou signaler ce manque.',
err_value_re_defined = "Erreur : la valeur de l'argument <b>_X1X_</b> est déjà définie. Choisir un seul argument et une seule valeur.",
err_value_missing = "Erreur : Cet argument est nécessaire mais absent : <b>_X1X_</b>. Il faut le définir.",
err_none_value = "Erreur : Aucun argument n'a été défini.",
err_internal_notice_wsid = "Erreur interne : Signalez que l'argument interne <b>_X1X_</b> est inconnu dans les notices.",
} -- Trad
local arg_lang = "fr" -- {{CONTENTLANG}} -- = ":" to display a category to document it rather than truly categorize
-- Trad[arg_lang] = { }
-- Trad[arg_lang]["options"] = " "
local args_trad = { } -- Trad[arg_lang] -- translation of template identifier and texts
if arg_lang == "en" then args_trad = Trad_en end
if arg_lang == "es" then args_trad = Trad_es end
if arg_lang == "fr" then args_trad = Trad_fr end
local args_val = nil -- direct acces to values of arguments and parameters linked
local args_source = nil -- arguments sources au niveau du module
function Trad.txt(key) -- give the translation of indentified texts, or arguments indentifier, or errors messages
local t = args_trad[key]
if t == nil then t="" end
return t
end
function Trad.init_lang(_lang)
-- if Trad.init_lang(_lang) == _lang then OK
-- en : init or change the language and its table
-- es : inicializar o cambiar el idioma y su mesa
-- fr : initialiser ou modifier la langue et sa table
local args_table = nil
if type(_lang) ~= "string" then return nil end
-- args_table = Trad[_lang]
-- This repair a Lua bug : Trad[arg_lang]["options"] = value give an error
-- if _lang == "en" then args_table = Trad_en end
-- if _lang == "es" then args_table = Trad_es end
-- if _lang == "fr" then args_table = Trad_fr end
if _lang == "en" then args_table = Trad.en end
if _lang == "es" then args_table = Trad.es end
if _lang == "fr" then args_table = Trad.fr end
if type(args_table) == "table" then
arg_lang = _lang
args_trad = args_table
return arg_lang
else
return nil
end
end
local local_erreurs = { } -- collecte de toutes les erreurs
local erreur_add = function(wt_ref, v1, v2, v3, v4, v5)
-- erreur_add("err_value_re_defined", k, key, xyz) -- pick wt_ref, replace _XnX_ by vN, keep error text
if type(wt_ref) ~= "string" then return "" end
-- if args_trad == nil then args_trad = Trad[arg_lang] end -- translation of template identifier and texts end
local wt = args_trad[wt_ref]
wt = tostring(wt)
if v1 ~= nil then wt = string.gsub(wt, "_X1X_", tostring(v1) ) end
if v2 ~= nil then wt = string.gsub(wt, "_X2X_", tostring(v2) ) end
if v3 ~= nil then wt = string.gsub(wt, "_X3X_", tostring(v3) ) end
if v4 ~= nil then wt = string.gsub(wt, "_X4X_", tostring(v4) ) end
if v4 ~= nil then wt = string.gsub(wt, "_X5X_", tostring(v5) ) end
table.insert(local_erreurs, wt)
return wt
end
local erreur_lister = function(titre)
local erreurs_wt = ""
if type(titre) ~= "string" then
titre = args_trad["err_error_list_head"]
end
for i, err in pairs(local_erreurs) do -- Pour tous les parametres connus
if err ~= "nil" then
erreurs_wt = erreurs_wt .. '⦁ ' .. '<span style="color:red;" >' .. tostring(err) .. '</span>' .. '<br/>'
end
end
if erreurs_wt == "" then return "" end
if type(titre) == "string" then erreurs_wt = '<br/>' .. titre .. '<br/>' .. erreurs_wt end
return erreurs_wt
end
local Argts = {
args_known_default = { -- wsdata translations
-- Argts in order without names, with their keyword for use as others arguments
-- Argts dans l'ordre, non nommés, avec leur keyword pour traitement comme les autres arguments
--[ [
"lastname", -- 1
"firstname", -- 2
"birthyear", -- 3
"deathyear", -- 4
--] ]
-- The arguments for authority records are treated separately
-- Les arguments pour les notices d'autorités sont traités à part
-- special arguments to modify the fonctions and outputs of this module
-- arguments speciaux pour modifier le fonctionnement et les sorties de ce module
c = {val = "", typ = "opt", need = "0", list = 1,
keyword = "c", old = "ws-catview"},
options = {val = "", typ = "opt", need = "0", list = 1,
keyword = "options", old = "ws-options"},
-- All arguments have a keyword parameter identical to the registration name, except synonyms
-- Tous les arguments ont un parametre keyword identique au nom d'enregistrement, sauf les synonymes
lastname = {val = "", typ = "dat", need = "1", list = 2,
keyword = "lastname", old = "ws-name"},
initiale = {val = "", typ = "dat", need = "1", list = 2,
keyword = "initiale", old = "ws-initiale"},
familyname = {val = "", typ = "dat", need = "0", list = 9,
keyword = "familyname", old = "ws"},
firstname = {val = "", typ = "dat", need = "0", list = 2,
keyword = "firstname", old = "ws-firstname"},
pseudonym = {val = "", typ = "ctr", need = "0", list = 9,
keyword = "pseudonym", old = "ws"},
title = {val = "", typ = "dat", need = "0", list = 9,
keyword = "title", old = "ws"},
Galliname = {val = "", typ = "dat", need = "0", list = 9,
keyword = "Galliname", old = "ws-firstgall"},
sex = {val = "", typ = "dat", need = "0", list = 9,
keyword = "sex", old = "sexe"},
sortkey = {val = "", typ = "dat", need = "0", list = 9,
keyword = "sortkey", old = "ws-key"},
image = {val = "", typ = "ctr", need = "0", list = 2,
keyword = "image", old = "ws-image"},
birthyear = {val = "", typ = "dat", need = "0", list = 2,
keyword = "birthyear", old = "ws-naissance ws_birthdate"},
birth = {val = "", typ = "syn", need = "0", list = 1,
keyword = "birthyear", old = "ws-naissance"},
birthcentury = {val = "", typ = "dat", need = "0", list = 2,
keyword = "birthcentury", old = "siecleNaissance"},
birthuncertain ={val = "", typ = "dat", need = "0", list = 3,
keyword = "birthuncertain", old = "incertitudeNaissance"},
deathyear = {val = "", typ = "dat", need = "0", list = 2,
keyword = "deathyear", old = "ws-deces ws_deathdate"},
death = {val = "", typ = "syn", need = "0", list = 1,
keyword = "deathyear", old = "ws-deces"},
deathcentury = {val = "", typ = "dat", need = "0", list = 2,
keyword = "deathcentury", old = "siecleNaissance"},
deathuncertain ={val = "", typ = "dat", need = "0", list = 3,
keyword = "deathuncertain", old = "incertitudeDeces"},
description = {val = "", typ = "ctr", need = "0", list = 1,
keyword = "description", old = "ws_description"},
occupation = {val = "", typ = "ctr", need = "0", list = 3,
keyword = "occupation", old = "ws-metier"},
genre = {val = "", typ = "ctr", need = "0", list = 3,
keyword = "genre", old = "ws-genre"},
language = {val = "", typ = "ctr", need = "0", list = 3,
keyword = "language", old = "ws-language"},
country = {val = "", typ = "ctr", need = "0", list = 3,
keyword = "country", old = "ws-country"},
prize = {val = "", typ = "ctr", need = "0", list = 4,
keyword = "prize", old = "ws-prix"},
rights = {val = "", typ = "ctr", need = "0", list = 1,
keyword = "rights", old = "rights"},
wikipedia = {val = "", typ = "ctr", need = "0", list = 2,
keyword = "wikipedia", old = "ws-wikipedia"},
wikiquote = {val = "", typ = "ctr", need = "0", list = 2,
keyword = "wikiquote", old = "ws-wikiquote"},
commons = {val = "", typ = "ctr", need = "0", list = 2,
keyword = "commons", old = "ws-commons"},
commonscat = {val = "", typ = "ctr", need = "0", list = 3,
keyword = "commonscat", old = "ws-commons-category"},
namespace = {val = "", typ = "ctr", need = "1", list = 4,
keyword = "namespace", old = "ws-namespace"},
category = {val = "", typ = "ctr", need = "0", list = 3,
keyword = "category", old = "ws-category"},
-- arguments for notices's properties
ARC = {val = "", typ = "not", need = "0", list = 3,
keyword = "ARC", old = "ws-ARC"},
ARCid = {val = "", typ = "not", need = "0", list = 3,
keyword = "ARCid", old = "ws-ARCid"},
ARCitem = {val = "", typ = "not", need = "0", list = 3,
keyword = "ARCitem", old = "ws-ARCitem"},
ARCorg = {val = "", typ = "not", need = "0", list = 3,
keyword = "ARCorg", old = "ws-ARCorg"},
ARCsub = {val = "", typ = "not", need = "0", list = 3,
keyword = "ARCsub", old = "ws-ARCsub"},
BNF = {val = "", typ = "not", need = "0", list = 3,
keyword = "BNF", old = "ws-BNF"},
GKD = {val = "", typ = "not", need = "0", list = 3,
keyword = "GKD", old = "ws-GKD"},
GKD_V1 = {val = "", typ = "not", need = "0", list = 3,
keyword = "GKD_V1", old = "ws-GKD-V1"},
IA = {val = "", typ = "not", need = "0", list = 3,
keyword = "IA", old = "ws-IA"},
ARCHIVE = {val = "", typ = "not", need = "0", list = 3,
keyword = "ARCHIVE", old = "ws-ARCHIVE"},
IBL = {val = "", typ = "not", need = "0", list = 3,
keyword = "IBL", old = "ws-IBL"},
IBLid = {val = "", typ = "not", need = "0", list = 3,
keyword = "IBLid", old = "ws-IBLid"},
IBLbook = {val = "", typ = "not", need = "0", list = 3,
keyword = "IBLbook", old = "ws-IBLbook"},
ISBN = {val = "", typ = "not", need = "0", list = 3,
keyword = "ISBN", old = "ws-ISBN"},
ISFDB = {val = "", typ = "not", need = "0", list = 3,
keyword = "ISFDB", old = "ws-ISFDB"},
ISFDBid = {val = "", typ = "not", need = "0", list = 3,
keyword = "ISFDBid", old = "ws-ISFDBid"},
ISFDBpub = {val = "", typ = "not", need = "0", list = 3,
keyword = "ISFDBpub", old = "ws-ISFDBpub"},
ISFDBtitle = {val = "", typ = "not", need = "0", list = 3,
keyword = "ISFDBtitle", old = "ws-ISFDBtitle"},
LCCN = {val = "", typ = "not", need = "0", list = 3,
keyword = "LCCN", old = "ws-LCCN"},
LT = {val = "", typ = "not", need = "0", list = 3,
keyword = "LT", old = "ws-LT"},
OCLC = {val = "", typ = "not", need = "0", list = 3,
keyword = "OCLC", old = "ws-OCLC"},
OL = {val = "", typ = "not", need = "0", list = 3,
keyword = "OL", old = "ws-OL"},
PND = {val = "", typ = "not", need = "0", list = 3,
keyword = "PND", old = "ws-PND"},
SELIBR = {val = "", typ = "not", need = "0", list = 3,
keyword = "SELIBR", old = "ws-SELIBR"},
SUDOC = {val = "", typ = "not", need = "0", list = 3,
keyword = "SUDOC", old = "ws-SUDOC"},
SWD = {val = "", typ = "not", need = "0", list = 3,
keyword = "SWD", old = "ws-SWD"},
ULAN = {val = "", typ = "not", need = "0", list = 3,
keyword = "ULAN", old = "ws-ULAN"},
VIAF = {val = "", typ = "not", need = "0", list = 3,
keyword = "VIAF", old = "ws-VIAF"},
WORLDCATID = {val = "", typ = "not", need = "0", list = 3,
keyword = "WORLDCATID", old = "ws-WORLDCATID"},
XXX = {val = "", typ = "not", need = "0", list = 3,
keyword = "XXX", old = "ws-XXX"},
-- arguments managed only by program, not read from template
-- prm.arg_memorize("catspace", frame:preprocess("{{ns:Category}}")) -- memorize the localized namespace "Category"
catspace = {val = "", typ = "prg", need = "0", list = 9,
keyword = "catspace", old = "catspace"},
}, -- local Argts args_known_default
--[[ nameList of notices's properties
-->|ARCid|ARCitem|ARCorg|ARCsub<!--
-->|ARC=National Archives and Records Administration<!--
-->|BNF=Bibliothèque nationale de France<!--
-->|GKD|GKD-V1=Gemeinsame Kšrperschaftsdatei<!--
-->|IA|ARCHIVE=Internet Archive<!--
-->|IBL|IBLid|IBLbook=Internet Book List<!--
-->|ISBN=International Standard Book Number<!--
-->|ISFDBid|ISFDBpub|ISFDBtitle<!--
-->|ISFDB=Internet Speculative Fiction Database<!--
-->|LCCN=Numéro de contrôle de la Bibliothèque du Congrès<!--
-->|LT=Library Thing<!--
-->|OCLC=Online Computer Library Center<!--
-->|OL=Open Library<!--
-->|PND=Personennamendatei<!--
-->|SELIBR=National Library of Sweden<!--
-->|SUDOC=Système universitaire de documentation<!--
-->|SWD=Schlagwortnormdatei<!--
-->|ULAN=Union List of Artist Names<!--
-->|VIAF=Fichier d'autorité international virtuel<!--
-->|WORLDCATID=WorldCat<!--
-->|XXX=XXX autorité<!--
-->|#default={{{wp|{{{3|}}} }}} <!--
--]]
args_source_example = { categoryEN = "cat author", imageEN = "Smith.jpg", prize = "Nobel", categorie = "catAuteur", image = "Franc.jpg", prix = "NobelFr", categoria = "catAuteur", imagen = "Espangnol.jpg", premio = "NobelES", },
args_known = nil,
args_source = nil,
-- prototype = {args_known = Argts.args_known_default, args_source = Argts.args_source_example, arg_lang = {{CONTENTLANG}}, },
mt = {},
mt_index = function (table, key)
return Argts.prototype[key]
end,
} -- Argts object
function Argts.prototype()
Argts.args_known = Argts.args_known_default
Argts.args_source = Argts.args_source_example
arg_lang = {{CONTENTLANG}}
end
function Argts.new(o) -- create a new object from the class Argts
-- see : Objects Classes http://www.lua.org/pil/16.1.html
-- see : The __index Metamethod http://www.lua.org/pil/13.4.1.html
-- function Account:new (obj)
o = o or {} -- create object if user does not provide one
-- o.__index = Argts
o.mt = {}
o.mt.__index = mt_index
setmetatable(o, Argts.mt) -- self is a prototype for o
return o
end
-- local current_space = mw.site.namespaces.name -- present namespace from system
local current_space = "" -- frame:preprocess("{{ns:0}}") -- Module namespace from system
local module_space = "" -- frame:preprocess("{{ns:Module}}") -- Module namespace from system
local template_space = "" -- frame:preprocess("{{ns:Template}}") -- Template namespace from system
local author_space = "" -- frame:preprocess("{{ns:Author}}") -- Category namespace from system
local category_space = "" -- frame:preprocess("{{ns:Category}}") -- Category namespace from system
function Argts.args_init(_known, _source, _lang) -- initialize all the values to "" in arg table
-- args_init(args_known, args_source, "fr")
local args_known = Argts.args_known
local args_source = Argts.args_source_example -- arguments sources au niveau du module
-- category_space = frame:preprocess("{{ns:Category}}") -- {{ns:Category}}
-- prm.arg_memorize("catspace", frame:preprocess("{{ns:Category}}")) -- memorize the localized namespace "Category"
trck('<br/>* args_init default args_known_default=' .. tostring(Argts.args_known_default) )
trck(', args_known=' .. tostring(args_known) )
trck(', args_source_example=' .. tostring(Argts.args_source_example) )
trck(', Argts.args_source=' .. tostring(args_source) )
trck(', Argts["args_source"]=' .. tostring(Argts["args_source"]) )
trck(', module.args_source_example.image=' .. tostring(Argts["args_source_example"]["image"]) )
trck('<br/> current_space=' .. tostring(current_space) )
trck(', module_space=' .. tostring(module_space) )
trck(', template_space=' .. tostring(template_space) )
trck(', author_space=' .. tostring(author_space) )
trck(', category_space=' .. tostring(category_space) )
trck(', arg_lang=' .. tostring(arg_lang) )
if _known ~= nil then
args_known = _known
Argts.args_known = args_known
end
if _source ~= nil then
args_source = _source
Argts.args_source = _source
end
-- arg_lang = {{CONTENTLANG}} -- langue du wiki par defaut
Trad.init_lang( {{CONTENTLANG}} )
--if type(_lang) == "string" then
-- arg_lang = _lang
--end
--if arg_lang == "en" then args_trad = Trad_en end
--if arg_lang == "es" then args_trad = Trad_es end
--if arg_lang == "fr" then args_trad = Trad_fr end
-- if type(_lang) == "string"
-- then arg_lang = _lang
-- else arg_lang = {{CONTENTLANG}} end
-- if option("en") then arg_lang = "en" end
-- if option("es") then arg_lang = "es" end
-- if option("fr") then arg_lang = "fr" end
-- args_trad = Trad[arg_lang]
trck('<br/>* args_init usual args_known=' .. tostring(Argts.args_known) )
trck(', module.args_source.image=' .. tostring(args_source["image"]) )
trck(', arg_lang=' .. tostring(arg_lang) )
trck(', catspace=' .. tostring(category_space) )
trck(', author_space=' .. tostring(author_space) )
end -- Argts.args_init(_known, _source, _lang)
function Argts.arg_memorize(argname, argval, tr) -- memorize the value in local table
-- arg_memorize("firstname", "Victor")
local args_known = Argts.args_known
if tr ~= nil then trck(', arg_memorize call argname='..argname..', argval='..argval) end
if argname == nil then return "" end
if argval == nil then return "" end
local arg_to_mem = args_known[argname]
if arg_to_mem == nil then return "" end
arg_to_mem["val"] = argval
local keyword = arg_to_mem["keyword"]
return argname, argval
end -- Argts.arg_memorize(argname, argval, tr)
function Argts.argv(argname, tr) -- read arg value from local data, tr = with debug track
-- arg = Argts.argv("name") -- read the argument from local memory, no matter the language of the wiki
-- arg = Argts.argv("name", "tr") -- the same, with a text track of the debug
local args_known = Argts.args_known
if tr ~= nil then trck(', argv call argname='..tostring(argname) ) end
if type(argname) ~= "string" then return "" end
if args_known[argname] == nil then return "" end
--[[
if args_known[argname]["typXXX"] == "dat" then
local keyword = args_known[argname]["keyword"]
if tr ~= nil then trc=trc..', dat keyword='..tostring(keyword) end
if keyword == nil then return "" end
local _known = tostring(args_known[argname]["val"])
local _data = tostring(Argts.argv(keyword))
if tr ~= nil then trc=trc..', _known='.._known..', _data='.._data end
return Argts.argv(keyword)
end
if args_known[argname]["typXXX"] == "ctr" then
local keyword = args_known[argname]["keyword"]
if tr ~= nil then trc=trc..', ctr keyword='..tostring(keyword) end
if keyword == nil then return "" end
local _known = tostring(args_known[argname]["val"])
local _ctr = tostring(Argts.argv(keyword))
if tr ~= nil then trc=trc..', _known='.._known..', _ctr='.._ctr end
return Argts.argv(keyword)
end
if args_known[argname]["typXXX"] == "xxx" then
local keyword = args_known[argname]["keyword"]
if tr ~= nil then trc=trc..', ctr val='..Argts.argv(keyword) end
return Argts.argv(keyword)
end
--]]
return args_known[argname]["val"] or ""
end -- Argts.argv(argname, tr)
function Argts.arg_input(args_src, argname, tr)
-- multilingual read an arg from the template, memorize it, tr = with debug track
-- arg_input(args_src, "firstname")
-- verify params, and convert nil to ""
local args_known = Argts.args_known
if args_src == nil then args_src = Argts.args_source end
if tr ~= nil then trck(', _known='.._known..', _ctr='.._ctr) end
local max = table.getn(args_src)
if tr ~= nil then trck('<br/>* arg_input '..', args_known_default='..tostring(Argts.args_known_default)..', args_known='..tostring(args_known)..', args_src='..tostring(args_src)..', max='..tostring(max) ) end
local max = table.getn(args_src)
if tr ~= nil then trck('<br/>* arg_input max='..tostring(max)..', argname='..tostring(argname) ) end
if type(argname) ~= "string" then argname = "" end
if tr ~= nil then trck(', argname?='..tostring(argname) ) end
if argname == "" then return "" end
-- MW.log( ' arg_input argname='..tostring(argname)..', arg_lang='..tostring(arg_lang) ) -- trace to console
local argname_ = args_known[argname]
if tr ~= nil then trck(', args_known[argname]='..tostring(args_known[argname]) ) end
if argname_ == nil then return "" end
arglingual = args_trad[argname] -- multilingual name of the arg in the template
if type(arglingual) ~= "string" then arglingual = argname end
if tr ~= nil then trck(', arglingual?='..tostring(arglingual) ) end
if type(arglingual) ~= "string" then arglingual = "" end
if arglingual == "" then return "" end
if tr ~= nil then trck(', arglingual='..tostring(arglingual) ) end
local argval = args_src[arglingual] -- multilingual read the arg from the template
if type(argval) ~= "string" then argval = "" end
if tr ~= nil then trck(', argval='..tostring(argval) ) end
Argts.arg_memorize(argname, argval) -- memorize the value in local table
return trc
-- local t = Trad[arg_lang][argname]
end -- function Argts.arg_input(args_src, argname, tr)
function Argts.args_import_all(args_src, args_kwn)
-- import all arguments from template, or other source
-- Argts.args_import_all(Argts.args_source_example, Argts.args_known_default)
local err, er1, t2 = "", "", ""
local key, argval = "kkk", "xxx"
local argknw, arglingual = nil, ""
-- This repair a Lua bug : Argts.any_function or Argts.any_table disappears
if args_src == nil then args_src = Argts.args_source end
if args_kwn == nil then args_kwn = Argts.args_known_default end
if arg_input == nil then arg_input = Argts.arg_input end
if args_kwn == nil then return " args_kwn=nil " end
if args_src == nil then return " args_src=nil " end
local max = table.getn(args_kwn)
-- args_trad = Trad[arg_lang] -- translation of template identifier and texts
-- if arg_lang == "en" then args_trad = Trad_en end
-- if arg_lang == "es" then args_trad = Trad_es end
-- if arg_lang == "fr" then args_trad = Trad_fr end
Trad.init_lang(arg_lang)
trck('<br/>* args_import_all '..', args_known_default='..tostring(Argts.args_known_default) )
trck(', args_known='..tostring(args_known)..', args_kwn='..tostring(args_kwn) )
trck(', args_source='..tostring(args_source)..', args_src='..tostring(args_src) )
trck(',<br/>* arg_lang=' .. tostring(arg_lang) )
trck(', max='..tostring(max) )
trck(', catspace=' .. tostring(category_space) )
trck(', author_space=' .. tostring(author_space) )
local arg_found, key_found = false, false
for k, parm in pairs(args_kwn) do -- Pour tous les parametres connus
if type(parm) == "string" then -- args en ordre numerique et renvoi vers un argument nommé
key = tostring(parm)
k = k
t2 = " " .. tostring(k) .. "-"
else
key = tostring(parm["keyword"])
k = 0
t2 = ""
end -- parm["keyword"] end
arglingual = tostring(args_trad[key]) -- args_trad OK
if arglingual == "nil" then arglingual = key end
argknw = args_kwn[key]
if argknw == nil then
err = err .. erreur_add("err_internal_argument_unknown", arglingual)
else
local val_prec = tostring(argknw["val"]) -- valeur deja definie
Argts.arg_input(args_src, key) -- multilingual read an arg
local val = tostring(Argts.argv(key, tr))
-- trck( tostring(arglingual) .. ":" )
if val_prec ~= "" then
err = err .. erreur_add("err_value_re_defined", arglingual)
end
if k == 0 then -- pour les arguments nommés
argval = tostring(argknw["val"])
else -- pour les arguments dans l'ordre
argval = val
end
trck(', '..t2..tostring(key)..'['..tostring(arglingual)..']')
if argknw["typ"] == "prg" then
-- arguments managed only by program, but read from template
trck("<b>"..tostring(argval) .. "</b> . . . " )
arg_found = true
else
if type(argval) == "string" then
if key == "options" then
trck_on = option("track")
local_options = argval
trck(" local_options="..tostring(local_options).." argval=")
if option("en") then Trad.init_lang("en") end
if option("en") then Trad.init_lang("es") end
if option("en") then Trad.init_lang("fr") end
end
trck("<b>"..tostring(argval) .. "</b> . . . " )
arg_found = true
end
end
argneed = tostring(argknw["need"])
if (argval == "") and (argneed == "1") then
err = err .. erreur_add(err_value_missing, arglingual.."++")
end
end
end
if arg_found == false then
err = err .. erreur_add(err_none_value)
end
-- local_erreurs = local_erreurs .. err -- collecte de toutes les erreurs
if option("erreurs", debug_options) then trck(err) end
trck("<br/>")
return err
end -- function Argts.args_import_all(args_src, args_kwn)
function Argts.generDoc1(paramName, k, paramData, opt)
-- t = t .. generDoc1("nom", "ws-name", "docligne docdef")
-- Normaliser les parametres et signaler les erreurs
-- Toujours afficher quelque chose dans la documentation du module ou du modèle.
-- t = t .. " [" .. tostring(argknw) .. "/L=" .. tostring(arglingual) .. "/V=<big><b>" .. tostring(val) .. "</b></big>] ."
if type(paramName) ~= "string" then
paramName = " paramName ? "
end -- signaler l'erreur
if type(paramData) ~= "string" then paramData = " paramData ? " end -- paramètre vide, non défini
opt = " "..tostring(opt).." " -- transparent, sinon peut donner nil, non génant
-- former le texte à afficher
local retourLigne = "" -- "<br/>"
local t2=" "..tostring(k) -- .."-"
if option("docligne", opt) then retourLigne = "" end
if option("docdef", opt) and (paramData == "") then return "" end
if k ~= 0 then paramName = t2 end -- pour les parametres non nommés
return " | " .. paramName .. " = <b>" .. paramData .. "</b>" .. retourLigne
end -- function Argts.generDoc1(paramName, paramId, opt)
local Argtest = { "Rimbaud", "Arthur", options = " debug fr docavant ", 1234, droits = "70", droits = "non", gauche = "ggcchh", deces = "1357", anneeDeces = "1842", image = "Carjat Arthur Rimbaud 1872 n2.jpg", pays = "France" }
function Argts.generDoc(opt)
-- Gérer des paramètres pour la documentation du module
-- "docmax" tous les paramètres existants
-- "docmin" quelques paramètres de base
-- "docdef" seulement les paramètres définis, ayant une valeur non nulle
-- "docnotice" generer les doc des notices
-- "docligne" mettre tous les paramètres sur une seule ligne
-- This repair a Lua bug : Argts.any_function or Argts.any_table disappears
local args_kwn = Argts.args_known_default
local key, argknw, argval = "", "", ""
local t, val = "", ""
local lst = true
t = t .. "<br/>{{Auteur"
for k, parm in pairs(args_kwn) do -- Pour tous les parametres connus
val = ""
if type(parm) == "string" then -- args en ordre numerique et renvoi vers un argument nommé
key = tostring(parm)
k = k
else
key = tostring(parm["keyword"])
k = 0
end -- parm["keyword"] end
argknw = args_kwn[key]
-- arglingual = tostring(Trad.txt(key))
arglingual = tostring(args_trad[key]) -- multilingual name of the arg in the template
if arglingual == "nil" then arglingual = key end
-- if arglingual type(Argts[key]) == "table" then
-- if Argts[key]["typ"] == "not" then arglingual = key end
-- t = t .. ":" .. tostring(arglingual)
-- end
val = tostring(argknw["val"])
lst = false
if option("docmin", opt) and (parm["list"] == 1) then lst = true end
if option("docdef", opt) and (val ~= "") then lst = true end
if option("docmax", opt) then lst = true end
-- t = t .. Argts.generDoc1(arglingual, val, opt)
lst = true
if lst then -- lister arg si autorisé
t = t .. Argts.generDoc1(arglingual, k, val, opt)
end
end
t = t .. "}}<br/><br/>"
-- if option("erreurs", debug_options) then t = t .. '<span style="color:red;" >' .. local_erreurs .. '</span>' end
return t
end -- function Argts.generDoc(opt)
local notices_properties = { -- Table of notices's properties, to automate them
-- REF_0 = reference en un seul numéro comme "cb11888266r"
-- REF_1/REF_2/REF_3 = reference en trois parties comme "123/456/789 ou "Hugo/Victor/Victor André"
{base = "ARC", _id = "ARC", _wsid = "ws-ARC", _sauf = "", _space = "", _type = "",
text = "National Archives and Records Administration",
wptx = "National%%20Archives%%20and%%20Records%%20Administration",
_link= "http://arcweb.archives.gov/arc/action/ExternalPersonIdSearch?id=REF_0"},
{base = "ARC", _id = "ARCgeo", _wsid = "ws-ARCgeo", _sauf = "", _space = "", _type = "Geo",
text = "National Archives and Records Administration",
wptx = "National%%20Archives%%20and%%20Records%%20Administration",
_link= "http://arcweb.archives.gov/arc/action/ExternalPersonIdSearch?id=REF_0"},
{base = "ARC", _id = "ARCid", _wsid = "ws-ARCid", _sauf = "", _space = "", _type = "Auteur",
text = "National Archives and Records Administration",
wptx = "National%%20Archives%%20and%%20Records%%20Administration",
_link= "http://arcweb.archives.gov/arc/action/ExternalPersonIdSearch?id=REF_0"},
{base = "ARC", _id = "ARCitem", _wsid = "ws-ARCitem", _sauf = "", _space = "", _type = "Book",
text = "National Archives and Records Administration",
wptx = "National%%20Archives%%20and%%20Records%%20Administration",
_link= "http://arcweb.archives.gov/arc/action/ExternalPersonIdSearch?id=REF_0"},
{base = "ARC", _id = "ARCorg", _wsid = "ws-ARCorg", _sauf = "", _space = "", _type = "Org",
text = "National Archives and Records Administration",
wptx = "National%%20Archives%%20and%%20Records%%20Administration",
_link= "http://arcweb.archives.gov/arc/action/ExternalPersonIdSearch?id=REF_0"},
{base = "ARC", _id = "ARCsub", _wsid = "ws-ARCsub", _sauf = "", _space = "", _type = "Auteur",
text = "National Archives and Records Administration",
wptx = "National%%20Archives%%20and%%20Records%%20Administration",
_link= "http://arcweb.archives.gov/arc/action/ExternalPersonIdSearch?id=REF_0"},
{base = "ARC", _id = "ARCHIVE", _wsid = "ws-ARCsub", _sauf = "", _space = "", _type = "Auteur",
text = "National Archives and Records Administration",
wptx = "National%%20Archives%%20and%%20Records%%20Administration",
_link= "http://www.archive.org/details/REF_0"},
{base = "BNF", _id = "BNF", _wsid = "BNF", _sauf = "", _space = "", _type = "Auteur",
text = "Bibliothèque nationale de France",
wptx = "Biblioth%%C3%%A8que%%20nationale%%20de%%20France",
_link= "http://catalogue.bnf.fr/ark:/12148/REF_0"},
{base = "DNB", _id = "DNB", _wsid = "DNB", _sauf = "", _space = "", _type = "Auteur",
text = "Bibliothèque nationale allemande",
wptx = "Biblioth%%C3%%A8que%%20nationale%%20allemande",
_link= "http://d-nb.info/gnd/REF_0"},
{base = "GKD", _id = "GKD", _wsid = "GKD", _sauf = "", _space = "", _type = "Auteur",
text = "Bibliothèque nationale allemande",
wptx = "Biblioth%%C3%%A8que%%20nationale%%20allemande",
_link= "http://d-nb.info/gnd/REF_0"},
{base = "GKD", _id = "GKD-V1", _wsid = "GKD-V1", _sauf = "", _space = "", _type = "Auteur",
text = "Bibliothèque nationale allemande",
wptx = "Biblioth%%C3%%A8que%%20nationale%%20allemande",
_link= "http://d-nb.info/gnd/REF_0"},
{base = "IA", _id = "ARCHIVE", _wsid = "IA", _sauf = "", _space = "", _type = "Auteur",
text = "Internet Archive",
wptx = "Internet%%20Archive",
_link= "http://www.archive.org/REF_0"},
{base = "IA", _id = "IA", _wsid = "IA", _sauf = "", _space = "", _type = "Auteur",
text = "Internet Archive",
wptx = "Internet%%20Archive",
_link= "http://www.archive.org/REF_0"},
{base = "IBL", _id = "IBL", _wsid = "IBL", _sauf = "", _space = "", _type = "Auteur",
text = "Internet Archive",
wptx = "Internet%%20Archive",
_link= "http://www.iblist.com/bookREF_0.html"},
{base = "IBL", _id = "IBLbook", _wsid = "IBLbook", _sauf = "", _space = "", _type = "Auteur",
text = "Internet Archive",
wptx = "Internet%%20Archive",
_link= "http://www.iblist.com/bookREF_0.html"},
{base = "IBL", _id = "IBLid", _wsid = "IBLid", _sauf = "", _space = "", _type = "Auteur",
text = "Internet Book List", -- Pas de page fr, en redirige vers Base de données bibliographiques
wptx = "Internet%%20Archive",
_link= "http://www.iblist.com/authorREF_0.html"},
--[[
linkList
pour memoire, pour chaque nomlien : [ [Catégorie:Nota{{{nomlien|{{{1|}}} }}}] ]
-->|ISBN=http://fr.wikisource.org/wiki/Spécial:Ouvrages_de_référence/{{{code|{{{2|}}} }}}<!--
-->|ISFDBid=http://www.isfdb.org/cgi-bin/ea.cgi?{{{code|{{{2|}}} }}}<!-- Auteur:
-->|ISFDBpub=http://www.isfdb.org/cgi-bin/pl.cgi?{{{code|{{{2|}}} }}}<!--
-->|ISFDBtitle=http://www.isfdb.org/cgi-bin/title.cgi?{{{code|{{{2|}}} }}}<!--
-->|ISFDB=http://catalogue.bnf.fr/ark:/12148/{{{code|{{{2|}}} }}}<!--
--]]
--[[ nameList of notices's properties
-->|ARCid|ARCitem|ARCorg|ARCsub<!--
-->|ARC=National Archives and Records Administration<!--
-->|BNF=Bibliothèque nationale de France<!--
-->|GKD|GKD-V1=Gemeinsame Kšrperschaftsdatei<!--
-->|IA|ARCHIVE=Internet Archive<!--
-->|IBL|IBLid|IBLbook=Internet Book List<!--
-->|ISBN=International Standard Book Number<!--
-->|ISFDBid|ISFDBpub|ISFDBtitle<!--
-->|ISFDB=Internet Speculative Fiction Database<!--
-->|LCCN=Numéro de contrôle de la Bibliothèque du Congrès<!--
-->|LT=Library Thing<!--
-->|OCLC=Online Computer Library Center<!--
-->|OL=Open Library<!--
-->|PND=Personennamendatei<!--
-->|SELIBR=National Library of Sweden<!--
-->|SUDOC=Système universitaire de documentation<!--
-->|SWD=Schlagwortnormdatei<!--
-->|ULAN=Union List of Artist Names<!--
-->|VIAF=Fichier d'autorité international virtuel<!--
-->|WORLDCATID=WorldCat<!--
-->|XXX=XXX autorité<!--
-->|#default={{{wp|{{{3|}}} }}} <!--
--]]
{base = "ISNI", _id = "ISNI", _wsid = "ws-ISNI", _sauf = "", _space = "", _type = "Auteur",
text = "International Standard Name Identifier",
wptx = "International%%20Standard%%20Name%%20Identifier",
_link="http://isni.oclc.nl/DB=1.2/SET=10/TTL=1/CMD?ACT=SRCHA&IKT=8006&SRT=&TRM=REF_0"},
{base = "OCLC", _id = "OCLC", _wsid = "ws-OCLC", _sauf = "", _space = "", _type = "Auteur",
text = "Online Computer Library Center",
wptx = "Online%%20Computer%%20Library%%20Center",
_link="http://www.worldcat.org/oclc/REF_0"},
{base = "PND", _id = "PND", _wsid = "ws-PND", _sauf = "", _space = "Portail", _type = "Auteur",
text = "Personennamendatei",
wptx = "Personennamendatei",
_link="http://d-nb.info/gnd/REF_0"},
--[[
linkList
pour memoire, pour chaque nomlien : [ [Catégorie:Nota{{{nomlien|{{{1|}}} }}}] ]
-->|ARCgeo=http://arcweb.archives.gov/arc/action/ExecuteRelatedGeographicalSearch?id={{{code|{{{2|}}} }}}&relationship=AD_SUBJECT<!--
-->|ARC<!--
-->|ARCid=http://arcweb.archives.gov/arc/action/ExternalPersonIdSearch?id={{{code|{{{2|}}} }}}<!--
-->|ARCitem=http://arcweb.archives.gov/arc/action/ExternalIdSearch?id={{{code|{{{2|}}} }}}<!--
-->|ARCorg=http://arcweb.archives.gov/arc/action/ExecuteRelatedOrganizationSearch?id={{{code|{{{2|}}} }}}&relationship=AD_SUBJECT<!--
-->|ARCsub=http://arcweb.archives.gov/arc/action/ExecuteRelatedTopicalSubjectsSearch?id={{{code|{{{2|}}} }}}<!--
-->|ARCHIVE=http://www.archive.org/details/{{{code|{{{2|}}} }}}<!--
-->|BNF=http://catalogue.bnf.fr/ark:/12148/{{{code|{{{2|}}} }}}<!--
-->|DNB=http://d-nb.info/gnd/{{{code|{{{2|}}} }}}<!--
-->|GKD=http://d-nb.info/gnd/{{{code|{{{2|}}} }}}<!--
-->|GKD-V1=http://d-nb.info/gnd/{{{code|{{{2|}}} }}}<!--
-->|IA|ARCHIVE=http://catalogue.bnf.fr/ark:/12148/{{{code|{{{2|}}} }}}<!--
-->|IBL<!--
-->|IBLbook=http://www.iblist.com/book{{{code|{{{2|}}} }}}.html<!--
-->|IBLid=http://www.iblist.com/author{{{code|{{{2|}}} }}}.html<!--
-->|ISBN=http://fr.wikisource.org/wiki/Spécial:Ouvrages_de_référence/{{{code|{{{2|}}} }}}<!--
-->|ISFDBid=http://www.isfdb.org/cgi-bin/ea.cgi?{{{code|{{{2|}}} }}}<!-- Auteur:
-->|ISFDBpub=http://www.isfdb.org/cgi-bin/pl.cgi?{{{code|{{{2|}}} }}}<!--
-->|ISFDBtitle=http://www.isfdb.org/cgi-bin/title.cgi?{{{code|{{{2|}}} }}}<!--
-->|ISFDB=http://catalogue.bnf.fr/ark:/12148/{{{code|{{{2|}}} }}}<!--
-->|LCCN=http://id.loc.gov/authorities/names/{{ParmPart|1|{{{code|{{{2|}}} }}} }}{{ParmPart|2|{{{code|{{{2|}}} }}} }}{{padleft:{{ParmPart|3|{{{code|{{{2|}}} }}} }}|6|0}}.html<!--
-->|LCCNid=http://id.loc.gov/authorities/names/{{ParmPart|1|{{{code|{{{2|}}} }}} }}{{ParmPart|2|{{{code|{{{2|}}} }}} }}{{padleft:{{ParmPart|3|{{{code|{{{2|}}} }}} }}|6|0}}.html<!--
-->|LCCNbook=http://lccn.loc.gov/{{{code|{{{2|}}} }}}<!--
-->|LT=http://www.librarything.com/work/{{{code|{{{2|}}} }}}<!--
-->|NLA=http://nla.gov.au/anbd.aut-an{{{code|{{{2|}}} }}}<!--
-->|OCLC=http://www.worldcat.org/oclc/{{{code|{{{2|}}} }}}<!--
-->|OL=http://openlibrary.org/books/{{{code|{{{2|}}} }}}<!--
-->|PND=http://d-nb.info/gnd/{{{code|{{{2|}}} }}}<!--
-->|SELIBR=http://libris.kb.se/auth/{{{code|{{{2|}}} }}}<!--
-->|SUDOC=http://www.idref.fr/{{{code|{{{2|}}} }}}<!--
-->|SWD=http://d-nb.info/gnd/{{{code|{{{2|}}} }}}<!--
-->|ULAN=http://www.getty.edu/vow/ULANFullDisplay?find=&role=&nation=&subjectid={{{code|{{{2|}}} }}}<!--
-->|VIAF=http://viaf.org/viaf/{{{code|{{{2|}}} }}}<!--
-->|WORLDCAT=http://www.worldcat.org/search?qt=worldcat_org_all&q={{ParmPart|1|{{{code|{{{2|}}} }}} }}+{{ParmPart|2|{{{code|{{{2|}}} }}} }}<!-- http://www.worldcat.org/search?qt=worldcat_org_all&q=Alain+Fournier
-->|WORLDCATch=http://www.worldcat.org/search?q={{ParmPart|1|{{{code|{{{2|}}} }}} }}-{{ParmPart|2|{{{code|{{{2|}}} }}} }}&qt=owc_search<!-- http://www.worldcat.org/search?q=Alain-Fournier&qt=owc_search
-->|WORLDCATID=http://www.worldcat.org/identities/{{{code|{{{2|}}} }}}<!--
-- http://www.worldcat.org/search?q=Alain-Fournier&qt=owc_search
-- http://www.worldcat.org/search?qt=worldcat_org_all&q=Alain+Fournier
-->|XXX=http://catalogue.bnf.fr/ark:/12148/{{{code|{{{2|}}} }}}[ [Catégorie:Nota{{{nomlien|{{{1|xxx}}} }}}] ]<!--
-->|#default=http://fr.wikisource.org/wiki/Modèle:Notice_Autorité<!--
--]]
--[[
wsdata["ws-ARC"] = args.ARC
wsdata["ws-ARCgeo"] = args.ARCgeo
wsdata["ws-ARCid"] = args.ARCid
wsdata["ws-ARCitem"] = args.ARCitem
wsdata["ws-ARCorg"] = args.ARCorg
wsdata["ws-ARCsub"] = args.ARCsub
wsdata["ws-ARCHIVE"] = args.ARCHIVE
wsdata["ws-BNF"] = args.BNF
wsdata["ws-GKD"] = args.GKD
wsdata["ws-GKD-V1"] = args["GKD-V1"]
wsdata["ws-IA"] = args.IA
wsdata["ws-IBL"] = args.IBL
wsdata["ws-IBLbook"] = args.IBLbook
wsdata["ws-IBLid"] = args.IBLid
wsdata["ws-ISBN"] = args.ISBN
wsdata["ws-ISNI"] = args.ISNI
wsdata["ws-LCCN"] = args.LCCN
wsdata["ws-OCLC"] = args.OCLC
wsdata["ws-NLA"] = args.NLA
wsdata["ws-PND"] = args.PND
wsdata["ws-SELIBR"] = args.SELIBR
wsdata["ws-SWD"] = args.SWD
wsdata["ws-VIAF"] = args.VIAF
wsdata["ws-WORLDCAT"] = args.WORLDCAT
wsdata["ws-WORLDCATch"] = args.WORLDCATch
wsdata["ws-WORLDCATID"] = args.WORLDCATID
wsdata["ws-XXX"] = args.XXX
--]]
{base = "SELIBR", _id = "SELIBR", _wsid = "ws-SELIBR", _sauf = "", _space = "Auteur", _type = "Auteur",
text = "Bibliothèque royale (Suède)",
wptx = "Biblioth%%C3%%A8que_royale_%%28Su%%C3%%A8de%%29",
_link="http://libris.kb.se/auth/REF_0"},
{base = "SUDOC", _id = "SUDOC", _wsid = "ws-SUDOC", _sauf = "", _space = "", _type = "Auteur",
text = "Système universitaire de documentation",
wptx = "Syst%%C3%%A8me%%20universitaire%%20de%%20documentation",
_link="http://www.idref.fr/REF_0"},
{base = "SWD", _id = "SWD", _wsid = "ws-SWD", _sauf = "", _space = "", _type = "Auteur",
text = "Schlagwortnormdatei",
wptx = "Schlagwortnormdatei",
_link="http://d-nb.info/gnd/REF_0"},
{base = "ULAN", _id = "ULAN", _wsid = "ws-ULAN", _sauf = "", _space = "", _type = "Auteur",
text = "Union List of Artist Names",
wptx = "Union%%20List%%20of%%20Artist%%20Names",
_link="http://www.worldcat.org/oclc/REF_0"},
{base = "VIAF", _id = "VIAF", _wsid = "ws-VIAF", _sauf = "", _space = "", _type = "Auteur",
text = "Fichier d'autorité international virtuel",
wptx = "Fichier%%20d%%27autorit%%C3%%A9%%20international%%20virtuel",
_link="http://viaf.org/viaf/REF_0"},
{base = "WORLDCAT", _id = "WORLDCAT", _wsid = "ws-WORLDCAT", _sauf = "", _space = "", _type = "",
text = "WorldCat",
wptx = "WorldCat",
_link="http://www.worldcat.org/search?qt=worldcat_org_all&q=REF_2+REF_1"},
{base = "WORLDCAT", _id = "WORLDCATch", _wsid = "ws-WORLDCATch",_sauf = "", _space = "", _type = "",
text = "WorldCat",
wptx = "WorldCat",
_link="http://www.worldcat.org/search?q=REF_2-REF_1&qt=owc_search"},
{base = "WORLDCAT", _id = "WORLDCATID", _wsid = "ws-WORLDCATID",_sauf = "", _space = "", _type = "Auteur",
text = "WorldCat",
wptx = "WorldCat",
_link="http://www.worldcat.org/identities/REF_0"},
-- Pour tests futurs sans perturber les notices réelles
{base = "XXX", _id = "XXXid", _wsid = "ws-XXX", _sauf = "", _space = "", _type = "Auteur",
text = "XXX autorité",
wptx = "XXX%%20autorit%%C3%%A9",
_link="http://catalogue.bnf.fr/ark:/12148/REF_0"}
} -- notices_properties table ws-OCLC ws-PND ws-ISNI SELIBR SWD VIAF WORLDCATch
--[[
boite deroulante pour module interactif ?
<a id="NavToggle3" class="NavToggle" href="javascript:toggleNavigationBar(3);">[Dérouler]</a>
--]]
-- {{Nota | BNF | {{{BNF | cb11888266r }}} | BNF | http://catalogue.bnf.fr/ark:/12148/{{{BNF|cb11888266r}}} | espace=Auteur }}
local HTMLnotice = function(control, data, ref, noticeN)
-- Generer le wikitexte d'une notice selon ref, "id", "sauf", et l'espace de nom
-- exemple : notice(control, data, "cb11888266r", noticeN)
if nil == noticeN then return "" end
local id = noticeN._id
if nil == id then return "" end
if nil == ref then ref = "" end
local wptx = toUTF8(noticeN.text)
-- wikitext structure
-- [[File:Farm-Fresh draw calligraphic.png|22px|link=http://lccn.loc.gov/cb11888266r|BNF : cb11888266r]]
local wt = '<span style="margin-left:10px;" > * [link_1 title_1] : [[File:Farm-Fresh draw calligraphic.png|22px|link=link_2|a_l_t]]</span>'
-- title1="ARCid"
wt = string.gsub(wt, "title_1", '' .. id)
-- link1="http://fr.wikipedia.org/wiki/Biblioth%C3%A8que_nationale_de_France"
wt = string.gsub(wt, "link_1", 'http://fr.wikipedia.org/wiki/' .. noticeN.wptx)
-- title2="BNF : cb11888266r"
wt = string.gsub(wt, "title_2", id .. " : " .. ref)
-- link2="http://catalogue.bnf.fr/ark:/12148/cb11888266r"
wt = string.gsub(wt, "link_2", noticeN._link)
-- alt="BNF : cb11888266r"
wt = string.gsub(wt, "a_l_t", id .. " : " .. ref)
-- Remplacer ref dans link
wt = string.gsub(wt, "REF_0", ref)
-- Remplacer des parties de ref dans link
local N = 1
-- ref = "ref1/ref2/ref3" comme "123/456/789" ou "Dubois/Angèle/Marie"
for refN in string.gmatch(ref, "[^/]") do
-- lire les portions de textes séparées par un /, ainsi [^/] selectionne tous les caracteres sauf /,
if refN ~= ref then -- si on trouve des portions de ref
wt = string.gsub(wt, "REF_" .. tostring(N), refN) -- on les remplace dans wt
end
N = N + 1
end
return wt
end -- HTMLnotice = function(control, data, ref, noticeN)
-- {base = "ARC", _id = "ARCid", _wsid = "ws-ARCid", _sauf = "", _space = "", _type = "Auteur",
-- text = "National Archives and Records Administration",
-- wptx = "National Archives and Records Administration",
-- _link="http://arcweb.archives.gov/arc/action/ExternalPersonIdSearch?id=REF_0"},
local noticeSelect = function(control, data) -- , id, sauf)
-- noticeList(control, data, "ARCorg", "", "", "cb11888266r", "http://catalogue.bnf.fr/ark:/12148/REF_0")
-- notice(control, data, id, sauf, ref, space, "ARCorg", "", "http://catalogue.bnf.fr/ark:/12148/REF_0")
-- notice(control, data, id, sauf, ref, space, "ARC", "ARCid", "http://catalogue.bnf.fr/ark:/12148/REF_0")
-- local notice = function(control, data, id, sauf, ref, space, _id, _sauf, _space, _link)
local t = "" -- "<br/>* noticeSelect:" .. tostring(id) .. " : "
for noticeN in table_iterator(notices_properties) do
-- pour toutes les notices connues de ce module
-- collecter les parametres de la notice
local id = noticeN._id -- id de la notice comme "ARC"
local ws_id = noticeN._wsid -- ws de la notice comme "ws-ARC"
local ref_id = Argts.argv(id) -- ref de la notice comme "cb11888266r"
local space_id = noticeN._space -- espace de nom de la notice comme "Portail" ou "Auteur"
if (type(space_id) ~= "string") then space_id = "" end -- si non defini space_id = ""
local _type = noticeN._type -- type de la notice "Auteur" ou "Book" autre
-- collecter les parametres d'une autre notice prioritaire
local id_sauf = noticeN._sauf -- comme "ARCid"
local ref_sauf = Argts.argv("ws-" .. id_sauf) -- comme "35096649" ref d'une autre notice prioritaire
-- collecter les parametres de sélection
local space = "_NAMESPACE_" -- espace de nom actuel comme "Portail" ou "Auteur"
-- t = t .. ", " .. tostring(id) .. "=" .. tostring(idat) .. ":" .. space_id
-- selectionner les notices à générer
if (nil ~= ref_id) then -- exclure la notice si elle n'est pas demandée
-- t = t .. HTMLnotice(control, data, ref_id, noticeN)
if (nil == ref_sauf) then -- exclure la notice si une autre est prioritaire et définie
if ("Auteur" == _type) then -- inclure les notices de type Auteur
if (space_id ~= "") then -- si la notice est liée à un space de nom
if (space_id == space) then -- inclure la notice seulement dans son espace de nom
t = t .. HTMLnotice(control, data, ref_id, noticeN)
end
else -- inclure les notices non liées à un space de nom
t = t .. HTMLnotice(control, data, ref_id, noticeN)
end
end
end
end
-- Générer l'affichage de la notice
-- t = t .. ", " .. tostring(_id) .. ":" .. tostring(wsid) .. "=" .. tostring(idat)
end
return '<span> - ' .. Trad.txt('author_Notices') .. ' : ' .. t .. '</span>'
end -- noticeSelect = function(control, data)
-- {base = "ARC", _id = "ARCid", _wsid = "ws-ARCid", _sauf = "", _space = "",
-- text = "National Archives and Records Administration",
-- _link="http://arcweb.archives.gov/arc/action/ExternalPersonIdSearch?id=REF_0"},
local scanNames = function(wt, data)
-- wt = scanNames("http://gallic ... &q=-ws-name-+-ws-firstname-", md_data) -- replace names for scans
-- anti errors
-- local name = tostring(data["ws-name"])
local name = Argts.argv("lastname")
if nil == name then name = "" end
local firstname = tostring(Argts.argv("firstname"))
if nil == firstname then firstname = "" end
local firstgall = firstname
if nil ~= Argts.argv("Galliname") then
firstgall = tostring(Argts.argv("Galliname"))
end
-- replace names for scans
wt = tostring(wt)
wt = tostring(string.gsub(wt, "ws_firstname", firstname) )
wt = tostring(string.gsub(wt, "ws_name", name) )
wt = tostring(string.gsub(wt, "ws_firstgall", firstgall) )
return wt
end
local HTMLscans = function(args, data)
-- wt = scanNames("http://gallic ... &q=-ws-name-+-ws-firstname-", md_data) -- replace names for scans
-- anti errors
-- Generate scans to display
local SCAN__gallica = "<span> [http://gallica.bnf.fr/Search?ArianeWireIndex=index&p=1&lang=FR&q=ws_name+ws_firstname Gallica] </span>"
SCAN__gallica = tostring(scanNames(SCAN__gallica, data) )
local SCAN__europeana = "<span> [http://www.europeana.eu/portal/search.html?query=who:ws_name,%20ws_firstname&qf=LANGUAGE:fr&qf=LANGUAGE:mul&qf=TYPE:TEXT Europeana] </span>"
SCAN__europeana = tostring(scanNames(SCAN__europeana, data) )
local SCAN__google = "<span> [https://www.google.fr/search?q=inauthor%3A%22ws_firstname+ws_name%22&ie=utf-8&oe=utf-8&aq=t Google] </span>"
SCAN__google = tostring(scanNames(SCAN__google, data) )
local scan_notices = noticeSelect(args, data)
local xxx = args_trad['author_Scans']
local yyy = Trad.txt('author_Scans')
local scans = '<div id="Author" class="vcard" style=" background-color:#F1F1DE; border:0px solid #CCCCCC; "><span>' .. Trad.txt('author_Scans') .. ' : ' .. SCAN__gallica .. SCAN__europeana .. SCAN__google .. scan_notices .. ' </span></div>'
return scans
end
-- Trad['fr']author_Scans = 'Scans fr : ', author_Scans
local droits = function(now, args, data)
local ri = Argts.argv("rights")
local deathdate = tonumber(Argts.argv("deathyear"))
local nowyear = tonumber(now.year)
if "mpf" == ri then
if nil == deathdate then
return ""
elseif nowyear < deathdate + 96 then
return Argts.argv("fr-rights-warning-template")
else
return ""
end
elseif "non" ~= ri then
local birthdate = tonumber(Argts.argv("birthyear"))
if nil == deathdate then
return ""
elseif nowyear < deathdate + 71 then
return Argts.argv("rights-warning-template")
elseif nil == birthdate then
return ""
elseif 1903 > birthdate then
return Argts.argv("rights-warning-template")
else
return ""
end
else
return ""
end
end
local catGen = function(catspace, catName, catText) -- generate category
-- catGen("Category", "Naissance en 1948", "texte affiché") -> [[:Category:Naissance 1948|Naissance 1948]]
if nil == catspace then return "" end
if nil == catName then return "" end
if (type(catText) == 'string') and (catText ~= '')
then catText = "|" .. catText
else catText = '' end
return "[[" .. catView .. catspace .. ":" .. catName .. catText .. "]]"
end
local catGroup = function(catspace, groupCat, groupList) -- generate some catagories
-- catGroup(control, "Pays %1", "France/Italie") -> [[Category:Pays France]] [[Category:Pays Italie]]
if nil == catspace then return "" end
if nil == groupCat then return "" end
if nil == groupList then return "" end
local cats = string.gsub(groupList, "[^/]+", "[[" .. catView .. catspace .. ":" .. groupCat .. "]] ")
cats = string.gsub(cats, "/", "")
return cats
end
local categories = function(control, data)
-- category_space = frame:preprocess("{{ns:Category}}") -- Category namespace from system, par init
local catspace = category_space
local cats = {}
local initiale = Argts.argv("initiale")
local sans = tostring(Argts.argv("authors-category-no-initials") )
catView = Argts.argv("c")
trck(" categories() initiale=" .. initiale .. " sans=" .. sans .. " catView=" .. catView)
-- if catView == "x:" then catView = ":" end
if catView ~= ":" then catView = "" end
if type(initiale) == "string" then
-- table.insert(cats, catGen(catspace, Argts.argv("authors-category-prefix") .. initiale ) )
table.insert(cats, catGen(catspace, author_space .. initiale ) )
trck( Argts.argv("authors-category-prefix") .. initiale )
elseif (sans ~= "string") and (sans ~= "") then
table.insert(cats, catGen(catspace, sans ) )
end
trck(" interwiki-category-linked-prefix ")
local wikipedia = Argts.argv("wikipedia")
local wikiquote = Argts.argv("wikiquote")
local commons = Argts.argv("commons")
local commonscat = Argts.argv("commons-category")
if nil ~= wikipedia then table.insert(cats, catGen(catspace, "Wikipedia") ) end
if nil ~= wikiquote then table.insert(cats, catGen(catspace, "Wikiquote") ) end
if nil ~= commons then table.insert(cats, catGen(catspace, "Wikimedia Commons") ) end
if nil ~= commonscat then table.insert(cats, catGen(catspace, "Wikimedia Commons category") ) end
trck(" birthyear=" .. Argts.argv("birthyear") .. " occupation=" .. Argts.argv("occupation") .. " Wikipedia=" .. Argts.argv("Wikipedia"))
trck( "Naissance en " .. Argts.argv("birthyear") )
-- if option("fr") then
table.insert(cats, catGroup(catspace, "Naissance en %1", Argts.argv("birthyear") ) )
table.insert(cats, catGroup(catspace, "Mort en %1", Argts.argv("deathyear") ) )
-- end
-- catGroup(control, "Pays %1", "France/Italie/Grèce")
-- |genre=Romanciers/Poètes/Auteurs de théatre
table.insert(cats, catGroup(catspace, "%1", Argts.argv("genre") ) )
-- |langue=français/japonais
table.insert(cats, catGroup(catspace, "Langue %1", Argts.argv("language") ) )
-- |metier=Académiciens/Personnalités politiques
table.insert(cats, catGroup(catspace, "%1", Argts.argv("occupation") ) )
-- |pays=France/Italie/Grèce
table.insert(cats, catGroup(catspace, "Pays %1", Argts.argv("country") ) )
-- |prix=Nobel de littérature/Pulitzer/Renaudot
table.insert(cats, catGroup(catspace, "Prix %1", Argts.argv("prize") ) )
-- table.insert(cats, catGen(catspace, Argts.argv("authors-category") ) )
-- table.insert(cats, catGen(catspace, "Birth in %1", Argts.argv("birthyear") ) )
-- table.insert(cats, catGen(catspace, "Death in %1", Argts.argv("deathyear") ) )
return table.concat(cats)
end -- categories = function(control, data)
local annotations = {}
annotations["lastname"] = "fn"
annotations["firstname"] = "n"
annotations["description"] = "label"
annotations["birthyear"] = "bday"
annotations["deathyear"] = "dday"
local microformat = function(data)
if data ~= " cette instruction desactive microformat pour debug. " then return "" end
local text = {}
local style = "display:none; speak:none;"
for n,v in pairs(data) do
local class = annotations[n]
local datum = mw.text.tag({name="span", contents=v, params={id=n,class=class}})
table.insert(text, datum)
end
return mw.text.tag({name="div", contents=table.concat(text), params={id="ws-data", class="vcard ws-noexport", style=style}})
end
local defaultsort = function(control, data)
local key = tostring(Argts.argv("sortkey"))
local name = tostring(Argts.argv("lastname"))
local given = tostring(Argts.argv("givenname"))
local family = tostring(Argts.argv("lastname"))
local name = key or name or ((given or "_") .. "," .. (family or ""))
-- local name = data["ws-key"] or data["ws-name"] or ((data["given-name"] or "_") .. "," .. (data["family-name"] or ""))
return mw.getCurrentFrame():preprocess("{{DEFAULTSORT:" .. name .. "}}")
-- return "{{DEFAULTSORT:" .. name .. "}}"
end
-- Too basic english version, do not use
local headbox = function(control, data)
local name = Argts.argv("sortkey") or Argts.argv("lastname") or ((Argts.argv("givenname") or "_") .. "," .. (Argts.argv("lastname") or ""))
local wikipedia = Argts.argv("wikipedia")
local wikiquote = Argts.argv("wikiquote")
local commons = Argts.argv("commons")
local commonscat = Argts.argv("commons-category")
local interwikis = {}
if nil ~= wikipedia then table.insert(interwikis, "* [[:wikipedia:" .. wikipedia .. "|" .. "Wikipedia]]\n") end
if nil ~= wikiquote then table.insert(interwikis, "* [[:wikiquote:" .. wikiquote .. "|" .. "Wikiquote]]\n") end
if nil ~= commons then table.insert(interwikis, "* [[:commons:" .. commons .. "|" .. "Wikimedia Commons]]\n") end
if nil ~= commonscat then table.insert(interwikis, "* [[:commons:Category:" .. commonscat .. "|" .. "Wikimedia Commons category]]\n") end
local links = "\n" .. table.concat(interwikis)
local desc = "'''" .. name .. "'''\n"
if Argts.argv("description") then
desc = desc .. "\n" .. Argts.argv("description")
end
local image
if Argts.argv("image") then
local caption = Argts.argv("image-caption") or ""
image = "[[File:" .. Argts.argv("image") .. "|125px|" .. caption .. "]]"
else
image = ""
end
-- FIXME: The styles, column widths, and CSS classes need adjusting.
return "{| class=\"wikitable\" width=\"100%\"\n|-" .. name .. "\n|-\n|" .. links .. "\n|" .. desc .. "\n|" .. image .. "\n|}\n"
end
-- French version
local headbox_fr = function(args, data)
-- Generate the main box, in HTML
local title = Argts.argv("title") -- or Argts.argv("lastname") or Argts.argv("sortkey") or Argts.argv("givenname")
if type(title) ~= "string" then title = "-" end
local desc = ""
if Argts.argv("description") then
desc = desc .. "\n" .. Argts.argv("description")
end
if type(desc) ~= "string" then desc = "" end
local image
if Argts.argv("image") then
local caption = Argts.argv("image-caption") or ""
-- image = "[[File:" .. data["ws-image"] .. "|125px|" .. caption .. "]]"
image = "[[File:" .. Argts.argv("image") .. "|frameless|170x170px||class=photo]]"
else
image = ""
end
if type(image) ~= "string" then image = "" end
local initiale = Argts.argv("initiale")
if type(initiale) ~= "string" then initiale = "" end
-- <br/><span style="color:#aaaa66; line-height:120%; ">\<\<</span> [[:Catégorie:Auteurs-{{{initiale|H}}}|Auteurs {{{initiale|H}}}]]<br /><br />
--
-- Generate interwikis links
local interwikis = {}
if nil ~= initiale then table.insert(interwikis, '<br/><span style="color:#aaaa66; line-height:120%; ">◀ </span> [[' .. catView .. category_space .. ':' .. author_space .. '-' .. initiale .. '|' .. author_space .. '-' .. initiale .. ']]<br/><br/>') end
-- Failed to encode the character ◀=(U+25C0) '<<' (U+25C4) at column 73 in line 60
-- string.gfind(ustring, "([%z\1-\127\194-\244][\128-\191]*)")
-- if nil ~= data.wikisource then table.insert(interwikis, '<span style="color:#232388; font-size:140%; line-height:120%; ">⦁ </span>[[wikisource:' .. control["namespace-author"] .. ':' .. data.wikisource .. '|Fac-similés]]<br/>') end
if nil ~= Argts.argv("wikisource") then table.insert(interwikis, '<span style="color:#232388; font-size:140%; line-height:120%; ">⦁ </span>[[wikisource:' .. author_space .. ':' .. Argts.argv("wikisource") .. '|Fac-similés]]<br/>') end
if nil == Argts.argv("wikipedia") then Argts["wikipedia"]["val"] = title end
if Argts.argv("wikipedia") ~= "" then table.insert(interwikis, '<span style="color:#232388; font-size:140%; line-height:120%; ">⦁ </span>[[wp:' .. Argts.argv("wikipedia") .. '|Biographie]]<br/>') end
-- if Argts.argv("wikipedia") ~= "" then table.insert(interwikis, '<span style="color:#232388; font-size:140%; line-height:120%; ">⦁ </span>' .. catGen(arg_lang .. ":wikipedia:" .. category_space, Argts.argv("wikipedia"), "BiographieXYZ") .. '<br/>') end
-- catGen(arg_lang .. ":wikipedia:" .. category_space, Argts.argv("wikipedia"), "Biographie")
-- catGen("Category", "Naissance en 1948", "texte affiché")
if nil == Argts.argv("wikiquote") then Argts["wikiquote"]["val"] = title end
if nil ~= Argts.argv("wikiquote") then table.insert(interwikis, '<span style="color:#232388; font-size:140%; line-height:120%; ">⦁ </span>[[wikiquote:' .. Argts.argv("wikiquote") .. '|Citations]]<br/>') end
if nil == Argts.argv("commons") then Argts["commons"]["val"] = title end
if nil ~= Argts.argv("commons") then table.insert(interwikis, '<span style="color:#232388; font-size:140%; line-height:120%; ">⦁ </span>[[commons:' .. Argts.argv("commons") .. '|Médias]]<br/>') end
-- ◄ Auteurs H • Fac-similés WS • Biographie WP • Citations WQ • Médias WM
-- if nil ~= data.wikipedia then table.insert(interwikis, "* [[:w:" .. data.wikipedia .. "|" .. "Wikipedia]]\n") end
-- if nil ~= data.wikiquote then table.insert(interwikis, "* [[:q:" .. data.wikiquote .. "|" .. "Wikiquote]]\n") end
-- if nil ~= data.commons then table.insert(interwikis, "* [[:commons:" .. data.commons .. "|" .. "Wikimedia Commons]]\n") end
-- if nil ~= data.commonscat then table.insert(interwikis, "* [[:commons:Category:" .. data.commonscat .. "|" .. "Wikimedia Commons category]]\n") end
local links = "\n" .. table.concat(interwikis)
--
-- FIXME: The styles, column widths, and CSS classes need adjusting.
-- FIXME: The french display is in HTML direct to better adapt the size and the look to plural environments.
--
-- Generate scans to display
local scans = HTMLscans(args, data)
--
-- Generate wikitext to display
local wt = '<div id="Author" class="vcard" style="margin-right:5px; box-shadow:0.2em 0.3em 0.2em #B7B7B7; background-color:#F1F1DE; padding:0.3em; width=99.9%; overflow-x:hidden; ">'
.. '<table cellspacing="0" cellpadding="0" style="background-color: transparent; border:{{{border|1}}}px solid #CCCCCC; padding:0em;">'
.. '<tr>'
.. '<td valign="middle" rowspan="2" style="padding: 0em 0.6em; background-color: #F1F1DE; text-align:left; font-size:90%; line-height:80%; ">'
.. '<div style="text-align:left; font-size:120%; padding-top:0.5em; text-indent:1em">'
.. links
.. '</div>'
.. '</td>'
.. '<td valign="top" align="center" style=" min-width:150px; border-left:{{{border|1}}}px solid #CCCCCC; padding:0.5em; ">'
.. '<span class="fn" id="AuthorName" style="line-height:90%; font-size:160%; font-weight:bold; padding-top:0.1em; border-bottom: none; ">'
.. title
.. '</span>'
.. '</td>'
.. '<td valign="middle" align="center" rowspan="2" style=" border-left:{{{border|1}}}px solid #CCCCCC; ">'
.. '<div id="AuthorImage" style=" padding:4px; ">'
.. image
.. '</div>'
.. '</td>'
.. '</tr>'
.. '<tr>'
.. '<td valign="top" align="center" style="width:100%; border-left:{{{border|1}}}px solid #CCCCCC; padding:1em; ">'
.. '<span class="label" style=" font-size:110%; line-height:80%; text-align:center; " >'
.. desc
.. '</span>'
.. '</td>'
.. '</tr>'
.. '<tr>'
.. '<td valign="top" align="center" colspan="3" style="width:100%; border-top:{{{border|1}}}px solid #CCCCCC; padding:1em; ">'
.. '<span class="label" style=" font-size:110%; line-height:80%; text-align:center; " >'
.. scans
.. '</span>'
.. '</td>'
.. '</tr>'
.. '</table>'
.. '</div>'
return wt
-- "{| class=\"wikitable\" width=\"100%\"\n|-" .. name .. "\n|-\n|" .. links .. "\n|" .. desc .. "\n|" .. image .. "\n|}\n"
end -- headbox_fr = function(args, data)
-- Générer la liste des notices.
local notices_liste = function(notices_properties, args)
-- notices_liste(notices_properties, args)
if type(notices_properties) ~= "table" then return "" end
if type(args) ~= "table" then return "" end
local t = "<br/>Paramètres de notices d'autorités connues du module : "
for noticeN in table_iterator(notices_properties) do
-- pour toutes les notices connues de ce module
-- collecter les parametres de la notice
local id = noticeN._id -- id de la notice comme "ARC"
local wsid = noticeN._wsid -- ws-id de la notice comme "ws-ARC"
t = t .. id .. "-"
if Argts[wsid] == nil then
-- erreur_add("err_internal_notice_wsid", tostring(wsid))
else
local _type = noticeN._type -- type de la notice "Auteur" ou "Book" ou autre
t = t .. ", " .. tostring(wsid) .. "=" .. tostring(id) .. ":" .. _type
if _type == "Auteur" then
Argts[wsid]["val"] = args[id] -- lire les paramètres de notices de type Auteur
t = t .. "+"
end
end
end
t = t .. "Fin des notices."
trck( t )
return t
end -- local notices_liste = function(notices_properties, args)
-- local unitestScribunto = require "Module:Unitest_Scribunto"
-- [[ -- Module:Unitest_Scribunto start
--[[
Example of result :
* Init of unit tests. test_list = table
* Begin of unit tests :
* 1 Site tested : mw.uri.fullUrl = //fr.wikisource.org/wiki/Module:Auteur.
* 2 Environment : Mediawiki 1.21wmf10 (d6c6dba) version UTC 2013-03-01 21:53:59.
* 3 Runtime and spaces : server UTC 2013-03-04 01:09:22, namespace=Modèle module_space=Module, template_space=Modèle viewErrors=true.
* 4 frame.args Error : frame.args.lastname = "error". The OK value was "OK" = frame:getParent().args.lastname.
* 5 sub table write Test OK : sub table write OK. / / / result OKOK ; exec_ok=true ; value_ok=true ; var_tested=td.C.X ; value_before=xx ; value_after=okvalue ; A=aa ; Y=yy .
* 6 Is Scribunto complete ? Error : Scribunto is not complete. / / / ; math=table ; os=table ; package=table ; string=table ; table=table ; mw=table ; frame=table ; mw.language=table ; mw.message=nil ; mw.site=table ; mw.title=nil ; mw.uri=table ; mw.ustring=table .
* End of unit tests. Statistic count : Nerr=2 / Ntests=6
--]]
--[[
Unitest_Scribunto like/from Scribunto_LuaEngineTestBase
http://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Test_cases
class ClassNameTest extends Scribunto_LuaEngineTestBase {
protected static $moduleName = 'ClassNameTest';
function getTestModules() {
return parent::getTestModules() + array(
'ClassNameTest' => __DIR__ . 'ClassNameTests.lua';
);
}
}
local testframework = require 'Module:TestFramework'
return testframework.getTestProvider( {
-- Tests go here
} )
Each test is itself a table, with the following properties:
name: The name of the test.
func: The function to execute.
args: Optional table of arguments to pass to the function.
expect: Results to expect.
type: Optional "type" of the test, default is "Normal".
local function AuteurTestCurrentNamespace(space) {
-- This repair a Lua bug : {{NAMESPACE}} give nothing in fr.wikisource.org
current_space = frame:preprocess("{{NAMESPACE}}") -- present namespace from system
-- This repair a Lua bug : mw.site.namespaces.name is unknown
module_space = frame:preprocess("{{ns:Module}}") -- Module namespace from system
template_space = frame:preprocess("{{ns:Template}}") -- Module namespace from system
author_space = frame:preprocess("{{ns:Author}}") -- Author namespace from system
category_space = frame:preprocess("{{ns:Category}}") -- Category namespace from system
if current_space == space then
end
return space .. "OK"
}
class ClassAuteurTest extends Scribunto_LuaEngineTestBase {
protected static $moduleName = 'ClassAuteurTest';
function getTestModules() {
return parent::getTestModules() + array(
'ClassAuteurTest' => __DIR__ . 'ClassAuteurTest.lua';
);
}
}
--]]
local formatdate = function(date_time)
-- formatime(date_time)
-- formate "20130302153557" en "2013-03-02 15:35:57"
date_time = tostring(date_time.year) .. "-" .. tostring(date_time.month) .. "-" .. tostring(date_time.day) .. " " .. tostring(date_time.hour) .. ":" .. tostring(date_time.min) .. ":" .. tostring(date_time.sec)
return date_time
end -- local formatdate = function(date_time)
local formatime = function(date_time)
-- formatime(date_time)
-- formate "20130302153557" en "2013-03-02 15:35:57"
date_time = tostring(date_time)
date_time = string.sub(date_time, 1, 4) .. "-" .. string.sub(date_time, 5, 6) .. "-" .. string.sub(date_time, 7, 8) .. " " .. string.sub(date_time, 9, 10) .. ":" .. string.sub( date_time, 11, 12) .. ":" .. string.sub(date_time, 13, 14)
return date_time
end -- local formatime = function(date_time)
local function if_exist(ok, wt, mw_uri, mw_uri_name)
-- ok, wt = if_exist(ok, wt, mw.uri, 'mw.uri')
local isnil = tostring(mw_uri)
local t = mw_uri_name .. '=' .. isnil
if isnil == "nil" then -- Y a-t-il erreur de valeur ?
ok = false -- Il y a une erreur de valeur
wt = wt .. ' ; <span style="color:red;" >' .. t .. '</span>'
else
ok = ok -- Il n'y a pas d'erreur de valeur
wt = wt .. ' ; ' .. t
end
return ok, wt
end
local sub_table_write_data = {
A = "aa",
B = "bb",
C = {
X = "xx",
Y = "yy"
}
}
local function sub_table_write_function(td)
-- test d'ecriture dans une sous table
local A = td.A
local Y = td.C.Y
local var_tested = "td.C.X"
local value_before = td.C.X
local value_after = value_before
td.C.X = "okvalue" -- INSTRUCTION UNDER TEST
value_after = td.C.X -- verifier aussi l'ecriture puis lecture
local value_ok = ( value_after == "okvalue" )
return value_ok, var_tested, value_before, value_after, A, Y
end
-- Series of unit tests. Série de tests unitaires.
-- require 'Module:TestFramework'
-- similar to : class ClassNameTest extends Scribunto_LuaEngineTestBase {
local tst = {
test_frame = nil, -- frame
test_result = "",
test_list = {
-- Tests go here
},
} -- tst object like Scribunto_LuaEngineTestBase
local Unitest_Scribunto_tested_site = { name = "Tested site",
func_test = function(parm, frame)
-- Get environment
local ok, out_OK, out_HS = true, parm.expect, "error"
local t = ""
local mw_uri_fullUrl = mw.uri.fullUrl('Module:Auteur') -- "Module:Auteur" )
t = t .. ": mw.uri.fullUrl = " .. tostring(mw_uri_fullUrl)
-- local mw_uri = mw.uri.new('Module:Auteur') -- "Module:Auteur" )
-- mw.uri.new( s )
-- local mw_title = mw.title.new('Module:Auteur') -- "Module:Auteur" )
-- t = t .. ": mw.uri.prefixedText = " .. tostring(mw_uri.prefixedText)
-- futur : mw.title.new( 'Module:Foo', 'Template' ) will create an object for the page Module:Foo
-- mw.title.makeTitle( 'Template', 'Module:Foo' ) will create an object for the page Template:Module:Foo.
-- mw.title object :
-- nsText: The text of the namespace for the page.
-- prefixedText: The title of the page, with the namespace and interwiki prefixes.
-- fullText: The title of the page, with the namespace and interwiki prefixes and the fragment.
-- local preprocess_url = frame:preprocess("{{fullurl:Module:Auteur}}")
-- t = t .. "<br/> preprocess_url = " .. tostring(preprocess_url)
out_OK = t
out_HS = t
return ok, tostring(out_OK), tostring(out_HS)
end,
args = {"x"},
expect = "OK",
type = "ToString",
ifok = "_N_TEST_ <b>_PRM_NM_</b> _OUT_OK_.",
iferr = '_N_TEST_ <b>_PRM_NM_</b> _OUT_HS_.</span>',
}
local Unitest_Scribunto_environment = { name = "Environment",
func_test = function(parm, frame)
-- Get environment
local ok, out_OK, out_HS = true, parm.expect, "error"
local t = ""
local date_time = frame:preprocess("{{#dateformat:{{CURRENTTIMESTAMP}}|ymd}}")
local now_date = os.date("%Y-%m-%d %H:%M:%S")
local mw_version = frame:preprocess("{{CURRENTVERSION}}")
local revision_time = frame:preprocess("{{REVISIONTIMESTAMP}}")
local dtnow, dtvers = now_date, revision_time
-- dtnow = formatime(now_date)
dtvers = formatime(dtvers)
t = t .. ": Mediawiki " .. tostring(mw_version) .. " version UTC " .. tostring(dtvers)
-- t = t .. " read by { {CURRENTVERSION} }"
out_OK = t
out_HS = t
return ok, tostring(out_OK), tostring(out_HS)
end,
args = {"x"},
expect = "OK",
type = "ToString",
ifok = "_N_TEST_ <b>_PRM_NM_</b> _OUT_OK_.",
iferr = '_N_TEST_ <b>_PRM_NM_</b> _OUT_HS_.</span>',
}
local Unitest_Scribunto_runtime_spaces = { name = "Runtime and spaces",
func_test = function(parm, frame)
local ok, out_OK, out_HS = true, parm.expect, "error"
local now_date = os.date("%Y-%m-%d %H:%M:%S")
local namespace = frame:preprocess("{{NAMESPACE}}") -- present namespace from system
local module_space = frame:preprocess("{{ns:Module}}") -- Module namespace from system
local template_space = frame:preprocess("{{ns:Template}}") -- Module namespace from system
local viewErrors = (namespace == module_space) or (namespace == template_space)
local t = ""
t = t .. ": server UTC " .. tostring(now_date) .. ", namespace=" .. tostring(namespace)
t = t .. " module_space=" .. tostring(module_space) .. ", template_space=" .. tostring(template_space)
t = t .. " viewErrors=" .. tostring(viewErrors)
--[[
current_space = frame:preprocess("{{NAMESPACE}}") -- present namespace from system
-- mw.site.namespaces.name is unknown
module_space = frame:preprocess("{{ns:Module}}") -- Module namespace from system
template_space = frame:preprocess("{{ns:Template}}") -- Module namespace from system
author_space = frame:preprocess("{{ns:Author}}") -- Author namespace from system
category_space = frame:preprocess("{{ns:Category}}") -- Category namespace from system
local current_space = frame:preprocess("{{NAMESPACE}}") -- present namespace from system
local REVISIONUSER = frame:preprocess("{{REVISIONUSER}}") -- current user when previewing an edit
local ns_Module = frame:preprocess("{{ns:Module}}") -- {{ns:User}} namespace translated
local ns_Template = frame:preprocess("{{ns:Template}}") -- {{ns:User}} namespace translated
local int_edit = frame:preprocess("{{int:edit}}") -- {{int:edit}} → Edit, translate "edit"
local language_ar = frame:preprocess("{{#language:ar}}") -- full name of the language
-- {{FULLPAGENAMEE}} {{PAGENAMEE}} {{BASEPAGENAMEE}} {{SUBPAGENAMEE}}
-- {{SUBJECTPAGENAMEE}} {{ARTICLEPAGENAMEE}} {{TALKPAGENAMEE}}
local ARTICLEPAGENAMEE = frame:preprocess("{{ARTICLEPAGENAMEE}}")
local date_time = frame:preprocess("{{#dateformat:{{CURRENTTIMESTAMP}}|ymd}}")
local mw_version = frame:preprocess("{{CURRENTVERSION}}")
local revision_time = frame:preprocess("{{REVISIONTIMESTAMP}}")
local now_date = os.date("%Y-%m-%d %H:%M:%S")
-- local date_time = frame:preprocess("{{#dateformat:{{CURRENTTIMESTAMP}}|ymd}}")
-- local mw_version = frame:preprocess("{{CURRENTVERSION}}")
-- local revision_time = frame:preprocess("{{REVISIONTIMESTAMP}}")
-- local dtnow, dtvers = now_date, revision_time
-- dtnow = formatime(dtnow)
-- dtvers = formatime(dtvers)
-- t = t .. " read by { {CURRENTTIMESTAMP} }"
--]]
out_OK = t
out_HS = t
return ok, tostring(out_OK), tostring(out_HS)
end,
args = {"x"},
expect = "OK",
type = "ToString",
ifok = "_N_TEST_ <b>_PRM_NM_</b> _OUT_OK_.",
iferr = '_N_TEST_ <b>_PRM_NM_</b> _OUT_HS_.</span>',
}
local Unitest_Scribunto_frame_args = { name = "frame.args",
func_test = function(parm, frame)
-- * frame:getParent().args.lastname = Rimbaud
-- * frame.args.lastname = nil
local ok, out_OK, out_HS = true, parm.expect, "error"
local frame_args = frame.args
local getParent_args = frame:getParent().args
local arglingual = tostring(args_trad.lastname) -- multilingual name of the arg
local frame_val = tostring(frame_args[arglingual])
local getParent_val = tostring(getParent_args[arglingual])
local t = "* <b>" .. tostring(parm.name) .. "</b> "
local ok, out_REF, out_TEST = true, "", ""
out_REF = tostring(getParent_val)
out_TEST = tostring(frame_val)
if out_TEST == out_REF then -- OK
ok = true
else -- HS bug
ok = false
end
return ok, tostring(out_OK), tostring(out_HS)
end,
args = {"x"},
expect = "OK",
type = "ToString",
ifok = '_N_TEST_ <b>_PRM_NM_</b> Test OK : frame.args.lastname = "_OUT_HS_".',
iferr = '_N_TEST_ <b>_PRM_NM_</b> <span style="color:red;" >Error : frame.args.lastname = "_OUT_HS_". The OK value was "_OUT_OK_" = frame:getParent().args.lastname.</span>',
}
local Unitest_Scribunto_sub_table_write = { name = "sub table write",
func_test = function(parm, frame)
-- * Test sub table read OK : Test cx : td.C.X = cx, expected = cx, test OK.
-- * Test sub table write HS : Test x : tst.test_data.C.X = new val -> error
-- pcall( func, args ) -- return { true, func() } or return { false, error message }
-- how to read cousins in table, like cd ..other branch
local ok, out_OK, out_HS = true, parm.expect, "error"
-- local td_C_X_read = td.C.X
-- Run a protected call to detect the execution error
local exec_ok, value_ok, var_tested, value_before, value_after, A, Y = pcall( sub_table_write_function, sub_table_write_data )
local outest = " ; exec_ok=" .. tostring(exec_ok) .. " ; value_ok=" .. tostring(value_ok) .. " ; var_tested=" .. tostring(var_tested) .. " ; value_before=" .. tostring(value_before) .. " ; value_after=" .. tostring(value_after) .. " ; A=" .. tostring(A) .. " ; Y=" .. tostring(Y)
if exec_ok then -- OK
ok = true -- Il n'y a pas d'erreur d'execution
out_OK = " result OK-- " .. outest
if value_ok then -- Y a-t-il erreur de valeur ?
ok = true -- Il n'y a pas d'erreur de valeur
out_OK = " result OKOK " .. outest
else -- HS bug
ok = false -- Il y a une erreur de valeur
out_HS = " result OKHS " .. outest
end
else -- HS bug
ok = false -- ll y a une erreur d'execution
out_HS = " result HS-- " .. outest
end
return ok, tostring(out_OK), tostring(out_HS)
end,
args = {"x"},
expect = "OK",
type = "ToString",
ifok = '_N_TEST_ <b>_PRM_NM_</b> Test OK : sub table write OK. / / / _OUT_OK_ .',
iferr = '_N_TEST_ <b>_PRM_NM_</b> <span style="color:red;" >Error : sub table write HS. / / / _OUT_HS_ .</span>',
}
local Unitest_Scribunto_complete = { name = "Is Scribunto complete ?",
func_test = function(parm, frame)
-- * Test sub table read OK : Test cx : td.C.X = cx, expected = cx, test OK.
-- * Test sub table write HS : Test x : tst.test_data.C.X = new val -> error
-- pcall( func, args ) -- return { true, func() } or return { false, error message }
-- how to read cousins in table, like cd ..other branch
local ok, out_OK, out_HS = true, parm.expect, "error"
-- local td_C_X_read = td.C.X
-- Run a protected call to detect the execution error
local exec_ok, value_ok, var_tested, value_before, value_after, A, Y = pcall( sub_table_write_function, sub_table_write_data )
local outest = " ; exec_ok=" .. tostring(exec_ok) .. " ; value_ok=" .. tostring(value_ok) .. " ; var_tested=" .. tostring(var_tested) .. " ; value_before=" .. tostring(value_before) .. " ; value_after=" .. tostring(value_after) .. " ; A=" .. tostring(A) .. " ; Y=" .. tostring(Y)
local ok, wt = true, ''
ok, wt = if_exist(ok, wt, math, 'math')
ok, wt = if_exist(ok, wt, os, 'os')
ok, wt = if_exist(ok, wt, package, 'package')
ok, wt = if_exist(ok, wt, string, 'string')
ok, wt = if_exist(ok, wt, table, 'table')
ok, wt = if_exist(ok, wt, mw, 'mw')
ok, wt = if_exist(ok, wt, frame, 'frame')
ok, wt = if_exist(ok, wt, mw.language, 'mw.language')
ok, wt = if_exist(ok, wt, mw.message, 'mw.message')
ok, wt = if_exist(ok, wt, mw.site, 'mw.site')
ok, wt = if_exist(ok, wt, mw.title, 'mw.title')
ok, wt = if_exist(ok, wt, mw.uri, 'mw.uri')
ok, wt = if_exist(ok, wt, mw.ustring, 'mw.ustring')
out_OK = wt
out_HS = wt
return ok, tostring(out_OK), tostring(out_HS)
end,
args = {"x"},
expect = "OK",
type = "ToString",
ifok = '_N_TEST_ <b>_PRM_NM_</b> Test OK : sub table write OK. / / / _OUT_OK_ .',
iferr = '_N_TEST_ <b>_PRM_NM_</b> <span style="color:red;" >Error : Scribunto is not complete.</span> / / / _OUT_HS_ .',
}
function tst.init( frame, test_list, test_data )
-- tst.init(frame, tst.test_list)
-- tst.test_list is the default value
if type(frame) == "table" then tst.test_frame = frame end
if type(test_list) == "table" then tst.test_list = test_list end
table.insert( tst.test_list, Unitest_Scribunto_tested_site )
table.insert( tst.test_list, Unitest_Scribunto_environment )
table.insert( tst.test_list, Unitest_Scribunto_runtime_spaces )
table.insert( tst.test_list, Unitest_Scribunto_frame_args )
table.insert( tst.test_list, Unitest_Scribunto_sub_table_write )
table.insert( tst.test_list, Unitest_Scribunto_complete )
if type(test_data) == "table" then tst.test_data = test_data end
local t = "<br/>* Init of unit tests. test_list = " .. tostring( tst.test_list ) .. "<br/>"
tst.test_result = tst.test_result .. t
return t
end -- function tst.init( frame, test_list, test_data )
function tst.run_all_tests( frame )
local input_args = frame.args.input or frame.args
local result = ""
local wt, t = "", "* Begin of unit tests :<br/>"
local n, nerr = 0, 0
local ok, out_OK, out_HS = true, "", ""
for key, parm in pairs(tst.test_list) do -- Pour tous les parametres connus
n = n + 1
wt = ""
if parm.type == "ToString" then -- args en ordre numerique et renvoi vers un argument nommé
ok, out_OK, out_HS = parm.func_test(parm, frame)
-- pcall( func, args ) -- return { true, func() } or return { false, error message }
-- t = t .. '* ' .. tostring(n) .. ' <b>' .. tostring(parm.name) .. '</b> result =' .. tostring(result) .. ' '
if ok then -- si le test est OK
wt = parm.ifok
-- t = t .. ' ' .. parm.ifok .. '</span>' .. out_OK .. '<br/>'
else -- si le test est HS
wt = parm.iferr
-- t = t .. '<span style="color:red;" >' .. parm.iferr .. '</span>' .. out_HS .. '<br/>'
nerr = nerr + 1
end
wt = string.gsub(wt, "_PRM_NM_", tostring(parm.name) )
wt = string.gsub(wt, "_N_TEST_", tostring(n) )
wt = string.gsub(wt, "_N_ERR_", tostring(nerr) )
wt = string.gsub(wt, "_OUT_OK_", tostring(out_OK) )
wt = string.gsub(wt, "_OUT_HS_", tostring(out_HS) )
-- t = t .. '* ' .. tostring(n) .. ' <b>' .. tostring(parm.name) .. '</b> ' .. wt
t = t .. '* '.. wt .. "<br/>"
end
end
t = t .. "* End of unit tests. Statistic count : Nerr=" .. tostring( nerr ) .. " / Ntests=" .. tostring( n ) .. "<br/>"
tst.test_result = tst.test_result .. t
return tst.test_result
end -- function tst.run_all_tests( frame )
-- end of tst object
--]] -- Module:Unitest_Scribunto end
local function AuteurTestRun(frame)
-- if ifBug == nil then return AuteurTestRun()
local t = "<br/>AuteurTestRun : list of cases :<br/>"
local current_space = frame:preprocess("{{NAMESPACE}}") -- present namespace from system
-- Run a standard test of Lua in scribunto
local t = "<br/>AuteurTestRun : <b>frame.args</b> or frame:getParent().args ? :<br/>"
local mw_version = frame:preprocess("{{CURRENTVERSION}}")
local revision_time = frame:preprocess("{{REVISIONTIMESTAMP}}")
-- local date_time = frame:preprocess("{{CURRENTTIMESTAMP}}")
local date_time = frame:preprocess("{{#dateformat:{{CURRENTTIMESTAMP}}|ymd}}")
local frame_args = frame.args
local getParent_args = frame:getParent().args
local arglingual = tostring(args_trad.lastname) -- multilingual name of the arg in the template
-- Get environment
t = t .. "* Get environment :<br/>"
t = t .. ".....* 20130228 18:40 LTC CURRENTVERSION MediaWiki 1.21wmf10 (52304ce) read by http://fr.wikisource.org/wiki/Sp%C3%A9cial:Version <br/>"
t = t .. ".....* 20130228 18:40 LTC CURRENTVERSION Mediawiki 1.21wmf10 (72462da) read by {{CURRENTVERSION}} <br/>"
t = t .. ".....* Mediawiki " .. tostring(mw_version) .. " from UTC = " .. tostring(revision_time) .. "<br/>"
t = t .. ".....* test run UTC = " .. tostring(date_time) .. "<br/>"
t = t .. ".....* frame:getParent().args = " .. tostring(getParent_args) .. "<br/>"
t = t .. ".....* frame.args = " .. tostring(frame_args) .. "<br/>"
local argval = tostring(getParent_args[arglingual])
t = t .. ".....* frame:getParent().args.lastname = " .. tostring(argval) .. "<br/>"
local argval = tostring(frame_args[arglingual])
t = t .. ".....* frame.args.lastname = " .. tostring(argval) .. "<br/>"
-- Test simple table read
local cx = tst.test_data.C.X
t = t .. "* Test <b>simple table read OK</b> :<br/>"
t = t .. ".....* Test aa : td.A = " .. tst.test_data.A .. ", expected =a a, test OK.<br/>"
t = t .. "* Test <b>sub table read OK</b> :<br/>"
t = t .. ".....* Test cx : td.C.X = " .. tst.test_data.C.X .. ", expected = cx, test OK.<br/>"
-- Test sub table write
-- in some cases sub table can not be write. which ones ?
tst.test_data.C.X = 'xx'
t = t .. "* Test <b>sub table write OK</b> :<br/>"
t = t .. ".....* Test x : tst.test_data.C.X = " .. tst.test_data.C.X .. ", expected = x, test OK.<br/>"
t = t .. ".....* Test t : tst.txt('t') = " .. tst.txt('t') .. ", expected = t, test OK.<br/>"
tst.test_result = tst.test_result .. t
return t
end
-- Interface http://scribunto.wmflabs.org/
local p = {}
-- Interface pour générer une entête de page d'auteur.
function p.auteur(frame)
trck_on = option("track")
-- local args = frame.args
-- 28/02/2013 This repair Lua bug : args = frame.args is a table but without arguments
local args = frame:getParent().args -- local pframe
local now = { year = args.year, month = args.month, day = args.day } -- UTC ?
-- local prm = Argts.new() -- create a new object from the class Argts, to update later
local prm = Argts -- arguments connus, known arguments
-- current_space = " ns=" .. mw.site.namespaces.name -- {{NAMESPACE}}
-- current_space = " ns0=" .. frame:preprocess("{{ns:0}}") -- present namespace from system
-- This repair a Lua bug : {{NAMESPACE}} give nothing in fr.wikisource.org
current_space = frame:preprocess("{{NAMESPACE}}") -- present namespace from system
-- This repair a Lua bug : mw.site.namespaces.name is unknown
module_space = frame:preprocess("{{ns:Module}}") -- Module namespace from system
template_space = frame:preprocess("{{ns:Template}}") -- Module namespace from system
author_space = frame:preprocess("{{ns:Author}}") -- Author namespace from system
category_space = frame:preprocess("{{ns:Category}}") -- Category namespace from system
prm.args_init(prm.args_known_default, args)
-- prm.args_init(nil, args, "fr")
-- local Argtest = { options = " debug fr docavant ", "Rimbaud", "Arthur", "1234", droits = "70", pays = "France" }
if ArgXXXtest ~= nil then
local t = prm.args_import_all(Argtest) -- Argts.args_import_all(args_src, args_kwn)
t = t..Argts.generDoc("") -- Documentation des arguments dés leur lecture
return t
end
--[[
-- Interact parameters
-- |nom=Hugo|prénom=Victor|prénomGall= Arthur
-- The syntax var.Name is just syntactic sugar for var["Name"]
local lastname = args.nom
local last_initial = args.initiale
if "!NO_INITIALS" == last_initial then last_initial = nil end
local firstname = args["prénom"] or last_initial
if nil ~= lastname then
if firstname ~= nil then
title = firstname .. " " .. lastname
else
title = lastname
end
end
wsdata["lastname"] = lastname
wsdata["ws-firstname"] = firstname
wsdata["ws-initial"] = last_initial
wsdata["ws-title"] = title
wsdata["family-name"] = lastname
wsdata["given-name"] = firstname
local wsdata = {}
local param_type = "<br/>Paramètres de notices d'autorités connues du module : "
for noticeN in table_iterator(notices_properties) do
-- pour toutes les notices connues de ce module
-- collecter les parametres de la notice, voir docnotice
local id = noticeN._id -- id de la notice comme "ARC"
local wsid = noticeN._wsid -- ws-id de la notice comme "ws-ARC"
if Argts[wsid] == nil then
-- erreur_add("err_internal_notice_wsid", tostring(wsid))
else
local _type = noticeN._type -- type de la notice "Auteur" ou "Book" ou autre
param_type = param_type .. ", " .. tostring(wsid) .. "=" .. tostring(id) .. ":" .. _type
if _type == "Auteur" then
Argts[wsid]["val"] = args[id] -- lire les paramètres de notices de type Auteur
param_type = param_type .. "+"
end
end
end
--]]
prm.args_import_all(args) -- args : import all arguments from template, or other source
local_options = options_change(local_options, Argts.args_known_default["options"]["val"], "init")
doc_args_import_all = Argts.generDoc("") -- Documentation des arguments dés leur lecture
trck('<br/>* ')
local argval = prm.argv("birthdate") -- read arg value from local data
trck('<br/>* ')
local argval = prm.argv("deathdate") -- read arg value from local data
-- local_options = options_change(local_options, Argts.argv("options", tr), "init")
--
-- Interact parameters
local lastname = prm.argv("lastname")
local firstname = prm.argv("firstname")
local Galliname = prm.argv("Galliname")
local pseudonym = prm.argv("pseudonym")
local sortkey = prm.argv("sortkey")
local familyname = prm.argv("familyname")
local title = prm.argv("title")
local initiale = prm.argv("initiale")
lastname = lastname or pseudonym or sortkey or familyname or initiale
if title == "" then
if lastname ~= "" then
if firstname == "" then
title = lastname
else
title = firstname .. " " .. lastname
end
-- elseif Galliname ~= "" then
-- title = Galliname .. " " .. lastname
end
end
-- if there is no firstname, try to extract it from lastname
-- ...
-- link to other wikis
local wikipedia = prm.argv("wikipedia")
local wikiquote = prm.argv("wikiquote")
local commons = prm.argv("commons")
if wikipedia == "" then wikipedia = title end
if wikiquote == "" then wikiquote = title end
if commons == "" then commons = title end
-- title = firstname .. " " .. lastname
prm.arg_memorize("lastname", lastname)
prm.arg_memorize("firstname", firstname)
prm.arg_memorize("title", title)
prm.arg_memorize("wikipedia", wikipedia)
prm.arg_memorize("wikiquote", wikiquote)
prm.arg_memorize("commons", commons)
--
-- Generer des tests et documentations optionnels avant le wikitexte normal
local unitest = ""
if option("unitest") then
tst.init(frame) -- tst.init( frame, test_list, test_data )
tst.run_all_tests( frame )
unitest = tst.test_result
end
local docavant = ""
if option("docavant") then
docavant = doc_args_import_all
end
local errs = ""
if option("erreurs") then errs = erreur_lister() end
-- docavant = Argts.generDoc("")
--
-- Generer le wikitext et HTML normal, categories et autres (sauf options contraires)
local box = headbox_fr(args, wsdata)
if option("nobox") then box = "" end
local cat = categories(control, wsdata)
if option("nocat") then cat = "" end
local dat = microformat(wsdata)
local drs = droits(now, control, wsdata)
local ds = defaultsort(control, wsdata)
--
-- Generer des tests et documentations optionnels après le wikitexte normal
local doc_notice = ""
if option("docnotice") then doc_notice = notices_liste(notices_properties, args) end
local docapres = ""
if option("docapres") then
docapres = doc_args_import_all
end
local track = ""
if trck_on then track = trc end
-- if option("track") then track = trc end
-- errs = erreur_lister("<br/>Erreurs pendant l'affichage initial de l'entète d'auteur :")
-- errs = '<span style="color:red;" >' .. errs .. '</span>'
-- end
return unitest .. docavant .. errs .. box .. cat .. dat .. drs .. ds .. doc_notice .. docapres .. track .. '<br/>'
end -- p.auteur(frame)
-- Alias pour Interface pour générer une entête de page d'auteur.
function p.fr(frame)
return p.auteur(frame)
end -- p.fr(frame)
-- Interface pour générer une notice d'autorité indépendante sur une personne, un livre ou autre.
function p.notice(frame)
-- local pframe = frame:getParent()
-- local args = pframe.args
local args = frame.args
local now = { year = args.year, month = args.month, day = args.day }
-- local prm = Argts.new() -- create a new object from the class Argts
local prm = Argts -- arguments connus, known arguments
category_space = frame:preprocess("{{ns:Category}}") -- Category namespace from system
author_space = frame:preprocess("{{ns:Author}}") -- Category namespace from system
prm.args_init(prm.args_known_default, args, "fr")
-- local Argtest = { options = " debug fr docavant ", "Rimbaud", "Arthur", "1234", droits = "70", pays = "France" }
if ArgXXXtest ~= nil then
local t = prm.args_import_all(Argtest) -- Argts.args_import_all(args_src, args_kwn)
t = t..Argts.generDoc("") -- Documentation des arguments dés leur lecture
return t
end
arg_lang = "en"
-- Generate wikitext and others
local ntc = HTMLnotice(control, data, ref, noticeN)
return ntc
end -- p.notice(frame)
-- Alias pour Interface pour générer une notice d'autorité indépendante sur une personne, un livre ou autre.
function p.nt(frame)
return p.notice(frame)
end -- p.nt(frame)
return p