본문으로 이동

모듈:PD

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

아래 퍼블릭 도메인 틀을 생성합니다.

require('strict')

--[=[
Implements PD templates
]=]
local p = {} --p stands for package

local getArgs = require('Module:Arguments').getArgs
local error_function = require('Module:Error')['error']
local yesno = require('Module:Yesno')

-- utility definitions
local licenseScopeModule = require('Module:License_scope')
p.license_scope = licenseScopeModule._license_scope
p.license_grammar = licenseScopeModule._license_grammar

p.license = require('Module:License')._license

local licenseWikidataModule = require('Module:License Wikidata')
function p.getAuthorDeathYear(years)
	return licenseWikidataModule.getWorkCreatorOrAuthorDeathYear({['deathyears'] = years})
end
function p.getPublicationYear(years)
	return licenseWikidataModule.getWorkOrAuthorPublicationYear({['pubyears'] = years})
end

p.currentyear = tonumber(os.date("%Y"))
p.currentmonth = tonumber(os.date("%m"))
p.currentday = tonumber(os.date("%d"))
p.PD_US_cutoff = math.min(p.currentyear - 95, 1978)

p.namespace = mw.title.getCurrentTitle().nsText
p.is_author_namespace = p.namespace == '저자' or p.namespace == '저자토론'

p.PD_image = 'PD-icon.svg'
p.US_flag_image = 'Flag of the United States.svg'

--[=[
Generates error license
]=]
function p.error_text(text, basecat)
	local category
	if basecat then
		category = "저작권 침해 의심"
	else
		category = "저작권 침해 의심"
	end
	return p.license({
		['image'] = 'PDmaybe-icon.svg',
		['category'] = category,
		['text'] = error_function({text})
	})
end

--[=[
Handle year bucketing
]=]
function p.year_floor(cutoffs, year)
	if year then
		table.sort(cutoffs, function(a, b) return a > b end)
		for k, cutoff in pairs(cutoffs) do
			if p.currentyear - year > cutoff then
				return cutoff
			end
		end
	end
	return nil
end

--[=[
[category]-[year bucket] or [category]
]=]
function p.category_with_year_floor(category, cutoffs, year)
	local year_floor = p.year_floor(cutoffs, year)
	if year_floor then
		return category .. "-" .. year_floor
	else
		return category
	end
end

--[=[
[category]-old-[year bucket] or [category]
]=]
function p.category_with_deathyear_floor(category, year)
	local year_floor = p.year_floor({100, 95, 80, 75, 70, 60, 50, 30, 25}, year)
	if year_floor then
		return category .. "-old-" .. year_floor
	else
		return category
	end
end

function p.frame_category_with_deathyear_floor(frame)
	local args = getArgs(frame)
	return p.category_with_deathyear_floor(args[1] or args.category, args[2] or args.year or args.deathyear)
end

--[=[
Text about where else a work is PD
]=]

function p.shorter_term_text(deathyear, film, deathyear_display_hide)
	deathyear = p.getAuthorDeathYear({deathyear})
	film = yesno(film or 'no')
	deathyear_display_hide = deathyear_display_hide
	
	local text = "\n----\n"
	if deathyear and deathyear <= p.currentyear then
		local deathyear_display = deathyear
		if deathyear <= 0 then
			deathyear_display = "기원전 " .. (-deathyear + 1)
		end
		
		if film then
			text = text .. "해외의 저작권법에 따르면 영화의 저자에는 다음 인물도 포함될 수 있습니다.\n* 주요 감독\n* 각본가 및/또는 대사를 작성한 다른 작가\n* 작곡가/작사가(영화에 음향이 포함된 경우)\n*촬영 감독\n*영화의 줄거리를 구성하는 데 기초가 된 작품의 원 저자\n\n"
		end
		
		if not deathyear_display_hide then
			if p.is_author_namespace then
				text = text .. "이 저자는 "
			else
				text = text .. "이 저작물의 가장 오래 생존한 저자는 "
			end
			text = text .. deathyear_display .. "년에 사망하였으므로, "
		end
		
		if p.is_author_namespace then
			text = text .. '이 저자의 저작물은'
		else
			text = text .. '이 저작물은'
		end
		
		text = text .. " '''사후 저작권 보호 기간이 " .. p.currentyear - deathyear - 1 .. "년 이하'''인 일부 국가와 지역에서는 '''퍼블릭 도메인'''입니다. "
	end
	text = text .. "이 저작물은 외국 저작물에 대해 '''[[:w:단기 보호 기간 조항|단기 보호 기간 조항]]'''을 적용하는, 더 긴 저작권 보호 기간을 가진 일부 국가 및 지역에서도 '''퍼블릭 도메인'''에 속할 수 있습니다."
	return text
end

return p