Moduł:Sandbox/Draco flavus/TestX

Z Wikiźródeł, wolnej biblioteki

Dokumentacja dla tego modułu może zostać utworzona pod nazwą Moduł:Sandbox/Draco flavus/TestX/opis

local p = {}
function p.test(frame)
	local childFrame = frame:newChild{title = 'Strona:Szlachcic Zawalnia (1844—1846). Tom 1.pdf/101', args = {'{{ROOTPAGENAME}}'} }
	--wynik = childFrame:preprocess('{{ROOTPAGENAME}}') 
	wynik = mw.getCurrentFrame():getTitle()
	wynik = childFrame:getTitle()
	wynik = childFrame:preprocess('{{ROOTPAGENAME}}')
	wynik = frame:newChild{title='Strona:Szlachcic Zawalnia (1844—1846). Tom 1.pdf/101', args={}}:preprocess('{{ROOTPAGENAME}}')
	--wynik = mw.getCurrentFrame():getTitle()
	--wynik = mw.title.new(frame:getParent():getTitle()):getContent()
	return wynik
end

function p.test1(frame)
    local PageResult = ""
    local PageName = ""
    local PageContent= "{{}}"
    local i = 0
    local j = 0
    local l = ""
    local szablon = 'ML/super'
    local address = frame.args[1]
    PageContent= mw.title.new(address):getContent()
    i, j = string.find(PageContent, "{{ *Dane tekstu"  )
	i, j = string.find(PageContent, "%b{}" , i )
	PageResult = " " .. string.sub(PageContent, i, j-2):gsub("[^|]*","",1) .. "|"
   	PageResult = PageResult:gsub("%b{}",
   		function(s1) return string.gsub(s1,"|", "🐉") end)
   	PageResult = PageResult:gsub("%b[]",
   		function(s1) return string.gsub(s1,"|", "🐉") end)
   	
   	if PageResult:match("| *" .. "licencja" .. "[ ]*=[ ]*[^|]*") then
		l = PageResult:match("| *" .. "licencja" .. "[ ]*=[ ]*[^|]*"):gsub("| *" .. "licencja" .. "[ ]*=[ ]*", ""):gsub("🐉", "|")
		return frame:preprocess(l)
	elseif PageResult:match("| *" .. "referencja" .. "[ ]*=[ ]*[^|]*") then
		l = PageResult:match("| *" .. "referencja" .. "[ ]*=[ ]*[^|]*"):gsub("| *" .. "referencja" .. "[ ]*=[ ]*", ""):gsub("🐉", "|")
		return frame:preprocess("{{" .. szablon .. "|" .. l .. "}}")
	else
		return "Brak odpowiedniego argumentu w szablonie!"
   	end
end

function p.test2(frame)
    local PageResult = ""
    local PageName = ""
    local PageContent= "{{}}"
    local i = 0
    local j = 0
    local l = ""
	local address = string.gsub('' .. frame.args[1], '^%s*(.-)%s*$', '%1' .. '')
	PageContent= mw.title.new(address):getContent()
    i, j = string.find(PageContent, "{{ *Dane tekstu"  )
	i, j = string.find(PageContent, "%b{}" , i )
	PageResult = " " .. string.sub(PageContent, i, j-2):gsub("[^|]*","",1) .. "|"
   	PageResult = PageResult:gsub("%b{}",
   		function(s1) return string.gsub(s1,"|", "🐉") end)
   	PageResult = PageResult:gsub("%b[]",
   		function(s1) return string.gsub(s1,"|", "🐉") end)
   	
   	if PageResult:match("| *" .. "referencja" .. "[ ]*=[ ]*[^|]*") then
   		return "Dopuszczamy tylko pojedyncze dziedziczenie!"
   	elseif PageResult:match("| *" .. "_licencja" .. "[ ]*=[ ]*[^|]*") then
		l = PageResult:match("| *" .. "_licencja" .. "[ ]*=[ ]*[^|]*"):gsub("| *" .. "_licencja" .. "[ ]*=[ ]*", ""):gsub("🐉", "|")
		return frame:preprocess(l)
   	elseif PageResult:match("| *" .. "licencja" .. "[ ]*=[ ]*[^|]*") then
		l = PageResult:match("| *" .. "licencja" .. "[ ]*=[ ]*[^|]*"):gsub("| *" .. "licencja" .. "[ ]*=[ ]*", ""):gsub("🐉", "|")
		return frame:preprocess(l)
	else
		return "Brak odpowiedniego argumentu w szablonie!"
   	end
end

return p