モジュール:Cite
| このモジュールはテンプレート読み込みサイズが制限値に近いページでのみ使用してください。通常の記事では適切なCS1・CS2・CS-ja出典テンプレートを使用してください。 |
| Luaモジュールを使用しています: |
| {{Cite arXiv}} | arXivのプレプリント論文 |
|---|---|
| {{Cite AV media}} | 音声・動画 |
| {{Cite AV media notes2}} | ライナーノーツ |
| {{Cite bioRxiv}} | bioRxivのプレプリント論文 |
| {{Cite book2}} | 書籍 |
| {{Cite CiteSeerX}} | CiteSeerXの論文 |
| {{Cite conference2}} | 会議の報告書 |
| {{Cite document}} | ごく短い紙の書類 |
| {{Cite encyclopedia2}} | 事典・辞典 |
| {{Cite episode}} | ラジオとテレビ番組 |
| {{Cite interview2}} | インタビュー |
| {{Cite journal2}} | 学術論文 |
| {{Cite magazine2}} | 雑誌・定期刊行物 |
| {{Cite mailing list}} | 公開メーリングリスト |
| {{Cite map}} | 地図 |
| {{Cite medRxiv}} | medRxivのプレプリント論文 |
| {{Cite news2}} | 新聞・ニュース記事 |
| {{Cite newsgroup}} | ニュースグループ |
| {{Cite podcast}} | ポッドキャスト |
| {{Cite press release2}} | プレスリリース |
| {{Cite report2}} | レポート |
| {{Cite serial}} | 音声と動画の連作 |
| {{Cite sign}} | 標識・掲示板 |
| {{Cite speech}} | 演説 |
| {{Cite SSRN}} | SSRNの論文 |
| {{Cite tech report}} | 技術レポート |
| {{Cite thesis2}} | 学位論文 |
| {{Cite web2}} | ウェブ出典 |
| 関連カテゴリ | 特定の出典テンプレート |
使い方
[編集]このモジュールはテンプレート読み込みサイズが制限値に近いページ内のCS1・CS2・CS-ja出典テンプレートを置き換えるために使用できます。必要に応じてラッパーテンプレートからも使用できます。
例
[編集]出典テンプレートの名前からciteを除いた部分(cite book → book, cite web → web)を指定します。{{citation}}を置き換えるには、citationを指定します。
{{#invoke:cite |<template name>|<cs1 parameters>}}
ここで、
#invoke:cite– Module:citeを呼び出します。|<template name>– 接頭辞citeを除いたテンプレート名。これは#invoke:が実行する関数名です。大文字と小文字を区別しません。|<cs1 parameters>–{{cite <template name>}}に指定すべき引数。
{{cite book2}}を使用した
{{cite book2 |author=EB Green |date=1915 |title=Title |publisher=PseudoRandom}}- EB Green (1915). Title. PseudoRandom.
を置き換える場合は、
{{#invoke:cite |book |author=EB Green |date=1915 |title=Title |publisher=PseudoRandom}}- EB Green (1915). Title. PseudoRandom.
または
{{#invoke:cite |book2 |author=EB Green |date=1915 |title=Title |publisher=PseudoRandom}}- EB Green (1915). Title. PseudoRandom.
と書きます。
{{cite book ja}}を使用した
{{cite book ja |author=百科太郎 |date=1915 |title=タイトル |publisher=発行者}}- 百科太郎『タイトル』発行者、1915年。
を置き換える場合は、
{{#invoke:cite |book |和書 |author=百科太郎 |date=1915 |title=タイトル |publisher=発行者}}- 百科太郎『タイトル』発行者、1915年。
または
{{#invoke:cite |book ja |author=百科太郎 |date=1915 |title=タイトル |publisher=発行者}}- 百科太郎『タイトル』発行者、1915年。
と書きます。
require ('strict');
local isSandbox = mw.getCurrentFrame():getTitle():find('sandbox', 1, true) --日本語版独自: sandboxを分岐
local sandbox = isSandbox and '/sandbox' or ''
local cfg = mw.loadData ('Module:Cite/config' .. sandbox);
--[[--------------------------< 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});
local cs_module = 'CS1' --日本語版独自: CS-jaを分岐
if args_t[1] == '和書' then cs_module = 'CS-ja'
elseif args_t.language then
if args_t.language:lower() == 'ja' then cs_module = 'CS-ja'
elseif args_t.language:lower() == 'ja-jp' then cs_module = 'CS-ja'
elseif args_t.language:lower() == 'japanese' then cs_module = 'CS-ja'
elseif args_t.language:lower() == '日本語' then cs_module = 'CS-ja' end
end
template = template:lower(); -- lowercase for table indexes
if cfg.known_templates_t[template] then -- do we recognize this template name?
elseif cfg.known_templates_t[template:gsub("2$", "")] then -- 日本語版独自: {{cite xxx2}}
template = template:gsub("2$", "");
cs_module = 'CS1';
elseif cfg.known_templates_t[template:gsub(" ja$", "")] then -- 日本語版独自: {{cite xxx ja}}
template = template:gsub(" ja$", "");
cs_module = 'CS-ja';
else
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/' .. cs_module .. sandbox)._citation (nil, args_t, config_t); -- go render the citation
end
--[[--------------------------< E X P O R T S >---------------------------------------------------------------
]]
return setmetatable({}, {__index = -- returns an empty TABLE whose metatable has the __index set so that, for any given KEY, it returns
function(_, template) -- this anonymous function called as function(TABLE, KEY)
return function (frame) return cite (frame, template) end; -- which in turn returns a function that calls cite() with the KEY name
end
})