Open main menu
Home
Random
Donate
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:DYK nompage links
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
-- This module implements {{DYK nompage links}}. local formatStringSingle = [[ <div class="plainlinks hlist"> * ( %s * %s ) </div>]] local formatStringMulti = [[ <div class="plainlinks hlist"> * ( %s ) </div> <div class="plainlinks hlist"> * ( Article history links: %s ) </div>]] local p = {} local function makeWikitextError(msg) return string.format('<strong class="error">Error: %s</strong>', msg) end local function makeFullUrl(page, query, display) local url = mw.uri.fullUrl(page, query) if not url then url = makeWikitextError(string.format( '"%s" is not a valid page name', tostring(page) )) end return string.format( '[%s %s]', tostring(url), display ) end function p.main(frame) local mArguments = require('Module:Arguments') local mTableTools = require('Module:TableTools') local args = mArguments.getArgs(frame, { wrappers = 'Template:DYK nompage links' }) local nominationPage = args.nompage local historyPages = mTableTools.compressSparseArray(args) return p._main(nominationPage, historyPages) end function p._main(nominationPage, historyPages) -- Deal with bad input. if not nominationPage then return makeWikitextError('no nomination page specified') end if not historyPages or not historyPages[1] then return makeWikitextError('no articles specified') end -- Find out whether we are dealing with multiple history pages. local isMulti = #historyPages > 1 -- Make the nompage link. local nominationLink do local currentPage = mw.title.getCurrentTitle().prefixedText local dykSubpage = 'Template:Did you know nominations/' .. nominationPage if currentPage == dykSubpage then nominationLink = string.format( '[[Template talk:Did you know#%s|Back to T:TDYK]]', nominationPage ) else nominationLink = makeFullUrl( 'Template:Did you know nominations/' .. nominationPage, {action = 'edit'}, 'Review or comment' ) end end -- Make the history links. local historyLinks do if isMulti then local links = {} for i, page in ipairs(historyPages) do links[#links + 1] = makeFullUrl( page, {action = 'history'}, page ) end historyLinks = table.concat(links, '\n* ') else historyLinks = makeFullUrl( historyPages[1], {action = 'history'}, 'Article history' ) end end -- Assemble the output. local stringToFormat = isMulti and formatStringMulti or formatStringSingle return string.format(stringToFormat, nominationLink, historyLinks) end return p
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:High-use
(
edit
)
Template:Tl
(
edit
)
Module:DYK nompage links/doc
(
edit
)