Edge Rewrite
// HTMLRewriter · presentation

This page was redesigned at the edge.

Cloudflare fetched the original article and streamed it through HTMLRewriter to apply an entirely new visual system without rebuilding the source page.

Jump to content

Module:Mourning

From Wikipedia, the free encyclopedia
local p = {}

local function parseDeathDate(raw)
	if not raw or raw == "" then
		return nil
	end

	local m, d = raw:match("{{%s*[Dd]eath date and age%s*|%s*%d+%s*|%s*(%d+)%s*|%s*(%d+)")
	if m and d then
		return tonumber(m), tonumber(d)
	end

	m, d = raw:match("{{%s*[Dd]eath date%s*|%s*%d+%s*|%s*(%d+)%s*|%s*(%d+)")
	if m and d then
		return tonumber(m), tonumber(d)
	end

	return nil
end

function p.main(frame)
	local rawDeathDate = frame.args.death_date

	local month, day = parseDeathDate(rawDeathDate)
	if not month or not day then
		return ""
	end

	local utcNow = os.date("!*t")

	if month == utcNow.month and day == utcNow.day then
		return frame:expandTemplate{
			title = 'Top icon',
			args = {
				imagename = 'Black Ribbon.svg',
				description = 'This person died on this day.',
				id = 'z'
			}
		}
	end

	return ""
end

return p