Module:If preview/sandbox: Difference between revisions

Content deleted Content added
No edit summary
Undid revision 1246785899 by Awesome Aasim (talk)
 
(15 intermediate revisions by the same user not shown)
Line 1:
local p = {}
local getArgs = require("Module:Arguments").getArgs
p._counter = 1
local yn = require("Module:Yesno")
local cfg = mw.loadData('Module:If preview/configuration')
p.pvwc = p.pvwc or package.loaded["Module:If preview/preview warning counter"]
or require("Module:If preview/preview warning counter")
 
--[[
Line 11 ⟶ 14:
]]
function p.main(frame)
local args = getArgs(frame)
if cfg.preview then
return frame.args[1] or ''
else
return frame.args[2] or ''
end
end
Line 28 ⟶ 32:
function p.pmain(frame)
return p.main(frame:getParent())
end
 
function p.consoleWarning(frame)
mw.addWarning("[" .. p._counter .. "] " .. frame.args[1])
p._counter = p._counter + 1
return ''
end
 
Line 53 ⟶ 51:
if not cfg.preview then return '' end
if yn(args['consolewarning']) then mw.addWarning('[' .. p.pvwc.incr() .. '] ' .. (args[1] or cfg.missing_warning)) end
return warning_text(warning) .. mw.getCurrentFrame():preprocess("{{safesubst:#invoke:If preview/sandbox|consoleWarning|1=" .. warning .. "}}" )
return warning_text(warning)
end
 
Line 61 ⟶ 60:
This function returns a "preview warning", which is the first argument marked
up with HTML and some supporting text, depending on whether the page is being previewed.
 
disabled since we'll implement the template version in general
 
]]
-- function p.warning(frame)
-- return p mw._warningaddWarning(frame.args[1] or cfg.missing_warning)
-- return p._warning(frame:getParent().args)
-- end
 
--[[
Line 73 ⟶ 71:
]]
function p.pwarning(frame)
local args = getArgs(frame)
return p._warning(frame:getParent().args)
return p._warning(args)
end
 
--[[
Does both mw.addWarning and preview warning
]]
 
function p.warn(text)
if text == nil or text == "" then return "" end
mw.addWarning("'["' .. p._counterpvwc.incr() .. "'] "' .. frame.args[1]text)
return p._warning({text})
end
 
--[[
Console warning
]]
function p.consoleWarning(frame)
local args = getArgs(frame)
mw.addWarning('[' .. p.pvwc.incr() .. '] ' .. (args[1] or cfg.missing_warning))
return ''
end