Module:Wikipedia fork: Difference between revisions
EnWikiAdmin (talk | contribs) Created page with "local mHatnote = require('Module:Hatnote') local mArguments = require('Module:Arguments') local libraryUtil = require('libraryUtil') local checkType = libraryUtil.checkType local p = {} function p.wikipedia_fork(frame) -- Get arguments from the frame local args = mArguments.getArgs(frame) return p._wikipedia_fork(args) end function p._wikipedia_fork(args) -- Check that args is a table checkType('_wikipedia_fork', 1, args, 'table', true) args = a..." |
EnWikiAdmin (talk | contribs) No edit summary |
||
Line 28: | Line 28: | ||
-- Return the message wrapped in a hatnote | -- Return the message wrapped in a hatnote | ||
return mHatnote._hatnote(message) | return mHatnote._hatnote(message, {selfref = args.selfref}) | ||
end | end | ||
return p | return p |
Revision as of 02:10, 14 November 2024
Documentation for this module may be created at Module:Wikipedia fork/doc
local mHatnote = require('Module:Hatnote')
local mArguments = require('Module:Arguments')
local libraryUtil = require('libraryUtil')
local checkType = libraryUtil.checkType
local p = {}
function p.wikipedia_fork(frame)
-- Get arguments from the frame
local args = mArguments.getArgs(frame)
return p._wikipedia_fork(args)
end
function p._wikipedia_fork(args)
-- Check that args is a table
checkType('_wikipedia_fork', 1, args, 'table', true)
args = args or {}
-- Retrieve the article name and import date
local articleName = args.article_name or mw.title.getCurrentTitle().text
local importDate = args.import_date or "an unknown date"
-- Create the forked article message
local message = string.format(
"This article was forked from the [https://en.wikipedia.org/wiki/%s Wikipedia article] on %s.",
mw.uri.encode(articleName, "PATH"), -- Encode the article name for URL
importDate
)
-- Return the message wrapped in a hatnote
return mHatnote._hatnote(message, {selfref = args.selfref})
end
return p