Content deleted Content added
switch from "https://lccn.loc.gov/$1" to "https://www.loc.gov/item/$1" links and add tracking when no "id" provided for the strange case where "long=yes" resulting in "https://lccn.loc.gov/Name?$1" links at Special:WhatLinksHere/Module:LCCN/doc |
unnecessary |
||
(3 intermediate revisions by the same user not shown) | |||
Line 50:
local args = frame:getParent().args
local id = blank_to_nil(args[1] or args.id)
local title = blank_to_nil(args[2] or args.title or args.name)▼
local left_part, right_part, url▼
if not id then
error("Template:LCCN: You must provide an ID.")▼
local letter_width = (id:match("^%s*[0-9][0-9]") and id:len() < 10) and 0 or 2▼
right_part = expr(padright(id, letter_width + 8, '.00000'):sub(letter_width + 3, letter_width + 8))▼
url = "https://www.loc.gov/item/" .. left_part .. padleft(right_part, 6, 0)▼
end
▲ local title = blank_to_nil(args[2] or args.title or args.name)
▲
if args.long == "yes" then
return ("
url, title or mw.title.getCurrentTitle().text)
▲ error("Template:LCCN: You must provide an ID.")
end
return ("[[LCCN (identifier)|LCCN]] [%s %s-%s]%s"):format(
url, left_part, right_part, title and (' – ' .. title) or '')
end
|