Module:Infobox: Difference between revisions
Jump to navigation
Jump to search
Reverted all my edits |
merge changes from dev |
||
| Line 2: | Line 2: | ||
function p.build(title, entries, prev_link, next_link) | function p.build(title, entries, prev_link, next_link) | ||
local s = '<div style="\n' .. | local s = '<div style="\n' | ||
.. "border: 1px solid #999;\n" | |||
.. "margin: 0;\n" | |||
.. "margin-left: 1em;\n" | |||
.. "margin-bottom: 0.5em;\n" | |||
.. "padding: 0.5em;\n" | |||
.. "background-color: #f0f0f0;\n" | |||
.. "min-width: 15em;\n" | |||
.. "float: right;\n" | |||
.. "max-width: 100%;\n" | |||
.. "overflow: auto;\n" | |||
.. '">\n' | |||
.. '{| width="100%" style="border-collapse: collapse;"\n' | |||
.. '|+ style="font-weight: bold; text-align: center;" | ' | |||
local has_adjacent = (prev_link and #prev_link > 0) or (next_link and #next_link > 0) | local has_adjacent = (prev_link and #prev_link > 0) or (next_link and #next_link > 0) | ||
if has_adjacent then | if has_adjacent then | ||
s = s .. '<table style="width: 100%; margin: 0"><tr>' | s = s | ||
.. '<table style="width: 100%; margin: 0"><tr>' | |||
.. '<td style="width: 15%; text-align: left; white-space: nowrap; font-size: smaller">' | .. '<td style="width: 15%; text-align: left; white-space: nowrap; font-size: smaller">' | ||
.. (prev_link or | .. (prev_link or "") | ||
.. | .. "</td>" | ||
.. '<td style="width: 70%; padding-left: 1em; padding-right: 1em; text-align: center">' | .. '<td style="width: 70%; padding-left: 1em; padding-right: 1em; text-align: center">' | ||
.. title | .. title | ||
.. | .. "</td>" | ||
.. '<td style="width: 15%; text-align: right; white-space: nowrap; font-size: smaller">' | .. '<td style="width: 15%; text-align: right; white-space: nowrap; font-size: smaller">' | ||
.. (next_link or | .. (next_link or "") | ||
.. | .. "</td>" | ||
.. | .. "</tr></table>" | ||
else | else | ||
s = s .. title | s = s .. title | ||
end | end | ||
s = s .. | s = s .. "\n" | ||
for | for _, entry in ipairs(entries) do | ||
if #entry > 1 then | if #entry > 1 then | ||
local caption = entry[1] | local caption = entry[1] | ||
local text = entry[2] | local text = entry[2] | ||
s = s .. | s = s | ||
.. "|-\n" | |||
.. '| style="text-align:right; padding-right: 0.25em" | ' | |||
.. caption | |||
.. "\n" | |||
.. '| style="background-color: white; padding-left: 0.25em; font-weight: bold" | ' | |||
.. text | |||
.. "\n" | |||
elseif #entry == 1 then | elseif #entry == 1 then | ||
local text = entry[1] | local text = entry[1] | ||
s = s .. | s = s .. "|-\n" .. '| colspan="2" style="text-align: center;" | ' .. text .. "\n" | ||
end | end | ||
end | end | ||
s = s .. | s = s .. "|}</div>" | ||
return s | return s | ||
end | end | ||
return p | return p | ||
Revision as of 20:21, 1 April 2024
- This module implements a metatemplate, and may be invoked by templates using its corresponding template Template:Infobox, or used directly from other modules.
Module:Infobox is a module that implements the {{Infobox}} template. Infobox templates can be made by using the template or by calling the _sidebar function from another module.
On templates, you can create an infobox by using {{Infobox}}, which calls this module's wrapper function.
local infobox= require("Module:Infobox")._infobox to create an infobox.
| Introspection summary for Module:Infobox | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
| |||||||||
No function descriptions were provided. The Lua code may have further information.
local p = {}
function p.build(title, entries, prev_link, next_link)
local s = '<div style="\n'
.. "border: 1px solid #999;\n"
.. "margin: 0;\n"
.. "margin-left: 1em;\n"
.. "margin-bottom: 0.5em;\n"
.. "padding: 0.5em;\n"
.. "background-color: #f0f0f0;\n"
.. "min-width: 15em;\n"
.. "float: right;\n"
.. "max-width: 100%;\n"
.. "overflow: auto;\n"
.. '">\n'
.. '{| width="100%" style="border-collapse: collapse;"\n'
.. '|+ style="font-weight: bold; text-align: center;" | '
local has_adjacent = (prev_link and #prev_link > 0) or (next_link and #next_link > 0)
if has_adjacent then
s = s
.. '<table style="width: 100%; margin: 0"><tr>'
.. '<td style="width: 15%; text-align: left; white-space: nowrap; font-size: smaller">'
.. (prev_link or "")
.. "</td>"
.. '<td style="width: 70%; padding-left: 1em; padding-right: 1em; text-align: center">'
.. title
.. "</td>"
.. '<td style="width: 15%; text-align: right; white-space: nowrap; font-size: smaller">'
.. (next_link or "")
.. "</td>"
.. "</tr></table>"
else
s = s .. title
end
s = s .. "\n"
for _, entry in ipairs(entries) do
if #entry > 1 then
local caption = entry[1]
local text = entry[2]
s = s
.. "|-\n"
.. '| style="text-align:right; padding-right: 0.25em" | '
.. caption
.. "\n"
.. '| style="background-color: white; padding-left: 0.25em; font-weight: bold" | '
.. text
.. "\n"
elseif #entry == 1 then
local text = entry[1]
s = s .. "|-\n" .. '| colspan="2" style="text-align: center;" | ' .. text .. "\n"
end
end
s = s .. "|}</div>"
return s
end
return p