Changes

Jump to navigation Jump to search

Module:Citation

2,335 bytes added, 21:29, 31 August 2012
Added processing of more parameters.
}
function hideinprint(frame, content)
return content
end
function onlyinprint(frame, content)
return ""
end
local sep = args.separator or " "
args.suffix = args.suffix or ""
local t0 = onlyinprint(frame, args.label .. sep .. args.id) local t1 = hideinprint(frame, "[[" .. args.link .. "|" .. args.label .. "]]" .. sep .. "[" .. args.prefix .. z.wikitext.urlencode(args.id) .. args.suffix .. " " .. nowiki(frame, args.id) .. "]")
return t0 .. t1
end
local sep = args.separator or " "
args.suffix = args.suffix or ""
local t0 = onlyinprint(frame, args.label .. sep .. args.id) local t1 = hideinprint(frame, "[[" .. args.link .. "|" .. args.label .. "]]" .. sep .. "[[" .. args.prefix .. args.id .. args.suffix .. "|" .. nowiki(frame, args.id) .. "]]")
return t0 .. t1
end
function url(frame, id)
local t0 = onlyinprint(frame, id) local t1 = hideinprint(frame, "[" .. id .. " " .. nowiki(frame, id) .. "]")
return t0 .. t1
end
local initials = {}
for word in string.gmatch(first, "%S+") do
table.insert(initials, string.sub(word,1,1))-- .. ".") -- vancouver Vancouver format does not include full stops.
end
return table.concat(initials, "")--, " ")--vancouver Vancouver format does not include spaces.
end
function listpeople(sep, format, maskcontrol, people) local sep = control.sep local namesep = control.namesep local format = control.format local maximum = control.maximum
local text = {}
for i,person in ipairs(people) do
if (person.last ~= nil) then
local mask = person.mask local one if ( maximum ~= nil and i == maximum + 1 ) then one = "et al." elseif ( maximum ~= nil and i > maximum + 1 ) then break elseif (mask ~= nil) then local n = tonumber(mask) if (n ~= nil) then one = string.rep("—",n) else one = mask end else one = person.last local first = person.first if (first ~= nil) then if ( "vanc" == format ) then first = reducetoinitials(first) end one = one .. namesep .. first end if (person.link ~= nil) then one = one "[[" .. person.link .. ", |" .. first one .. "]]" end
end
if (person.link ~= nil) then one = "[[" .. person.link .. "|" .. one .. "]]" end
table.insert(text, one)
end
end
return table.concat(text, sep .. " ")
end
last = last,
first = args["author" .. i .. "-first"] or args["author-first" .. i] or args["first" .. i] or args["given" .. i],
link = args["author" .. i .. "-link"] or args["author-link" .. i] or args["author" .. i .. "link"] or args["authorlink" .. i], mask = args["author" .. i .. "-mask"] or args["author-mask" .. i] or args["author" .. i .. "mask"] or args["authormask" .. i]
}
end
last = last,
first = args["editor" .. i .. "-first"] or args["editor-first" .. i] or args["EditorGiven" .. i],
link = args["editor" .. i .. "-link"] or args["editor-link" .. i] or args["editor" .. i .. "link"] or args["editorlink" .. i], mask = args["editor" .. i .. "-mask"] or args["editor-mask" .. i] or args["editor" .. i .. "mask"] or args["editormask" .. i]
}
end
local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
local AuthorSep = config.AuthorSep or "&#59;"
local PPrefix = config.PPrefix or "p."
local PPPrefix = config.PPPrefix or "pp."
args["author1-first"] = args["author1-first"] or args["author-first"] or args ["first"]
args["author1-link"] = args["author1-link"] or args["author-link"]
args["author1-mask"] = args["author1-mask"] or args["author-mask"]
args["author1link"] = args["author1link"] or args["authorlink"]
args["editor1"] = args["editor1"] or args["editor"]
args["editor1-first"] = args["editor1-first"] or args["editor-first"]
args["editor1-link"] = args["editor1-link"] or args["editor-link"]
args["editor1-mask"] = args["editor1-mask"] or args["editor-mask"]
args["editor1link"] = args["editor1link"] or args["editorlink"]
-- Pick out the relevant fields from the arguments. Different citation templates define different field names for the same underlying things.
local AuthorMask = args.authormask or args["author-mask"]
local AuthorFormat = args["author-format"] or args.authorformat
local Authors = args.authors
local i
local OrigYear = args.origyear
local Date = args.date
local LayDate = args.laydate
local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
local TransTitle = args.trans_title
local ZBL = args.zbl or args.ZBL
local Quote = args.quote or args.quotation
local PostScript = args.postscript
local LaySummary = args.laysummary
local LaySource = args.laysource
-- At this point fields may be nil if they weren't specified in the template use. We can use that fact.
-- Now perform various field 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 ( Authors == nil ) then Authors local AuthorNameSep = args["author-name-separator"] or args["name-separator"] or ", " local AuthorSep = args["author-separator"] or args["separator"] or "&#59; " local AuthorFormat = args["author-format"] or args.authorformat local AuthorMaximum = listpeopletonumber(args["display-authors"] or args.displayauthors) or 8 local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, AuthorMaskmaximum = AuthorMaximum } Authors = listpeople(control, a) end if ( Editors == nil ) then Editors local EditorNameSep = args["editor-name-separator"] or args["name-separator"] or ", " local EditorSep = args["editor-separator"] or args["separator"] or "&#59; " local EditorFormat = args["editor-format"] or args.editorformat local EditorMaximum = listpeopletonumber(AuthorSepargs["display-editors"] or args.displayeditors) or 3 local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, EditorMaskmaximum = EditorMaximum } Editors = listpeople(control, e) end
if ( Date == nil ) then
Date = Year
if ( AccessDate ~= nil ) then AccessDate = " Accessed on " .. AccessDate .. "." else AccessDate = "" end
if ( SubscriptionRequired ~= nil ) then
SubscriptionRequired = " " .. z.wikitext.tagHTMLTag(frame, {name="span", contents="(subscription required)", params={style="font-size:0.95em; font-size: 90%; color: #555"}})
else
SubscriptionRequired = ""
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
if ( Quote ~= nil ) then Quote = " \"" .. Quote .. "\"" PostScript = "" else if ( PostScript ~= nil ) then PostScript = " " .. PostScript else PostScript = "" end Quote = "" end
local Archived
if ( nil ~= ArchiveURL ) then
else
Archived = ""
end
local Lay
if ( nil ~= LaySumary ) then
if ( LayDate ~= nil ) then LayDate = " (" .. LayDate .. ")" else LayDate = "" end
if ( LaySource ~= nil ) then LaySource = " – ''" .. LaySource .. "''" else LaySource = "" end
Lay = LaySummary .. LaySource .. LayDate
else
Lay = ""
end
local Publisher
-- 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. AccessDate .. Archived .. Via .. SubscriptionRequired .. Lay .. Quote.. PostScript
local tcommon = Title .. Type .. Format .. Edition .. Language .. Periodical .. Series .. Volume .. Issue .. Page .. Pages .. At .. "."
Date = Date .. OrigYear
end
local args = { class="citation " .. (config.CitationClass or ""), id=id }
text = z.wikitext.tagHTMLTag(frame, {name="span", contents=text, params=args})
end
local OCinS = z.wikitext.tagHTMLTag(frame, {name="span", contents=" ", params={class="Z3988",title=OCinStitle,style="display: none;"}})
return text .. OCinS
if ( page ~= nil ) then
local contents = ":" .. page
p = z.wikitext.tagHTMLTag(frame, {name="sup",contents=contents,params={class="reference",style="white-space:nowrap;"}})
end
return z.wikitext.tag(frame, {name="ref",contents="",params={name=name,group=group}}) .. p
end
local references = z.wikitext.tag(frame, {name="references",contents=contents,params={group=group}})
return z.wikitext.tagHTMLTag(frame, {name="div",contents=references,params=params})
end
params.class="reference"
if ( args.noid == nil or args.noid == "" ) then params.id = "ref_" .. P1 .. P3 end
return z.wikitext.tagHTMLTag(frame, {name="sup",contents=contents,params=params})
end
Anonymous user

Navigation menu