Changes
Added processing of more parameters.
end
function doinowiki(frame, content) return z.wikitext.tag(frame, {name="nowiki",contents=content,params={}})end function externallinkid(frame, args) local sep = args.separator or " " args.suffix = args.suffix or "" local t0 = onlyinprint(frame, args.label .. sep .. id) local text t1 = hideinprint(frame, "[[Digital object identifier" .. args.link .. "|doi" .. args.label .. "]]:" .. sep .. "[http://dx" .. args.prefix .doi.org/"{{urlencode:" .. args. id .. "}} " .. zargs.suffix .. " " .. nowiki(frame, args.id) .. "]") return t0 .wikitext.tagt1end function internallinkid(frame, {nameargs) local sep =args.separator or "nowiki " local t0 = onlyinprint(frame,contentsargs.label .. sep .. id) local t1 =idhideinprint(frame,params="[[" .. args.link .. "|" .. args.label .. "]]" .. sep .. "[[" .. args.prefix .. "{{urlencode:" .. args.id .. "}}|" .. nowiki(frame, args.id) .. "]]") return t0 .. t1end function amazon(frame, id, domain) if ( nil == domain ) then domain = "com" elseif ( "jp" == domain or "uk" == domain ) then domain = "co." .. domain end local text = externallinkid(frame, {link="Amazon Standard Identification Number",label="ASIN",prefix="//www.amazon."..domain.."/dp/",id=id})
if ( string.sub(id,1,3) ~= "10." ) then
text = text .. "[[Category:Pages with DOI errors]]"
end
return text
end
function doi(frame, id, broken, inactive, nocat)
local text = externallinkid(frame, {link="Digital object identifier",label="doi",prefix="http://dx.doi.org/",id=id,separator=":"})
local cat = ""
if ( inactive ~= nil ) then
inactive = " (inactive " .. inactive .. ")"
cat = cat .. "[[Category:Pages with DOIs inactive since " .. z.wikitext.canonicalcleanuptime(inactive) .. "]]"
else
inactive = ""
end
if ( string.sub(id,1,3) ~= "10." ) then
cat = cat .. "[[Category:Pages with DOI errors]]"
end
if ( nocat ~= nil and nocal ~= "" ) then cat = "" end
return text .. inactive .. cat
end
function url(frame, id)
local t0 = onlyinprint(frame, id)
local t1 = hideinprint(frame, "[" .. id .. " " .. nowiki(frame, id) .. "]")
return t0 .. t1
end
function openlibrary(frame, id)
local cat = ""
local prefix = ""
local code = string.sub(id,string.length(id),1)
if ( code == "A" ) then
prefix = "http://openlibrary.org/authors/OL"
elseif ( code == "M" ) then
prefix = "http://openlibrary.org/books/OL"
elseif ( code == "W" ) then
prefix = "http://openlibrary.org/works/OL"
else
prefix = "http://openlibrary.org/OL"
cat = cat .. "[[Category:Pages with OL errors]]"
end
local text = externallinkid(frame, {link="Open Library",label="OL",prefix=prefix,id=id})
return text .. cat
end
local Language = args.language
local Format = args.format
local Ref = args.ref or args.Ref
local ARXIV = args.arxiv or argx.ARXIV
local ASIN = args.asin or args.ASIN
local ASINTLD = args["ASIN-TLD"]
local BIBCODE = args.bibcode or args.BIBCODE
local DOI = args.doi or args.DOI
local DoiBroken = args.DoiBroken
local ID = args.id or args.ID
local ISBN = args.isbn or args.ISBN
local DOI ISSN = args.doi issn or args.DOIISSN local ID JFM = args.id jfm or args.ID JFM local JSTOR = args.jstor or args.JSTOR local LCCN = args.lccn or args.LCCN local MR = args.mr or args.MR local OCLC = args.oclc or args.OCLC local OL = args.ol or args.OL local OSTI = args.osti or args.OSTI local PMC = args.pmc or args.PMC local PMID = args.pmid or args.PMID local Ref RFC = args.ref rfc or args.RefRFC local SSRN = args.ssrn or args.SSRN local ZBL = args.zbl or args.ZBL
-- At this point fields may be nil if they weren't specified in the template use. We can use that to perform various substitutions.
-- We also add leading spaces and surrounding markup and punctuation to the various parts of the citation, but only when they are non-nil.
if ( PublicationPlace ~= nil ) then PublicationPlace = " " .. PublicationPlace .. ":" else PublicationPlace = "" end
if ( Language ~= nil ) then Language = " (in " .. Language .. ")" else Language = "" end
if ( Volume ~= nil ) then Volume = " '''" .. Volume .. "'''" else Volume = "" end
if ( Issue ~= nil ) then Issue = " (" .. Issue .. ")" else Issue = "" end
if ( Series ~= nil ) then Series = " " .. Series .. "." else Series = "" end
if ( Format ~= nil ) then Format = " (" .. Format .. ")" else Format = "" end
if ( Date ~= nil ) then Date = " (" .. Date .. ")" else Date = "" end
if ( Authors == nil ) then Authors = listpeople(config, a) end
if ( Editors == nil ) then Editors = listpeople(config, e) end
if ( ARXIV ~= nil ) then ARXIV = externallinkid(frame, {label="arXiv",link="arXiv",prefix="http://arxiv.org/abs/",id=ARXIV,separator=":"}) else ARXIV = "" end
if ( ASIN ~= nil ) then ASIN = amazon(frame, ASIN, ASINTLD) else ASIN = "" end
if ( BIBCODE ~= nil ) then BIBCODE = externallinkid(frame, {label="Bibcode",link="Bibcode",prefix="http://adsabs.harvard.edu/abs/",id=BIBCODE,separator=":"}) else BIBCODE = "" end
if ( DOI ~= nil ) then DOI = " " .. doi(frame, DOI, DoiBroken) else DOI = "" end
if ( ID ~= nil ) then ID = " " .. ID else ID = "" end
if ( ISBN ~= nil ) then ISBN = " " .. internalinkid(frame, {label="ISBN",link="International Standard Book Number",prefix="Special:BookSources/",id=ISBN}) else ISBN = "" end
if ( ISSN ~= nil ) then ISSN = " " .. externalinkid(frame, {label="ISSN",link="International Standard Serial Number",prefix="//www.worldcat.org/issn/",id=ISSN}) else ISSN = "" end
if ( JFM ~= nil ) then JFM = " " .. externallinkid(frame, {label="JFM",link="Jahrbuch über die Fortschritte der Mathematik",prefix="http://www.zentralblatt-math.org/zmath/en/search/?format=complete&q=an:",id=JFM}) else JFM = "" end
if ( JSTOR ~= nil ) then JSTOR = " " .. externallinkid(frame, {label="JSTOR",link="JSTOR",prefix="http://www.jstor.org/stable/",id=JSTOR}) else JSTOR = "" end
if ( LCCN ~= nil ) then LCCN = " " .. externallinkid(frame, {label="LCCN",link="Library of Congress Control Number",prefix="http://lccn.loc.gov/",id=LCCN}) else LCCN = "" end
if ( MR ~= nil ) then MR = " " .. externallinkid(frame, {label="MR",link="Mathematical Reviews",prefix="http://www.ams.org/mathscinet-getitem?mr=",id=MR}) else MR = "" end
if ( OCLC ~= nil ) then OCLC = " " .. externallinkid(frame, {label="OCLC",link="Online Computer Library Center",prefix="//www.worldcat.org/oclc/",id=OCLC}) else OCLC = "" end
if ( OL ~= nil ) then OL = " " .. openlibrary(frame, id) else OL = "" end
if ( OSTI ~= nil ) then OSTI = " " .. externallinkid(frame, {label="OSTI",link="Office of Scientific and Technical Information",prefix="http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=",id=OSTI}) else OSTI = "" end
if ( PMC ~= nil ) then PMC = " " .. externallinkid(frame, {label="PMC",link="PubMed Central",prefix="//www.ncbi.nlm.nih.gov/pmc/articles/PMC",suffix="/?tool=pmcentrez",id=PMC}) else PMC = "" end
if ( PMID ~= nil ) then PMID = " " .. externallinkid(frame, {label="PMID",link="PubMed Identifier",prefix="//www.ncbi.nlm.nih.gov/pubmed/",id=PMID}) else PMID = "" end
if ( RFC ~= nil ) then RFC = " " .. externallinkid(frame, {label="RFC",link="Request for Comments",prefix="//tools.ietf.org/html/rfc",id=RFC}) else RFC = "" end
if ( SSRN ~= nil ) then SSRN = " " .. externallinkid(frame, {label="SSRN",link="Social Science Research Network",prefix="http://ssrn.com/abstract=",id=SSRN}) else SSRN = "" end
if ( URL ~= nil ) then URL = " " .. url(frame, URL) else URL = "" end
if ( ZBL ~= nil ) then ZBL = " " .. externallinkid(frame, {label="ZBL",link="Zentralblatt MATH",prefix="http://www.zentralblatt-math.org/zmath/en/search/?format=complete&q=an:",id=ZBL}) else ZBL = "" end
-- Piece all of the bits together at last. At this point, all of these should be guaranteed non-nil.
-- We build things this way because it is more efficient in LUA not to keep reassigning to the same string variable over and over.
local identifiers = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL
local text
if ( "" ~= Authors ) then
if ( "" ~= Date ) then Date = Date .. "." else Authors = Authors .. "." end
if ( "" ~= Editors ) then Editors = " in " .. Editors .. "." end
text = Authors .. Date .. Chapter .. Editors .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. ISBN .. DOI .. ID .. URLidentifiers
elseif ( "" ~= Editors) then
Editors = Editors .. " (eds.)"
if ( "" ~= Date ) then Date = Date .. "." else Editors = Editors .. "." end
text = Editors .. Date .. Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. ISBN .. DOI .. ID .. URLidentifiers
else
text = Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. Date .. ISBN .. DOI .. ID .. URLidentifiers
end
text = z.wikitext.tag(frame, {name="span", contents=text, params=args})
end
local OCinS = "" return text.. OCinS
end
end
-- This is used by template {{reflabelref label}}.
function z.reflabel(frame)
local pframe = frame:getParent()