Modul:Info: Unterschied zwischen den Versionen

CamNet - das Wiki
Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
Zeile 37: Zeile 37:
function p.main(frame)
function p.main(frame)
local args = getArgs(frame)
local args = getArgs(frame)
local payload = args.title or args[1] or mw.title.getCurrentTitle().prefixedText
local title = args.title or args[1] or mw.title.getCurrentTitle().prefixedText
local target = args.target or args[2] or mw.title.getCurrentTitle().id
local target = args.target or args[2] or mw.title.getCurrentTitle().id
local id = payload .. target
local payload = args.payload or ''
--local me = Class:new(mw.title.getCurrentTitle().prefixedText .. '_info_' .. stringHash(id))
local infoType = args.type or ''
local me = Class:new(nil)
local id = title .. targe .. type .. payload
local me = Class:new(mw.title.getCurrentTitle().prefixedText .. '_info_' .. stringHash(id))
me:initFromArgs(args)
me:initFromArgs(args)
me:storeData()
me:storeData()
-- me:addInfobox()
-- me:addInfobox()
-- me:addPageBody()
-- me:addPageBody()
  return me:render() .. id .. stringHash(id)
  return me:render()
end
end


return p
return p

Version vom 15. Mai 2022, 18:45 Uhr

Documentation icon Module documentation

This module implements template {{Info}}.

Usage

{{#invoke:Info|main}}

It also provides some additional "gateways" to some of Module:Info/class's static methods:

{{#invoke:Info|categorize}}
{{#invoke:Info|categoryPage}}
{{#invoke:Info|explainDataStore}}
{{#invoke:Info|gardeningCategoryPage}}
{{#invoke:Info|sfGenerateForm}}
{{#invoke:Info|sfGenerateFormEntry}}
{{#invoke:Info|sfGenerateFormLink}}
{{#invoke:Info|templateDocumentation}}

Maintenanace notes

This page was created by Module:Classgenerator and belongs to Class:Info.

local p = {}
local Class = require('Module:Info/class')
local getArgs = require('Module:Arguments').getArgs

local function stringHash(text)
	local counter = 1
	local len = string.len(text)
	for i = 1, len, 3 do 
	counter = math.fmod(counter*8161, 4294967279) +  -- 2^32 - 17: Prime!
		(string.byte(text,i)*16776193) +
		((string.byte(text,i+1) or (len-i+256))*8372226) +
		((string.byte(text,i+2) or (len-i+256))*3932164)
	end
	return math.fmod(counter, 4294967291) -- 2^32 - 5: Prime (and different from the prime in the loop)
end

function p.categorize(frame)
	return tostring(Class:categorize())
end

function p.categoryPage(frame)
	return tostring(Class:categoryPage())
end

function p.explainDataStore(frame)
	return tostring(Class:explainDataStore())
end

function p.gardeningCategoryPage(frame)
	return tostring(Class:gardeningCategoryPage())
end

function p.templateDocumentation(frame)
	return tostring(Class:templateDocumentation())
end

function p.main(frame)
	local args = getArgs(frame)
	local title = args.title or args[1] or mw.title.getCurrentTitle().prefixedText
	local target = args.target or args[2] or mw.title.getCurrentTitle().id
	local payload = args.payload or ''
	local infoType = args.type or ''
	local id = title .. targe .. type .. payload
	local me = Class:new(mw.title.getCurrentTitle().prefixedText .. '_info_' .. stringHash(id))
	me:initFromArgs(args)
	me:storeData()
--	me:addInfobox()
--	me:addPageBody()
 	return me:render()
end

return p