« Module:Etablissement » : différence entre les versions
		
		
		
		
		
		Aller à la navigation
		Aller à la recherche
		
				
		
		
	
| Aucun résumé des modifications | Aucun résumé des modifications | ||
| (12 versions intermédiaires par le même utilisateur non affichées) | |||
| Ligne 1 : | Ligne 1 : | ||
| local p = {} | 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/Lycée_Le_Corbusier' , | |||
| 		["label"] = 'Lycée Le Corbusier' , | |||
| 		["titre"] = 'Le Corbusier' , | |||
| 		["activité"] = 'Lycée' , | |||
| 		["adresse"] = '88 Rue de Villiers, 78300 Poissy' , | |||
| 		["latitude"] = '48.923503', | |||
| 		["longitude"] = '2.026752', | |||
| 		["site Web"] = 'http://www.lyc-lecorbusier-poissy.ac-versailles.fr', | |||
| 		["demo"] = '1' | |||
| 	    } | |||
| } | |||
| mw.log(p.infobox( newFrame ) ) | |||
| --]] | |||
| function p.infobox(f) | function p.infobox(f) | ||
| Ligne 8 : | Ligne 27 : | ||
|      -- init the prefix |      -- init the prefix | ||
|      local escr = ' |      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 geo = 'http://www.opengis.net/ont/geosparql#' | |||
|      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/' | ||
| Ligne 24 : | Ligne 45 : | ||
|      local object = linkedwiki.new(subject,"https://data.escr.fr/data") |      local object = linkedwiki.new(subject,"https://data.escr.fr/data") | ||
|    if linkedwiki.isEmpty(f.args['demo']) then | |||
| 	    --object:setDebug(true) | |||
| 	    object:removeSubject() -- delete all triples of this subject | |||
| 		-- Save the data in the infobox in a knowledge base | |||
| 	    mw.log(object:addPropertyWithIri(rdf .. 'type', escr .. 'Etablissement')) | |||
| 	    if f.args["activité"] == "Lycée" then mw.log(object:addPropertyWithIri(rdf .. 'type', escr .. 'Etablissement'..'#Lycée')) | |||
|     	elseif f.args["activité"] == "Université" then mw.log(object:addPropertyWithIri(rdf .. 'type', escr .. 'Etablissement'..'#Université')) | |||
|     	elseif f.args["activité"] == "Ecole supérieure" then mw.log(object:addPropertyWithIri(rdf .. 'type', escr .. 'Etablissement'..'#EcoleSupérieure')) | |||
|     	end | |||
|     	mw.log(object:addPropertyString(rdfs .. 'label', f.args['label'])) | |||
|     	mw.log(object:addProperty( escr .. 'Etablissement'..'#géolocalisation', 'Point('..f.args['longitude']..' '..f.args['latitude']..')', geo .. 'wktLiteral', '')) | |||
|     	mw.log(object:addPropertyWithIri( escr .. 'Etablissement'..'#siteWeb', f.args['site Web'])) | |||
|      end | |||
|      --Make infobox with capiunto |      --Make infobox with capiunto | ||
|      local infobox = capiunto.create({ |      local infobox = capiunto.create({ | ||
|          bodyStyle = 'width : 50px', |          --bodyStyle = 'width : 50px', | ||
|          -- bodyClass = 'gregoriusPape', |          -- bodyClass = 'gregoriusPape', | ||
|          title = ' |          title = f.args['activité'], | ||
|          -- top = objWikidata:checkString(rdfs .. 'label', f.args. |          -- top = objWikidata:checkString(rdfs .. 'label', f.args.Titre), | ||
|          top = f.args. |          top = f.args.titre, | ||
|          topStyle = 'background:# |          topStyle = 'background: #dfedff;  font-size: 1.4em; padding: 15px;' | ||
|      }) |      }) | ||
|      infobox:addWikitext(f.args['adresse']) | |||
|      infobox:addRow('géolocalisation', f.args['latitude']..','..f.args['longitude']) | |||
|      infobox:addRow('site Web', f.args['site Web']) | |||
|      return infobox |      return infobox | ||
| end | end | ||
| return p | return p | ||
Version actuelle datée du 4 octobre 2020 à 19:49
La documentation pour ce module peut être créée à Module:Etablissement/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/Lycée_Le_Corbusier' ,
		["label"] = 'Lycée Le Corbusier' ,
		["titre"] = 'Le Corbusier' ,
		["activité"] = 'Lycée' ,
		["adresse"] = '88 Rue de Villiers, 78300 Poissy' ,
		["latitude"] = '48.923503',
		["longitude"] = '2.026752',
		["site Web"] = 'http://www.lyc-lecorbusier-poissy.ac-versailles.fr',
		["demo"] = '1'
	    }
}
mw.log(p.infobox( newFrame ) )
--]]
function p.infobox(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 geo = 'http://www.opengis.net/ont/geosparql#'
    
    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 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")
   if linkedwiki.isEmpty(f.args['demo']) then
	    --object:setDebug(true)
	    object:removeSubject() -- delete all triples of this subject
		-- Save the data in the infobox in a knowledge base
	    mw.log(object:addPropertyWithIri(rdf .. 'type', escr .. 'Etablissement'))
	    
	    if f.args["activité"] == "Lycée" then mw.log(object:addPropertyWithIri(rdf .. 'type', escr .. 'Etablissement'..'#Lycée'))
    	elseif f.args["activité"] == "Université" then mw.log(object:addPropertyWithIri(rdf .. 'type', escr .. 'Etablissement'..'#Université'))
    	elseif f.args["activité"] == "Ecole supérieure" then mw.log(object:addPropertyWithIri(rdf .. 'type', escr .. 'Etablissement'..'#EcoleSupérieure'))
    	end
    	
    	mw.log(object:addPropertyString(rdfs .. 'label', f.args['label']))
    	mw.log(object:addProperty( escr .. 'Etablissement'..'#géolocalisation', 'Point('..f.args['longitude']..' '..f.args['latitude']..')', geo .. 'wktLiteral', ''))
    	mw.log(object:addPropertyWithIri( escr .. 'Etablissement'..'#siteWeb', f.args['site Web']))
  
    end
    --Make infobox with capiunto
    local infobox = capiunto.create({
        --bodyStyle = 'width : 50px',
        -- bodyClass = 'gregoriusPape',
        title = f.args['activité'],
        -- top = objWikidata:checkString(rdfs .. 'label', f.args.Titre),
        top = f.args.titre,
        topStyle = 'background: #dfedff;  font-size: 1.4em; padding: 15px;'
    })
    infobox:addWikitext(f.args['adresse'])
    infobox:addRow('géolocalisation', f.args['latitude']..','..f.args['longitude'])
    infobox:addRow('site Web', f.args['site Web'])
    return infobox
end
return p