<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wikimd.com/index.php?action=history&amp;feed=atom&amp;title=Module%3AFindYDCportal</id>
	<title>Module:FindYDCportal - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wikimd.com/index.php?action=history&amp;feed=atom&amp;title=Module%3AFindYDCportal"/>
	<link rel="alternate" type="text/html" href="https://wikimd.com/index.php?title=Module:FindYDCportal&amp;action=history"/>
	<updated>2026-04-20T21:26:00Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.44.2</generator>
	<entry>
		<id>https://wikimd.com/index.php?title=Module:FindYDCportal&amp;diff=6039983&amp;oldid=prev</id>
		<title>Prab: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://wikimd.com/index.php?title=Module:FindYDCportal&amp;diff=6039983&amp;oldid=prev"/>
		<updated>2024-12-16T20:17:45Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 20:17, 16 December 2024&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Prab</name></author>
	</entry>
	<entry>
		<id>https://wikimd.com/index.php?title=Module:FindYDCportal&amp;diff=6039982&amp;oldid=prev</id>
		<title>en&gt;Gonnym: add missing portals</title>
		<link rel="alternate" type="text/html" href="https://wikimd.com/index.php?title=Module:FindYDCportal&amp;diff=6039982&amp;oldid=prev"/>
		<updated>2024-05-27T18:13:43Z</updated>

		<summary type="html">&lt;p&gt;add missing portals&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;--[[&lt;br /&gt;
   For a given 3- or 4-digit year or decade, find the most specific portal&lt;br /&gt;
   which actually exists.&lt;br /&gt;
   Takes one parameter, which must be either a year (e.g. &amp;quot;1879&amp;quot;, &amp;quot;1123&amp;quot;)&lt;br /&gt;
   or a decade (e.g. &amp;quot;1940s&amp;quot;, &amp;quot;790s&amp;quot;).&lt;br /&gt;
   If a portal is found, return its name without the namespace prefix&lt;br /&gt;
   (e.g. for &amp;quot;Portal:1980s&amp;quot; return &amp;quot;1980s&amp;quot;); otherwise return an empty string.&lt;br /&gt;
   If the parameter is missing, empty, or does not fit the required format,&lt;br /&gt;
   an empty string is returned&amp;quot;&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
-- This table of existing decade portals is the first check of whether a portal&lt;br /&gt;
-- exists for a given decade.&lt;br /&gt;
-- If the decade is listed in this table, then a system call is made to verify its existence&lt;br /&gt;
-- This approach has two advantages:&lt;br /&gt;
-- 1/ It reduces server load by reducing the number of expensive system calls&lt;br /&gt;
-- 2/ It avoids creating backlinks to non-existing portals, because a each .exists check&lt;br /&gt;
--    generates a backlink&lt;br /&gt;
local existingDecadePortals = {&lt;br /&gt;
	[&amp;quot;1920s&amp;quot;] = true,&lt;br /&gt;
	[&amp;quot;1950s&amp;quot;] = true,&lt;br /&gt;
	[&amp;quot;1960s&amp;quot;] = true,&lt;br /&gt;
	[&amp;quot;1970s&amp;quot;] = true,&lt;br /&gt;
	[&amp;quot;1980s&amp;quot;] = true,&lt;br /&gt;
	[&amp;quot;1990s&amp;quot;] = true,&lt;br /&gt;
	[&amp;quot;2000s&amp;quot;] = true,&lt;br /&gt;
	[&amp;quot;2010s&amp;quot;] = true&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
-- check for the existence of a portal with the given name&lt;br /&gt;
-- if it exists, returns the name&lt;br /&gt;
-- otherwise returns nil&lt;br /&gt;
function doesPortalExist(portalName)&lt;br /&gt;
	local portalPage = mw.title.new( portalName, &amp;quot;Portal&amp;quot; )&lt;br /&gt;
	if (portalPage.exists) then&lt;br /&gt;
		return portalName&lt;br /&gt;
	end&lt;br /&gt;
	return nil&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- check for the existence of a portal with the name of that year&lt;br /&gt;
-- if it exists, returns the year&lt;br /&gt;
-- otherwise calls decadeCheck, and returns that result&lt;br /&gt;
-- otherwise returns nil&lt;br /&gt;
function checkYear(yearParam)&lt;br /&gt;
--[[&lt;br /&gt;
the year portals have all been deleted, so comment out this section&lt;br /&gt;
	if doesPortalExist(yearParam) then&lt;br /&gt;
		return yearParam&lt;br /&gt;
	end&lt;br /&gt;
]]--&lt;br /&gt;
-- myDecade = the year, with the last digit stripped&lt;br /&gt;
	--            e.g. &amp;quot;1694&amp;quot; → &amp;quot;1690&amp;quot;&lt;br /&gt;
	--            Note that a decade is written as usul=ally written &amp;quot;YYY0s&amp;quot;&lt;br /&gt;
	local myDecade = mw.ustring.gsub(yearParam, &amp;quot;%d$&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
	return checkDecade(myDecade)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- check for the existence of a portal with the name of that decade&lt;br /&gt;
-- if it exists, returns the year&lt;br /&gt;
-- otherwise calls decadeCheck, and returns that result&lt;br /&gt;
-- otherwise returns nil&lt;br /&gt;
function checkDecade(decadeParam)&lt;br /&gt;
	local mydecade = decadeParam .. &amp;quot;0s&amp;quot;&lt;br /&gt;
	if (existingDecadePortals[mydecade] == true) then&lt;br /&gt;
		if doesPortalExist(mydecade) then&lt;br /&gt;
			return mydecade&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	-- We don&amp;#039;t have a portal for the decade, so now try the century.&lt;br /&gt;
--[[&lt;br /&gt;
the century portals have all been deleted, so comment out this section&lt;br /&gt;
&lt;br /&gt;
	local myCenturyString = mw.ustring.gsub(decadeParam, &amp;quot;%d$&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
	local myCenturyNum = tonumber(myCenturyString)&lt;br /&gt;
	local myCenturyNum = tonumber(myCenturyString)&lt;br /&gt;
	-- increment by one, because we have now conveted e.g. &amp;quot;1870s&amp;quot; to &amp;quot;18&amp;quot;&lt;br /&gt;
	-- but that&amp;#039;s the 19th century&lt;br /&gt;
	myCenturyNum = myCenturyNum + 1&lt;br /&gt;
	-- the century portals have all been deleted, so disable the centeury checking&lt;br /&gt;
	-- return checkCentury(tostring(myCenturyNum))&lt;br /&gt;
]]--	return &amp;quot;&amp;quot;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- check for the existence of a portal with the name of that century&lt;br /&gt;
-- if it exists, returns the century&lt;br /&gt;
-- otherwise returns an empty string&lt;br /&gt;
function checkCentury(centuryParam)&lt;br /&gt;
	local myCenturyString = ordinal_numbers(centuryParam) .. &amp;quot; century&amp;quot;&lt;br /&gt;
	if doesPortalExist(myCenturyString) then&lt;br /&gt;
		return myCenturyString&lt;br /&gt;
	end&lt;br /&gt;
	return &amp;quot;&amp;quot;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- converts a string number to an string ordinal&lt;br /&gt;
-- e.g. 21 → 21st&lt;br /&gt;
--      17 → 17th&lt;br /&gt;
-- code copied from https://stackoverflow.com/questions/20694133/how-to-to-add-th-or-rd-to-the-date (license:CC BY-SA 3.0 )&lt;br /&gt;
function ordinal_numbers(n)&lt;br /&gt;
  local ordinal, digit = {&amp;quot;st&amp;quot;, &amp;quot;nd&amp;quot;, &amp;quot;rd&amp;quot;}, string.sub(n, -1)&lt;br /&gt;
  if tonumber(digit) &amp;gt; 0 and tonumber(digit) &amp;lt;= 3 and string.sub(n,-2) ~= 11 and string.sub(n,-2) ~= 12 and string.sub(n,-2) ~= 13 then&lt;br /&gt;
    return n .. ordinal[tonumber(digit)]&lt;br /&gt;
  else&lt;br /&gt;
    return n .. &amp;quot;th&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function trim(s)&lt;br /&gt;
   return s:match &amp;quot;^%s*(.-)%s*$&amp;quot;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.findydcportal(frame)&lt;br /&gt;
	-- Expects one parameter&lt;br /&gt;
	-- {{{1}}} = a 3- or 4-digit year or deacde&lt;br /&gt;
	--    e.g. 1916&lt;br /&gt;
	--         1504&lt;br /&gt;
	--         1630s&lt;br /&gt;
	--         920s&lt;br /&gt;
	local arg1 = frame.args[1]&lt;br /&gt;
	if arg1 == nil then&lt;br /&gt;
		return &amp;quot;&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
	arg1 = trim(arg1) -- strip leading and trailing spaces&lt;br /&gt;
	if (mw.ustring.match(arg1, &amp;quot;^%d%d%d%d?$&amp;quot;)) then&lt;br /&gt;
		-- it&amp;#039;s a 3- or 4-digit-year&lt;br /&gt;
		return checkYear(arg1)&lt;br /&gt;
	elseif (mw.ustring.match(arg1, &amp;quot;^%d%d%d?0s$&amp;quot;)) then&lt;br /&gt;
		-- it&amp;#039;s a 3- or 4-digit decade&lt;br /&gt;
		-- so strip the trailing &amp;quot;0s&amp;quot;&lt;br /&gt;
		local decadeArg = mw.ustring.gsub(arg1, &amp;quot;0s$&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
		return checkDecade(decadeArg)&lt;br /&gt;
	end&lt;br /&gt;
	-- If we get here, then arg1 was neither a year nor a decade&lt;br /&gt;
	-- This is going to be a helper template, and diagnostics woud be intrusive&lt;br /&gt;
	-- So just return an empty string&lt;br /&gt;
	return &amp;quot;&amp;quot;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>en&gt;Gonnym</name></author>
	</entry>
</feed>