Modul:PageUtil: Unterschied zwischen den Versionen
2017-11-11
(2015-03-11) |
(2017-11-11) |
||
Zeile 1: | Zeile 1: | ||
--[=[ | local PageUtil = { suite = "PageUtil", | ||
serial = "2017-11-11" }; | |||
--[=[ | |||
PageUtil | PageUtil | ||
]=] | ]=] | ||
PageUtil.maxPages = 200 | |||
Zeile 119: | Zeile 118: | ||
return r | return r | ||
end -- full() | end -- full() | ||
PageUtil.failsafe = function ( assert ) | |||
local r | |||
if not assert or assert <= PageUtil.serial then | |||
r = PageUtil.serial | |||
else | |||
r = false | |||
end | |||
return r | |||
end -- PageUtil.failsafe() | |||
Zeile 160: | Zeile 171: | ||
r = r .. mw.text.trim( s ) | r = r .. mw.text.trim( s ) | ||
end | end | ||
if n > | if n > PageUtil.maxPages then | ||
s = string.format( "'''Too many pages (max. %d)'''", | s = string.format( "'''Too many pages (max. %d)'''", | ||
PageUtil.maxPages ) | |||
r = string.format( "%s\n\n%s", | r = string.format( "%s\n\n%s", | ||
r, | r, | ||
Zeile 179: | Zeile 190: | ||
-- Export | -- Export | ||
local p = { } | local p = { } | ||
function p.isRedirect() | |||
return mw.title.getCurrentTitle().isRedirect and "1" or ""; | |||
end -- p.isRedirect | |||
p.merge = function ( frame ) | p.merge = function ( frame ) | ||
Zeile 187: | Zeile 202: | ||
return r | return r | ||
end | end | ||
p.failsafe = function ( frame ) | |||
-- Versioning interface | |||
local s = type( frame ) | |||
local since | |||
if s == "table" then | |||
since = frame.args[ 1 ] | |||
elseif s == "string" then | |||
since = frame | |||
end | |||
if since then | |||
since = mw.text.trim( since ) | |||
if since == "" then | |||
since = false | |||
end | |||
end | |||
return PageUtil.failsafe( since ) or "" | |||
end -- p.failsafe() | |||
function p.PageUtil() | function p.PageUtil() |