Module:Numlinks: Difference between revisions

Ganaram inukshuk (talk | contribs)
mNo edit summary
Ganaram inukshuk (talk | contribs)
m comments, minor code edits
Line 74: Line 74:
end
end


-- Generate previous links, if they are greater or equal to the minimum.
-- Generate previous links. Links are generated if the pages they link to
-- are greater than or equal to the minimum.
-- If the first link in the sequence is greater than the minimum, add an
-- If the first link in the sequence is greater than the minimum, add an
-- arrow before the first link.
-- arrow before the first link.
Line 113: Line 114:
end
end


-- Output
-- Output...
if is_table then
if is_table then
local out = {}
-- ...as a 3-cell table, for use with infoboxes.
table.insert(out, '{| style="width: 100%;"')
local result = {}
table.insert(out, '|-')
table.insert(result, '{| style="width: 100%;"')
table.insert(out, '| style="font-size: 0.75em;" | ' .. table.concat(prev_links, " "))
table.insert(result, '|-')
table.insert(out, '| style="width: 50%;" | ' .. current)
table.insert(result, '| style="font-size: 0.75em;" | ' .. table.concat(prev_links, " "))
table.insert(out, '| style="font-size: 0.75em;" | ' .. table.concat(next_links, " "))
table.insert(result, '| style="width: 50%;" | ' .. current)
table.insert(out, '|}')
table.insert(result, '| style="font-size: 0.75em;" | ' .. table.concat(next_links, " "))
return table.concat(out, "\n")
table.insert(result, '|}')
return table.concat(result, "\n")
else
else
local out = {}
-- ...as one long string, for use with navboxes with prev/next links.
table.insert(out, table.concat(prev_links, " "))
local result = {}
table.insert(out, current)
table.insert(result, table.concat(prev_links, " "))
table.insert(out, table.concat(next_links, " "))
table.insert(result, current)
return table.concat(out, " ")
table.insert(result, table.concat(next_links, " "))
return table.concat(result, " ")
end
end
end
end


-- wip; to be placed in its own module
-- wip; to be placed in its own module
--[[
function p.numlinks_2num(args)
function p.numlinks_2num(args)
local curr_num_1  = args["Num 1"]
local curr_num_1  = args["Num 1"]
Line 156: Line 160:
end
end
end
end
]]--


-- Main function (TODO: split functionality into two modules)
-- Main function
function p.numlinks(frame)
function p.numlinks(frame)
local args = getArgs(frame)
local args = getArgs(frame)