Difference between revisions of "Module:Project"

From DAAP
Jump to navigation Jump to search
 
(One intermediate revision by the same user not shown)
Line 43: Line 43:
 
   local subject = f.args.iri or linkedwiki.getCurrentIRI();
 
   local subject = f.args.iri or linkedwiki.getCurrentIRI();
 
   local object =  linkedwiki.new(subject)
 
   local object =  linkedwiki.new(subject)
object:setDebug(true)  
+
  --object:setDebug(true)  
 
   
 
   
 
   object:removeSubject() -- delete all triples of this subject
 
   object:removeSubject() -- delete all triples of this subject
Line 71: Line 71:
 
if not linkedwiki.isEmpty(f.args.Contact)
 
if not linkedwiki.isEmpty(f.args.Contact)
 
  then
 
  then
mw.log(object:addPropertyWithIri(daapProp..'contact',mw.uri.decode(tostring(mw.uri.fullUrl(contactPage)))))
+
mw.log(object:addPropertyWithIri(daapp..'contact',mw.uri.decode(tostring(mw.uri.fullUrl(contactPage)))))
 
end
 
end
 
-- :addRow('Keywords', object:checkItem(daapProp..'item',f.args.Keywords))
 
-- :addRow('Keywords', object:checkItem(daapProp..'item',f.args.Keywords))

Latest revision as of 16:15, 10 October 2019

Documentation for this module may be created at Module:Project/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 in English'] = 'Title english',
		['Title in French'] = 'Title french',
		Contact = 'Sana Tfaili',
		Website ='',
		Keywords = 'Classes,Espèces,Caractérisation',
		Device = 'Chain RamanEvolution;  microsprectromètre Labram HR (Horiba Scientific®)',
		Laboratory = 'Lip(Sys)2',
		['General method 1'] = 'Analyse desmacrophages_méthode 1_Y',
		['General method 2'] = 'method2',
		['General method 3'] = 'method3',
		['General method 4'] = 'method4',
		['General method 5'] = 'method5'
    } 
}
mw.log(p.infobox( newFrame ) )

]]
local p = {}

function p.infobox(f)
	local capiunto = require 'capiunto'
    local linkedwiki = require 'linkedwiki'
    
    --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.eu/wiki/Data:Project#'
   local daap = 'http://daap.eu/wiki/'
   local daapProp = 'http://daap.eu/wiki/Property:'
   local geo = 'http://www.w3.org/2003/01/geo/wgs84_pos#'
   local vcard = 'http://www.w3.org/2006/vcard/ns#'
 
 
 -- save data 
   local subject = f.args.iri or linkedwiki.getCurrentIRI();
   local object =  linkedwiki.new(subject)
   --object:setDebug(true) 
 
   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..'Project'))
mw.log(object:addPropertyWithIri(vcard..'organization-unit','http://daap.eu/wiki/Lip(Sys)2'))
	
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.Website) then
	mw.log(object:addPropertyWithIri(rdfs..'seeAlso',f.args.Website))  
end

if not linkedwiki.isEmpty(f.args.Picture) then
	mw.log(object:addPropertyWithIri(daapp..'picture',f.args.Picture))
end

local contactPage ='User:'..f.args.Contact
if not linkedwiki.isEmpty(f.args.Contact)
 then
	mw.log(object:addPropertyWithIri(daapp..'contact',mw.uri.decode(tostring(mw.uri.fullUrl(contactPage)))))
end
--	:addRow('Keywords', object:checkItem(daapProp..'item',f.args.Keywords))
--mw.log(object:addPropertyWithIri(daapProp..'useDevice',f.args.Device))
--mw.log(object:addPropertyWithIri(vcard..'organization-unit',f.args.Laboratory))
 
  local listPageMethod =''
 if not linkedwiki.isEmpty(f.args['General method 1'] ) then
	mw.log(object:addPropertyWithIri(daapp..'hasGeneralMethod',mw.uri.decode(tostring(mw.uri.fullUrl(f.args['General method 1'])))))
	listPageMethod = listPageMethod..'[['..f.args['General method 1']..']]<br/>'
--mw.log(object:getLastQuery())
end
if not linkedwiki.isEmpty(f.args['General method 2'] ) then
	mw.log(object:addPropertyWithIri(daapp..'hasGeneralMethod',mw.uri.decode(tostring(mw.uri.fullUrl(f.args['General method 2'])))))
	listPageMethod = listPageMethod..'[['..f.args['General method 2']..']]<br/>'
end

if not linkedwiki.isEmpty(f.args['General method 3'] ) then
	mw.log(object:addPropertyWithIri(daapp..'hasGeneralMethod',mw.uri.decode(tostring(mw.uri.fullUrl(f.args['General method 3'])))))
	listPageMethod = listPageMethod..'[['..f.args['General method 3']..']]<br/>'
end
if not linkedwiki.isEmpty(f.args['General method 4'] ) then
	mw.log(object:addPropertyWithIri(daapp..'hasGeneralMethod',mw.uri.decode(tostring(mw.uri.fullUrl(f.args['General method 4'])))))
	listPageMethod = listPageMethod..'[['..f.args['General method 4']..']]<br/>'
end
if not linkedwiki.isEmpty(f.args['General method 5'] ) then
	mw.log(object:addPropertyWithIri(daapp..'hasGeneralMethod',mw.uri.decode(tostring(mw.uri.fullUrl(f.args['General method 5'])))))
	listPageMethod = listPageMethod..'[['..f.args['General method 5']..']]<br/>'
end
 
   
   object:setConfig('http://daap.eu') 
	return capiunto.create( {
	    -- bodyStyle = 'border: 15px solid red',
		title =  object:checkLabelOfInternLink(subject, rdfs..'label',f.args.Title)  ,
                top = 'Project',
		topStyle = 'background:#cfc;font-size:larger',		
		bottom = f.args.Website
	} )
	:addRow('Contact', '<span class="plainlinks">[['..contactPage..'|'..f.args.Contact..']]</span><sub><span class="plainlinks" style="font-size: large;">[['..contactPage..'|&#9993;]]</span></sub>')
	:addRow('Keywords', f.args.Keywords)
	:addRow('Organization', f.args.Laboratory)
	
	:addRow('Méthode générale', listPageMethod)
	
	
	:addWikitext( "[[Category:Projet]]" )

end
return p