Module:Hatnote and Module:Hatnote/sandbox: Difference between pages
(Difference between pages)
imported>Ahecht Revert |
imported>Nihiltres Export default classes |
||
| Line 19: | Line 19: | ||
-- Helper functions | -- Helper functions | ||
-------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ||
local curNs = mw.title.getCurrentTitle().namespace | |||
p.missingTargetCat = | |||
--Default missing target category, exported for use in related modules | |||
((curNs == 0) or (curNs == 14)) and | |||
'Articles with hatnote templates targeting a nonexistent page' or nil | |||
local function getArgs(frame) | local function getArgs(frame) | ||
| Line 30: | Line 36: | ||
-- Removes the initial colon from a string, if present. | -- Removes the initial colon from a string, if present. | ||
return s:match('^:?(.*)') | return s:match('^:?(.*)') | ||
end | end | ||
| Line 108: | Line 97: | ||
end | end | ||
function p.disambiguate(page, disambiguator) | |||
-- Formats a page title with a disambiguation parenthetical, | |||
-- | -- i.e. "Example" → "Example (disambiguation)". | ||
(( | checkType('disambiguate', 1, page, 'string') | ||
' | checkType('disambiguate', 2, disambiguator, 'string', true) | ||
disambiguator = disambiguator or 'disambiguation' | |||
return mw.ustring.format('%s (%s)', page, disambiguator) | |||
end | |||
function p. | function p.defaultClasses(inline) | ||
-- | -- Provides the default hatnote classes as a space-separated string; useful | ||
-- | -- for hatnote-manipulation modules like [[Module:Hatnote group]]. | ||
return | |||
(inline == 1 and 'hatnote-inline' or 'hatnote') .. ' ' .. | |||
'navigation-not-searchable' | |||
end | end | ||
| Line 136: | Line 119: | ||
-- Produces standard hatnote text. Implements the {{hatnote}} template. | -- Produces standard hatnote text. Implements the {{hatnote}} template. | ||
-------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ||
function p.hatnote(frame) | function p.hatnote(frame) | ||