Moduuli:Hiekkalaatikko/Hunsvotti

Wikikirjastosta

Tämän moduulin ohjeistuksen voi tehdä sivulle Moduuli:Hiekkalaatikko/Hunsvotti/ohje

local p = {}

function p.Testi(frame)
	local out = {}
	
	table.insert(out, frame:getParent():getTitle())
	
	local title = mw.title.getCurrentTitle()
	
	table.insert(out, title.fullText)
	
	
	return "* " .. table.concat(out, "\n* ")
end

function p.Testi2(frame)
	local title = mw.title.new( frame.args["pääsivu"] )
	local title_self = mw.title:getCurrentTitle()
	local content = title:getContent()
	
	local chord = mw.ustring.match(title_self.fullText, "^Kitarakirja/Sointuluettelo:([A-G][♯♭])")
	local note = chord:lower()
	local chord1, chord2 = mw.ustring.match(title.fullText, "^Kitarakirja/Sointuluettelo:([A-G][♯♭])/([A-G][♯♭])")
	
	for line in mw.ustring.gmatch(content, "nuotit[12] [^|\n}]*") do
		if not mw.ustring.find(line, note) then
			content = mw.ustring.gsub( content, line, "" )
		end
	end
	
	
	--return frame:extensionTag{ name = "pre", content = content }

		
	if frame.args.nowiki then
		return '<pre>' .. content .. '</pre'
	end
	
	return '<div style="position: absolute; top: 0; right: 0; border: solid gray 1px; background-color: white; margin: 0.5em; padding: 0.5em;">\n'
	    .. 'Näytä: [[Kitarakirja/Sointuluettelo:' .. chord1 .. '/' .. chord1 .. '|' .. chord1 .. ']]/[[Kitarakirja/Sointuluettelo:' .. chord2 .. '/' .. chord2 .. '|' .. chord2 .. ']]\n'
		.. '[&#8203;[[' .. frame.args["pääsivu"] .. '|muokkaa]]&#8203;]<br/>\n'
		.. '</div>\n' 
		.. frame:preprocess( content )

end	


function p.Testi3(frame)
	local titleObj = mw.title.getCurrentTitle()
	
	return "*text: " .. titleObj.text .. "\n" ..
	"*fullText: " .. titleObj.fullText .. "\n" ..
	"*prefixedText: " .. titleObj.prefixedText .. "\n" ..
	"*rootText: " .. titleObj.rootText .. "\n" ..
	"*baseText: " .. titleObj.baseText .. "\n" ..
	"*subpageText: " .. titleObj.subpageText .. "\n"

end

function p.Testi4(frame)
	local titleObj = mw.title.makeTitle(0, "Musiikin taulukot/Symbolit/../Symbolit/Kertausmerkit")
	
	return "*text: " .. titleObj.text .. "\n" ..
	"*fullText: " .. titleObj.fullText .. "\n" ..
	"*prefixedText: " .. titleObj.prefixedText .. "\n" ..
	"*rootText: " .. titleObj.rootText .. "\n" ..
	"*baseText: " .. titleObj.baseText .. "\n" ..
	"*subpageText: " .. titleObj.subpageText .. "\n"

end

return p