Module:Wikipedia fork: Difference between revisions
EnWikiAdmin (talk | contribs) No edit summary Tag: Manual revert |
EnWikiAdmin (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
local mHatnote = require('Module:Hatnote') | local mHatnote = require('Module:Hatnote') | ||
local mArguments = require('Module:Arguments') | local mArguments = require('Module:Arguments') | ||
local libraryUtil = require('libraryUtil') | local libraryUtil = require('libraryUtil') | ||
local checkType = libraryUtil.checkType | local checkType = libraryUtil.checkType | ||
local p = {} | local p = {} | ||
function p.wikipedia_fork(frame) | function p.wikipedia_fork(frame) | ||
local args = mArguments.getArgs(frame) | local args = mArguments.getArgs(frame) | ||
return p._wikipedia_fork(args) | return p._wikipedia_fork(args) | ||
Line 12: | Line 11: | ||
function p._wikipedia_fork(args) | function p._wikipedia_fork(args) | ||
checkType('_wikipedia_fork', 1, args, 'table', true) | checkType('_wikipedia_fork', 1, args, 'table', true) | ||
args = args or {} | args = args or {} | ||
-- | -- look for either date or import_date | ||
local articleName = args.article_name or mw.title.getCurrentTitle().text | local articleName = args.article_name or mw.title.getCurrentTitle().text | ||
local importDate = args.import_date or "an unknown date" | local importDate = args.date or args.import_date or "an unknown date" | ||
local message = string.format( | local message = string.format( | ||
"This article | "This article incorporated content from the [https://en.wikipedia.org/wiki/%s Wikipedia article] on %s.", | ||
mw.uri.encode(articleName, "PATH"), | mw.uri.encode(articleName, "PATH"), | ||
importDate | importDate | ||
) | ) | ||
local hnOptions = { | local hnOptions = { | ||
selfref = args.selfref or false, | selfref = args.selfref or false, | ||
inline = 0, | inline = 0, | ||
extraclasses = 'hatnote navigation-not-searchable' | extraclasses = 'hatnote navigation-not-searchable' | ||
} | } | ||
return mHatnote._hatnote(message, hnOptions) | return mHatnote._hatnote(message, hnOptions) | ||
end | end | ||
return p | return p |
Latest revision as of 05:45, 18 May 2025
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