モジュールの解説[表示] [編集] [履歴] [キャッシュを破棄]

{{東文研}}の内部モジュール。

使用法 編集

{{#invoke:東文研|main}}

local p = {}

function p.error ( message )
	return '<strong class="error">エラー:' ..message ..'</strong>'
end

function p.main( frame )
	local args = require( 'Module:Arguments' ).getArgs( frame, { wrappers = 'Template:東文研', removeBlanks = false })

	-- 入力引数
	local label        = args.label      or args[1] or ''
	local id           = args.id         or args[2] or ''
	local title        = args.title      or args[3] or ''
	local switch       = args.switch     or args[4] or ''
	local date         = args.date       or args[5] or ''
	local accessdate   = args.accessdate or args[6] or ''
	local from         = args.from       or args[7] or ''

	-- 引数を元にいろいろ判定・追記処理

	if id == '' then
		id = frame:preprocess('{{#Property:P5567|from=' ..from ..'}}')
		if id == '' then
			return p.error('引数2またはidが入力されていません。')
		end
	end
	id = id ..'.html'

	-- default label(ラベル処理)
	if label == '' or label == '物故' then
		label = 'bukko'
	elseif label == '年史' then
		label = 'nenshi'
	elseif label == 'kuroda' or label == '黒田' or label == '黒田日記' or label == '黒田清輝日記' then
		label = 'kuroda_diary'
	elseif label == '白馬会' then
		label = 'hakuba'
	end

	-- author(執筆者)
	local author = ({
		bukko = '[[東京文化財研究所]]刊「日本美術年鑑」より',
		nenshi = '[[東京文化財研究所]]刊「日本美術年鑑」より',
		nenki = '「日本絵画史年紀資料集成 十―十四世紀」(1979年)および「日本絵画史年紀資料集成 十五世紀」(2011年)ほか(データベース作成:[[東京文化財研究所]])',
		kuroda_diary = '[[中央公論美術出版]]刊『[[黒田清輝]]日記』より(データベース作成:[[東京文化財研究所]])',
		hakuba = '植野健造作成白馬会関係新聞記事一覧より(データベース作成:[[東京文化財研究所]])',
	})[label]
	if author == nil then
		return p.error('labelの入力文字列が指定外です。')
	end
	author = author ..':'
	label = label ..'/'

	-- 表示タイトル(省略されていれば{{PAGENAME}})
	if title == '' then
		title = frame:preprocess('{{PAGENAME}}')
	end

	-- 執筆日
	if date ~= '' then
		date = '(' ..frame:preprocess('{{Citation/showdate|' ..date ..'}}') ..')、'
	end
	-- 閲覧日
	if accessdate ~= '' then
		accessdate = frame:preprocess('{{accessdate|' ..accessdate ..'}}')
	end

	-- テンプレートに返す文字列を整形
	local link = '[https://www.tobunken.go.jp/materials/' ..label ..id ..' ' ..title ..']'

	if switch == '' then
		return link ..' - [[東京文化財研究所]]'
	else
		return author ..'「' ..link ..'」' ..date ..accessdate
	end
end

return p