-- This module implements .
local p =
local function getGANIcon return require('Module:Icon')._mainend
local function makeWikilink(page, display) if display and display ~= page then return string.format('%s', page, display) else return string.format('%s', page) endend
local function getNominationPage(article, number) return string.format('Talk:%s/GA%d', article, number)end
local function makeArticleLink(options) assert(options.article, 'options.article not specified') assert(options.formattedArticle, 'options.formattedArticle not specified') local display if options.isItalic then display = string.format('%s', options.article) elseif options.display then display = options.display else display = options.formattedArticle end return makeWikilink(options.article, display)end
local function makeExistingNominationLink(nominationPage) return makeWikilink(nominationPage, 'nom')end
local function makeNewNominationLink(nominationPage) local url = mw.uri.fullUrl(nominationPage,) return string.format("
[%s start]", tostring(url) )endlocal function makeNominationLink(nominationPage) assert(nominationPage, 'no nominationPage argument given to makeNominationLink') local title = mw.title.new(nominationPage) if not title then error(string.format('%s is not a valid title', nominationPage), 2) elseif title.exists then return makeExistingNominationLink(nominationPage) else return makeNewNominationLink(nominationPage) endend
function p._main(args) -- Link parameters local formattedArticle = args[1] if not formattedArticle then error('No article specified', 2) end local article = formattedArticle:gsub("", ""):gsub("", "") local display = args[2]
-- Number local number if args['#'] then number = tonumber(args['#']) if not number then error("'%s' is not a valid number", args['#']) end else number = 1 end
-- Formatting parameters
-- Output local ret = if args.icon then ret[#ret + 1] = getGANIcon end ret[#ret + 1] = makeArticleLink ret[#ret + 1] = string.format('(%s)', makeNominationLink(getNominationPage(article, number)) ) return table.concat(ret, ' ')end
function p.main(frame) local args = require('Module:Arguments').getArgs(frame,) return p._main(args)end
return p