Content deleted Content added
m Trappist the monk moved page Module:Sandbox/trappist the monk/cite to Module:Cite without leaving a redirect: get it out of my sandbox; |
No edit summary |
||
Line 1:
require ('strict');
local cfg = mw.loadData ('Module:Cite/config');
--[[--------------------------< K N O W N _ T E M P L A T E S _ T >-------------------------------------------▼
▲--[[--------------------------<
Substitutes $1, $2, etc in <message> with data from <data_t>. Returns plain-text substituted string when
<data_t> not nil; returns <message> else.
]]
local function substitute (message, data_t)
return data_t and mw.message.newRawMessage (message, data_t):plain() or message;
end
}▼
--[[--------------------------<
Assembles an error message from module name, message text, help link, and error category.
]]
local function make_error_msg (frame, msg, nocat)
local module_name = frame:getTitle(); -- get the module name for prefix and help-link label
local namespace = mw.title.getCurrentTitle().namespace; -- used for categorization
local category_link = ((0 == namespace) and not nocat) and substitute ('[[Category:$1]]', {cfg.settings_t.err_category}) or '';
return substitute ('<span style="color:#d33">Error: {{#invoke:$2}}: $3 ([[:$1|$4]])</span>$5',
{
module_name, -- the module name with namespace
module_name:gsub ('Module:', ''), -- the module name without namespace
msg, -- the error message
cfg.settings_t.help, -- help wikilink display text
category_link -- link to error category (main namespace only)
})
end
--[[--------------------------< C I T E >---------------------------------------------------------------------
post-expand include size limit.
{{#invoke:Sandbox/trappist the monk/cite|cite|book|title=Title}}▼
]]
Line 73 ⟶ 50:
local args_t = require ('Module:Arguments').getArgs (frame);
if not args_t[1] then -- this is the template name; we must have a template name
return
end
Line 79 ⟶ 56:
args_t[1] = nil; -- unset, no longer needed (and would break the cs1|2 template)
if not cfg.known_templates_t[template] then
return
end
local config_t = {['CitationClass'] = cfg.citation_classes_t[template] or template};
return require ('Module:Citation/CS1/sandbox')._citation (nil, args_t, config_t); -- TODO: switch to live module
end
|