Module:Wikipedia fork

From Ikwipedia

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)
    local args = mArguments.getArgs(frame)
    return p._wikipedia_fork(args)
end

function p._wikipedia_fork(args)
    checkType('_wikipedia_fork', 1, args, 'table', true)
    args = args or {}

    -- look for either date or import_date
    local articleName = args.article_name or mw.title.getCurrentTitle().text
    local importDate = args.date or args.import_date or "an unknown date"

    local message = string.format(
        "This article incorporated content from the [https://en.wikipedia.org/wiki/%s Wikipedia article] on %s.",
        mw.uri.encode(articleName, "PATH"),
        importDate
    )

    local hnOptions = {
        selfref      = args.selfref or false,
        inline       = 0,
        extraclasses = 'hatnote navigation-not-searchable'
    }

    return mHatnote._hatnote(message, hnOptions)
end

return p