Module:Potus work table

--[=[ Implements Template:Potus work table ]=] require('strict')

local p = {} --p stands for package

local getArgs = require('Module:Arguments').getArgs

local presidents = { [1] = {'George Washington', 'Washington, George'}, [2] = {'John Adams (1735-1826)', 'Adams, John', 'John Adams'}, [3] = {'Thomas Jefferson', 'Jefferson, Thomas'}, [4] = {'James Madison', 'Madison, James'}, [5] = {'James Monroe', 'Monroe, James'}, [6] = {'John Quincy Adams', 'Adams, John Quincy'}, [7] = {'Andrew Jackson', 'Jackson, Andrew'}, [8] = {'Martin Van Buren', 'Buren, Martin Van'}, [9] = {'William Henry Harrison', 'Harrison, William Henry'}, [10] = {'John Tyler', 'Tyler, John'}, [11] = {'James K. Polk', 'Polk, James Knox'}, [12] = {'Zachary Taylor', 'Taylor, Zachary'}, [13] = {'Millard Fillmore', 'Fillmore, Millard'}, [14] = {'Franklin Pierce', 'Pierce, Franklin'}, [15] = {'James Buchanan', 'Buchanan, James'}, [16] = {'Abraham Lincoln', 'Lincoln, Abraham'}, [17] = {'Andrew Johnson', 'Johnson, Andrew'}, [18] = {'Ulysses S. Grant', 'Grant, Ulysses S.'}, [19] = {'Rutherford B. Hayes', 'Hayes, Rutherford B.'}, [20] = {'James Abram Garfield', 'Garfield, James Abram'}, [21] = {'Chester Alan Arthur', 'Arthur, Chester Alan'}, [22] = {'Grover Cleveland', 'Cleveland, Grover'}, [23] = {'Benjamin Harrison (1833-1901)', 'Harrison, Benjamin', 'Benjamin Harrison'}, [24] = {'Grover Cleveland', 'Cleveland, Grover'}, [25] = {'William McKinley', 'McKinley, William'}, [26] = {'Theodore Roosevelt', 'Roosevelt, Theodore'}, [27] = {'William Howard Taft', 'Taft, William Howard'}, [28] = {'Woodrow Wilson', 'Wilson, Woodrow'}, [29] = {'Warren G. Harding', 'Harding, Warren G.'}, [30] = {'Calvin Coolidge', 'Coolidge, Calvin'}, [31] = {'Herbert Hoover', 'Hoover, Herbert'}, [32] = {'Franklin Delano Roosevelt', 'Roosevelt, Franklin Delano'}, [33] = {'Harry S. Truman', 'Truman, Harry S.'}, [34] = {'Dwight D. Eisenhower', 'Eisenhower, Dwight D.'}, [35] = {'John F. Kennedy', 'Kennedy, John F.'}, [36] = {'Lyndon B. Johnson', 'Johnson, Lyndon B.'}, [37] = {'Richard Nixon', 'Nixon, Richard'}, [38] = {'Gerald Ford', 'Ford, Gerald'}, [39] = {'Jimmy Carter', 'Carter, Jimmy'}, [40] = {'Ronald Reagan', 'Reagan, Ronald'}, [41] = {'George Herbert Walker Bush', 'Bush, George Herbert Walker'}, [42] = {'William Jefferson Clinton', 'Clinton, William Jefferson'}, [43] = {'George Walker Bush', 'Bush, George Walker'}, [44] = {'Barack Obama', 'Obama, Barack Hussein'}, [45] = {'Donald John Trump', 'Trump, Donald John'}, [46] = {'Joseph Robinette Biden', 'Biden, Joe Robinette'} }

local function link_td(president, subpages) local links = {} for k, v in pairs(subpages) do local page = mw.title.new(president .. '/' .. v[1], 'Author') if page.exists then links[#links + 1] =  .. (v[2] or v[1]) ..  end end return ' ' .. table.concat(links, ' ') .. ' ' end

local function potus_tr(args) local n = tonumber(args.n)	local president = presidents[n][1] local president_sort = presidents[n][2] local president_display = presidents[n][3] or president local other = args.other or '' local president_td = ' ' .. president_sort .. ' ' .. president_display .. ' ' local subpages = { , -- Proclamations , -- Executive orders , -- Memoranda , -- Letters {{'Podcasts'}, {'Presidential radio addresses', 'Radio addresses'}, {'Weekly addresses'}} -- Media }	local link_list = {} for k, v in pairs(subpages) do		link_list[#link_list + 1] = link_td(president, v)	end local links = table.concat(link_list) return ' ' .. n .. ' ' .. president_td .. links .. ' ' .. other .. ' ' end

function p._potus_table(args) local table_open = ' ' end

function p.potus_table(frame) return p._potus_table(getArgs(frame)) end

return p