본문으로 이동

모듈:ISBN

위키문헌 ― 우리 모두의 도서관.
모듈 설명문서[만들기]
require('strict')

local p = {}

local getArgs = require('Module:Arguments').getArgs

local function check_isbn(args)
	return require('Module:Check isxn').check_isbn({args = args})
end

local function error_message(message)
	return require('Module:Error')['error']({message})
end

function p._ISBN(args)
	if not args[1] then
		return error_message('Missing ISBN')
	end
	local source = '[[Special:BookSources/' .. args[1] .. '|' .. (args[2] or 'ISBN') .. ' ' .. args[1] .. ']]'
	local check = check_isbn({[1] = args[1], ['error'] = '&nbsp;<span class="error" style="font-size:92%;">Invalid&nbsp;ISBN</span>'})
	local cat = ''
	if mw.title.getCurrentTitle():inNamespaces(0) then
		cat = '[[Category:' .. 'Pages with ISBN errors' .. ']]'
	end
	return source .. check .. cat
end

function p.ISBN(frame)
	return p._ISBN(getArgs(frame))
end

return p