Module:If preview/sandbox: Difference between revisions

Content deleted Content added
No edit summary
m Reverted edits by Awesome Aasim (talk) to last version by SilverLocust
Tags: Rollback Reverted
Line 1:
local p = {}
 
local getArgs = require("Module:Arguments").getArgs
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 14 ⟶ 11:
]]
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 33 ⟶ 29:
return p.main(frame:getParent())
end
 
 
local function warning_text(warning)
Line 51 ⟶ 48:
if not cfg.preview then return '' end
Does both mw.addWarning and preview (warning)
if yn(args['consolewarning']) then mw.addWarning('[' .. p.pvwc.incr() .. '] ' .. (args[1] or cfg.missing_warning)) end
return warning_text(warning)
end
Line 60 ⟶ 57:
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 mwp.addWarning_warning(frame.args[1] or cfg.missing_warning)
-- end
-- return p._warning(frame.args)
-- end
 
--[[
Line 71 ⟶ 69:
]]
function p.pwarning(frame)
-- return p._warning(frame:getParent().args)
local args = getArgs(frame)
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.pvwc.incr() .. '] ' .. 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