Module:GeneralMethod

From DAAP
Jump to navigation Jump to search

Documentation for this module may be created at Module:GeneralMethod/doc

--[[
-- Debug console

 frame = mw.getCurrentFrame() -- Get a frame object
newFrame = frame:newChild{ -- Get one with args
	title = 'Adrien IV' ,
 args = { 
	iri = 'http://example.com/test',
Title = 'test',
['Campagne 1'] = 'campagne 1',
['Campagne 2'] = 'campagne 2',
['Campagne 3'] = 'campagne 3',
['Campagne 4'] = 'campagne 4',
['Campagne 5'] = 'campagne 5',
['Campagne 6'] = 'campagne 6',
['Campagne 7'] = 'campagne 7',
['Campagne 8'] = 'campagne 8',
['Campagne 9'] = 'campagne 9',
['Campagne 10'] = 'campagne 10'
    }
}
mw.log(p.infobox( newFrame ) )

]]
local p = {}

function p.infobox(f)
	local capiunto = require 'capiunto'
    local linkedwiki = require 'linkedwiki'
    linkedwiki.setCurrentFrame(mw.getCurrentFrame())
    
    --prefix
   local rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
   local rdfs = 'http://www.w3.org/2000/01/rdf-schema#'
   local daapp = 'http://daap.dsi.universite-paris-saclay.fr/wiki/Data:Project#'
   local daap = 'http://daap.dsi.universite-paris-saclay.fr/wiki/'
   local daapProp = 'http://daap.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 listPageCampaign =''
 
 local subject = f.args.iri or linkedwiki.getCurrentIRI();
   local object =  linkedwiki.new(subject)

    object:removeSubject() -- delete all triples of this subject
 
  --object:addPropertyWithIri(PROPERTY,IRI)
   --object:addPropertyWithLitteral(PROPERTY,VALUE,TYPE,LANG) [LANG=nil=>default lang] [LANG=''=>no lang]
mw.log(object:addPropertyWithIri(rdf..'type',daapp..'GeneralMethod'))
	
if not linkedwiki.isEmpty(f.args['Title in English']) then
	mw.log(object:addPropertyString(rdfs..'label',f.args['Title in English'],''))
	mw.log(object:addPropertyString(rdfs..'label',f.args['Title in English'],'en'))
end
if not linkedwiki.isEmpty(f.args['Title in French']) then
	mw.log(object:addPropertyString(rdfs..'label',f.args['Title in French'],'fr'))
end

if not linkedwiki.isEmpty(f.args['Campagne 1'] ) then
	mw.log(object:addPropertyWithIri(daapp..'hasCampaign',mw.uri.decode(tostring(mw.uri.fullUrl(f.args['Campagne 1'])))))
	listPageCampaign = listPageCampaign..'[['..f.args['Campagne 1']..']]<br/>'
end
if not linkedwiki.isEmpty(f.args['Campagne 2'] ) then
	mw.log(object:addPropertyWithIri(daapp..'hasCampaign',mw.uri.decode(tostring(mw.uri.fullUrl(f.args['Campagne 2'])))))
	listPageCampaign = listPageCampaign..'[['..f.args['Campagne 2']..']]<br/>'
end

if not linkedwiki.isEmpty(f.args['Campagne 3'] ) then
	mw.log(object:addPropertyWithIri(daapp..'hasCampaign',mw.uri.decode(tostring(mw.uri.fullUrl(f.args['Campagne 3'])))))
	listPageCampaign = listPageCampaign..'[['..f.args['Campagne 3']..']]<br/>'
end
if not linkedwiki.isEmpty(f.args['Campagne 4'] ) then
	mw.log(object:addPropertyWithIri(daapp..'hasCampaign',mw.uri.decode(tostring(mw.uri.fullUrl(f.args['Campagne 4'])))))
	listPageCampaign = listPageCampaign..'[['..f.args['Campagne 4']..']]<br/>'
end
if not linkedwiki.isEmpty(f.args['Campagne 5'] ) then
	mw.log(object:addPropertyWithIri(daapp..'hasCampaign',mw.uri.decode(tostring(mw.uri.fullUrl(f.args['Campagne 5'])))))
	listPageCampaign = listPageCampaign..'[['..f.args['Campagne 5']..']]<br/>'
end
if not linkedwiki.isEmpty(f.args['Campagne 6'] ) then
	mw.log(object:addPropertyWithIri(daapp..'hasCampaign',mw.uri.decode(tostring(mw.uri.fullUrl(f.args['Campagne 6'])))))
	listPageCampaign = listPageCampaign..'[['..f.args['Campagne 6']..']]<br/>'
end
if not linkedwiki.isEmpty(f.args['Campagne 7'] ) then
	mw.log(object:addPropertyWithIri(daapp..'hasCampaign',mw.uri.decode(tostring(mw.uri.fullUrl(f.args['Campagne 7'])))))
	listPageCampaign = listPageCampaign..'[['..f.args['Campagne 7']..']]<br/>'
end
if not linkedwiki.isEmpty(f.args['Campagne 8'] ) then
	mw.log(object:addPropertyWithIri(daapp..'hasCampaign',mw.uri.decode(tostring(mw.uri.fullUrl(f.args['Campagne 8'])))))
	listPageCampaign = listPageCampaign..'[['..f.args['Campagne 8']..']]<br/>'
end
if not linkedwiki.isEmpty(f.args['Campagne 9'] ) then
	mw.log(object:addPropertyWithIri(daapp..'hasCampaign',mw.uri.decode(tostring(mw.uri.fullUrl(f.args['Campagne 9'])))))
	listPageCampaign = listPageCampaign..'[['..f.args['Campagne 9']..']]<br/>'
end
if not linkedwiki.isEmpty(f.args['Campagne 10'] ) then
	mw.log(object:addPropertyWithIri(daapp..'hasCampaign',mw.uri.decode(tostring(mw.uri.fullUrl(f.args['Campagne 10'])))))
	listPageCampaign = listPageCampaign..'[['..f.args['Campagne 10']..']]<br/>'
end

   
   --linkedwiki.setConfig('http://daap.dsi.universite-paris-saclay.fr') 
	return capiunto.create( {
	    -- bodyStyle = 'border: 15px solid red',
		title =  object:checkLabelOfInternLink(subject, rdfs..'label',f.args.Title)  ,
                top = 'Méthode générale',
		topStyle = 'background:#cfc;font-size:larger',		
	--	bottom = f.args.Website
	} )
	:addRow('Campagnes ', listPageCampaign	)
	:addWikitext( "[[Category:Méthode générale]]" )

end
 
return p