Module:Timeline
Documentation for this module may be created at Module:Timeline/doc
local function renderSection(title, year, schedule)
local out = {}
-- Colors based on category
local headerBg = "#3a506b"
if title == "Character News" then headerBg = "#6e473b" end
-- Table Wrapper
out[#out + 1] = '<div style="overflow-x:auto; border: 1px solid #d1d5db; border-radius: 12px; margin-bottom: 2em; box-shadow: 0 4px 12px rgba(0,0,0,0.05);">'
out[#out + 1] = '<table style="width:100%; border-collapse: collapse; background: #ffffff; margin: 0;">'
-- Section Title (Added !important to background)
out[#out + 1] = '<tr><th colspan="4" style="background:' .. headerBg .. ' !important; color:#ffffff !important; '
.. 'font-family:\'Georgia\', serif; font-size:1.1em; letter-spacing:0.1em; text-align:center; padding:12px; '
.. 'border-bottom:3px solid #e0a96d; text-transform:uppercase;">'
.. title .. "</th></tr>"
-- Column Headers (Forced styling)
local head = {}
for _, col in ipairs(COLUMNS) do
head[#head + 1] = '<th style="background:#f8fafc !important; color:#1e293b !important; font-family:\'Georgia\', serif; '
.. 'padding:10px; text-align:left; border-bottom:2px solid #e2e8f0; border-right:1px solid #e2e8f0; width:' .. col[2] .. ';">' .. col[1] .. "</th>"
end
out[#out + 1] = "<tr>" .. table.concat(head) .. "</tr>"
local day = 1
while day <= DAYS_PER_YEAR do
local events = schedule[day]
local count = #events
if count > 0 then
local default = Calendar.realDate(year, day)
local dates, span = {}, {}
for i, ev in ipairs(events) do
dates[i] = (ev.date ~= "") and ev.date or default
end
local i = 1
while i <= count do
local j = i
while j < count and dates[j + 1] == dates[i] do j = j + 1 end
span[i] = j - i + 1
i = j + 1
end
for idx, ev in ipairs(events) do
local row = {}
if idx == 1 then
row[#row + 1] = cell(
DAY_LABELS[day] .. ", Year " .. year,
(count > 1 and ' rowspan="' .. count .. '"' or "") .. ' style="padding:12px 10px; border-bottom:1px solid #e2e8f0; border-right:1px solid #e2e8f0; font-weight:bold; color:#1e293b; vertical-align:top;"'
)
end
row[#row + 1] = cell(ev.post, ' style="padding:12px 10px; border-bottom:1px solid #e2e8f0; border-right:1px solid #e2e8f0; vertical-align:top;"')
row[#row + 1] = cell(ev.char, ' style="padding:12px 10px; border-bottom:1px solid #e2e8f0; border-right:1px solid #e2e8f0; vertical-align:top;"')
if span[idx] then
row[#row + 1] = cell(
dates[idx],
(span[idx] > 1 and ' rowspan="' .. span[idx] .. '"' or "") .. ' style="padding:12px 10px; border-bottom:1px solid #e2e8f0; vertical-align:top; color:#64748b; font-size:0.9em; white-space:nowrap;"'
)
end
out[#out + 1] = "<tr>" .. table.concat(row) .. "</tr>"
end
day = day + 1
else
local first = day
while day <= DAYS_PER_YEAR and #schedule[day] == 0 do
day = day + 1
end
local last = day - 1
local startDate, endDate = Calendar.realDate(year, first), Calendar.realDate(year, last)
local dateText = (first == last) and startDate or (startDate .. " to " .. endDate)
out[#out + 1] = "<tr>"
.. cell(rangeLabel(first, last, year), ' style="padding:12px 10px; border-bottom:1px solid #e2e8f0; border-right:1px solid #e2e8f0; color:#64748b; font-style:italic; font-size:0.9em;"')
.. cell(EMPTY_ROW_TEXT, ' colspan="2" style="padding:12px 10px; border-bottom:1px solid #e2e8f0; border-right:1px solid #e2e8f0; color:#94a3b8; font-style:italic;"')
.. cell(dateText, ' style="padding:12px 10px; border-bottom:1px solid #e2e8f0; color:#64748b; font-size:0.9em; white-space:nowrap;"')
.. "</tr>"
end
end
out[#out + 1] = "</table>"
out[#out + 1] = "</div>"
return table.concat(out, "\n")
end