Module:Versuch

From Wikipedia!
Jump to navigation Jump to search

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

--	test module created by user:Gangleri
--	status: 2015-12-20 draft; working as expected

local p = {}
	mw.log()

local libraryUtil = require('libraryUtil')
-- from https://wikimania2015.wikimedia.org/wiki/Module:TableTools i.e. from [[wm2015:Module:TableTools]]
local TableTools = require('Module:TableTools')
-- from https://commons.wikimedia.org/wiki/Module:TableTools i.e. from [[c:Module:TableTools]]
local Teszt = require('Module:Teszt')

-- from module:Teszt
local function tableToString(t)
    local key
    local value
    local result
 
    result = tostring(type(t)) .. ' result:' .. '\n'
    if ( tostring(type(t)) ~= 'table' ) then
    	result = result .. 'WRONG TYPE' .. '\n\n'
    	return result
    end
 
    for key, value in pairs(t) do
    	result = result .. '\n' .. 'key is ' .. tostring(type(key)) .. ': '
        if (key == nil) then
    	result = result .. 'KEY is NIL '
        end
    	local myvalue = tostring(value)
    	if (myvalue == '') then
    		myvalue = 'EMPTY'
    	end
        if (tonumber(key) ~= nil) then
            result = result .. ':table[' .. key .. '] is ' .. myvalue .. '\n' 
        else
            result = result .. ':table[\'' .. key .. '\'] is ' .. myvalue .. '\n' 
        end
    end
 
    return result
end

function p.pruv()
--	local myPageTitle = mw.title.new( 'pruv', 829 )
	local myPageTitle = mw.title.new( 'Gangleri/tests/4x4 type square/Lua tests', 2 )
	local result = ''
    result = result .. ';newTitle\n'
--	result = result .. myPageTitle
    result = result .. tableToString(myPageTitle)
    result = result .. '\n' .. '[[' .. myPageTitle.fullText .. ']]' .. '\n\n'
    return result
end

function p.nokhapruv()
	local myactualFrame = mw.getCurrentFrame()
	local myactualArgs = myactualFrame.args
	local result = ''
    result = result .. ';CurrentFrame\n'
	if (myactualArgs == nil) then
		return result .. 'missing parameters: Syntax is pagename=foo|ns=bar : no validation is performed'
	else
		if (myactualArgs.pagename == nil) then
			return result .. 'missing pagename: Syntax is pagename=foo|ns=bar : no validation is performed'
		else
			local mypagename = tostring(myactualArgs.pagename)
			local myns = tonumber(myactualArgs.ns)
			if (mypagename == '') then
				return result .. 'missing pagename value: Syntax is pagename=foo|ns=bar : no validation is performed'
			else
				if (myns == nil) then
					myns = 0
				end
				local myPageTitle = mw.title.new( mypagename, myns )
--				result = result .. '[[' .. myPageTitle ..']]'
--				result = result .. myPageTitle
				result = result .. '[[' .. myPageTitle.prefixedText ..']]'
				return result
			end
		end
	end
end

function p.imagination(fullpagename)

--	key is string: :table['path'] is /wiki/Table
--	key is string: :table['hostPort'] is test.wikipedia.org
--	key is string: :table['host'] is test.wikipedia.org
--	key is string: :table['validate'] is function
--	key is string: :table['authority'] is test.wikipedia.org
--	key is string: :table['clone'] is function
--	key is string: :table['extend'] is function
--	key is string: :table['parse'] is function
--	key is string: :table['relativePath'] is /wiki/Table

	local myfullurl = mw.uri.fullUrl(tostring(fullpagename))
	local result = ''
    result = result .. ';fullUrl\n'
--	result = result .. myfullurl
    result = result .. tableToString(myfullurl)
--	result = result .. '\n' .. '[' .. 'https://' .. myfullurl .. ' ' .. 'myfullurl' .. ']'
--	result = result .. '\n' .. '[' .. 'https://' .. myfullurl.prefixedText .. ' ' .. 'myfullurl' .. ']'
--	result = result .. '\n' .. '[' .. 'https://' .. myfullurl.extend .. ' ' .. 'myfullurl' .. ']'
	result = result .. '\n' .. 'type of ' .. 'myfullurl.host' .. ' is ' ..  tostring(type(myfullurl.host)) .. '\n'
	result = result .. '\n' .. 'value of ' .. 'myfullurl.host' .. ' is ' ..  tostring(myfullurl.host) .. '\n'
--	result = result .. '\n' .. 'type of ' .. 'myfullurl:extend()' .. ' is ' ..  tostring(type(myfullurl:extend())) .. '\n'
	return result
end

function p.knowledge()
	local result = ''
	local myactualFrame = mw.getCurrentFrame()

	local myactualargs = myactualFrame.args
    result = result .. ';actualArgs\n'
    result = result .. tableToString(myactualargs)

	local myactualpagename = tostring(myactualargs.pagename)
	local myactualns = tonumber(myactualargs.ns)
	local mypagetitle = mw.title.new( myactualpagename, myactualns )
	result = result .. ';PageTitle\n'
	if ( tostring(type(mypagetitle)) ~= 'table' ) then
		result = result .. 'type is ' .. tostring(type(mypagetitle))
	else
		result = result .. tableToString(mypagetitle)
		result = result .. '\n' .. 'PageTitle is ' .. '[[' .. mypagetitle.prefixedText ..']]'
--		verify IF XISTS
		local mycontent = mypagetitle:getContent()
		result = result .. '\n\n' .. 'result of \'\'\'getContent()\'\'\' has type  ' .. tostring(type(mycontent))
		result = result .. '\n\n' .. 'content is:' .. '\n\n' .. '<div style="background:gray;" >'
		result = result .. mycontent .. '</div>'
	end
	return result
end

-- function p.main01()
function p.inspect_mw()
	local result = ''
	local dump = ''

	local myobject = mw
    result = result .. ';MW\n'
    result = result .. '\n' .. 'type is: ' .. tostring(type(myobject)) .. '\n\n'
    dump = mw.dumpObject(myobject)
    result = result .. dump
    return result
end

function p.main02()
	local result = ''
	local dump = ''

	local myobject = db
    result = result .. ';DB\n'
    result = result .. '\n' .. 'type is: ' .. tostring(type(myobject)) .. '\n\n'
    dump = mw.dumpObject(myobject)
    result = result .. dump
    return result
end

function p.main03()
	local result = ''
	local dump = ''

	local myobject = cfg
    result = result .. ';cfg\n'
    result = result .. '\n' .. 'type is: ' .. tostring(type(myobject)) .. '\n\n'
    dump = mw.dumpObject(myobject)
    result = result .. dump
    return result
end

function p.main04()
	local result = ''
	local dump = ''

	local myobject = page
    result = result .. ';page\n'
    result = result .. '\n' .. 'type is: ' .. tostring(type(myobject)) .. '\n\n'
    dump = mw.dumpObject(myobject)
    result = result .. dump
    return result
end

function p.main05()
	local result = ''
	local dump = ''

	local myobject = data
    result = result .. ';data\n'
    result = result .. '\n' .. 'type is: ' .. tostring(type(myobject)) .. '\n\n'
    dump = mw.dumpObject(myobject)
    result = result .. dump
    return result
end

function p.main06()
	local result = ''
	local dump = ''

	local myobject = info
    result = result .. ';info\n'
    result = result .. '\n' .. 'type is: ' .. tostring(type(myobject)) .. '\n\n'
    dump = mw.dumpObject(myobject)
    result = result .. dump
    return result
end

function p.main07()
	local result = ''
	local dump = ''

	local myobject = util
    result = result .. ';util\n'
    result = result .. '\n' .. 'type is: ' .. tostring(type(myobject)) .. '\n\n'
    dump = mw.dumpObject(myobject)
    result = result .. dump
    return result
end

function p.main08()
	local result = ''
	local dump = ''

	local myobject = wiki
    result = result .. ';wiki\n'
    result = result .. '\n' .. 'type is: ' .. tostring(type(myobject)) .. '\n\n'
    dump = mw.dumpObject(myobject)
    result = result .. dump
    return result
end

function p.main09()
	local result = ''
	local dump = ''

	local myobject = wmf
    result = result .. ';wmf\n'
    result = result .. '\n' .. 'type is: ' .. tostring(type(myobject)) .. '\n\n'
    dump = mw.dumpObject(myobject)
    result = result .. dump
    return result
end

function p.main10()
	local result = ''
	local dump = ''

	local myobject = wg
    result = result .. ';wg\n'
    result = result .. '\n' .. 'type is: ' .. tostring(type(myobject)) .. '\n\n'
    dump = mw.dumpObject(myobject)
    result = result .. dump
    return result
end

function p.main11()
	local result = ''
	local dump = ''

	local myobject = _W
    result = result .. ';_W\n'
    result = result .. '\n' .. 'type is: ' .. tostring(type(myobject)) .. '\n\n'
    dump = mw.dumpObject(myobject)
    result = result .. dump
    return result
end

-- function p.main23()
function p.inspect__G()
	local result = ''
	local dump = ''

	local myobject = _G
    result = result .. ';_G\n'
    result = result .. '\n' .. 'type is: ' .. tostring(type(myobject)) .. '\n\n'
    dump = mw.dumpObject(myobject)
    result = result .. dump
    return result
end

function p.main42(whoiswho)
	local result = ''
	local dump = ''
	local myframe = nil

--	result = result .. ';' .. tableToString(whoiswho) .. '\n'
    result = result .. ';' .. 'whoiswho' .. '\n'
	result = result .. '\n' .. 'type is: ' .. tostring(type(whoiswho)) .. '\n\n'
    dump = mw.dumpObject(whoiswho)
    result = result .. dump
    result = result .. '\n;' .. 'fullDump' .. '\n'

	myframe = mw.getCurrentFrame()
	who = string.sub(myframe.args.whoiswho, 1, -1)
    result = result .. '\n;' .. 'who is ' .. tostring(who) .. '\n'
    result = result .. '\n' .. 'type is: ' .. tostring(type(who)) .. '\n\n'

--	dump = mw.dumpObject(myframe.args.whoiswho)
--	dump = mw.dumpObject(who)
--	result = result .. dump
    return result
end

return p