Module:Numlinks: Difference between revisions
mNo edit summary |
m comments, minor code edits |
||
| Line 74: | Line 74: | ||
end | end | ||
-- Generate previous links | -- 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 | -- ...as a 3-cell table, for use with infoboxes. | ||
table.insert( | local result = {} | ||
table.insert( | table.insert(result, '{| style="width: 100%;"') | ||
table.insert( | table.insert(result, '|-') | ||
table.insert( | table.insert(result, '| style="font-size: 0.75em;" | ' .. table.concat(prev_links, " ")) | ||
table.insert( | table.insert(result, '| style="width: 50%;" | ' .. current) | ||
table.insert( | table.insert(result, '| style="font-size: 0.75em;" | ' .. table.concat(next_links, " ")) | ||
return table.concat( | table.insert(result, '|}') | ||
return table.concat(result, "\n") | |||
else | else | ||
local | -- ...as one long string, for use with navboxes with prev/next links. | ||
table.insert( | local result = {} | ||
table.insert( | table.insert(result, table.concat(prev_links, " ")) | ||
table.insert( | table.insert(result, current) | ||
return table.concat( | 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 | -- Main function | ||
function p.numlinks(frame) | function p.numlinks(frame) | ||
local args = getArgs(frame) | local args = getArgs(frame) | ||