Module:Redirect hatnote: Difference between revisions
From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
Content added Content deleted
(Added hack to categorize pages using odd edge-case behaviour) |
(Updated with sandbox/testcases-tested behaviour that changes defaulting and adds tracking for a different wierd behaviour) |
||
Line 86: | Line 86: | ||
-- phrase "For cats, see [[Felines]]".) |
-- phrase "For cats, see [[Felines]]".) |
||
-- Returns a string, or nil if no use was specified. |
-- Returns a string, or nil if no use was specified. |
||
-- The isFirst parameter is |
-- The isFirst parameter is legacy, but partly maintained for its effect of |
||
-- cancelling empty use items. |
|||
-- table in the data array. If isFirst is specified, the redirect parameter |
|||
useTable = useTable or {} |
useTable = useTable or {} |
||
local use |
local use |
||
Line 95: | Line 95: | ||
return nil |
return nil |
||
elseif tonumber(useTable.use) == 1 then |
elseif tonumber(useTable.use) == 1 then |
||
--This is really strange behaviour, so it gets a category hack to see if it's actually being used. |
|||
use = 'other uses' |
|||
⚫ | |||
else |
else |
||
use = useTable.use |
use = useTable.use |
||
end |
end |
||
local pages = useTable.pages or {} |
local pages = useTable.pages or {} |
||
redirect = redirect[1] or error( |
|||
if isFirst then |
|||
'no redirect was supplied', |
|||
⚫ | |||
'isFirst was set in formatUseTable, but no redirect was supplied', |
|||
) |
|||
⚫ | |||
⚫ | |||
) |
|||
⚫ | |||
else |
|||
--pages[1] = pages[1] or useTable.use .. ' (disambiguation)' |
|||
--Terrible but temporary hack switches above line to below if to test prevalence of this behaviour: |
|||
if not pages[1] then |
|||
pages[1] = useTable.use .. ' (disambiguation)' |
|||
⚫ | |||
end |
|||
end |
|||
pages = mHatnote.formatPages(unpack(pages)) |
pages = mHatnote.formatPages(unpack(pages)) |
||
pages = mw.text.listToText(pages) |
pages = mw.text.listToText(pages) |
||
Line 146: | Line 138: | ||
if data[1] and data[1].use and data[1].use ~= 'other uses' then |
if data[1] and data[1].use and data[1].use ~= 'other uses' then |
||
for i = 2, #data do |
for i = 2, #data do |
||
text[#text + 1] = formatUseTable(data[i] or {}, false) |
text[#text + 1] = formatUseTable(data[i] or {}, false, redirect) |
||
end |
end |
||
end |
end |