« Module:CFCR » : différence entre les versions

De ESCR
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())
linkedwiki.setCurrentFrame(mw.getCurrentFrame())
--  -- init the prefix
    -- init the prefix
--  local escr = 'https://data.escr.fr/wiki/Data:'
    local escr = 'https://data.escr.fr/wiki/Data:'
      
      
--  local rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
    local rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
--  local rdfs = 'http://www.w3.org/2000/01/rdf-schema#'
    local rdfs = 'http://www.w3.org/2000/01/rdf-schema#'
--  -- local xsd = 'http://www.w3.org/2001/XMLSchema#'
    -- local xsd = 'http://www.w3.org/2001/XMLSchema#'
--  -- local wdt = 'http://www.wikidata.org/prop/direct/'
    -- local wdt = 'http://www.wikidata.org/prop/direct/'
--  -- local wd = 'http://www.wikidata.org/entity/'
    -- local wd = 'http://www.wikidata.org/entity/'
--  -- local p = 'http://www.wikidata.org/prop/'
    -- local p = 'http://www.wikidata.org/prop/'
--  -- local pq = 'http://www.wikidata.org/prop/qualifier/'
    -- local pq = 'http://www.wikidata.org/prop/qualifier/'
--  -- local ps = 'http://www.wikidata.org/prop/statement/'
    -- local ps = 'http://www.wikidata.org/prop/statement/'
--  local vcard = 'http://www.w3.org/2006/vcard/'
    local vcard = 'http://www.w3.org/2006/vcard/'


--  local dateFormat = "d M Y"
    local dateFormat = "d M Y"


--  local subject = f.args.iri or linkedwiki.getCurrentIRI();  --find the iri of the current page
    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")
    local object = linkedwiki.new(subject,"https://data.escr.fr/data")
--  --object:setDebug(true)
    --object:setDebug(true)


-- -- for key,value in pairs(f.args) do
-- for key,value in pairs(f.args) do
-- --    mw.log("found member " .. key);
--    mw.log("found member " .. key);
-- -- end
-- end


      
      
--  if linkedwiki.isEmpty(f.args['demo']) then
    if linkedwiki.isEmpty(f.args['demo']) then
-- object:removeSubject() -- delete all triples of this subject
object:removeSubject() -- delete all triples of this subject
      
      
--    -- Save the data in the infobox in a knowledge base
    -- Save the data in the infobox in a knowledge base
--    mw.log(object:addPropertyWithIri(rdf .. 'type', vcard .. 'Individual'))
    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 .. 'fn', f.args['nom']..' '.. f.args['prénom']))
--    mw.log(object:addPropertyString(vcard .. 'family-name', f.args['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:addPropertyString(vcard .. 'given-name', f.args['prénom']))
     
     
--    mw.log(object:addPropertyWithIri(rdf .. 'type', escr .. 'CFCR#Référent'))
    mw.log(object:addPropertyWithIri(rdf .. 'type', escr .. 'CFCR#Référent'))
--  end
    end


--  --Make infobox with capiunto
    --Make infobox with capiunto
--  local infobox = capiunto.create({
    local infobox = capiunto.create({
--      title = 'Référent CFCR',
        title = 'Référent CFCR',
--      top = f.args['nom']..' '..f.args['prénom'],
        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;'
        topStyle = 'background: #dfedff;  font-size: 1.4em; margin: 5px; display: inline-block; width: -webkit-fill-available; padding: 15px;'
--  })
    })


     --return infobox
     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