Module:Settlement short description
Appearance
![]() | This Lua module is used on approximately 712,000 pages, or roughly 1% of all pages. To avoid major disruption and server load, any changes should be tested in the module's /sandbox or /testcases subpages, or in your own module sandbox. The tested changes can be added to this page in a single edit. Consider discussing changes on the talk page before implementing them. |
![]() | This module depends on the following other modules: |
Usage
Used in Template:Infobox settlement to generate short descriptions.
--generates auto short description for use in infobox settlement
local p = {}
local plain = require('Module:Plain text')._main
local getArgs = require('Module:Arguments').getArgs
local categoryHandler = require( 'Module:Category handler' ).main
local tableTools = require ('Module:TableTools')
function p.shortdesc(text, frame)
return frame:expandTemplate{title = 'Short description', args = {text}}
end
function p.main(frame)
local args = getArgs (frame, {frameOnly = true})
local settlement_type = plain(args[1])
local short_description = plain(args[2])
local subdivision_name = plain(args[3])
local subdivision_name1 = plain(args[4])
local subdivision_name2 = plain(args[5])
if short_description then
if (short_description == 'no') then
return
else
return p.shortdesc(short_description, frame)
end
end
if not settlement_type then settlement_type = 'Place' end
if not subdivision_name then return p.shortdesc(settlement_type, frame, 1, true) end
if (string.find(settlement_type, subdivision_name)
or (subdivision_name1 and string.find(settlement_type, subdivision_name1, 1, true))) then
return categoryHandler{'[[Category:Infobox settlement pages with bad settlement type]]', nocat = args.nocat}
else
if not(subdivision_name2 and string.find(settlement_type, '[nN]eighbo[u]?rhood')) then
subdivision_name2 = nil
end
return p.shortdesc(string.format('%s in %s', settlement_type,
table.concat(tableTools.compressSparseArray({subdivision_name2, subdivision_name1, subdivision_name}), ', ')), frame)
end
end
return p