Module:R:it:GDLI
Appearance
- The following documentation is generated by Module:documentation. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
This module implements the reference template {{R:it:GDLI}}
.
local export = {}
function export.show(frame)
local args = require("Module:parameters").process(frame:getParent().args, {
["head"] = { default = mw.title.getCurrentTitle().text },
[1] = { alias_of = "head" },
["num"] = { }, ["sense"] = { alias_of = "num" },
["volume"] = { }, ["vol"] = { alias_of = "volume" },
["page"] = { }, ["pages"] = { },
})
local volume = args.volume
if volume == nil then
error("Please specify volume.")
-- The two supplementary volumes are treated on the site as the 23rd and 25th volume respectively.
elseif volume == "sup2004" then
volume = 23
elseif volume == "sup2009" then
volume = 25
else
volume = tonumber(volume)
if volume == nil or volume > 21 then
error("Volume given is invalid.")
end
end
if args.page and args.pages then
error("You cannot specify both |page= and |pages=.")
end
if args.page == nil and args.pages == nil then
error("Please specify page.")
end
local page_index = string.match(args.page or args.pages, "^%d+")
if page_index == nil then
error("Page input is not valid.")
end
-- There is an offset between the url number and the actual page which changes for each volume.
page_index = page_index + ({
[ 1] = 9, [ 2] = 5, [ 3] = 6,
[ 4] = 7, [ 5] = 7, [ 6] = 7,
[ 7] = 7, [ 8] = 7, [ 9] = 7,
[10] = 7, [11] = 8, [12] = 7,
[13] = 8, [14] = 8, [15] = 8,
[16] = 7, [17] = 8, [18] = 7,
[19] = 7, [20] = 7, [21] = 8,
[23] = 18, [25] = 0,
})[volume]
local output_args = {
title = "w:it:Grande dizionario della lingua italiana",
publisher = "UTET",
year = ({
[ 1] = "1966", [ 2] = "1962", [ 3] = "1964",
[ 4] = "1966", [ 5] = "1968", [ 6] = "1970",
[ 7] = "1972", [ 8] = "1973", [ 9] = "1975",
[10] = "1978", [11] = "1981", [12] = "1984",
[13] = "1986", [14] = "1988", [15] = "1990",
[16] = "1992", [17] = "1994", [18] = "1996",
[19] = "1998", [20] = "2000", [21] = "2002",
[23] = "2004", [25] = "2009",
})[volume],
page = args.page, pages = args.pages,
pageurl = "https://www.gdli.it/sala-lettura/vol/" .. volume .. "?seq=" .. page_index,
}
-- The argument <num> is to provide the disambiguating number for homographs.
if args.num then
output_args.entry = args.head .. "<sup>" .. args.num .. "</sup>"
else
output_args.entry = args.head
end
if volume == 23 then
output_args.volume_plain = "supplement 2004"
elseif volume == 25 then
output_args.volume_plain = "supplement 2009"
else
-- The manual "volume" to <volume_plain> is because the cite-book recognises the en dash
-- and renders "volumes" instead of the singular.
output_args.volume_plain = "volume " .. volume .. " ''" .. ({
[1] = "a–balb", [2] = "balc–cerr", [3] = "cert–dag",
[4] = "dah–duu", [5] = "e–fin", [6] = "fio–graul",
[7] = "grav–ing", [8] = "ini–libb", [9] = "libe–med",
[10] = "mee–moti", [11] = "moto–orac", [12] = "orad–pere",
[13] = "perf–po", [14] = "pra–py", [15] = "q–ria",
[16] = "rib–roba", [17] = "robb–schi", [18] = "scho–sik",
[19] = "sil–sque", [20] = "squi–tog", [21] = "toi–z",
})[volume] .. "''"
end
return frame:expandTemplate { title = "cite-book", args = output_args }
end
return export