Module:Sandbox/Ahecht/Catalog lookup link explained
local p =
function p.main(frame) local args = local out = local defaultSeparator = ', ' local lockIcon = -- discard empty parameters and trim whitespace for k, v in pairs(frame:getParent.args) do if v and mw.ustring.match(v,'%S') then args[k] = mw.text.trim(v) end end if args[1] then local i = 1 while args[i] do if i
1 then -- if first item, add article link if args['article-link'] or args['article-name'] then if args['article-link'] then out = '' .. (args['article-name'] or args['article-link']) .. '' else out = args['article-name'] end out = out .. (args['article-postfix'] or ) .. ' ' else out = (args['article-postfix'] or ) end else -- otherwise, add separator if ((not args[i+1]) and args['list-leadout']) then -- if last item if mw.ustring.match(mw.ustring.sub(args['list-leadout'],1,1), '[%a]') then out = out .. ' ' end out = out .. args['list-leadout'] .. args['leadout-postfix'] .. ' ' else -- if not last item or list-leadout isn't specified out = out .. (args['list-separator'] or defaultSeparator) end end -- generate link local item = (args['item-prefix'] or ) .. args[i] .. (args['item-postfix'] or ) if args['link-prefix'] then item = '[' .. args['link-prefix'] .. mw.uri.encode(args[i]) .. (args['link-postfix'] or ) .. ' '.. item .. ']' if lockIcon[args['url-access']] then item = item .. '
' .. lockIcon[args['url-access']] .. '' end end out = out .. item i = i + 1 end end if lockIcon[args['url-access']] or args['plain-links'] then out = '
' .. out .. '' end return outend
return p