Content deleted Content added
multiple minor fixes from sandbox |
make function exportable; improve title linking; minor bugfix Tag: Reverted |
||
Line 1:
-- Version:
local
require('Module:No globals')
Line 25:
-- we need three exceptions in English for 1st, 2nd, 3rd, 21st, .. 31st, etc.
-------------------------------------------------------------------------------
local card = tonumber(cardinal)
if not card then return cardinal end
Line 224:
end
return maxpos
end
--[=[-------------------------< G E T _ N A M E _ L I S T >----------------------------------------------------
Line 339:
end
function
local
-- parameters that don't get passed to Citation
local expand = citeq_args.expand -- when set to anything, causes {{cite q}} to render <code><nowiki>{{citation|...}}</nowiki></code>
local qid = citeq_args[1] or citeq_args.qid
local wdl = citeq_args.wdl
local template = citeq_args.template
citeq_args.expand = nil
citeq_args[1] = nil
citeq_args.qid = nil
citeq_args.wdl = nil
citeq_args.template = nil
-- if title supplied, flag to not read html title
local titleforced = (citeq_args.title ~= nil)
Line 382 ⟶ 371:
citeq_args[name] = getValue( {data.id, fwd = "ALL", osd = "no", noicon = "true", qid = qid, maxvals = data.maxvals, linked = data.linked, rank = data.rank or "best", citeq_args[name] } )
if data.populate_from_journal then
citeq_args[name] =
end
if citeq_args[name] and citeq_args[name]:find('[[Category:Articles with missing Wikidata information]]', 1, true) then
Line 423 ⟶ 412:
citeq_args.url = getValue( {"P2699", ps = 1, qid = qid, maxvals = 0, citeq_args.url } ) -- try url
if citeq_args.publisher == "Unknown" then -- look for "stated as" (P1932)
local stated_as = getValue( {"P123", ps = 1, qid = qid, maxvals = 1, qual="P1932", qo="y"} )
if stated_as then citeq_args.publisher = stated_as end
end
local htmltitle = getValue( {"P1476", qual = "P6833", ps = 1, qid = qid, maxvals = 1, qo = "y"} )
if htmltitle then
citeq_args.title = htmltitle:gsub("</?i>", "''")
else
or mw.wikibase.getLabel(qid)
or (citeq_args.language and mw.wikibase.getLabelByLang(qid, citeq_args.language))
or ("No label or title -- debug: " .. qid)
if citeq_args.url
citeq_args.title = wrap_nowiki(title_display)
else
local slink = mw.wikibase.getSitelink(qid)
local slink_flag =
local wrap_title = ''
if citeq_args.title then
if slink then
wrap_title = wrap_nowiki(citeq_args.title)
slink_flag = true
else
citeq_args.title = wrap_nowiki(citeq_args.title)
end
else
if slink then
if slink:lower() == title_display:lower() then
citeq_args.title = '[[' .. slink .. ']]'
else
wrap_title = wrap_nowiki(slink:gsub("%s%(.+%)$", ""):gsub(",.+$", ""))
slink_flag = true
end
else
citeq_args.title = wrap_nowiki(title_display)
end
end
if slink_flag then
if slink == wrap_title then -- direct link
citeq_args.title = '[[' .. slink .. ']]'
else -- piped link
citeq_args.title = '[[' .. slink .. '|' .. wrap_title .. ']]'
end
end
end
end
end
Line 523 ⟶ 529:
-- change edition to ordinal if it's set and numeric
citeq_args.edition = citeq_args.edition and p.makeOrdinal(citeq_args.edition)
-- code to make a guess what template to use from the supplied parameters
-- (first draft for proof-of-concept)
if citeq_args.isbn then
template = template or "book"
elseif citeq_args.journal then
template = template or "journal"
elseif citeq_args.website then
template = template or "web"
end
Line 558 ⟶ 564:
else
citeq_args.id = id;
end
-- clean up any blank parameters
for k, v in pairs(citeq_args) do
if v == "" then citeq_args[k] = nil end
end
-- if |expand=<anything>, write a nowiki'd version to see what the {{citation}} template call looks like
if
local expand_args = {
if expand == "self" then
citeq_args.id = old_id; -- restore original |id= parameter
expand_args = {
end
for p, v in pairs (citeq_args) do -- spin through citeq_args and
table.insert (expand_args, p .. '=' .. v)
end
-- make the nowiki'd string and done
return
end
Line 584 ⟶ 595:
end
function p.cite_q (frame)
local args = {}
for k, v in pairs(frame:getParent().args) do
if v ~= "" then args[k] = v end
end
for k, v in pairs(frame.args) do
if v ~= "" then args[k] = v end
end
return p._cite_q(args)
end
return p
|