Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Module:Cite

Permanently protected module
From Wikipedia, the free encyclopedia
Module documentation[view] [edit] [history] [purge]
WarningThis Lua module is used onapproximately 50,000 pages and changes may be widely noticed. Test changes in the module's/sandbox or/testcases subpages, or in your ownmodule sandbox. Consider discussing changes on thetalk page before implementing them.
This module shouldonly be used on articles that are near thepost-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:
Citation Style 1 templates
{{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 alsoSpecific-source templates
Citation Style 1 wrapper templates

Usage

This module may be used to replace any of the cs1|2 templates in articles that are nearing thepost-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

This module requires no parameters but does require the canonical name of a cs1 template without thecite prefix:cite bookbook,cite webweb. To replace{{citation}} templates, usecitation.

The structure for calls to this module:

{{#invoke:cite |<template name>|<cs1 parameters>}}

where:

#invoke:cite – calls this module: Module:cite
|<template name> – is the canonical name of the template without thecite prefix; this is the#invoke: function call; case insensitive
|<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|book|author=EB Green|date=1915|title=Title|publisher=PseudoRandom}}
EB Green (1915).Title. PseudoRandom.
The abovedocumentation istranscluded fromModule:Cite/doc.(edit |history)
Editors can experiment in this module'ssandbox(edit |diff) and testcases(create) pages.
Subpages of this module.

require('strict');localcfg=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.]]localfunctionsubstitute(message,data_t)returndata_tandmw.message.newRawMessage(message,data_t):plain()ormessage;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.]]localfunctionmake_error_msg(frame,msg)localmodule_name=frame:getTitle();-- get the module name for prefix and help-link labellocalnamespace=mw.title.getCurrentTitle().namespace;-- used for categorizationlocalcategory_link=(0==namespace)andsubstitute('[[Category:$1]]',{cfg.settings_t.err_category})or'';returnsubstitute('<span style="color:#d33">Error: &#x7B;{[[$1|#invoke:$2]]}}: $3 ([[:$4|$5]])</span>$6',{module_name,-- the module name with namespacemodule_name:gsub('Module:',''),-- the module name without namespacemsg,-- the error messagecfg.settings_t.help_text_link,-- help wikilink to text at help pagecfg.settings_t.help,-- help wikilink display textcategory_link-- link to error category (for main namespace errors only)})end--[[--------------------------< C I T E >---------------------------------------------------------------------Function to call Module:Citation/CS1/sandbox with appropriate parameters.  For use when an article exceeds thepost-expand include size limit.{{#invoke:cite|book|title=Title}}]]localfunctioncite(frame,template)localargs_t=require('Module:Arguments').getArgs(frame,{frameOnly=true});template=template:lower();-- lowercase for table indexesifnotcfg.known_templates_t[template]then-- do we recognize this template name?returnmake_error_msg(frame,substitute(cfg.settings_t.unknown_name,{template}));-- nope; abandon with error messageendlocalconfig_t={['CitationClass']=cfg.citation_classes_t[template]ortemplate};-- set CitationClass valuereturnrequire('Module:Citation/CS1')._citation(nil,args_t,config_t);-- go render the citationend--[[--------------------------< E X P O R T S >---------------------------------------------------------------]]returnsetmetatable({},{__index=-- returns an empty TABLE whose metatable has the __index set so that, for any given KEY, it returnsfunction(_,template)-- this anonymous function called as function(TABLE, KEY)returnfunction(frame)returncite(frame,template)end;-- which in turn returns a function that calls cite() with the KEY nameend})
Retrieved from "https://en.wikipedia.org/w/index.php?title=Module:Cite&oldid=1290436560"
Category:
Hidden category:

[8]ページ先頭

©2009-2025 Movatter.jp