« Module:CFCR » : différence entre les versions
Aller à la navigation
Aller à la recherche
Aucun résumé des modifications |
Aucun résumé des modifications |
||
Ligne 19 : | Ligne 19 : | ||
local linkedwiki = require 'linkedwiki' | local linkedwiki = require 'linkedwiki' | ||
linkedwiki.setCurrentFrame(mw.getCurrentFrame()) | |||
-- init the prefix | |||
local escr = 'https://data.escr.fr/wiki/Data:' | |||
local rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#' | |||
local rdfs = 'http://www.w3.org/2000/01/rdf-schema#' | |||
-- local xsd = 'http://www.w3.org/2001/XMLSchema#' | |||
-- local wdt = 'http://www.wikidata.org/prop/direct/' | |||
-- local wd = 'http://www.wikidata.org/entity/' | |||
-- local p = 'http://www.wikidata.org/prop/' | |||
-- local pq = 'http://www.wikidata.org/prop/qualifier/' | |||
-- local ps = 'http://www.wikidata.org/prop/statement/' | |||
local vcard = 'http://www.w3.org/2006/vcard/' | |||
local dateFormat = "d M Y" | |||
local subject = f.args.iri or linkedwiki.getCurrentIRI(); --find the iri of the current page | |||
local object = linkedwiki.new(subject,"https://data.escr.fr/data") | |||
--object:setDebug(true) | |||
-- for key,value in pairs(f.args) do | |||
-- mw.log("found member " .. key); | |||
-- end | |||
if linkedwiki.isEmpty(f.args['demo']) then | |||
object:removeSubject() -- delete all triples of this subject | |||
-- Save the data in the infobox in a knowledge base | |||
mw.log(object:addPropertyWithIri(rdf .. 'type', vcard .. 'Individual')) | |||
mw.log(object:addPropertyString(vcard .. 'fn', f.args['nom']..' '.. f.args['prénom'])) | |||
mw.log(object:addPropertyString(vcard .. 'family-name', f.args['nom'])) | |||
mw.log(object:addPropertyString(vcard .. 'given-name', f.args['prénom'])) | |||
mw.log(object:addPropertyWithIri(rdf .. 'type', escr .. 'CFCR#Référent')) | |||
end | |||
--Make infobox with capiunto | |||
local infobox = capiunto.create({ | |||
title = 'Référent CFCR', | |||
top = f.args['nom']..' '..f.args['prénom'], | |||
topStyle = 'background: #dfedff; font-size: 1.4em; margin: 5px; display: inline-block; width: -webkit-fill-available; padding: 15px;' | |||
}) | |||
return infobox | |||
return mw.logObject( f.args ) | --return mw.logObject( f.args ) | ||
end | end | ||
return p | return p |
Version du 4 octobre 2020 à 13:52
La documentation pour ce module peut être créée à Module:CFCR/doc
local p = {}
--[[ For test
frame = mw.getCurrentFrame() -- Get a frame object
newFrame = frame:newChild{ -- Get one with args
title = 'Dupond Bertrand' ,
args = {
iri = 'https://data.escr.fr/wiki/Utilisateur:Dupond_Bertrand' ,
["nom"] = 'Dupond' ,
["prénom"] = 'Bertrand',
["demo"] = '1'
}
}
mw.log(p.referent( newFrame ) )
--]]
function p.referent(f)
local capiunto = require 'capiunto'
local linkedwiki = require 'linkedwiki'
linkedwiki.setCurrentFrame(mw.getCurrentFrame())
-- init the prefix
local escr = 'https://data.escr.fr/wiki/Data:'
local rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
local rdfs = 'http://www.w3.org/2000/01/rdf-schema#'
-- local xsd = 'http://www.w3.org/2001/XMLSchema#'
-- local wdt = 'http://www.wikidata.org/prop/direct/'
-- local wd = 'http://www.wikidata.org/entity/'
-- local p = 'http://www.wikidata.org/prop/'
-- local pq = 'http://www.wikidata.org/prop/qualifier/'
-- local ps = 'http://www.wikidata.org/prop/statement/'
local vcard = 'http://www.w3.org/2006/vcard/'
local dateFormat = "d M Y"
local subject = f.args.iri or linkedwiki.getCurrentIRI(); --find the iri of the current page
local object = linkedwiki.new(subject,"https://data.escr.fr/data")
--object:setDebug(true)
-- for key,value in pairs(f.args) do
-- mw.log("found member " .. key);
-- end
if linkedwiki.isEmpty(f.args['demo']) then
object:removeSubject() -- delete all triples of this subject
-- Save the data in the infobox in a knowledge base
mw.log(object:addPropertyWithIri(rdf .. 'type', vcard .. 'Individual'))
mw.log(object:addPropertyString(vcard .. 'fn', f.args['nom']..' '.. f.args['prénom']))
mw.log(object:addPropertyString(vcard .. 'family-name', f.args['nom']))
mw.log(object:addPropertyString(vcard .. 'given-name', f.args['prénom']))
mw.log(object:addPropertyWithIri(rdf .. 'type', escr .. 'CFCR#Référent'))
end
--Make infobox with capiunto
local infobox = capiunto.create({
title = 'Référent CFCR',
top = f.args['nom']..' '..f.args['prénom'],
topStyle = 'background: #dfedff; font-size: 1.4em; margin: 5px; display: inline-block; width: -webkit-fill-available; padding: 15px;'
})
return infobox
--return mw.logObject( f.args )
end
return p