diff --git a/module_citeq.lua b/module_citeq.lua
index 646ea91..8bca78e 100644
--- a/module_citeq.lua
+++ b/module_citeq.lua
@@ -726,6 +726,7 @@ local function _cite_q (citeq_args)
local wikisource_sitelink = mw.wikibase.getSitelink(qid, cfg.i18n_t.wikisource) or nil
if wikisource_sitelink then
slink = 's:'..wikisource_sitelink; -- use 's:' instead of ':s:' so that cs1|2 includes wikisource icon
+ citeq_args.via = citeq_args.via or '[[Wikisource]]'; -- set |via=[[Wikisource]] if not already set
wslink = true
end
end
@@ -1120,42 +1121,46 @@ local function _cite_q (citeq_args)
return output .. erratumid .. eoc .. retract .. table.concat(opt_cat, ' ') .. cq_errors
end
+
+--[[--------------------------< C I T E _ Q >------------------------------------------------------------------
+
+template entry point
+
+]]
+
local function 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
- args.qid = args.qid or args[1] or ""
- if args.qid == "" then return nil end
- args[1] = nil
+ local args = require ('Module:Arguments').getArgs(frame);
- local citesep = (args.citesep or "")
- if citesep == "" then citesep = ", " end
+ args.qid = args.qid or args[1];
+ if not args.qid then return nil end -- this should return an error message?
+ args[1] = nil; -- unset; not needed
+
+ local citesep = args.citesep; -- separator string between separate cites of {{cite q|q..., q...}}; any need to keep this?
+ if not citesep then citesep = ", " end
citesep = citesep:gsub('"', '') -- strip double quotes after setting default to allow |citesep="" as a blank separator
- args.citesep = nil
+ args.citesep = nil; -- unset; not needed
- local tag = args.tag or ""
- if tag == "" then tag = nil end
- args.tag = nil
+ local tag = args.tag; -- for applying tags like [...]; is the name of the tag
+-- if not tag then tag = nil end
+ args.tag = nil; -- unset; not needed
- local list = args.list or ""
- if list == "" then list = nil end
- args.list = nil
+ local list = args.list -- undocumented |list= gets a template name; what templates are appropriate? added at [[Special:Diff/1004682832]]
+-- if list == "" then list = nil end
+ args.list = nil; -- unset; not needed
args.language = args.language or args.lang
args.lang = nil
-- QID as normal form; emit error if not ^Q%d+$ (e.g. a Wikidata URL)
- local qid_form = mw.ustring.match(mw.text.trim(args.qid), "^Q%d+$") or nil
- if not qid_form then
- return ' {{[[Template:Cite Q|Cite Q]]}}: QID parameter must be supplied as "Q" followed by digits, e.g. Q12345 ([[Template:Cite Q#Error messages|help]]) ' .. cfg.i18n_t.trackingcats["invalid-qid"]
+-- local qid_form = mw.ustring.match(mw.text.trim(args.qid), "^Q%d+$") or nil
+-- if not qid_form then
+-- return ' {{[[Template:Cite Q|Cite Q]]}}: QID parameter must be supplied as "Q" followed by digits, e.g. Q12345 ([[Template:Cite Q#Error messages|help]]) ' .. cfg.i18n_t.trackingcats["invalid-qid"]
+ if not args.qid:match ('^Q%d+$') then
+ return cfg.i18n_t.errors.bad_qid_form .. cfg.i18n_t.trackingcats["invalid-qid"];
end
local cites = {}
- for q in args.qid:gmatch("Q%d+") do
+ for q in args.qid:gmatch("Q%d+") do -- for processing separate cites of {{cite q|q..., q...}}; any need to keep this?
-- make a new copy of the arguments
local newargs = {}
for k, v in pairs(args) do
@@ -1172,13 +1177,14 @@ local function cite_q (frame)
end
end
- if list then
+ if list then -- undocumented |list= gets a template name; what templates are appropriate? added at [[Special:Diff/1004682832]]
return frame:expandTemplate{ title = list, args = cites }
else
return table.concat(cites, citesep)
end
end
+
--[[--------------------------< E X P O R T E D F U N C T I O N S >------------------------------------------
]]
diff --git a/module_citeq_config.lua b/module_citeq_config.lua
index a211f58..6108c45 100644
--- a/module_citeq_config.lua
+++ b/module_citeq_config.lua
@@ -10,6 +10,7 @@ local i18n_t = {
["wdq"] = "[[WDQ (identifier)|Wikidata]]", -- go through "WDQ (identifier)" redirect to reduce clutter in "What links here" and improve reverse lookup. Keep in sync with {{QID}}.
["wikisource"] = "enwikisource",
["errors"] = {
+ bad_qid_form = ' {{[[Template:Cite Q|Cite Q]]}}: QID parameter must be supplied as "Q" followed by digits, e.g. Q12345 ([[Template:Cite Q#Error messages|help]])',
["local-article-not-found"] = "Local article not found.",
["no-label-or-title"] = "No label or title -- debug: ",
missing_name = '%s [[File:Edit icon on Wikisite.svg|14px|class=noviewer|alt=|link=[[:d:%s]] ]]'; -- %s: .label, '', .qid