模块:Cite
外观

![]() | 本模块应仅在条目接近模板展开后长度超过限制时使用,以防止超出限制。除非存在紧急技术需求,否则应使用常规的cs1系列模板或{{citation}} 模板 |
![]() | 此模块使用Lua语言: |
{{Cite arXiv}} | arXiv预印本 |
---|---|
{{Cite AV media}} | 影音媒体 |
{{Cite AV media notes}} | 影音媒体内页说明 |
{{Cite bioRxiv}} | bioRxiv预印本 |
{{Cite book}} | 书籍 |
{{Cite citeseerx}} | CiteSeerX论文 |
{{Cite conference}} | 会议论文 |
{{Cite encyclopedia}} | 引用百科全书的资料 |
{{Cite episode}} | 广播和电视节目 |
{{Cite interview}} | 访谈 |
{{Cite journal}} | 学术期刊 |
{{Cite magazine}} | 杂志和期刊 |
{{Cite mailing list}} | 公共邮件列表 |
{{Cite map}} | 地图 |
{{Cite news}} | 新闻报导 |
{{Cite newsgroup}} | 线上新闻组 |
{{Cite podcast}} | 播客 |
{{Cite press release}} | 新闻稿 |
{{Cite report}} | 报告 |
{{Cite serial}} | 广播和电视节目系列 |
{{Cite sign}} | 标志、匾额、铭牌或徽章 |
{{Cite speech}} | 演讲 |
{{Cite ssrn}} | SSRN论文 |
{{Cite techreport}} | 技术报告 |
{{Cite thesis}} | 学位论文 |
{{Cite tweet}} | Twitter推文 |
{{Cite web}} | 上述模板未包含的其他网络资料 |
参见 | |
用法
[编辑]本模块可用于替换接近模板展开后长度超过限制的条目中的任何cs1/2系列模板。此类使用应仅用于防止条目超出模板限制。必要时,本模块也可用于封装cs1/2模板的模板中。
示例
[编辑]本模块不需要特殊参数,但需要指定cs1模板的规范名称(不带cite
前缀):cite book
→ book
,cite web
→ web
。替换{{citation}}
模板时使用citation
。
模块调用结构:
{{#invoke:cite |<模板名称>|<cs1参数>}}
其中:
#invoke:cite
– 调用本模块|<模板名称>
– 不带cite
前缀的模板规范名称(不区分大小写)|<cs1参数>
–{{cite <模板名称>}}
所需的所有参数
从{{cite book}}
转换:
{{cite book |author=作者 |date=1915 |title=标题 |publisher=示例出版社}}
- 作者. 标题. 示例出版社. 1915.
使用:
{{#invoke:cite |book |author=作者 |date=1915 |title=标题 |publisher=示例出版社}}
- Module:Citation/CS1第1759行Lua错误:assign to undeclared variable 'citation'
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)
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 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 (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 the
post-expand include size limit.
{{#invoke:cite|book|title=Title}}
]]
local function cite (frame, template)
local args_t = require ('Module:Arguments').getArgs (frame, {frameOnly=true});
template = template:lower(); -- lowercase for table indexes
if not cfg.known_templates_t[template] then -- do we recognize this template name?
return make_error_msg (frame, substitute (cfg.settings_t.unknown_name, {template})); -- nope; abandon with error message
end
local config_t = {['CitationClass'] = cfg.citation_classes_t[template] or template}; -- set CitationClass value
return require ('Module:Citation/CS1')._citation (nil, args_t, config_t); -- go render the citation
end
--[[--------------------------< E X P O R T S >---------------------------------------------------------------
]]
local p = {};
local function index (_, template) -- This function gets called by the metatable as index(table, key)
return function (frame) return cite (frame, template) end; -- Return a function which calls cite() with the key name
end
local metatable = {['__index'] = index} -- Set __index, which is returned if table[key] is nil, to the index function
setmetatable (p, metatable) -- Assign the metatable to the returned table
return p