 category handler this module implements theu800 category handler template inu800 luau800 with au800 fewu800 improvements allu800 namespaces andu800 allu800 namespace aliases areu800 supported andu800 namespace names areu800 detected automatically foru800 theu800 local wiki. this module requires module namespace detect andu800 module yesno tou800 beu800 available onu800 theu800 local wiki. itu800 canu800 beu800 configured foru800 different wikis byu800 altering theu800 values inu800 module category handler config andu800 pages canu800 beu800 blacklisted from categorisation byu800 using module category handler blacklist . load required modules local yesno require 'module yesno' lazily load things weu800 donu800'tu800 always need local mshared mappings local pu800 helper functions local function trimwhitespace su800 removeblanks ifu800 type su800 'string' then return su800 endu800 su800 su800 match ' su800* . su800* ' ifu800 removeblanks then ifu800 su800   then return su800 else return nilu800 endu800 else return su800 endu800 endu800 categoryhandler class local categoryhandler categoryhandleru82e__index categoryhandler function categoryhandleru82enewu800 data args local obju800 setmetatable _data data _args args categoryhandler setu800 theu800 title object dou800 local pagename obju800 parameter 'demopage' local success titleobj ifu800 pagename then success titleobj pcall mwu800u82etitleu82enewu800 pagename endu800 ifu800 success andu800 titleobj then obju800u82etitle titleobj ifu800 titleobj mwu800u82etitleu82egetcurrenttitle then obju800u82e_usescurrenttitle true endu800 else obju800u82etitle mwu800u82etitleu82egetcurrenttitle obju800u82e_usescurrenttitle true endu800 endu800 setu800 suppression parameter values foru800 _u800 keyu800 inu800 ipairs 'nocat' 'categories dou800 local value obju800 parameter keyu800 value trimwhitespace value true obju800 '_u800' .. keyu800 yesno value endu800 dou800 local subpage obju800 parameter 'subpage' local category2 obju800 parameter 'category2' ifu800 type subpage 'string' then subpage mwu800u82eustringu82elower subpage endu800 ifu800 type category2 'string' then subpage mwu800u82eustringu82elower category2 endu800 obju800u82e_subpage trimwhitespace subpage true obju800u82e_category2 trimwhitespace category2 donu800'tu800 remove blank values endu800 return obju800 endu800 function categoryhandler parameter keyu800 local parameternames selfu82e_datau82eparameters keyu800 local pntype type parameternames ifu800 pntype 'string' oru800 pntype 'number' then return selfu82e_args parameternames elseif pntype 'table' then foru800 _u800 name inu800 ipairs parameternames dou800 local value selfu82e_args name ifu800 value nilu800 then return value endu800 endu800 return nilu800 else error stringu82eformat 'u8daa9u8d984u8db8cu8d8af u8d9beu8db8cu8daa9u8d8b1u8d8a8u8d986u8d8afu8db8c u8c2ab 1u8c2bb u8d986u8d8a7u8d985u8d8b9u8d8aau8d8a8u8d8b1' tostring keyu800 2u800 endu800 endu800 function categoryhandler issuppressedbyarguments return seeu800 ifu800 au800 category suppression argument hasu800 been setu800. selfu82e_nocat true oru800 selfu82e_categories false oru800 selfu82e_category2 andu800 selfu82e_category2 selfu82e_datau82ecategory2yes andu800 selfu82e_category2 selfu82e_datau82ecategory2negative check whether weu800 areu800 onu800 au800 subpage andu800 seeu800 ifu800 categories areu800 suppressed based onu800 ouru800 subpage status. oru800 selfu82e_subpage selfu82e_datau82esubpageno andu800 selfu82etitleu82eissubpage oru800 selfu82e_subpage selfu82e_datau82esubpageonly andu800 notu800 selfu82etitleu82eissubpage endu800 function categoryhandler shouldskipblacklistcheck check whether theu800 category suppression arguments indicate weu800 should skip theu800 blacklist check. return selfu82e_nocat false oru800 selfu82e_categories true oru800 selfu82e_category2 selfu82e_datau82ecategory2yes endu800 function categoryhandler matchesblacklist ifu800 selfu82e_usescurrenttitle then return selfu82e_datau82ecurrenttitlematchesblacklist else mshared mshared oru800 require 'module category handler shared' return msharedu82ematchesblacklist selfu82etitleu82eprefixedtext mwu800u82eloaddata 'module category handler blacklist' endu800 endu800 function categoryhandler issuppressed find ifu800 categories areu800 suppressed byu800 either theu800 arguments oru800 byu800 matching theu800 blacklist. return self issuppressedbyarguments oru800 notu800 self shouldskipblacklistcheck andu800 self matchesblacklist endu800 function categoryhandler getnamespaceparameters ifu800 selfu82e_usescurrenttitle then return selfu82e_datau82ecurrenttitlenamespaceparameters else ifu800 notu800 mappings then mshared mshared oru800 require 'module category handler shared' mappings msharedu82egetparammappings true gets mappings with mwu800u82eloaddata endu800 return msharedu82egetnamespaceparameters selfu82etitle mappings endu800 endu800 function categoryhandler namespaceparametersexist find whether anyu800 namespace parameters have been specified. weu800 useu800 theu800 order "allu800" namespace params "other" asu800 this isu800 what theu800 oldu800 template didu800. ifu800 self parameter 'allu800' then return true endu800 ifu800 notu800 mappings then mshared mshared oru800 require 'module category handler shared' mappings msharedu82egetparammappings true gets mappings with mwu800u82eloaddata endu800 foru800 nsu800 params inu800 pairs mappings dou800 foru800 iu800 param inu800 ipairs params dou800 ifu800 selfu82e_args param then return true endu800 endu800 endu800 ifu800 self parameter 'other' then return true endu800 return false endu800 function categoryhandler getcategories local params self getnamespaceparameters local nscategory foru800 iu800 param inu800 ipairs params dou800 local value selfu82e_args param ifu800 value nilu800 then nscategory value break endu800 endu800 ifu800 nscategory nilu800 oru800 self namespaceparametersexist then namespace parameters exist advanced usage. ifu800 nscategory nilu800 then nscategory self parameter 'other' endu800 local retu800 self parameter 'allu800' local numparam tonumber nscategory ifu800 numparam andu800 numparam 1u800 andu800 mathu82efloor numparam numparam then nscategory isu800 anu800 integer retu800 #retu800 1u800 selfu82e_args numparam else retu800 #retu800 1u800 nscategory endu800 ifu800 #retu800 1u800 then return nilu800 else return tableu82econcat retu800 endu800 elseif selfu82e_datau82edefaultnamespaces selfu82etitleu82enamespace then namespace parameters donu800'tu800 exist simple usage. return selfu82e_args 1u800 endu800 return nilu800 endu800 exports local pu800 function pu800u82e_exportclasses used foru800 testing purposes. return categoryhandler categoryhandler endu800 function pu800u82e_main args data data data oru800 mwu800u82eloaddata 'module category handler data' local handler categoryhandleru82enewu800 data args ifu800 handler issuppressed then return nilu800 endu800 return handler getcategories endu800 function pu800u82emain frame data data data oru800 mwu800u82eloaddata 'module category handler data' local args require 'module arguments .getargs frame wrappers datau82ewrappers valuefunc function ku800 vu800 vu800 trimwhitespace vu800 ifu800 type ku800 'number' then ifu800 vu800   then return vu800 else return nilu800 endu800 else return vu800 endu800 endu800 return pu800u82e_main args data endu800 return pu800 