본문으로 이동

모듈:Do not move to Commons

위키문헌, 우리 모두의 도서관.
모듈 설명문서[보기] [편집] [역사] [새로 고침]

{{공용에 올리지 마세요}}를 생성합니다.

--[=[
Implements [[Template:Do not move to Commons]]
]=]
require('strict')

local p = {} --p stands for package

local getArgs = require('Module:Arguments').getArgs
local yesno = require('Module:Yesno')
local messageBox = require('Module:Message box').main

function p._do_not_move_to_commons(args)
	local localyear = tonumber(os.date("%Y"))
	local namespace = mw.title.getCurrentTitle().nsText
	
	local expiry = args['만료'] or args['기한'] or args.expiry or args.expire or args.expires or args['until']
	-- hacky, needs to handle non-math input into expr better
	if expiry and tonumber(string.sub(expiry, 1, 1)) then
		expiry = tonumber(mw.ext.ParserFunctions.expr(tostring(expiry)))
	else
		expiry = nil
	end
	
	local has_expired = expiry and expiry < localyear
	local why = args['이유'] or args.why or args.reason
	local test = yesno(args['테스트']) or yesno(args.test) or yesno(args.temporary) or yesno(args['local']) or false
	local imageright = ""
	
	local text = "<p><strong>이 파일을 [[commons:위키미디어 공용|위키미디어 공용]]에 올리지 마세요.</strong></p>"
	if test then
		text = text .. "<p>" .. (why or "이 파일은 임시 혹은 테스트용 파일이거나 한국어 위키문헌에만 관련 있는 파일입니다. 따라서 위키미디어 공용의 [[commons:Commons:Project scope/ko|프로젝트의 범위]]가 아닙니다.") .. "</p>"
		imageright = "<span style='line-height:50%; text-align:center;'>[[File:PD-icon.svg|40px|link=|퍼블릭 도메인]]</span>"
	else
		text = text .. "<p>이 파일은 [[w:미국|미국]] 내에서 [[w:퍼블릭 도메인|퍼블릭 도메인]]이지만, " .. (why or "<strong>저작자의 국가에서는 퍼블릭 도메인이 아닙니다</strong>") .. ". 위키미디어 공용에는 저작자의 국가와 미국에서 모두 퍼블릭 도메인인 자료(또는 양 국가에서 [[commons:Commons:Licensing/ko|자유 콘텐츠인 자료]])만 올릴 수 있습니다.</p><p style='font-size:83%;'>자세한 사항은 [[Commons:Commons:Licensing/ko|공용:라이선스]], [[위키문헌:퍼블릭 도메인]], [[위키문헌:저작권]]과 [[틀:PD-US]]에서 확인해 주세요.</p>"
		imageright = "<span style='line-height:50%; text-align:center;'>[[File:PD-icon.svg|40px|link=|퍼블릭 도메인]]<br><br>[[File:Flag of the United States.svg|50px|link=|미국의 국기]]</span>"
	end
	if expiry then
		text = text .. "<p style='font-size:83%;'>이 메시지는 " .. expiry .. "년 말에 만료됩니다.</p>"
	end
	
	local category
	local nocat = yesno(args['상위']) or yesno(args['분류없음']) or yesno(args.parent) or yesno(args.nocat) or yesno(args.demo) or (namespace ~= "파일" and namespace ~= "분류")
	if nocat then
		category = ""
	elseif has_expired then
		category = "[[분류:공용에 올릴 수 있게 된 파일]]"
--	elseif expiry then
--		category = "[[분류:공용에 올릴 수 없는 파일/" .. expiry .. "]]"
	elseif test then
		category = "[[분류:공용에 올릴 수 없는 파일/테스트]]"
	else
		category = "[[분류:공용에 올릴 수 없는 파일/연도 미지정]]"
	end
	
	-- check if invocation uses numbered parameters, since those aren't supported
	local has_unnamed_parameters = false
	for k, v in pairs(args) do
		if tonumber(k) then
			has_unnamed_parameters = true
		end
	end
	if has_unnamed_parameters then
		category = category .. "[[분류:알 수 없는 변수를 사용한 공용에 올리지 마세요 틀]]"
	end
	
	if has_expired then
		return category
	else
		return messageBox(
			"imbox",
			{
				['type'] = "style",
				['imageright'] = imageright,
				['text'] = text .. category
			}
		)
	end
end

function p.do_not_move_to_commons(frame)
	local args = getArgs(frame)
	return p._do_not_move_to_commons(args)
end

return p