Module:Wikipedia fork
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)
end
return p