Module:TAFI article
This module depends on the following other modules: |
This module retrieves the page name from the (year)/(week)/1 subpages of WP:TAFI. If the page is a redirect, the redirect target is retrieved instead.
Usage[edit]
To retrieve the current article, use
{{#invoke:TAFI article|main}}
To retrieve the article for a specific year and week, use
{{#invoke:TAFI article|main|YYYY=|WW=}}
Examples[edit]
- Current article ( to update)
{{#invoke:TAFI article|main}}
→ Lua error: expandTemplate: template "Wikipedia:Today's articles for improvement/2024/21/1" does not exist.- Article from 2015 week 32
{{#invoke:TAFI article|main|YYYY=2015|WW=32}}
→ Farmhouse- Resolving a redirect
{{Wikipedia:Today's articles for improvement/9999/2/1}}
→ Paris, TX[[{{#invoke:TAFI article|main|YYYY=9999|WW=2}}]]
→ Paris, Texas
local p = {}
local redirModule = require "Module:Redirect"
local redir = redirModule.luaMain
-- Named arguments (optional) |YYYY= and |WW= used, like: {{#invoke:TAFI article|main|YYYY=2016|WW=06}}
function p.main(frame)
local year = frame.args.YYYY or os.date( "%G" ) -- Specified year, or else the current year
local week = frame.args.WW or os.date( "%V" ) -- Specified week, or else the current week
week = tonumber(week) -- Remove zero-padding, if present
local title = frame:expandTemplate{ title = 'Wikipedia:Today\'s articles for improvement/' .. year .. '/' .. week .. '/1' } -- transclude page to get article title
article = redir(title) or title -- Get target if title is a redirect
return article
end
return p