Editing Module:Hatnote
Jump to navigation
Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
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 | end | ||
Line 166: | Line 141: | ||
hatnote | hatnote | ||
:attr('role', 'note') | :attr('role', 'note') | ||
:addClass( | :addClass(inline == 1 and 'hatnote-inline' or 'hatnote') | ||
:addClass('navigation-not-searchable') | |||
:addClass(extraclasses) | :addClass(extraclasses) | ||
:addClass(options.selfref and 'selfref' or nil) | :addClass(options.selfref and 'selfref' or nil) | ||
:wikitext(s) | :wikitext(s) | ||
return mw.getCurrentFrame():extensionTag{ | return mw.getCurrentFrame():extensionTag{ | ||
name = 'templatestyles', args = { src = 'Module:Hatnote/styles.css' } | name = 'templatestyles', args = { src = 'Module:Hatnote/styles.css' } |