Module:Citation/CS1/sandbox: Difference between revisions

Content deleted Content added
No edit summary
Module support
Line 4,392:
]]
 
Framelocal =function frame; _citation(args, config, lookups) -- save a copy in case we need to display an error message in preview mode
local function citation(frame)
Frame = frame; -- save a copy in case we need to display an error message in preview mode
 
local config = {}; -- table to store parameters from the module {{#invoke:}}
for k, v in pairs( frame.args ) do -- get parameters from the {{#invoke}} frame
config[k] = v;
-- args[k] = v; -- crude debug support that allows us to render a citation from module {{#invoke:}}; skips parameter validation; TODO: keep?
end
-- i18n: set the name that your wiki uses to identify sandbox subpages from sandbox template invoke (or can be set here)
local sandbox = ((config.SandboxPath and '' ~= config.SandboxPath) and config.SandboxPath) or '/sandbox'; -- sandbox path from {{#invoke:Citation/CS1/sandbox|citation|SandboxPath=/...}}
is_sandbox = nil ~= string.find (frame:getTitle()lookups.title, sandbox, 1, true); -- is this invoke the sandbox module?
sandbox = is_sandbox and sandbox or ''; -- use i18n sandbox to load sandbox modules when this module is the sandox; live modules else
 
 
local pframe = frame:getParent()
local styles;
cfg = mw.loadData ('Module:Citation/CS1/Configuration' .. sandbox); -- load sandbox versions of support modules when {{#invoke:Citation/CS1/sandbox|...}}; live modules else
Line 4,414 ⟶ 4,406:
identifiers = require ('Module:Citation/CS1/Identifiers' .. sandbox);
metadata = require ('Module:Citation/CS1/COinS' .. sandbox);
styles = 'Module:Citation/CS1' .. sandbox .. '/styles.css';
 
utilities.set_selected_modules (cfg); -- so that functions in Utilities can see the selected cfg tables
Line 4,423 ⟶ 4,414:
z = utilities.z; -- table of error and category tables in Module:Citation/CS1/Utilities
 
is_preview_mode = not utilities.is_set (frame:preprocess ('{{REVISIONID}}')lookups.revisionid);
 
local args = {}; -- table where we store all of the template's arguments
local suggestions = {}; -- table where we store suggestions if we need to loadData them
local error_text; -- used as a flag
Line 4,431 ⟶ 4,422:
local capture; -- the single supported capture when matching unknown parameters using patterns
local empty_unknowns = {}; -- sequence table to hold empty unknown params for error message listing
for k, v in pairs( pframe.args ) do -- get parameters from the parent (template) frame
v = mw.ustring.gsub (v, '^%s*(.-)%s*$', '%1'); -- trim leading/trailing whitespace; when v is only whitespace, becomes empty string
if v ~= '' then
Line 4,509 ⟶ 4,500:
 
return table.concat ({
frame:extensionTag ('lookups.templatestyles', '', {src=styles}),
citation0( config, args)
});
end
 
local function citation(frame)
local config = {}; -- table to store parameters from the module {{#invoke:}}
for k, v in pairs( frame.args ) do -- get parameters from the {{#invoke}} frame
config[k] = v;
-- args[k] = v; -- crude debug support that allows us to render a citation from module {{#invoke:}}; skips parameter validation; TODO: keep?
end
local pframe = frame:getParent()
local args = pframe.args
local styles = 'Module:Citation/CS1' .. sandbox .. '/styles.css';
local lookups = {
title = frame:getTitle(),
revisionid = frame:preprocess ('{{REVISIONID}}'),
templatestyles = frame:extensionTag ('templatestyles', '', {src=styles})
}
return _citation(args, config, lookups)
end
 
Line 4,518 ⟶ 4,526:
]]
 
return {citation = citation, _citation = _citation};