yoohoo! hot sauce please
10:27, 7 September 2026 (UTC)
Editing
Module:Funni categorizer2
From 2swagg wiki
Jump to navigation
Jump to search
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 p = {} local core = require('Module:Infobox categorizer') local config = mw.loadData('Module:Funni categorizer2/config') local where = 'Module:Funni categorizer2/config' local dims = core.need(config, 'dimensions', where) local maintenance = core.need(config, 'maintenance', where) local invalidOverrideCat = core.need(maintenance, 'invalidOverride', where .. '.maintenance') local usingOverrideCat = core.need(maintenance, 'usingOverride', where .. '.maintenance') local D = {} for _, key in ipairs({ 'type', 'year', 'site', 'parent', 'posts', }) do D[key] = core.need(dims, key, where .. '.dimensions') end local types = core.compileAliasSet({ core.need(config, 'types', where) }, { match = 'substring' }) local sites = core.compileAliasSet({ mw.loadData('Module:Infobox categorizer/sites') }, { match = 'substring' }) local variants = core.compileAliasSet({ mw.loadData('Module:Infobox categorizer/variants') }) local siteBucket = core.fromMap(config.siteBuckets or {}) -- unused now, for future folding split sites back into Other-site categories local misuseCfg = core.need(config, 'misuse', where) local misuse = core.compileAliasSet({ { { category = 'trend', aliases = core.need(misuseCfg, 'aliases', where .. '.misuse') } } }) core.need(misuseCfg, 'warning', where .. '.misuse') core.need(misuseCfg, 'maintenance', where .. '.misuse') local function aliasOverride(compiled) return function(value) return core.parseAliasSetOverride(value, compiled) end end local function typeOverride(value) return core.parseExactOverride(value, { 'variant', 'subvariant' }) end local function variantCanon(value) local found, valid = core.parseAliasSetOverride(value, variants) return valid and found[1] or value end local function maint(dim, key) return dim.maintenance and dim.maintenance[key] end function p._categories(args) local out = core.newList() local function has(field) return core.trim(args[field]) ~= '' end local function emit(pattern, state) for _, value in ipairs(state.values) do out:add(core.fill(pattern, value)) end end local typeMatches = core.matchAliasSets(args.type, types) local misused = #core.matchAliasSets(args.type, misuse) > 0 if misused then mw.addWarning(misuseCfg.warning) out:add(misuseCfg.maintenance) end local detectedType = 'variant' for _, value in ipairs(typeMatches) do if value == 'subvariant' then detectedType = 'subvariant' end end local kind = core.resolve { candidates = { detectedType }, override = args.category_type, parse = typeOverride, max = 1, } local classification = kind.values[1] if kind.source ~= 'override' and has('type') and #typeMatches == 0 and not misused then out:add(maint(D.type, 'unrecognized')) end local year = core.resolve { candidates = core.findYears(args.origin), override = args.category_year, parse = core.parseYearOverride, suppress = args.noyearcat, -- backward compatability max = 1, } if year.source ~= 'suppressed' then if year.values[1] then out:add(core.fill(D.year.name[classification], year.values[1])) else out:add(D.year.undated[classification]) end if year.overflow then out:add(maint(D.year, 'overflow')) end end local site = core.resolve { candidates = core.matchAliasSets(args.origin, sites), override = args.category_site, parse = aliasOverride(sites), canon = siteBucket, } emit(D.site.name[classification], site) if site.source == 'detected' and site.undetected then out:add(maint(D.site, 'unrecognized')) end local parent = core.resolve { candidates = core.findLinkTargets(args.based_on), override = args.category_parent, parse = core.parseLinkTargetOverride, canon = variantCanon, applicable = classification == 'subvariant', suppress = args.noparentcat, max = 3, } if parent.source == 'detected' or parent.source == 'override' then emit(D.parent.name, parent) if #parent.values == 0 then out:add(maint(D.parent, 'undetected')) end if parent.overflow then out:add(maint(D.parent, 'overflow')) end end if classification == 'variant' then local counts = core.readDataAttr(args.booru_posts, 'boorusearch-count') if #counts == 0 then out:add(maint(D.posts, 'missing')) else out:add(core.pickBand(core.parseNumber(counts[1]), D.posts.bands)) end end if core.anyCustomized(kind, year, site, parent) then out:add(usingOverrideCat) end if core.anyInvalid(kind, year, site, parent) then out:add(invalidOverrideCat) end return out end p.main = core.makeMain(p._categories, config.namespaces) return p
Summary:
Please note that all contributions to 2swagg wiki 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
2swagg wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Funni categorizer2/doc
(
edit
)
Navigation menu
Page actions
Module
Discussion
Read
Edit source
History
Page actions
Module
Discussion
More
Tools
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Search
janny
Noticeboard
Tools
What links here
Related changes
Special pages
Page information