Anonymous user
Module:Cite Q/sandbox: Difference between revisions
Jump to navigation
Jump to search
layer "last, first" functionality on top of existing function
Richardpruen (talk | contribs) m (1 revision imported) |
(layer "last, first" functionality on top of existing function) |
||
Line 3: | Line 3: | ||
local p = {} | local p = {} | ||
require(' | require('strict') | ||
local wdib = require('Module:WikidataIB') | local wdib = require('Module:WikidataIB') | ||
local getValue = wdib._getValue | local getValue = wdib._getValue | ||
Line 173: | Line 173: | ||
local sitelink = mw.wikibase.getSitelink(qnumber) | local sitelink = mw.wikibase.getSitelink(qnumber) | ||
if qnumber == "Q2818964" then sitelink = nil end -- suppress link to "Various authors" | if qnumber == "Q2818964" then sitelink = nil end -- suppress link to "Various authors" | ||
if v.qualifiers and v.qualifiers.P1932 then | if v.qualifiers and v.qualifiers.P9688 and v.qualifiers.P9687 then | ||
label = v.qualifiers.P9688[1].datavalue.value .. ", " .. v.qualifiers.P9687[1].datavalue.value | |||
elseif v.qualifiers and v.qualifiers.P1932 then | |||
label = v.qualifiers.P1932[1].datavalue.value | label = v.qualifiers.P1932[1].datavalue.value | ||
else | else | ||
label = mw.wikibase.getLabel(qnumber) | label = mw.wikibase.getLabel(qnumber) | ||
Line 479: | Line 479: | ||
if url then | if url then | ||
citeq_args.url = mw.text.split( url, " (", true )[1] | citeq_args.url = mw.text.split( url, " (", true )[1] | ||
local arcurl = mw.ustring.match( url, "%((.*)%)" ) | local arcurl = mw.ustring.match( url, " %((.*)%)" ) -- when there is an archive url, <url> holds: url<space>(archive url); here extract the archive url if present | ||
if arcurl then | if arcurl then | ||
local arcy, arcm, arcd = arcurl:match("(20%d%d)%p?(%d%d)%p?(%d%d)") | local arcy, arcm, arcd = arcurl:match("(20%d%d)%p?(%d%d)%p?(%d%d)") | ||
Line 618: | Line 618: | ||
end | end | ||
if author_count > 8 then -- convention in astronomy journals, optional mode for this? | if author_count > 8 then -- convention in astronomy journals, optional mode for this? | ||
citeq_args['display-authors'] = citeq_args['display-authors'] or 3 | if 'all' == citeq_args['display-authors'] then | ||
citeq_args['display-authors'] = nil; -- unset because no longer needed | |||
else | |||
citeq_args['display-authors'] = citeq_args['display-authors'] or 3 -- limit to three displayed names | |||
end | |||
end | end | ||
Line 628: | Line 632: | ||
end | end | ||
if editor_count > 8 then -- convention in astronomy journals, optional mode for this? | if editor_count > 8 then -- convention in astronomy journals, optional mode for this? | ||
citeq_args['display-editors'] = citeq_args['display-editors'] or 3 | if 'all' == citeq_args['display-editors'] then | ||
citeq_args['display-editors'] = nil; -- unset because no longer needed | |||
else | |||
citeq_args['display-editors'] = citeq_args['display-editors'] or 3 -- limit to three displayed names | |||
end | |||
end | end | ||