Module:Firehose links
From PickiPedia: A knowledge base of bluegrass, old time psychedelic jams, and other public domain music
Documentation for this module may be created at Module:Firehose links/doc
-- Helpers for Template:Firehose.
--
-- The firehose runs its #ask with link=none, because Semantic MediaWiki
-- otherwise hands the template a pre-rendered link for every value, which
-- defeats both #titleparts and any attempt to relabel the episode link.
--
-- The cost of link=none is that guest names arrive as plain text, comma-joined
-- when an episode has more than one. Linking that string whole would produce a
-- single broken redlink -- one link containing "Sam Bush, Jerry Douglas" -- so
-- split it and link each name on its own. Linking guests is the point of the
-- exercise: it is what connects an episode to the people in it.
--
-- Note for future editors: do not wrap this header in a --[==[ ]==] block
-- comment containing wiki link syntax. Lua reads the inner brackets as nested
-- long brackets and refuses to load the module.
local p = {}
-- Values the title parser sometimes yields that are not people, and so should
-- be shown but never linked.
local NOT_A_PERSON = {
["and more"] = true,
["more"] = true,
["etc"] = true,
["etc."] = true,
}
function p.guestlinks( frame )
local raw = frame.args[1] or ""
if raw:match( "^%s*$" ) then
return ""
end
local out = {}
for name in ( raw .. "," ):gmatch( "%s*(.-)%s*," ) do
if name ~= "" then
if NOT_A_PERSON[ name:lower() ] then
table.insert( out, name )
else
table.insert( out, "[[" .. name .. "]]" )
end
end
end
return table.concat( out, ", " )
end
return p