词条 | Module:Sandbox/Evad37/Auto footer links |
释义 | local acModule = require('Module:Authority control') local nbModule = require('Module:Navbox') local pModule = require('Module:Portal') local wdModule = require('Module:WikidataIB') local p = {} p.propId = { location = 'P276', adminEntity = 'P131', -- state, province, territory, etc country = 'P17', partOf = 'P361', instanceOf = 'P31', subclassOf = 'P279' } --== Utility functions ==--p.trimAll = function(argsTable) local trimmedArgs = {} for key, val in pairs(argsTable) do if type(val) == 'string' then val = val:match('^%s*(.-)%s*$') if val ~= then trimmedArgs[key] = val end else trimmedArgs[key] = val end end return trimmedArgs end p.getWdValue = function(property_id, item_id) local wdArgs = { args = { [1] = property_id, qid = item_id or false, rank = 'best', fetchwikidata = 'ALL', linked = 'no', maxvals = '1', noicon = 'true', onlysourced = 'no' } } return wdModule.getValue(wdArgs) end -- TODO: Portal-related function(s)p.tryForPortal = function(item_id, props) for _i, prop in ipairs(props) do local value = p.getWdValue(prop, item_id) local title = mw.title.new(value, 'Portal') if title.exists then return title.text end end return false end p.getLocationPortal = function(item_id) return p.tryForPortal(item_id, { p.propId.location, p.propId.adminEntity, p.propId.country }) end p.getTypePortal = function(item_id) return p.tryForPortal(item_id, { p.propId.partOf, p.propId.instanceOf, p.propId.subclassOf }) end -- TODO: Sister project-related function(s)-- TODO: Authority control-related function(s)-- TODO: Navbox-related function(s)-- Template entry point:p.main = function(frame) local parent = frame.getParent(frame) local output = p._main(parent.args) return frame:preprocess(output) end -- Module entry point:p._main = function(_args) local args = p.trimAll(_args) -- TODO: -- (1) Generate portal links, if any found; -- (2) Generate sister project links, if any found; -- (3) Generate authority control links, if any found; -- (4) put it all together in a navbox, if anything found return --TODO end return p |
随便看 |
|
开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。