Module:RCChronology: Difference between revisions
No edit summary |
No edit summary Tag: Reverted |
||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
local function wrapTitle(title) | |||
return '"' .. "'''" .. title .. "'''" .. '"' | |||
end | |||
local function makePrevCell(prev, rcnum, cornum, use_cor) | local function makePrevCell(prev, rcnum, cornum, use_cor) | ||
Line 6: | Line 10: | ||
end | end | ||
local info = | local info = wrapTitle(prev) | ||
local detail = "" | local detail = "" | ||
Line 31: | Line 35: | ||
end | end | ||
local info = | local info = wrapTitle(display_title) | ||
local detail = "" | local detail = "" | ||
Line 51: | Line 55: | ||
end | end | ||
local info = | local info = wrapTitle(next_) | ||
local detail = "" | local detail = "" | ||
Revision as of 09:57, 3 July 2025
Documentation for this module may be created at Module:RCChronology/doc
local p = {}
local function wrapTitle(title)
return '"' .. "'''" .. title .. "'''" .. '"'
end
local function makePrevCell(prev, rcnum, cornum, use_cor)
if not prev or prev == "" then
return '<td style="width: 33%; padding: .2em .1em .2em .1em;"></td>'
end
local info = wrapTitle(prev)
local detail = ""
if use_cor and use_cor:lower() == "yes" and cornum then
detail = string.format("<br />(COR# %d)", cornum - 1)
elseif rcnum then
detail = string.format("<br />(RC# %d)", rcnum - 1)
end
return string.format(
'<td style="width: 33%%; text-align: center; vertical-align: top; padding: .2em .1em .2em .1em;">%s%s</td>',
info, detail
)
end
local function makeThisCell(this, rcnum, cornum, use_cor, title_fallback)
local display_title
if this and this ~= "" then
display_title = this
elseif title_fallback and title_fallback ~= "" then
display_title = title_fallback
else
display_title = mw.title.getCurrentTitle().rootText or "Unknown"
end
local info = wrapTitle(display_title)
local detail = ""
if use_cor and use_cor:lower() == "yes" and cornum then
detail = string.format("<br />(COR# %d)", cornum)
elseif rcnum then
detail = string.format("<br />(RC# %d)", rcnum)
end
return string.format(
'<td style="width: 33%%; text-align: center; vertical-align: top; padding: .2em .1em .2em .1em;">%s%s</td>',
info, detail
)
end
local function makeNextCell(next_, rcnum, cornum, use_cor)
if not next_ or next_ == "" then
return '<td style="width: 33%; padding: .2em 0 .2em .1em;"></td>'
end
local info = wrapTitle(next_)
local detail = ""
if use_cor and use_cor:lower() == "yes" and cornum then
detail = string.format("<br />(COR# %d)", cornum + 1)
elseif rcnum then
detail = string.format("<br />(RC# %d)", rcnum + 1)
end
return string.format(
'<td style="width: 33%%; text-align: center; vertical-align: top; padding: .2em 0 .2em .1em;">%s%s</td>',
info, detail
)
end
function p.rcRow(frame)
local args = frame.args
local prev = args["prev_rc_title"]
local this = args["this_rc_title"]
local next_ = args["next_rc_title"]
local rcnum = tonumber(args["rc#"])
local cornum = tonumber(args["cor#"])
local use_cor = args["use_cor#"]
local title_fallback = args["title"]
local row = '<table style="background: transparent; color: inherit; width: 100%; min-width: 100%; border-collapse: collapse; display: inline-table;">\n'
row = row .. '<tr style="line-height: 1.4em;">\n'
row = row .. makePrevCell(prev, rcnum, cornum, use_cor)
row = row .. makeThisCell(this, rcnum, cornum, use_cor, title_fallback)
row = row .. makeNextCell(next_, rcnum, cornum, use_cor)
row = row .. '</tr></table>'
return row
end
return p