Module:Cite
![]() | This module should only be used on articles that are near the post-expand include size limit, in order to prevent them exceeding it. Unless there is a pressing technical need, use appropriate cs1 and {{citation}} templates |
![]() | This module depends on the following other modules: |
{{Cite arXiv}} | arXiv preprints |
---|---|
{{Cite AV media}} | audio and visual media |
{{Cite AV media notes}} | AV media liner notes |
{{Cite bioRxiv}} | bioRxiv preprints |
{{Cite book}} | books and chapters |
{{Cite CiteSeerX}} | CiteSeerX papers |
{{Cite conference}} | conference papers |
{{Cite document}} | short, stand-alone, offline documents |
{{Cite encyclopedia}} | edited collections |
{{Cite episode}} | radio or TV episodes |
{{Cite interview}} | interviews |
{{Cite journal}} | academic journals |
{{Cite magazine}} | magazines, periodicals |
{{Cite mailing list}} | public mailing lists |
{{Cite map}} | maps |
{{Cite medRxiv}} | medRxiv preprints |
{{Cite news}} | news articles |
{{Cite newsgroup}} | online newsgroups |
{{Cite podcast}} | podcasts |
{{Cite press release}} | press releases |
{{Cite report}} | reports |
{{Cite serial}} | audio or video serials |
{{Cite sign}} | signs, plaques |
{{Cite speech}} | speeches |
{{Cite SSRN}} | SSRN papers |
{{Cite tech report}} | technical reports |
{{Cite thesis}} | theses |
{{Cite web}} | web sources not covered by the above |
See also | Specific-source templates Citation Style 1 wrapper templates |
Usage
[edit]This module may be used to replace any of the cs1|2 templates in articles that are nearing the post-expand include size limit. Such use should only be done to prevent an article from exceeding the PEIS limit. If necessary, this module may be used in templates that wrap a cs1|2 template.
Examples
[edit]This module requires only one parameter: the first positional parameter. That parameter takes as a value, the canonical name of a cs1 template without the cite
prefix: cite book
→ book
, cite web
→ web
. To replace {{citation}}
templates, use citation
.
The structure for calls to this module:
{{#invoke:cite |cite |<template name>|<cs1 parameters>}}
where:
#invoke:cite
– calls this module: Module:cite|cite
– is the function in Module:cite that is to be executed:cite()
|<template name>
– is the canonical name of the template without thecite
prefix|<cs1 parameters>
– are all of the parameters required by{{cite <template name>}}
To go from {{cite book}}
:
{{cite book |author=EB Green |date=1915 |title=Title |publisher=PseudoRandom}}
- EB Green (1915). Title. PseudoRandom.
write:
{{#invoke:cite |cite |book |author=EB Green |date=1915 |title=Title |publisher=PseudoRandom}}
- EB Green (1915). Title. PseudoRandom.
TemplateData
[edit]TemplateData for Cite
This module for use on articles that are approaching the post-expand include size limit. For all other usage information, see [[Module:Cite]].
Parameter | Description | Type | Status | |
---|---|---|---|---|
1 | 1 | canonical name (without the 'cite' prefix) of the template to be replaced; to replace 'cite book', use 'book'. | String | required |
require ('strict');
local cfg = mw.loadData ('Module:Cite/config');
--[[--------------------------< S U B S T I T U T E >----------------------------------------------------------
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
--[[--------------------------< M A K E _ E R R O R _ M S G >--------------------------------------------------
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: {{[[$1|#invoke:$2]]}}: $3 ([[:$4|$5]])</span>$6',
{
module_name, -- the module name with namespace
module_name:gsub ('Module:', ''), -- the module name without namespace
msg, -- the error message
cfg.settings_t.help_text_link, -- help wikilink to text at help page
cfg.settings_t.help, -- help wikilink display text
category_link -- link to error category (main namespace only)
})
end
--[[--------------------------< C I T E >---------------------------------------------------------------------
Function to call Module:Citation/CS1/sandbox with appropriate parameters. For use when an article exceeds the
post-expand include size limit.
{{#invoke:cite|cite|book|title=Title}}
]]
local function cite (frame)
local args_t = require ('Module:Arguments').getArgs (frame, {frameOnly=true});
if not args_t[1] then -- this is the template name; we must have a template name
return make_error_msg (frame, cfg.error_messages_t.missing); -- no template name; abandon with error message
end
local template = args_t[1]:lower(); -- lowercase for table indexes
args_t[1] = nil; -- unset, no longer needed (and would break the cs1|2 template)
if not cfg.known_templates_t[template] then -- do we recognize this template name?
return make_error_msg (frame, substitute (cfg.error_messages_t.unknown, {template})); -- nope; abandon with error message
end
local config_t = {['CitationClass'] = cfg.citation_classes_t[template] or template};
return require ('Module:Citation/CS1')._citation (nil, args_t, config_t); -- go render the citation
end
--[[--------------------------< E X P O R T S >---------------------------------------------------------------
]]
return {
cite = cite,
}