Module:HF/Infobox/Tools

local Infobox = {}

-- Libraries and Global functions --

-- stands for High Frequency local HF = require('Module:HF') -- Parses invocation and template parameters, trims whitespace, and removes blanks. local getArgs = require('Dev:Arguments').getArgs -- Generates lists local L = require('Dev:List') -- Language functions local language = mw.language.new('en')

-- Pattern Constants local stripLinkToTarget = '^%[*([^%[|]*)|?'

-- The page title of whatever page is calling the function local pageTitle = mw.title.getCurrentTitle.text

-- Local functions (used only in this Module) --

-- Replaces local function nameCheck ( target ) local nq = mw.smw.ask{ HF.Link(target:match(stripLinkToTarget)), '?Maintenance' } if type(nq) == 'table' and nq[1]['Maintenance'] == 'Name' then return true else return nil end end -- -- Public functions (called from a Template or article) -- --

function Infobox.titleTools(frame) local args = getArgs(frame) local out = {} if mw.title.getCurrentTitle.isContentPage == true then table.insert( out, HF.Category('Tools') ) if args['unnamed tool'] == 'Yes' then mw.smw.set{ ['Maintenance'] = 'Name' } table.insert( out, ("%s"):format( pageTitle:match("%s*[^(]*") ) )		else			table.insert( out, pageTitle:match("%s*[^(]*") ) end mw.smw.set { ['Name'] = pageTitle:gsub('&#39;',"'") } return table.concat( out ) .. ( args['ref'] or '' ) elseif mw.title.getCurrentTitle.namespace == 10 and not pageTitle:match('/testcases') then return nil else return args['english'] or pageTitle:match("[^(]*")	end end

function Infobox.toolsRelated(frame) local args = getArgs(frame) local out = {} local tools = args['related tools'] and mw.text.split( args['related tools'], ',%s*' ) if type(tools) == 'table' then for _,tool in ipairs( tools ) do			table.insert( out, HF.Link( tool, tool:match('%s*[^(]*')))		end		return table.concat(out)	end end

function Infobox.toolsUsers(frame) local args = getArgs(frame) local out = {} local types = { null = true, anime = true, manga = true, novel = true, game = true, movie = true, ['movie canon'] = true }	local users = args['users'] and mw.text.split( args['users'], ',%s*' ) if type(users) == 'table' then for _,user in ipairs( users ) do			if type(user) == 'string' and #user > 1 then local base = nameCheck ( user ) and ("%s"):format( HF.Link ( user:match('[^~]*'), user:match('[^~]*'):match('%s*[^(]*')					) )					or HF.Link ( user:match('[^~]*'), user:match('[^~]*'):match('%s*[^(]*')					) local extra = user:match('~(.*)') local type = (extra and types[extra:lower]) and language:ucfirst(extra) mw.smw.set { ['User tech'] = user:match('[^~]*') .. ';' .. (type or 'null')} if extra ~= nil and types[extra:lower] and extra ~= 'null' then if extra:lower == 'movie canon' then table.insert( out, base .. ' (Movie only)' ) else table.insert( out, base .. (' (%s only)'):format( language:ucfirst(extra) ) ) end else table.insert( out, base ) end end end return L.makeList( 'bulleted', out ) end end

- -- Exported functions (used in this and other Modules) -- - -- None. - -- Output (send it back to whatever called it) -- - return Infobox