Module:Device

From DAAP
Jump to navigation Jump to search

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

--[[
-- Debug console

frame = mw.getCurrentFrame() -- Get a frame object
newFrame = frame:newChild{ -- Get one with args
	title = 'RamanEvolution' ,
 args = { 
	iri = 'http://daap.dsi.universite-paris-saclay.fr/wiki/Lip(Sys)2/RamanEvolution_Spectrometer' ,
    Title = 'RamanEvolution' ,
    ['Pilot process'] = 'Sana Tfaili' ,
    Email = 'sana.tfaili@u-psud.fr' ,
    Website ='' ,
    Keywords = 'Q862228',
    Picture = 'http://www.horiba.com/typo3temp/pics/e2f0ca2913.jpg' ,
    Latitude = '48.7623' ,
    Longitude = '2.27359' ,
    Organisation = 'Lip(Sys)2' 

    }
}
mw.log(p.infobox( newFrame ) )
]]

local p = {}

function p.infobox(f)
	local capiunto = require 'capiunto'
    local linkedwiki = require 'linkedwiki'
    linkedwiki.setCurrentFrame(mw.getCurrentFrame())
    
	local endpointUpsud = 'http://opendata1.opendata.u-psud.fr/sparql'
   local subject = f.args.iri or linkedwiki.getCurrentIRI();
   
   local rdfs = 'http://www.w3.org/2000/01/rdf-schema#'
   local daapd = 'http://daap.dsi.universite-paris-saclay.fr/wiki/Data:Device#'
   local geo = 'http://www.w3.org/2003/01/geo/wgs84_pos#'
   local vcard = 'http://www.w3.org/2006/vcard/ns#'
   
   local object =  linkedwiki.new(subject)
   --object:setDebug(true)
 
 --  mw.log(object:checkItem(daapd..'item',f.args.Keywords))
 --   mw.log(object:getLastQuery())
    
	return capiunto.create( {
	    -- bodyStyle = 'border: 15px solid red',
	    
		title =  object:checkLabelOfInternLink(subject, rdfs..'label',f.args.Title)  ,
        top = 'Device',
		topStyle = 'background:#cfc;font-size:larger',		
		bottom =  object:checkIriOfExternLink('Website',rdfs..'seeAlso',f.args.Website)
	} )
	:addImage(object:checkImage(daapd..'picture',f.args.Picture),"", "device_image" )
	:addRow('Pilot process', object:checkUser(daapd..'pilotProcess',f.args['Pilot process'],""))
	:addRow('Keywords', object:checkItem(daapd..'item',f.args.Keywords))
    :addRow('Organisation', object:checkTitle(vcard..'organization-unit',f.args.Organisation))
	:addRow('Latitude', object:checkValue(geo..'lat',f.args.Latitude))
	:addRow('Longitude', object:checkValue(geo..'long',f.args.Longitude))
	:addWikitext( object:getMaintenanceCategory() ..  "[[Category:Device]]" )
	
end
 
return p