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 whether template= in the query is what breaks links afterwards (via update-page on MediaWiki MCP Server)
Magent (talk | contribs)
Test the extra printouts (via update-page on MediaWiki MCP Server)
Line 4: Line 4:


local function visible( s )
local function visible( s )
s = ( s or "" ):gsub( "\127[^\127]*\127", "<MARKER>" )
s = ( s or "" ):gsub( "\127", "<DEL>" )
s = s:gsub( "&", "&amp;" ):gsub( "<", "&lt;" ):gsub( ">", "&gt;" )
s = s:gsub( "&", "&amp;" ):gsub( "<", "&lt;" ):gsub( ">", "&gt;" )
return s
return s
end
end


local function ask( frame, extra )
local function ask( frame, printouts )
local args = {
local args = { "[[Has performer::Harry Clark]]" }
"[[Has performer::Harry Clark]]",
for _, one in ipairs( printouts ) do
"?Has track name=track",
"mainlabel=record",
"link=none",
"searchlabel=",
"limit=200",
}
for _, one in ipairs( extra ) do
table.insert( args, one )
table.insert( args, one )
end
end
local raw = frame:callParserFunction( "#ask", args )
for _, one in ipairs( {
return mw.text.unstrip( raw or "" )
"mainlabel=record", "link=none", "searchlabel=", "limit=200",
end
"format=plainlist", "sep=@@", "template=Studio appearance row",
 
} ) do
-- With a row template, as the real module does.
table.insert( args, one )
function p.withtemplate( frame )
end
local raw = ask( frame, { "format=plainlist", "sep=@@", "template=Studio appearance row" } )
return frame:callParserFunction( "#ask", args )
return "got " .. visible( raw ) .. " -- link after: [[4masks]]"
end
end


-- Without one: the values come back separated by SMW's own punctuation.
function p.one( frame )
function p.notemplate( frame )
local raw = ask( frame, { "?Has track name=track" } )
local raw = ask( frame, { "format=list", "sep=@@", "propsep=||" } )
return "BEFORE " .. visible( raw ) .. " AFTER " .. visible( mw.text.unstrip( raw ) )
return "got " .. visible( raw ) .. " -- link after: [[4masks]]"
end
end


-- No query at all, for a baseline.
function p.all( frame )
function p.noask( frame )
local raw = ask( frame, {
return "got nothing -- link after: [[4masks]]"
"?Has track name=track", "?Has track number=number", "?Has instrument=instrument",
} )
return "BEFORE " .. visible( raw ) .. " AFTER " .. visible( mw.text.unstrip( raw ) )
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 visible( s )
	s = ( s or "" ):gsub( "\127", "<DEL>" )
	s = s:gsub( "&", "&amp;" ):gsub( "<", "&lt;" ):gsub( ">", "&gt;" )
	return s
end

local function ask( frame, printouts )
	local args = { "[[Has performer::Harry Clark]]" }
	for _, one in ipairs( printouts ) do
		table.insert( args, one )
	end
	for _, one in ipairs( {
		"mainlabel=record", "link=none", "searchlabel=", "limit=200",
		"format=plainlist", "sep=@@", "template=Studio appearance row",
	} ) do
		table.insert( args, one )
	end
	return frame:callParserFunction( "#ask", args )
end

function p.one( frame )
	local raw = ask( frame, { "?Has track name=track" } )
	return "BEFORE " .. visible( raw ) .. " AFTER " .. visible( mw.text.unstrip( raw ) )
end

function p.all( frame )
	local raw = ask( frame, {
		"?Has track name=track", "?Has track number=number", "?Has instrument=instrument",
	} )
	return "BEFORE " .. visible( raw ) .. " AFTER " .. visible( mw.text.unstrip( raw ) )
end

return p