Différences entre versions de « Module:Oeuvre »

De Gregorius 3.0
Sauter à la navigation Sauter à la recherche
 
(10 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 = 'https://gregorius.dsi.universite-paris-saclay.fr/wiki/Fratelli_tutti' ,
 +
["Wikidata ID"] = 'Q335987' ,
 +
["Bnf ID"] = '' ,
 +
["Titre"] = '' ,
 +
["Siecle"] = '',
 +
["Auteur"] = '',
 +
["Type"] = '',
 +
["Date"] = '',
 +
["Lieu de publication"] = '',
 +
["Suite"] = ''
 +
    }
 +
}
 +
mw.log(p.infobox( newFrame ) )
 +
]]
 +
 +
 
local p = {}
 
local p = {}
 
   
 
   
Ligne 4 : Ligne 26 :
 
     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 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 gregProp = '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#'
   
+
  local wdt = 'http://www.wikidata.org/prop/direct/'
   linkedwiki.setEndpoint(endpointUpsud)
+
  local wd = 'http://www.wikidata.org/entity/'
   linkedwiki.setSubject(linkedwiki.getCurrentIRI())
+
  local dateFormat = "d M Y"
+
 
return capiunto.create( {
+
  local subject = f.args.iri or linkedwiki.getCurrentIRI(); -- read the iri of the current page
    -- bodyStyle = 'border: 15px solid red',
+
  --local subject = linkedwiki.getCurrentIRI(); -- read the iri of the current page
 +
  local object = linkedwiki.new(subject)
 +
   object:removeSubject() -- delete all triples of this subject (associees au nom de)
 +
 
 +
  if not linkedwiki.isEmpty(f.args['Image']) then --just added to cure error
 +
mw.log(object:addPropertyWithIri(gregProp..'picture',f.args["Image"]))
 +
end
 +
 
 +
    local iriWikidata = ""
 +
    local objWikidata = nil
 +
    local linkWikidata = ""
 +
    local topWikidata = ""
 +
 
 +
   if not linkedwiki.isEmpty(f.args['Wikidata ID']) then
 +
  local idConfigWikidata ='http://www.wikidata.org'
 +
local taglang ='fr'
 +
iriWikidata = wd .. f.args['Wikidata ID']
 +
objWikidata = linkedwiki.new(iriWikidata,idConfigWikidata,taglang) -- create object with same config of wikidata
 +
---- and use the same ID of wikidata to get the informations relative to that object
 +
  linkWikidata ='['..iriWikidata..' '..f.args['Wikidata ID']..']'
 +
  topWikidata  = objWikidata:checkString(rdfs..'label',f.args.Title)
 +
  end
 +
 
 +
-- we build our own infobox
 +
local infobox = capiunto.create( {
 +
    bodyStyle = 'width : 50px',
 
    bodyClass = 'gregoriusOeuvre',
 
    bodyClass = 'gregoriusOeuvre',
title =  'Oeuvre',
+
title =  'Oeuvre' ,
         top = linkedwiki.checkLink(linkedwiki.getCurrentIRI(), rdfs..'label',f.args.Title)  ,
+
         top = topWikidata ,
topStyle = 'background:#0066CC;height:50px;font-size: 25px;vertical-align:middle',
+
topStyle = 'background:#FFD200;height:50px;font-size: 25px;vertical-align:middle',
bottom = linkedwiki.checkExternLink('Website',rdfs..'seeAlso',f.args.Website)
+
bottom = object:checkExternLink('Lien vers le texte',rdfs..'seeAlso',f.args.Website)
 
} )
 
} )
:addRow('Titre', linkedwiki.checkString(daapProp..'titre',f.args.Titre))
+
 
:addRow('Date', linkedwiki.checkString(daapProp..'date',f.args.Date))
+
--return capiunto.create( {
:addRow('Siècle', linkedwiki.checkString(daapProp..'siecle',f.args.Siecle))
+
    -- bodyStyle = 'border: 15px solid red',
:addRow('Auteur', linkedwiki.checkString(daapProp..'auteur',f.args.Auteur))
+
--    bodyClass = 'gregoriusOeuvre',
:addWikitext( linkedwiki.getMaintenanceCategory() .. "[[Category:Interdisciplinary Unit]]"
+
-- title =  'Oeuvre',
.."[[Category:Oeuvre]]" )
+
    --    top = object:checkString(gregProp..'titre',f.args.Type) ,
end
+
-- topStyle = 'background:#0066CC;height:50px;font-size: 20px;color:white;vertical-align:middle',
+
-- bottom = object:checkExternLink('Lien vers le texte',rdfs..'seeAlso',f.args.Website)
 +
--} )
 +
--end
 +
 +
if not linkedwiki.isEmpty(f.args['Wikidata ID']) then
 +
-- :addRow('Titre',objWikidata:checkString(wdt.."P1476",f.args['Titre']))
 +
infobox:addImage( objWikidata:checkImage(wdt..'P18',f.args["Image"]),"Legende TODO", "infobox" )
 +
infobox:addRow('Titre',objWikidata:checkString(rdfs..'label',f.args.Title) )
 +
infobox:addRow('Auteur',objWikidata:checkTitle(wdt.."P50",f.args['Auteur']))
 +
infobox:addRow('Type',objWikidata:checkTitle(wdt.."P31",f.args['Type']))
 +
infobox:addRow('Date', objWikidata:checkDate(wdt.."P577",f.args['Date'],dateFormat))
 +
infobox:addRow('Lieu de publication',objWikidata:checkTitle(wdt.."P291",f.args['Lieu de publication']))
 +
infobox:addRow('Suit',objWikidata:checkTitle(wdt.."P155",f.args['Suit']))
 +
--infobox:addRow('Lieu de décès', objWikidataLieuDeces:checkString(rdfs.."label",f.args['Lieu de décès']))
 +
----add charges recouvertes
 +
--infobox:addRow('Charges recouvertes', objWikidata:checkTitle(wdt..'P106', f.args['Charges recouvertes'], 'fr' ) )
 +
else
 +
-- :addRow('Titre',f.args['Titre'])
 +
infobox:addImage( f.args["Image"])
 +
infobox:addRow('Titre',f.args['Titre'])
 +
infobox:addRow('Auteur',f.args['Auteur'])
 +
infobox:addRow('Type',f.args['Type'])
 +
infobox:addRow('Date', f.args['Date'],dateFormat)
 +
infobox:addRow('Lieu de publication',f.args['Lieu de publication'])
 +
infobox:addRow('Suit',f.args['Suit'])
 +
----add charges recouvertes
 +
--infobox:addRow('Charges recouvertes', f.args['Charges recouvertes'])
 +
end
 +
    --infobox:addRow('Date', f.args['Date'])
 +
return infobox
 +
end
 
return p
 
return p

Version actuelle datée du 29 octobre 2021 à 13:44

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

--[[
-- Debug console
frame = mw.getCurrentFrame() -- Get a frame object
newFrame = frame:newChild{ -- Get one with args
	title = 'oeuvre_test' ,
 args = { 
 iri = 'https://gregorius.dsi.universite-paris-saclay.fr/wiki/Fratelli_tutti' ,
["Wikidata ID"] = 'Q335987' ,
["Bnf ID"] = '' ,
["Titre"] = '' ,
["Siecle"] = '',
["Auteur"] = '',
["Type"] = '',
["Date"] = '',
["Lieu de publication"] = '',
["Suite"] = ''
    }
}
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 rdfs = 'http://www.w3.org/2000/01/rdf-schema#'
   local gregProp = '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 wdt = 'http://www.wikidata.org/prop/direct/'
   local wd = 'http://www.wikidata.org/entity/'
   local dateFormat = "d M Y"

   local subject = f.args.iri or linkedwiki.getCurrentIRI(); -- read the iri of the current page
   --local subject = linkedwiki.getCurrentIRI(); -- read the iri of the current page
   local object =  linkedwiki.new(subject)
   object:removeSubject() -- delete all triples of this subject (associees au nom de)

   if not linkedwiki.isEmpty(f.args['Image']) then --just added to cure error
		mw.log(object:addPropertyWithIri(gregProp..'picture',f.args["Image"]))
	end 

    local iriWikidata = ""
    local objWikidata = nil
    local linkWikidata = ""
    local topWikidata = ""

   if not linkedwiki.isEmpty(f.args['Wikidata ID']) then
   		local idConfigWikidata ='http://www.wikidata.org'
		local taglang ='fr'
		iriWikidata = wd .. f.args['Wikidata ID']
		objWikidata = linkedwiki.new(iriWikidata,idConfigWikidata,taglang) -- create object with same config of wikidata
	---- and use the same ID of wikidata to get the informations relative to that object 
	   linkWikidata ='['..iriWikidata..' '..f.args['Wikidata ID']..']'
	   topWikidata  = objWikidata:checkString(rdfs..'label',f.args.Title)
   end

	-- we build our own infobox 
	local infobox = capiunto.create( {
	    bodyStyle = 'width : 50px',
	    bodyClass = 'gregoriusOeuvre',
		title =  'Oeuvre' ,
        top = topWikidata ,
		topStyle = 'background:#FFD200;height:50px;font-size: 25px;vertical-align:middle',		
		bottom = object:checkExternLink('Lien vers le texte',rdfs..'seeAlso',f.args.Website)
	} )

	--return capiunto.create( {
	    -- bodyStyle = 'border: 15px solid red',
	--    bodyClass = 'gregoriusOeuvre',
	--	title =  'Oeuvre',
    --    top = object:checkString(gregProp..'titre',f.args.Type) ,
	--	topStyle = 'background:#0066CC;height:50px;font-size: 20px;color:white;vertical-align:middle',		
	--	bottom = object:checkExternLink('Lien vers le texte',rdfs..'seeAlso',f.args.Website)
	--} )
	--end
	
	if not linkedwiki.isEmpty(f.args['Wikidata ID']) then
	--	:addRow('Titre',objWikidata:checkString(wdt.."P1476",f.args['Titre']))
		infobox:addImage( objWikidata:checkImage(wdt..'P18',f.args["Image"]),"Legende TODO", "infobox" )
		infobox:addRow('Titre',objWikidata:checkString(rdfs..'label',f.args.Title) )
		infobox:addRow('Auteur',objWikidata:checkTitle(wdt.."P50",f.args['Auteur']))
		infobox:addRow('Type',objWikidata:checkTitle(wdt.."P31",f.args['Type']))
		infobox:addRow('Date', objWikidata:checkDate(wdt.."P577",f.args['Date'],dateFormat))
		infobox:addRow('Lieu de publication',objWikidata:checkTitle(wdt.."P291",f.args['Lieu de publication']))
		infobox:addRow('Suit',objWikidata:checkTitle(wdt.."P155",f.args['Suit']))	
		--infobox:addRow('Lieu de décès', objWikidataLieuDeces:checkString(rdfs.."label",f.args['Lieu de décès']))
		----add charges recouvertes
		--infobox:addRow('Charges recouvertes', objWikidata:checkTitle(wdt..'P106', f.args['Charges recouvertes'], 'fr' ) )
	else
	--	:addRow('Titre',f.args['Titre'])
		infobox:addImage( f.args["Image"])
		infobox:addRow('Titre',f.args['Titre'])
		infobox:addRow('Auteur',f.args['Auteur'])
		infobox:addRow('Type',f.args['Type'])
		infobox:addRow('Date', f.args['Date'],dateFormat)
		infobox:addRow('Lieu de publication',f.args['Lieu de publication'])
		infobox:addRow('Suit',f.args['Suit'])
		----add charges recouvertes
		--infobox:addRow('Charges recouvertes', f.args['Charges recouvertes'])
	end
    --infobox:addRow('Date', f.args['Date'])
	return infobox
end	
return p