Difference between revisions of "Module:TAFI article"
Jump to navigation
Jump to search
blackwiki>Evad37 (WW) |
blackwiki>Evad37 (fix typo) |
||
| Line 9: | Line 9: | ||
local year = frame.args.YYYY or os.date( "%G" ) -- Specified year, or else the current year | 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 | local week = frame.args.WW or os.date( "%V" ) -- Specified week, or else the current week | ||
| − | local title = frame:expandTemplate{ title = ' | + | 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 | article = redir(title) or title -- Get target if title is a redirect | ||
return article | return article | ||
Revision as of 08:23, 8 February 2016
| 30px | 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
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
- Current article (Script error: No such module "Purge". to update)
{{#invoke:TAFI article|main}}→ Lua error: expandTemplate: template "Wikipedia:Today's articles for improvement/2026/25/1" does not exist.- Article from 2015 week 32
{{#invoke:TAFI article|main|YYYY=2015|WW=32}}→ Lua error: expandTemplate: template "Wikipedia:Today's articles for improvement/2015/32/1" does not exist.- Resolving a redirect
{{Wikipedia:Today's articles for improvement/9999/2/1}}→ {{Wikipedia:Today's articles for improvement/9999/2/1}}[[{{#invoke:TAFI article|main|YYYY=9999|WW=2}}]]→ [[Lua error: expandTemplate: template "Wikipedia:Today's articles for improvement/9999/2/1" does not exist.]]
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
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