Module:Hatnote: Difference between revisions
From Chalo Chatu, Zambia online encyclopedia
Chalochatu (talk | contribs) m 1 revision imported |
Chalochatu (talk | contribs) No edit summary |
||
| Line 21: | Line 21: | ||
local function getArgs(frame) | local function getArgs(frame) | ||
mArguments = require('Module:Arguments') | mArguments = require('Module:Arguments') | ||
return mArguments.getArgs(frame, {parentOnly = true}) | return mArguments.getArgs(frame, {parentOnly = true}) | ||
| Line 28: | Line 26: | ||
local function removeInitialColon(s) | local function removeInitialColon(s) | ||
return s:match('^:?(.*)') | return s:match('^:?(.*)') | ||
end | end | ||
function p.defaultClasses(inline) | function p.defaultClasses(inline) | ||
return (inline == 1 and 'hatnote-inline' or 'hatnote') .. ' navigation-not-searchable' | |||
return | |||
end | end | ||
function p.disambiguate(page, disambiguator) | function p.disambiguate(page, disambiguator) | ||
checkType('disambiguate', 1, page, 'string') | checkType('disambiguate', 1, page, 'string') | ||
checkType('disambiguate', 2, disambiguator, 'string', true) | checkType('disambiguate', 2, disambiguator, 'string', true) | ||
| Line 50: | Line 41: | ||
function p.findNamespaceId(link, removeColon) | function p.findNamespaceId(link, removeColon) | ||
checkType('findNamespaceId', 1, link, 'string') | checkType('findNamespaceId', 1, link, 'string') | ||
checkType('findNamespaceId', 2, removeColon, 'boolean', true) | checkType('findNamespaceId', 2, removeColon, 'boolean', true) | ||
| Line 70: | Line 57: | ||
function p.makeWikitextError(msg, helpLink, addTrackingCategory, title) | function p.makeWikitextError(msg, helpLink, addTrackingCategory, title) | ||
checkType('makeWikitextError', 1, msg, 'string') | checkType('makeWikitextError', 1, msg, 'string') | ||
checkType('makeWikitextError', 2, helpLink, 'string', true) | checkType('makeWikitextError', 2, helpLink, 'string', true) | ||
yesno = require('Module:Yesno') | yesno = require('Module:Yesno') | ||
title = title or mw.title.getCurrentTitle() | title = title or mw.title.getCurrentTitle() | ||
local helpText | local helpText | ||
if helpLink then | if helpLink then | ||
| Line 85: | Line 68: | ||
helpText = '' | helpText = '' | ||
end | end | ||
local category | local category | ||
if not title.isTalkPage | if not title.isTalkPage | ||
and title.namespace ~= 2 | and title.namespace ~= 2 | ||
and yesno(addTrackingCategory) ~= false | and yesno(addTrackingCategory) ~= false | ||
then | then | ||
category = 'Hatnote templates with errors' | category = 'Hatnote templates with errors' | ||
| Line 100: | Line 83: | ||
category = '' | category = '' | ||
end | end | ||
return mw.ustring.format( | return mw.ustring.format( | ||
'<strong class="error">Error: %s%s.</strong>%s', | '<strong class="error">Error: %s%s.</strong>%s', | ||
| Line 110: | Line 94: | ||
local curNs = mw.title.getCurrentTitle().namespace | local curNs = mw.title.getCurrentTitle().namespace | ||
p.missingTargetCat = | p.missingTargetCat = | ||
((curNs == 0) or (curNs == 14)) and | ((curNs == 0) or (curNs == 14)) and | ||
'Articles with hatnote templates targeting a nonexistent page' or nil | 'Articles with hatnote templates targeting a nonexistent page' or nil | ||
function p.quote(title) | function p.quote(title) | ||
local quotationMarks = { | local quotationMarks = { | ||
["'"]=true, ['"']=true, ['“']=true, ["‘"]=true, ['”']=true, ["’"]=true | ["'"]=true, ['"']=true, ['“']=true, ["‘"]=true, ['”']=true, ["’"]=true | ||
} | } | ||
local quoteLeft, quoteRight = | local quoteLeft, quoteRight = | ||
quotationMarks[string.sub(title, 1, 1)], | quotationMarks[string.sub(title, 1, 1)], | ||
quotationMarks[string.sub(title, -1, -1)] | quotationMarks[string.sub(title, -1, -1)] | ||
| Line 133: | Line 114: | ||
-------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ||
-- Hatnote | -- Hatnote | ||
-------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ||
p[''] = function (frame) return p.hatnote(frame:newChild{ title = "Template:Hatnote" }) end | |||
p[''] = function (frame) | |||
return p.hatnote(frame:newChild{ title = "Template:Hatnote" }) | |||
end | |||
function p.hatnote(frame) | function p.hatnote(frame) | ||
| Line 172: | Line 154: | ||
:wikitext(s) | :wikitext(s) | ||
return | return tostring(hatnote) | ||
end | end | ||
return p | return p | ||
