Module:Campaign

From DAAP
Jump to navigation Jump to search

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

--[[
-- Debug console

 frame = mw.getCurrentFrame() -- Get a frame object
newFrame = frame:newChild{ -- Get one with args
	title = 'test' ,
 args = { 
	iri = 'http://example.com/test',
['Title in English'] = 'Title in English',
['Title in French'] = 'Analyse des macrophages Campagne 1 : 2017',
Folder = 'file://192.168.1.13/backup/DEV1-PC/test',
DateBegin = '2017-12-20' ,
DateEnd = '2017-12-30' ,
Responsible = 'Sana Tfaili'
    }
}
mw.log(p.infobox( newFrame ) )

]]
local p = {}

function p.infobox(f)
	local capiunto = require 'capiunto'
    local linkedwiki = require 'linkedwiki'
    linkedwiki.setCurrentFrame(mw.getCurrentFrame())
    
    
   -- local urlFolder = 'file:///z:/'
   -- local iriFolder = 'file:///filer.ups.u-psud.fr/archivagesciences/'
   local dateFormat = "d M Y"
    
    --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/Individual'
   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 xsd = 'http://www.w3.org/2001/XMLSchema#'

 -- save data 
   local subject = f.args.iri or linkedwiki.getCurrentIRI();
   local object =  linkedwiki.new(subject)
 --linkedwiki.setDebug(true) 
 
--   object:removeSubject() -- delete all triples of this subject
 
  --object:addPropertyWithIri(PROPERTY,IRI)
   --object:addPropertyWithLiteral(PROPERTY,VALUE,TYPE,LANG) [LANG=nil=>default lang] [LANG=''=>no lang]
mw.log(object:addPropertyWithIri(rdf..'type',daapp..'Campaign'))
	
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

local linkFolder = ""
--the arg Folder is obsolete, it is replaced by Private folder
if not linkedwiki.isEmpty(f.args.Folder) then
	mw.log(object:addPropertyWithIri(daapp..'filesDestination', f.args.Folder))
		linkFolder = linkFolder .. "["..f.args.Folder.." Private folder of the campaign]"
end
--if not linkedwiki.isEmpty(f.args['Private folder']) then
--	mw.log(object:addPropertyWithIri(daapp..'filesDestination', f.args['Private folder']))
--	linkFolder =   linkFolder .. "["..f.args['Private folder'].." Private folder of the campaign]"
--end
if not linkedwiki.isEmpty(f.args['Public folder']) then
	mw.log(object:addPropertyWithIri(daapp..'filesFinalDestination', f.args['Public folder']))
		linkFolder =   linkFolder .. "<br/>["..f.args['Public folder'].."  Public folder of the campaign]"
end


local strDateBegin = ''
if not linkedwiki.isEmpty(f.args.DateBegin) then
	mw.log(object:addPropertyWithLiteral(daapp..'dateBegin',f.args.DateBegin,xsd..'date',''))
	strDateBegin = f.args.DateBegin --object:printDateInWiki(dateFormat,f.args.DateBegin,nil)
end
local strDateEnd = ''
if not linkedwiki.isEmpty(f.args.DateEnd) then
	mw.log(object:addPropertyWithLiteral(daapp..'dateEnd',f.args.DateEnd,xsd..'date',''))
	strDateEnd = f.args.DateEnd -- object:printDateInWiki(dateFormat,f.args.DateEnd,nil)
end

if not linkedwiki.isEmpty(f.args.Responsable) then
	mw.log(object:addPropertyWithIri(daapp..'responsible',tostring(mw.uri.fullUrl('User:'..f.args.Responsable))))
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 = 'Campagne',
		topStyle = 'background:#cfc;font-size:larger',		
		bottom = linkFolder 
	} )
	:addRow('Date begin', strDateBegin)
	:addRow('Date end', strDateEnd)
	:addRow('Responsible', '[[User:'..f.args.Responsible..']]')
	:addWikitext( "[[Category:Campagne]]" )
	


end
 
return p