Module:Firehose links: Difference between revisions
From PickiPedia: A knowledge base of bluegrass, old time psychedelic jams, and other public domain music
Jump to navigationJump to search
Split comma-joined guest values so each name links separately (via create-page on MediaWiki MCP Server) |
Rename guestlinks to topiclinks; episodes record topics, not only guests (via update-page on MediaWiki MCP Server) |
||
| Line 5: | Line 5: | ||
-- defeats both #titleparts and any attempt to relabel the episode link. | -- defeats both #titleparts and any attempt to relabel the episode link. | ||
-- | -- | ||
-- The cost of link=none is that | -- The cost of link=none is that topic names arrive as plain text, comma-joined | ||
-- when an episode has more than one. Linking that string whole would produce a | -- 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 | -- single broken redlink -- one link containing "Sam Bush, Jerry Douglas" -- so | ||
-- split it and link each name on its own. Linking | -- split it and link each name on its own. Linking topics is the point of the | ||
-- exercise: it is what | -- exercise: it is what puts an episode on the page of every person, band or | ||
-- place it is about. | |||
-- | -- | ||
-- Note for future editors: do not wrap this header in a --[==[ ]==] block | -- Note for future editors: do not wrap this header in a --[==[ ]==] block | ||
| Line 17: | Line 18: | ||
local p = {} | local p = {} | ||
-- Values the title parser sometimes yields that are not | -- Values the title parser sometimes yields that are not entities, and so | ||
-- be shown but never linked. | -- should be shown but never linked. | ||
local | local NOT_AN_ENTITY = { | ||
["and more"] = true, | ["and more"] = true, | ||
["more"] = true, | ["more"] = true, | ||
| Line 26: | Line 27: | ||
} | } | ||
function p. | function p.topiclinks( frame ) | ||
local raw = frame.args[1] or "" | local raw = frame.args[1] or "" | ||
if raw:match( "^%s*$" ) then | if raw:match( "^%s*$" ) then | ||
| Line 35: | Line 36: | ||
for name in ( raw .. "," ):gmatch( "%s*(.-)%s*," ) do | for name in ( raw .. "," ):gmatch( "%s*(.-)%s*," ) do | ||
if name ~= "" then | if name ~= "" then | ||
if | if NOT_AN_ENTITY[ name:lower() ] then | ||
table.insert( out, name ) | table.insert( out, name ) | ||
else | else | ||
| Line 45: | Line 46: | ||
return table.concat( out, ", " ) | return table.concat( out, ", " ) | ||
end | end | ||
-- Former name, kept so an older revision of a calling template does not break. | |||
p.guestlinks = p.topiclinks | |||
return p | return p | ||
Revision as of 08:31, 20 August 2026
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 topic 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 topics is the point of the
-- exercise: it is what puts an episode on the page of every person, band or
-- place it is about.
--
-- 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 entities, and so
-- should be shown but never linked.
local NOT_AN_ENTITY = {
["and more"] = true,
["more"] = true,
["etc"] = true,
["etc."] = true,
}
function p.topiclinks( 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_AN_ENTITY[ name:lower() ] then
table.insert( out, name )
else
table.insert( out, "[[" .. name .. "]]" )
end
end
end
return table.concat( out, ", " )
end
-- Former name, kept so an older revision of a calling template does not break.
p.guestlinks = p.topiclinks
return p