Module:Version: Difference between revisions
From Vintage Story Wiki
m (Includeonly for category transclusion) |
Tag: Undo |
||
Line 17: | Line 17: | ||
end | end | ||
categories = categories .. '[[Category:Versions]]' | categories = categories .. '[[Category:Versions]]' | ||
return | return categories | ||
end | end | ||
Latest revision as of 10:19, 4 September 2022
Documentation for this module may be created at Module:Version/doc
local p = {}
function p.categories(f)
local title = mw.title.getCurrentTitle().baseText
local ver = {}
for v in (title..'-'):gmatch('(.-)-') do
table.insert(ver, v)
end
local categories = ''
if ver[2] ~= nil then
if ver[2]:find('pre') then
categories = '[[Category:' .. ver[1] .. ' pre-releases]]' .. '[[Category:' .. ver[1] .. ' development versions]]'
elseif ver[2]:find('rc') then
categories = '[[Category:' .. ver[1] .. ' release candidates]]' .. '[[Category:' .. ver[1] .. ' development versions]]'
end
end
categories = categories .. '[[Category:Versions]]'
return categories
end
function p.prevNextLinks(f)
local args = require( 'Module:ProcessArgs' ).merge( true )
local leftArrows = '<span style="margin-right:-0.35em">◄</span>◄ '
local rightArrows = ' <span style="margin-right:-0.35em">►</span>►'
local prev = ''
if args.prev then
if args.prev:match('-(.*)') then
prev = args.prev:match('-(.*)')
prev = '[[' .. args.prev .. '|◄ ' .. prev .. ']]'
else
prev = '[[' .. args.prev .. '|◄ ' .. args.prev .. ']]'
end
end
local next = ''
if args.next then
if args.next:match('-(.*)') then
next = args.next:match('-(.*)')
next = '[[' .. args.next .. '|' .. next .. ' ►]]'
else
next = '[[' .. args.next .. '|' .. args.next .. ' ►]]'
end
end
local prevParent = ''
if args.prevparent then
prevParent = '[[' .. args.prevparent .. '|' .. leftArrows .. args.prevparent .. ']]'
end
local nextParent = ''
if args.nextparent then
nextParent = args.nextparent:match('-(.*)')
nextParent = '[[' .. args.nextparent .. '|' .. args.nextparent .. rightArrows .. ']]'
end
if args.nextparent and args.next then
nextParent = nextParent .. '<br>'
end
if args.prevparent and args.prev then
prevParent = prevParent .. '<br>'
end
if args.ver then
if args.prev then
if args.prev:find(args.ver) == nil then
prev = '[[' .. args.prev .. '|◄ ' .. args.prev .. ']]'
end
end
if args.next then
if args.next:find(args.ver) == nil then
next = '[[' .. args.next .. '|' .. args.next .. ' ►]]'
end
end
end
local width
if (args.next or args.nextparent) and (args.prev or args.prevparent) then
width = '50%'
else
width = '100%'
end
local body = '<table style="width: 100%; margin: auto;><tr><td style="width:' .. width .. '">' .. prevParent .. prev .. '</td><td>' .. nextParent .. next .. '</td></tr></table>'
return body
end
return p