Modul:Hatnote: Perbedaan revisi
Loncat ke navigasi
Loncat ke pencarian
we templatestyles now
Mediawiki>Gervant of Shiganshina k (Cleanup.) |
Mediawiki>Izno (we templatestyles now) |
||
Baris 94: | Baris 94: | ||
-- Make the category text. | -- Make the category text. | ||
local category | local category | ||
if not title.isTalkPage and yesno(addTrackingCategory) ~= false then | if not title.isTalkPage -- Don't categorise talk pages | ||
category = ' | and title.namespace ~= 2 -- Don't categorise userspace | ||
and yesno(addTrackingCategory) ~= false -- Allow opting out | |||
then | |||
category = 'Hatnote templates with errors' | |||
category = string.format( | category = string.format( | ||
'[[%s:%s]]', | '[[%s:%s]]', | ||
Baris 105: | Baris 108: | ||
end | end | ||
return string.format( | return string.format( | ||
'<strong class="error"> | '<strong class="error">Error: %s%s.</strong>%s', | ||
msg, | msg, | ||
helpText, | helpText, | ||
Baris 117: | Baris 120: | ||
checkType('disambiguate', 1, page, 'string') | checkType('disambiguate', 1, page, 'string') | ||
checkType('disambiguate', 2, disambiguator, 'string', true) | checkType('disambiguate', 2, disambiguator, 'string', true) | ||
disambiguator = disambiguator or ' | disambiguator = disambiguator or 'disambiguation' | ||
return string.format('%s (%s)', page, disambiguator) | return string.format('%s (%s)', page, disambiguator) | ||
end | end | ||
Baris 127: | Baris 130: | ||
-- with colons if necessary, and links to sections are detected and displayed | -- with colons if necessary, and links to sections are detected and displayed | ||
-- with " § " as a separator rather than the standard MediaWiki "#". Used in | -- with " § " as a separator rather than the standard MediaWiki "#". Used in | ||
-- the {{format | -- the {{format link}} template. | ||
-------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ||
Baris 137: | Baris 140: | ||
if not link then | if not link then | ||
return p.makeWikitextError( | return p.makeWikitextError( | ||
' | 'no link specified', | ||
'Template:Format | 'Template:Format link#Errors', | ||
args.category | args.category | ||
) | ) | ||
Baris 177: | Baris 180: | ||
local prePipe, display = link:match('^(.-)|(.*)$') | local prePipe, display = link:match('^(.-)|(.*)$') | ||
link = prePipe or link | link = prePipe or link | ||
-- Find the page, if it exists. | |||
-- For links like [[#Bar]], the page will be nil. | |||
local preHash, postHash = link:match('^(.-)#(.*)$') | |||
local page | |||
if not preHash then | |||
-- We have a link like [[Foo]]. | |||
page = link | |||
elseif preHash ~= '' then | |||
-- We have a link like [[Foo#Bar]]. | |||
page = preHash | |||
end | |||
-- Find the section, if it exists. | -- Find the section, if it exists. | ||
local | local section | ||
if postHash and postHash ~= '' then | |||
section = postHash | |||
end | |||
return { | return { | ||
Baris 228: | Baris 245: | ||
local page = maybeItalicize(parsed.page, options.italicizePage) | local page = maybeItalicize(parsed.page, options.italicizePage) | ||
local section = maybeItalicize(parsed.section, options.italicizeSection) | local section = maybeItalicize(parsed.section, options.italicizeSection) | ||
if section then | if not page then | ||
display = string.format('§ %s', section) | |||
elseif section then | |||
display = string.format('%s § %s', page, section) | display = string.format('%s § %s', page, section) | ||
else | else | ||
Baris 250: | Baris 269: | ||
if not s then | if not s then | ||
return p.makeWikitextError( | return p.makeWikitextError( | ||
' | 'no text specified', | ||
'Template:Hatnote# | 'Template:Hatnote#Errors', | ||
args.category | args.category | ||
) | ) | ||
Baris 274: | Baris 293: | ||
end | end | ||
return string.format( | return string.format( | ||
'<div role="note" class="%s">%s</div>', | '%s<div role="note" class="%s">%s</div>', | ||
mw.getCurrentFrame():extensionTag{ | |||
name = 'templatestyles', args = { src = 'Module:Hatnote/styles.css' } | |||
}, | |||
table.concat(classes, ' '), | table.concat(classes, ' '), | ||
s | s |