Bearbeiten von „Modul:PageUtil“
Zur Navigation springen
Zur Suche springen
Die Bearbeitung kann rückgängig gemacht werden. Bitte prüfe den Vergleich unten, um sicherzustellen, dass du dies tun möchtest, und veröffentliche dann unten deine Änderungen, um die Bearbeitung rückgängig zu machen.
Aktuelle Version | Dein Text | ||
Zeile 1: | Zeile 1: | ||
--[=[ 2015-03-11 | |||
-- | |||
PageUtil | PageUtil | ||
* merge() | |||
]=] | ]=] | ||
PageUtil | -- table for export | ||
local PageUtil = {} | |||
local MaxPages = 200 | |||
Zeile 15: | Zeile 15: | ||
-- Format message with class="error" | -- Format message with class="error" | ||
-- alert -- string, with message | -- alert -- string, with message | ||
-- frame -- object | -- frame -- object | ||
-- Returns message with markup | -- Returns message with markup | ||
local | local r = alert | ||
if frame then | if frame then | ||
r = string.format( "%s * %s", frame:getTitle(), r ) | |||
end | end | ||
r = string.format( "<span class=\"error\">ERROR * %s</span>", r ) | |||
return r | |||
end -- fault() | end -- fault() | ||
Zeile 77: | Zeile 76: | ||
end | end | ||
else | else | ||
r = | r = string.format( "<div class=\"error\">%s</div>", | ||
source ) | |||
end | end | ||
end | end | ||
Zeile 108: | Zeile 106: | ||
seed = source | seed = source | ||
end | end | ||
r = string.format( "%s\n%s | r = frame:expandTemplate( { title = seed } ) | ||
r = string.format( "<span id='%s'></span>\n%s", segment, r ) | |||
table.insert( assembly, { source, segment } ) | table.insert( assembly, { source, segment } ) | ||
else | else | ||
r = | r = string.format( "<div class=\"error\">%s</div>", | ||
page.prefixedText ) | |||
end | end | ||
else | else | ||
r = string.format( "%s '%s'", "Unknown page", access | r = string.format( "<div class=\"error\">%s '%s'</div>", | ||
"Unknown page", access ) | |||
end | end | ||
return r | return r | ||
end -- full() | end -- full() | ||
Zeile 246: | Zeile 160: | ||
r = r .. mw.text.trim( s ) | r = r .. mw.text.trim( s ) | ||
end | end | ||
if n > | if n > MaxPages then | ||
s = string.format( "'''Too many pages (max. %d)'''", | s = string.format( "'''Too many pages (max. %d)'''", | ||
MaxPages ) | |||
r = string.format( "%s\n\n%s", | r = string.format( "%s\n\n%s", | ||
r, | r, | ||
Zeile 265: | Zeile 179: | ||
-- Export | -- Export | ||
local p = { } | local p = { } | ||
p.merge = function ( frame ) | p.merge = function ( frame ) | ||
Zeile 285: | Zeile 186: | ||
end | end | ||
return r | return r | ||
end | end | ||
function p.PageUtil() | function p.PageUtil() |