Différences entre versions de « Module:Oeuvre »
		
		
		
		
		
		Sauter à la navigation
		Sauter à la recherche
		
				
		
		
	
| (7 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 rdfs = 'http://www.w3.org/2000/01/rdf-schema#' |     local rdfs = 'http://www.w3.org/2000/01/rdf-schema#' | ||
| − |     local  | + |     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. | + |    local wd = 'http://www.wikidata.org/entity/' | 
| − |     linkedwiki. | + |    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', | 	    bodyClass = 'gregoriusOeuvre', | ||
| − | 		title =  'Oeuvre', | + | 		title =  'Oeuvre' , | 
| − |          top =  | + |          top = topWikidata , | 
| − | 		topStyle = 'background:# | + | 		topStyle = 'background:#FFD200;height:50px;font-size: 25px;vertical-align:middle',		 | 
| − | 		bottom =  | + | 		bottom = object:checkExternLink('Lien vers le texte',rdfs..'seeAlso',f.args.Website) | 
| 	} ) | 	} ) | ||
| − | 	: | + | |
| − | 	:addRow(' | + | 	--return capiunto.create( { | 
| − | + | 	    -- bodyStyle = 'border: 15px solid red', | |
| − | + | 	--    bodyClass = 'gregoriusOeuvre', | |
| − | + | 	--	title =  '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