پودمان:PD
ظاهر
توضیحات این پودمان میتواند در پودمان:PD/توضیحات قرار گیرد.
--[=[
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')
local license_scope = require('Module:License_scope')._license_scope
local license_grammar = require('Module:License_scope')._license_grammar
--p.license = require('Module:License')._license -- not working yet
function p.license(args)
return mw.getCurrentFrame():expandTemplate {
['title'] = 'License',
['args'] = args
}
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.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 = basecat .. "-possible-copyright-violations"
else
category = "Possible copyright violations"
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, 99, 96, 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)
film = yesno(film or 'no')
local text = "\n----\n"
if deathyear then
if film then
text = text .. "Copyright law abroad tends to consider the following people authors of a film:\n* The principal director\n* The screenwriter, and/or other writers of dialogue\n* The composer/lyricist (if the film is accompanied by sound)\n*The cinematographer\n* By extension, the authors of any works that may serve as the basis for a film's plot\n\nThe longest-living of these authors"
else
text = text .. "The longest-living author of " .. license_grammar({"this work", "these works"})
end
text = text .. " died in " .. deathyear .. ", so " .. license_grammar({"this work is", "these works are"}) .. " in the '''public domain''' in countries and areas where the copyright term is the author's '''life plus " .. p.currentyear - deathyear - 1 .. " years or less'''. "
end
text = text .. license_grammar({"This work", "These works"}) .. " may be in the '''public domain''' in countries and areas with longer native copyright terms that apply the '''[[w:Rule of the shorter term|rule of the shorter term]]''' to ''foreign works''."
return text
end
return p