diff --git a/module_citeq.lua b/module_citeq.lua index 6774519..489dc74 100644 --- a/module_citeq.lua +++ b/module_citeq.lua @@ -7,7 +7,7 @@ local followQid = wdib._followQid local getPropertyIDs = wdib._getPropertyIDs local cite_cfg = mw.loadData ('Module:Cite/config') local cfg = mw.loadData ('Module:Cite_Q/config') -local cs1_module = 'Module:Citation/CS1' -- don't load the module yet, may not be needed +local cs1_module = 'Module:Citation/CS1' -- don't load the module yet, may not be needed -------------------------------------------------------------------------------- -- makeOrdinal needs to be internationalised along with cfg.i18n_t @@ -427,6 +427,19 @@ local function _cite_q (citeq_args) if stated_as then citeq_args.publisher = stated_as end end + -- Handle thesis args - degree, supervising institution + local is_thesis = false + if citeq_args.thesis_degree then + is_thesis = true + citeq_args.degree = citeq_args.thesis_degree + citeq_args.thesis_degree = nil + end + if citeq_args.thesis_submitted_to then + is_thesis = true + citeq_args.publisher = citeq_args.thesis_submitted_to + citeq_args.thesis_submitted_to = nil + end + if not titleforced then -- Handle subtitle. if citeq_args.title then @@ -578,6 +591,8 @@ local function _cite_q (citeq_args) citeq_args.asin = nil -- suppress ASIN if ISBN exists elseif citeq_args.journal then template = template or "journal" + elseif is_thesis then + template = template or "thesis" elseif citeq_args.website then template = template or "web" end @@ -598,6 +613,34 @@ local function _cite_q (citeq_args) citeq_args.id = id end + local opt_cat = '' + + -- Indicator if item has been retracted + local retract = '' + if citeq_args.retracted_by then + opt_cat = cfg.i18n_t.trackingcats.retracted + local retract_qid = followQid({qid = qid, props = "P5824"}) + local retract_id = string.gsub(retract_qid, 'Q', '') + local retr_params = { + citeq = 'yes', + id = frame:expandTemplate{ + title = 'QID', args = {qid = retract_id} + } + } + retr_params.doi = getValue({"P356", ps = 1, qid = retract_qid}) or nil + retr_params.doi = retr_params.doi and retr_params.doi:lower() or nil + retr_params.bibcode = getValue({"P819", ps = 1, qid = retract_qid}) or nil + retr_params.pmc = getValue({"P932", ps = 1, qid = retract_qid}) or nil + retr_params.pmid = getValue({"P698", ps = 1, qid = retract_qid}) or nil + if 'yes' == citeq_args['retracted-intentional'] then + retr_params.intentional = 'yes' + end + retract = ' ' .. frame:expandTemplate{ title = "Retracted", args = retr_params } + end + -- remove non-CS1 retraction properties + citeq_args.retracted_by = nil + citeq_args['retracted-intentional'] = nil + -- clean up any blank parameters for k, v in pairs(citeq_args) do if v == "" then citeq_args[k] = nil end @@ -632,10 +675,6 @@ local function _cite_q (citeq_args) erratumid = "" end - local opt_cat = '' - if getValue( {"P5824", ps = 1, qid = qid} ) then - opt_cat = cfg.i18n_t.trackingcats.retracted - end if getValue( {"P1366", ps = 1, qid = qid} ) then opt_cat = opt_cat .. cfg.i18n_t.trackingcats.replaced end @@ -654,7 +693,7 @@ local function _cite_q (citeq_args) title = "Cite "..template, args = citeq_args } .. cfg.i18n_t.trackingcats["unknown-template"] end - return output .. erratumid .. opt_cat + return output .. erratumid .. retract .. opt_cat end local function cite_q (frame) diff --git a/module_citeq_config.lua b/module_citeq_config.lua index a5ae4a5..efc142e 100644 --- a/module_citeq_config.lua +++ b/module_citeq_config.lua @@ -71,6 +71,9 @@ local simple_properties_t = { hdl = {id = "P1184", maxvals = 1}, -- take care of |hdl-access=? ismn = {id = "P1208", maxvals = 1}, journal = {id = "P1433", maxvals = 1}, + thesis_degree = {id = "P13338", maxvals = 1}, + thesis_submitted_to = {id = "P4101", maxvals = 1}, + retracted_by = {id = "P5824", maxvals = 1}, -- transient, non-CS1 citeseerx = {id = "P3784", maxvals = 1}, osti = {id = "P3894", maxvals = 1}, -- take care of |osti-access=? biorxiv = {id = "P3951", maxvals = 1},