Documentation for this module may be created at Module:VersionHistoryItems/doc
local p = {} --p stands for package
--[[
function p.get( frame )
{{#invoke:VersionHistoryItems|get|page=..}}
* if page is empty, current page is used
* this function return an array with parameters:
* Current version description (text)
* Current version number (text)
* Current version date (text)
* versionHistory (holds subarrays with values from "version History item" multiple instance templates)
Debug console tests:
without page parameter:
=p.get(mw.getCurrentFrame():newChild{title="test"})
with page parameter (use current page):
=p.get(mw.getCurrentFrame():newChild{title="test",args={["page"]="Persoon/1"}})
with empty page parameter (use current page):
=p.get(mw.getCurrentFrame():newChild{title="test",args={["page"]=""}})
--]]
function p.get( frame )
local result = { [1] = {} } -- all results are placed inside the [1] subtable to make this work with ArrayFunctions #af_foreach, might be changed later
-- get page from frame or default to current page
local page = frame.args['page']
if page == nil or page =='' then
mw.log('page is empty, using current page')
page = mw.title.getCurrentTitle().fullText
end
mw.log('page = ' .. page)
-- get version history instances from ws-base-props slot
local baseProps = mw.slots.slotTemplates( 'ws-base-props', page )
if baseProps == nil then return mw.af.export(result) end
local versionHistory = baseProps['Base properties'][1]['Version history']
if versionHistory == nil then return mw.af.export(result) end
local versionHistoryItems = versionHistory['Version history item']
result[1]['Version history'] = versionHistoryItems
result[1]['Version history unparsed'] = versionHistory['_text']
result[1]['Current version number'] = versionHistoryItems[1]['Version number']['_text']
result[1]['Current version description'] = versionHistoryItems[1]['Version description']['_text']
result[1]['Current version date'] = versionHistoryItems[1]['Version date']['_text']
mw.log('result =')
mw.logObject(result)
return mw.af.export(result)
end
return p;