Changes

Jump to navigation Jump to search

Module:Citation

207 bytes removed, 18:10, 25 August 2012
Fixed some argument handling.
end
function anchorid(frameargs) local P1 = frame.args[1] or "" local P2 = frame.args[2] or "" local P3 = frame.args[3] or "" local P4 = frame.args[4] or "" local P5 = frame.args[5] or ""
return "CITEREF" .. P1 .. P2 .. P3 .. P4 .. P5
end
function name(frameargs) local P1 = frame.args[1] or "" if ( frame.args[5] ~= nil) then
return P1 .. " et al."
else
local P2 = frame.args[2] or "" local P3 = frame.args[3] or "" local P4 = frame.args[4] or "" if ( frame.args[4] ~= nil ) then
P4 = " " .. P4
P3 = " & " .. P3
P2 = " & " .. P2
elseif ( frame.args[3] ~= nil ) then
P3 = " " .. P3
P2 = " & " .. P2
elseif ( frame.args[2] ~= nil ) then
P2 = " " .. P2
end
end
function crossref(pframeframe, args) local config = frame).args local LB = frameconfig.BracketLeft or "" local RB = frameconfig.BracketRight or "" local anchor = pframeargs.ref or pframeargs.Ref or anchorid(pframeargs) local text = name(pframeargs) local loc = pframeargs.loc or "" local page = pframeargs.p or pframeargs.page or nil local pages = pframeargs.pp or pframeargs.pages or nil
if ( page ~= nil ) then
local pagesep = frameconfig.PageSep or ""
text = text .. pagesep .. page
end
if ( pages ~= nil ) then
local pagessep = frameconfig.PagesSep or ""
text = text .. pagessep .. pages
end
local ps = pframeargs.Postscript or ""
return LB .. "[[#" .. anchor .. "|" .. text .. "]]" .. RB .. ps
end
function citation0(pframeframe, args) local config = frame).args local AuthorMask = pframeargs.authormask or pframeargs.authormask local Surname1 = pframeargs.last or pframeargs.surname or pframeargs.last1 or pframeargs.surname1 or pframeargs.author1 or pframeargs.authors or pframeargs.author local Surname2 = pframeargs.last2 or pframeargs.surname2 or pframeargs.author2 local Surname3 = pframeargs.last3 or pframeargs.surname3 or pframeargs.author3 local Surname4 = pframeargs.last4 or pframeargs.surname4 or pframeargs.author4 local Surname5 = pframeargs.last5 or pframeargs.surname5 or pframeargs.author5 local Surname6 = pframeargs.last6 or pframeargs.surname6 or pframeargs.author6 local Surname7 = pframeargs.last7 or pframeargs.surname7 or pframeargs.author7 local Surname8 = pframeargs.last8 or pframeargs.surname8 or pframeargs.author8 local Surname9 = pframeargs.last9 or pframeargs.surname9 or pframeargs.author9 local Given1 = pframeargs.first1 or pframeargs.given1 or pframeargs.first or pframeargs.given local Given2 = pframeargs.first2 or pframeargs.given2 local Given3 = pframeargs.first3 or pframeargs.given3 local Given4 = pframeargs.first4 or pframeargs.given4 local Given5 = pframeargs.first5 or pframeargs.given5 local Given6 = pframeargs.first6 or pframeargs.given6 local Given7 = pframeargs.first7 or pframeargs.given7 local Given8 = pframeargs.first8 or pframeargs.given8 local Given9 = pframeargs.first9 or pframeargs.given9 local Authorlink1 = pframeargs.authorlink or pframeargs.author1link or pframeargs.authorlink1 local Authorlink2 = pframeargs.author2link or pframeargs.authorlink2 local Authorlink3 = pframeargs.author3link or pframeargs.authorlink3 local Authorlink4 = pframeargs.author4link or pframeargs.authorlink4 local Authorlink5 = pframeargs.author5link or pframeargs.authorlink5 local Authorlink6 = pframeargs.author6link or pframeargs.authorlink6 local Authorlink7 = pframeargs.author7link or pframeargs.authorlink7 local Authorlink8 = pframeargs.author8link or pframeargs.authorlink8 local Authorlink9 = pframeargs.author9link or pframeargs.authorlink9 local Coauthors = pframeargs.coauthor or pframeargs.coauthors local Date = pframeargs.date or ((pframeargs.day or "") .. (pframeargs.month or "") .. (pframeargs.year or pframeargs.publicationdate or "")) local Title = pframeargs.title local URL = pframeargs.archiveurl or pframeargs.url local Series = pframeargs.series local Volume = pframeargs.volume local Issue = pframeargs.issue or pframeargs.number local Edition = pframeargs.edition local Place = pframeargs.place or pframeargs.location local PublicationPlace = pframeargs.publicationplace or pframeargs.place or pframeargs.location local Publisher = pframeargs.publisher local Language = pframeargs.language local Format = pframeargs.format local ISBN= pframeargs.isbn or pframeargs.ISBN local DOI= pframeargs.doi or pframeargs.DOI
if ( Title ~= nil ) then Title = " ''" .. Title .. "''." else Title = "" end
if ( Publisher ~= nil ) then Publisher = " " .. Publisher .. "." else Publisher = "" end
if ( Language ~= nil ) then text = text .. " (in " .. Language .. ")" end
if ( ISBN ~= nil ) then text = text .. " ISBN " .. ISBN end
if ( DOI ~= nil ) then text = text .. " " .. doi(frame, DOI) end
return text
end
function p.SFNID(frame)
local pframe = frame:getParent()
return anchorid(pframe.args)
end
function p.Harvard(frame)
local pframe = frame:getParent()
return crossref(frame, pframe, frame.args)
end
function p.citation(frame)
local pframe = frame:getParent()
return citation0citation(frame, pframe, frame.args)
end
function p.sfn(frame)
local pframe = frame:getParent()
local content = crossref(frame, pframe, frame.args) local args = { name = anchorid(pframe.args) }
-- return mw.text.tag{name = "ref", contents = content, params = args}
return tag(frame, {name = "ref", contents = content, params = args})
Anonymous user

Navigation menu