Module:Studio debug: Difference between revisions

From PickiPedia: A knowledge base of bluegrass, old time psychedelic jams, and other public domain music
Jump to navigationJump to search
Magent (talk | contribs)
Test the extra printouts (via update-page on MediaWiki MCP Server)
Magent (talk | contribs)
Isolate the licence lookup (via update-page on MediaWiki MCP Server)
Line 3: Line 3:
local p = {}
local p = {}


local function visible( s )
local function rows( frame )
s = ( s or "" ):gsub( "\127", "<DEL>" )
local raw = frame:callParserFunction( "#ask", {
s = s:gsub( "&", "&amp;" ):gsub( "<", "&lt;" ):gsub( ">", "&gt;" )
"[[Has performer::Harry Clark]]",
return s
"?Has track name=track",
end
"?Has track number=number",
 
"?Has instrument=instrument",
local function ask( frame, printouts )
"mainlabel=record",
local args = { "[[Has performer::Harry Clark]]" }
"link=none",
for _, one in ipairs( printouts ) do
"searchlabel=",
table.insert( args, one )
"limit=200",
end
"format=plainlist",
for _, one in ipairs( {
"sep=@@",
"mainlabel=record", "link=none", "searchlabel=", "limit=200",
"template=Studio appearance row",
"format=plainlist", "sep=@@", "template=Studio appearance row",
} )
} ) do
raw = mw.text.unstrip( raw or "" )
table.insert( args, one )
raw = raw:gsub( "\127[^\127]*\127", "" ):gsub( "<[^>]+>", "" )
end
local record = raw:match( "^(.-)||" ) or ""
return frame:callParserFunction( "#ask", args )
return record:match( "^([^#]*)" ) or record
end
end


function p.one( frame )
-- Query, then link. No licence lookup.
local raw = ask( frame, { "?Has track name=track" } )
function p.nolicence( frame )
return "BEFORE " .. visible( raw ) .. " AFTER " .. visible( mw.text.unstrip( raw ) )
local record = rows( frame )
return '<div style="font-weight:600;">[[' .. record .. "]]</div>"
end
end


function p.all( frame )
-- Query, then ask the record for its licence, then link.
local raw = ask( frame, {
function p.withlicence( frame )
"?Has track name=track", "?Has track number=number", "?Has instrument=instrument",
local record = rows( frame )
local licence = frame:callParserFunction( "#show", {
record, "?Has license", "link=none", "default=",
} )
} )
return "BEFORE " .. visible( raw ) .. " AFTER " .. visible( mw.text.unstrip( raw ) )
licence = mw.text.unstrip( licence or "" )
licence = licence:gsub( "\127[^\127]*\127", "" ):gsub( "<[^>]+>", "" )
return '<div style="font-weight:600;">[[' .. record .. "]]</div> licence=[" .. licence .. "]"
end
end


return p
return p

Revision as of 21:43, 17 September 2026

Documentation for this module may be created at Module:Studio debug/doc

-- Temporary. Delete once Module:Studio sessions is behaving.

local p = {}

local function rows( frame )
	local raw = frame:callParserFunction( "#ask", {
		"[[Has performer::Harry Clark]]",
		"?Has track name=track",
		"?Has track number=number",
		"?Has instrument=instrument",
		"mainlabel=record",
		"link=none",
		"searchlabel=",
		"limit=200",
		"format=plainlist",
		"sep=@@",
		"template=Studio appearance row",
	} )
	raw = mw.text.unstrip( raw or "" )
	raw = raw:gsub( "\127[^\127]*\127", "" ):gsub( "<[^>]+>", "" )
	local record = raw:match( "^(.-)||" ) or ""
	return record:match( "^([^#]*)" ) or record
end

-- Query, then link. No licence lookup.
function p.nolicence( frame )
	local record = rows( frame )
	return '<div style="font-weight:600;">[[' .. record .. "]]</div>"
end

-- Query, then ask the record for its licence, then link.
function p.withlicence( frame )
	local record = rows( frame )
	local licence = frame:callParserFunction( "#show", {
		record, "?Has license", "link=none", "default=",
	} )
	licence = mw.text.unstrip( licence or "" )
	licence = licence:gsub( "\127[^\127]*\127", "" ):gsub( "<[^>]+>", "" )
	return '<div style="font-weight:600;">[[' .. record .. "]]</div> licence=[" .. licence .. "]"
end

return p