Home
Random
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/Evad37/Auto footer links
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
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
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Sandbox/Evad37/Auto footer links/doc
(
edit
)