« 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
 
(8 versions intermédiaires par le même utilisateur non affichées)
Ligne 7 : Ligne 7 :
args = {
args = {
iri = 'https://data.escr.fr/wiki/Utilisateur:Dupond_Bertrand' ,
iri = 'https://data.escr.fr/wiki/Utilisateur:Dupond_Bertrand' ,
["nom"] = 'Dupond' ,
["année"] = '2021' ,
["prénom"] = 'Bertrand',
["niveau"] = 'école supérieure' ,
["établissement"] = 'Mon école',
["classe"] = 'A1',
["méthode pour le contacter"] = ' à contacter par email',
["demo"] = '1'
["demo"] = '1'
    }
    }
Ligne 19 : Ligne 22 :
     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 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 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
    -- Save the data in the infobox in a knowledge base
    mw.log(object:addPropertyWithIri(rdf .. 'type', escr .. 'CFCR#Référent'))
    mw.log(object:addPropertyWithIri(rdf .. 'type', escr .. 'CFCR#Référent'..f.args['année']))
   
    mw.log(object:addProperty(escr .. 'CFCR#niveau', f.args['niveau'] ))
    mw.log(object:addPropertyWithIri(escr .. 'CFCR#établissement', mw.uri.decode(mw.title.new(f.args['établissement']):fullUrl()) ))
    -- mw.log(object:getLastQuery())
    mw.log(object:addProperty(escr .. 'CFCR#classe', f.args['classe'] ))
    mw.log(object:addProperty(escr .. 'CFCR#methodePourLeContacter', f.args['méthode pour le contacter'] ))
    end


    --Make infobox with capiunto
    local infobox = capiunto.create({
        title = 'Référent CFCR '..f.args['année'],
        top = '[['..f.args['établissement']..']]',
        topStyle = 'background: #dfedff;  font-size: 1.4em;padding: 15px;'
    })
      
      
--  if linkedwiki.isEmpty(f.args['demo']) then
    if not linkedwiki.isEmpty(f.args['classe']) then
-- object:removeSubject() -- delete all triples of this subject
infobox:addRow('Classe', f.args['classe'])
   
    end
--    -- 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
    infobox:addWikitext(f.args['méthode pour le contacter'] )
--  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 infobox
     return mw.logObject( f.args )
     --return mw.logObject( f.args )
end
end


return p
return p

Version actuelle datée du 4 octobre 2020 à 18:48

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' ,
		["année"] = '2021' ,
		["niveau"] = 'école supérieure' ,
		["établissement"] = 'Mon école',
		["classe"] = 'A1',
		["méthode pour le contacter"] = ' à contacter par email',
		["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 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
	    -- Save the data in the infobox in a knowledge base
	    mw.log(object:addPropertyWithIri(rdf .. 'type', escr .. 'CFCR#Référent'))
	    mw.log(object:addPropertyWithIri(rdf .. 'type', escr .. 'CFCR#Référent'..f.args['année']))
	    
	    mw.log(object:addProperty(escr .. 'CFCR#niveau', f.args['niveau'] ))
	    mw.log(object:addPropertyWithIri(escr .. 'CFCR#établissement', mw.uri.decode(mw.title.new(f.args['établissement']):fullUrl()) ))
	    -- mw.log(object:getLastQuery())
	    mw.log(object:addProperty(escr .. 'CFCR#classe', f.args['classe'] ))
	    mw.log(object:addProperty(escr .. 'CFCR#methodePourLeContacter', f.args['méthode pour le contacter'] ))
    end

    --Make infobox with capiunto
    local infobox = capiunto.create({
        title = 'Référent CFCR '..f.args['année'],
        top = '[['..f.args['établissement']..']]',
        topStyle = 'background: #dfedff;  font-size: 1.4em;padding: 15px;'
    })
    
     if not linkedwiki.isEmpty(f.args['classe']) then
		infobox:addRow('Classe', f.args['classe'])
     end

    infobox:addWikitext(f.args['méthode pour le contacter'] )

    return infobox
    --return 	mw.logObject( f.args )
end

return p