モジュール:サンドボックス/Nami-ja/sandbox

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

{{ }}

local p={}

function p.main( frame )
	-- 入力引数格納
	local type	= frame.args.type		or frame.args[1] or ''
	local id	= frame.args.id			or frame.args[2] or ''
	local title	= frame.args.title		or frame.args[3] or ''
	local acdate	= frame.args.accessdate		or frame.args[4] or ''
	local ref	= frame.args.ref		or ''

	if ref == '' then
		ref = p.textref (type, title)
	end
end

-- language
function p.textlang ( type )
	local lang = ''
	if type == 'imdbc' or type == 'imdbp' or type == 'amc' or type == 'amp' then
		lang = 'en'
	end

	return lang
end

-- URL処理
function p.texturl ( type, id )
	local text = ({
		acc = 'https://www.allcinema.net/cinema/' ..id,
		acp = 'https://www.allcinema.net/person/' ..id,

		mwc = 'https://moviewalker.jp/' ..id ..'/',
		mwp = 'https://moviewalker.jp/person/' ..id ..'/',

		edcc = 'https://eiga.com/movie/' ..id ..'/',
		edcp = 'https://eiga.com/person/' ..id ..'/',

		knc = 'http://www.kinenote.com/main//public/cinema/detail.aspx?cinema_id=' ..id,
		knp = 'http://www.kinenote.com/main//public/cinema/person.aspx?person_id=' ..id,

		jcdbc = 'https://www.japanese-cinema-db.jp/Details?id=' ..id,
		scc = 'https://www.shochiku.co.jp/cinema/database/' ..id ..'/',

		jmdbc = 'http://www.jmdb.ne.jp/' ..id ..'.htm',
		jmdbp = 'http://www.jmdb.ne.jp/person/' ..id ..'.htm',

		imdbc = 'https://www.imdb.com/title/' ..id ..'/',
		imdbp = 'https://www.imdb.com/name/' ..id ..'/',

		amc = 'https://www.allmovie.com/movie/' ..id,
		amp = 'https://www.allmovie.com/artist/' ..id,
	})[type]

	if text then
		return text
	end
end

-- 定形テキスト
function p.textlink ( type )
	local link = ({
		acc, acp = 'allcinema',
		mwc, mwp = 'Movie Walker',
		edcc, edcp = '映画.com',
		knc, knp = 'キネマ旬報映画データベース{{!}}KINENOTE',
		jcdbc = '文化庁',
		scc = '松竹',
		jmdbc, jmdbp = '日本映画データベース{{!}}JMDb',
		imdbc, imdbp = 'IMDb',
		amc, amp = 'オールムービー{{!}}AllMovie',
	})[type]

	if link then
		return '[[' ..link ..']]'
	end
end

-- 定形ref
function p.textref ( type, title, ref )
	local tref = ({
		acc, acp = 'allcinema',
		mwc, mwp = 'Movie Walker',
		edcc, edcp = '映画.com',
		knc, knp = 'KINENOTE',
		jcdbc = '文化庁',
		scc = '松竹',
		jmdbc, jmdbp = 'JMDb',
		imdbc, imdbp = 'IMDb',
		amc, amp = 'AllMovie',
	})[type]

	if tref then
		return tref ..'-' ..title
	end
end

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

return p