Différences entre versions de « Module:Lieu »

De Gregorius 3.0
Sauter à la navigation Sauter à la recherche
 
(8 versions intermédiaires par 3 utilisateurs non affichées)
Ligne 1 : Ligne 1 :
 +
--[[
 +
-- Debug console
 +
frame = mw.getCurrentFrame() -- Get a frame object
 +
newFrame = frame:newChild{ -- Get one with args
 +
title = 'oeuvre_test' ,
 +
args = {
 +
iri = 'http://157.136.249.54/wiki/oeuvre_test' ,
 +
--["Wikidata ID"] = 'Q335987',
 +
["Titre"] = 'Rome' ,
 +
["Nom original"] = 'Roma',
 +
["Pays"] = 'Italie',
 +
["Maire"] = 'Francesco Paolo Tronca',
 +
["Code postal"] = '00100',
 +
["Gentile"] = 'Romains'
 +
    }
 +
}
 +
mw.log(p.infobox( newFrame ) )
 +
]]
 +
 +
 
local p = {}
 
local p = {}
 
   
 
   
Ligne 4 : Ligne 24 :
 
     local capiunto = require 'capiunto'
 
     local capiunto = require 'capiunto'
 
     local linkedwiki = require 'linkedwiki'
 
     local linkedwiki = require 'linkedwiki'
+
    linkedwiki.setCurrentFrame(mw.getCurrentFrame()) -- added by hand
 +
 
 
local endpointUpsud = 'http://opendata1.opendata.u-psud.fr/sparql'
 
local endpointUpsud = 'http://opendata1.opendata.u-psud.fr/sparql'
 
   
 
   
 
   local rdfs = 'http://www.w3.org/2000/01/rdf-schema#'
 
   local rdfs = 'http://www.w3.org/2000/01/rdf-schema#'
   local daapProp = 'http://gregorius.fr/wiki/Property:'
+
   local rp = 'http://gregorius.dsi.universite-paris-saclay.fr/wiki/Property:'
 
   local geo = 'http://www.w3.org/2003/01/geo/wgs84_pos#'
 
   local geo = 'http://www.w3.org/2003/01/geo/wgs84_pos#'
 
   local vcard = 'http://www.w3.org/2006/vcard/ns#'
 
   local vcard = 'http://www.w3.org/2006/vcard/ns#'
 
   
 
   
  linkedwiki.setEndpoint(endpointUpsud)
+
  local subject = linkedwiki.getCurrentIRI(); -- read the iri of the current page
  linkedwiki.setSubject(linkedwiki.getCurrentIRI())
+
  local object =  linkedwiki.new(subject)
+
 
return capiunto.create( {
+
  if not linkedwiki.isEmpty(f.args['Nom original']) then
    bodyStyle = 'width : 25px',
+
mw.log(object:addProperty(rp..'Nomoriginal',f.args['Nom original']))
 +
  end
 +
 
 +
  --object:setDebug(true) --uncomment for debugging
 +
 
 +
local infobox = capiunto.create( {
 +
    bodyStyle = 'max-width : 20px',
 
    bodyClass = 'gregoriusLieu',
 
    bodyClass = 'gregoriusLieu',
title =  linkedwiki.checkLink(linkedwiki.getCurrentIRI(), rdfs..'label',f.args.Title)  ,
+
title =  object:checkLink(subject, rdfs..'label',f.args.Title)  ,
 
         top = 'Lieu',
 
         top = 'Lieu',
 
topStyle = 'background:#99FFCC;font-size:larger',
 
topStyle = 'background:#99FFCC;font-size:larger',
bottom = linkedwiki.checkExternLink('Website',rdfs..'seeAlso',f.args.Website)
+
bottom = object:checkExternLink('Website',rdfs..'seeAlso',f.args.Website)
 
} )
 
} )
:addImage(linkedwiki.checkImage(daapProp..'picture',f.args.Picture),"", "city_image" )
+
 
:addRow('Nom original', linkedwiki.checkString(daapProp..'nom original',f.args.NomOriginal))
+
infobox:addRow('Nom original',f.args['Nom original'])
:addRow('Pays', linkedwiki.checkString(daapProp..'pays',f.args.Pays))
+
infobox:addRow('Pays',f.args['Pays'])
:addRow('Maire', linkedwiki.checkString(daapProp..'maire',f.args.Maire))
+
infobox:addRow('Maire',f.args['Maire'])
:addRow('Code postal', linkedwiki.checkString(daapProp..'code postal',f.args.CodePostal))
+
infobox:addRow('Code postal',f.args['Code postal'])
:addRow('Gentilé', linkedwiki.checkString(daapProp..'gentile',f.args.Gentile))
+
infobox:addRow('Gentile', f.args['Gentile'])
:addWikitext( linkedwiki.getMaintenanceCategory() ..  "[[Category:Interdisciplinary Unit]]"
+
 
.."[[Category:Lieu]]" )
+
--infobox:addImage(object:checkImage(daapProp..'Image',f.args.Picture),"", "bodyStyle" )
 +
--infobox:addRow('Nom original', object:checkString(daapProp..'nom original',f.args.NomOriginal))
 +
--infobox:addRow('Pays', object:checkString(daapProp..'pays',f.args.Pays))
 +
--infobox:addRow('Maire', object:checkString(daapProp..'maire',f.args.Maire))
 +
--infobox:addRow('Code postal', object:checkString(daapProp..'code postal',f.args.CodePostal))
 +
--infobox:addRow('Gentile', object:checkString(daapProp..'gentile',f.args.Gentile))
 +
--infobox:addWikitext( object:getMaintenanceCategory() ..  "[[Category:Interdisciplinary Unit]]"
 +
-- .."[[Category:Lieu]]" )
 +
 +
return infobox
 +
 
 
end
 
end
 
   
 
   
 
return p
 
return p

Version actuelle datée du 29 octobre 2021 à 09:47

La documentation pour ce module peut être créée à Module:Lieu/doc

--[[
-- Debug console
frame = mw.getCurrentFrame() -- Get a frame object
newFrame = frame:newChild{ -- Get one with args
	title = 'oeuvre_test' ,
 args = { 
iri = 'http://157.136.249.54/wiki/oeuvre_test' ,
--["Wikidata ID"] = 'Q335987',
["Titre"] = 'Rome' ,
["Nom original"] = 'Roma',
["Pays"] = 'Italie',
["Maire"] = 'Francesco Paolo Tronca',
["Code postal"] = '00100',
["Gentile"] = 'Romains'
    }
}
mw.log(p.infobox( newFrame ) )
]]


local p = {}
 
function p.infobox(f)
    local capiunto = require 'capiunto'
    local linkedwiki = require 'linkedwiki'
    linkedwiki.setCurrentFrame(mw.getCurrentFrame()) -- added by hand

	local endpointUpsud = 'http://opendata1.opendata.u-psud.fr/sparql'
 
   local rdfs = 'http://www.w3.org/2000/01/rdf-schema#'
   local rp = 'http://gregorius.dsi.universite-paris-saclay.fr/wiki/Property:'
   local geo = 'http://www.w3.org/2003/01/geo/wgs84_pos#'
   local vcard = 'http://www.w3.org/2006/vcard/ns#'
 
  local subject = linkedwiki.getCurrentIRI(); -- read the iri of the current page
  local object =  linkedwiki.new(subject)
  
  if not linkedwiki.isEmpty(f.args['Nom original']) then
	mw.log(object:addProperty(rp..'Nomoriginal',f.args['Nom original']))
  end 
  
  --object:setDebug(true) --uncomment for debugging

	local infobox = capiunto.create( {
	    bodyStyle = 'max-width : 20px',
	    bodyClass = 'gregoriusLieu',
		title =  object:checkLink(subject, rdfs..'label',f.args.Title)  ,
        top = 'Lieu',
		topStyle = 'background:#99FFCC;font-size:larger',		
		bottom = object:checkExternLink('Website',rdfs..'seeAlso',f.args.Website)
	} )

	infobox:addRow('Nom original',f.args['Nom original'])
	infobox:addRow('Pays',f.args['Pays'])
	infobox:addRow('Maire',f.args['Maire'])
	infobox:addRow('Code postal',f.args['Code postal'])
	infobox:addRow('Gentile', f.args['Gentile'])

	--infobox:addImage(object:checkImage(daapProp..'Image',f.args.Picture),"", "bodyStyle" )
	--infobox:addRow('Nom original', object:checkString(daapProp..'nom original',f.args.NomOriginal))
	--infobox:addRow('Pays', object:checkString(daapProp..'pays',f.args.Pays))
	--infobox:addRow('Maire', object:checkString(daapProp..'maire',f.args.Maire))
	--infobox:addRow('Code postal', object:checkString(daapProp..'code postal',f.args.CodePostal))
	--infobox:addRow('Gentile', object:checkString(daapProp..'gentile',f.args.Gentile))	
	--infobox:addWikitext( object:getMaintenanceCategory() ..  "[[Category:Interdisciplinary Unit]]"
	--			.."[[Category:Lieu]]" )
	
	return infobox

end
 
return p