Module:Infobox: Difference between revisions

Ganaram inukshuk (talk | contribs)
mNo edit summary
Ganaram inukshuk (talk | contribs)
m cleanup comments
Line 11: Line 11:
function p.infobox_header(title, adjacent_links)
function p.infobox_header(title, adjacent_links)
local header = ''
local header = ''
if adjacent_links == nil then
if #adjacent_links == 2 then
header = title .. '\n'
elseif #adjacent_links == 2 then
local prev_link = adjacent_links[1]
local prev_link = adjacent_links[1]
local next_link = adjacent_links[2]
local next_link = adjacent_links[2]
Line 25: Line 23:
.. '</table>'
.. '</table>'
elseif #adjacent_links == 8 then
elseif #adjacent_links == 8 then
-- First row
header = header
header = header
.. '<table style="width: 100%; margin: 0;">\n'
.. '<table style="width: 100%; margin: 0;">\n'
Line 43: Line 40:
.. '<td style="width: 15%; text-align: right; white-space: nowrap; font-size: 0.75em;">'                    .. (adjacent_links[8] or "") .. '</td>\n'
.. '<td style="width: 15%; text-align: right; white-space: nowrap; font-size: 0.75em;">'                    .. (adjacent_links[8] or "") .. '</td>\n'
.. '</tr>\n'
.. '</tr>\n'
.. '</table>' -- End of table
-- End
.. '</table>'
else
else
header = title .. "\n"
header = title
end
end
Line 116: Line 111:
-- Preprocess adjacent links
-- Preprocess adjacent links
-- If there are two adjacent links (such as with edos), then links
-- If there are two adjacent links (such as with edos), then links will be
-- will be placed on the left and right of the title
-- placed on the left and right of the title:
-- [Link 1] Title [Link 2]
-- [Link 1] Title [Link 2]
-- - Link 1 is previous, link 2 is next
-- - Link 1 is previous, link 2 is next
-- If there are eight adjacent links (such as with mosses), then
-- If there are eight adjacent links (such as with mosses), then links
-- links surround the title, forming a 3x3 grid as such:
-- surround the title in a 3x3 grid:
-- [Link 1] [Link 2] [Link 3]
-- [Link 1] [Link 2] [Link 3]
-- [Link 4]  Title  [Link 5]
-- [Link 4]  Title  [Link 5]
Line 128: Line 123:
-- present, then rows for those two sets of links are added. Having no links
-- present, then rows for those two sets of links are added. Having no links
-- defaults to having only the title.
-- defaults to having only the title.
local adjacent_links = {}
local is_upper_lower_links_present = args["Upper Left Link"] ~= nil or args["Upper Link"] ~= nil or args["Upper Right Link"] ~= nil
local is_upper_lower_links_present = args["Upper Left Link"] ~= nil or args["Upper Link"] ~= nil or args["Upper Right Link"] ~= nil
or args["Lower Left Link"] ~= nil or args["Lower Link"] ~= nil or args["Lower Right Link"] ~= nil
or args["Lower Left Link"] ~= nil or args["Lower Link"] ~= nil or args["Lower Right Link"] ~= nil
local is_side_links_present  = args["Left Link"] ~= nil or args["Right Link"] ~= nil
local is_side_links_present  = args["Left Link"] ~= nil or args["Right Link"] ~= nil
local adjacent_links = {}
if is_upper_lower_links_present then
if is_upper_lower_links_present then
table.insert(adjacent_links, args["Upper Left Link" ] or "")
table.insert(adjacent_links, args["Upper Left Link" ] or "")
Line 149: Line 144:
args["Adjacent Links"] = adjacent_links
args["Adjacent Links"] = adjacent_links
-- Clear individual links, as they've been combined into one table
-- Cleanup individual links, as they've been combined into one table
args["Upper Left Link" ] = nil
args["Upper Left Link" ] = nil
args["Upper Link"      ] = nil
args["Upper Link"      ] = nil
Line 160: Line 155:
-- Preprocess rows
-- Preprocess rows
-- Set row count to 30; if more rows are needed, this can be changed or a
-- Set row count to 30, under the reasoning that an infobox may need more
-- module can be written for that.
-- rows and/or headers. This may be increased to 40 if needed.
local rows = {}
local rows = {}
for i = 1, 30 do
for i = 1, 30 do