Module:Infobox body of water tracking: Difference between revisions
Appearance
Content deleted Content added
limit error checking to main (article) space |
more tracking per request at Template talk:Infobox body of water and consolidate mainspace check |
||
Line 19: | Line 19: | ||
local cats = '' |
local cats = '' |
||
local maincats = '' |
|||
local args = frame:getParent().args |
local args = frame:getParent().args |
||
local AZ = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' |
local AZ = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' |
||
local warnmsg = {} |
local warnmsg = {} |
||
if |
if isblank(args['image']) then |
||
⚫ | |||
⚫ | |||
elseif isblank(args['alt']) then |
|||
⚫ | |||
⚫ | |||
⚫ | |||
end |
end |
||
if isblank(args['coords']) and isblank(args['coordinates']) then |
if isblank(args['coords']) and isblank(args['coordinates']) then |
||
⚫ | |||
if mw.title.getCurrentTitle().namespace == 0 then |
|||
⚫ | |||
⚫ | |||
if (isblank(args['pushpin_map']) ) then |
|||
maincats = maincats .. '[[Category:Articles using infobox body of water without pushpin_map]]' |
|||
elseif isblank(args['pushpin_map_alt']) then |
|||
maincats = maincats .. '[[Category:Articles using infobox body of water without pushpin_map_alt]]' |
|||
⚫ | |||
if (isblank(args['image_bathymetry']) ) then |
|||
maincats = maincats .. '[[Category:Articles using infobox body of water without image_bathymetry]]' |
|||
elseif isblank(args['alt_bathymetry']) then |
|||
maincats = maincats .. '[[Category:Articles using infobox body of water without alt_bathymetry]]' |
|||
end |
end |
||
Line 85: | Line 96: | ||
end |
end |
||
if (no_convert_parameters > 0) then |
if (no_convert_parameters > 0) then |
||
maincats = maincats .. '[[Category:Pages using infobox body of water with a non-automatically converted dimension|' .. |
|||
if mw.title.getCurrentTitle().namespace == 0 then |
|||
⚫ | |||
string.sub(AZ,no_convert_parameters, no_convert_parameters+1) .. ']]' |
string.sub(AZ,no_convert_parameters, no_convert_parameters+1) .. ']]' |
||
⚫ | |||
end |
end |
||
Line 95: | Line 104: | ||
cats = '<div class="hatnote" style="color:red"><strong>Infobox body of water warning:</strong> ' .. table.concat(warnmsg, '<br>') .. '</div>' .. cats |
cats = '<div class="hatnote" style="color:red"><strong>Infobox body of water warning:</strong> ' .. table.concat(warnmsg, '<br>') .. '</div>' .. cats |
||
end |
end |
||
end |
|||
⚫ | |||
cats = cats .. maincats |
|||
end |
|||
return cats |
return cats |
||
end |
end |
Revision as of 18:04, 9 July 2020
![]() | This module is rated as ready for general use. It has reached a mature form and is thought to be relatively bug-free and ready for use wherever appropriate. It is ready to mention on help pages and other Wikipedia resources as an option for new users to learn. To reduce server load and bad output, it should be improved by sandbox testing rather than repeated trial-and-error editing. |
![]() | This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing. |
This module is used by Template:Infobox body of water.
Usage
{{#invoke:Infobox body of water tracking|tracking}}
Tracking/maintenance categories
- Category:Wikipedia infobox body of water articles needing maintenance (3)
- Category:Articles using infobox body of water without coordinates (140)
- Category:Articles using infobox body of water without image (7,482)
- Category:Articles using infobox body of water without alt (9,356)
- Category:Articles using infobox body of water without pushpin_map (999)
- Category:Articles using infobox body of water without pushpin_map_alt (10,655)
- Category:Articles using infobox body of water without image_bathymetry (18,102)
- Category:Articles using infobox body of water without alt_bathymetry (488)
- Category:Articles using infobox body of water with mapframe (171)
- Category:Pages using infobox body of water with a non-automatically converted dimension (14)
- Category:Pages using infobox body of water with duplicate parameters (4)
- Category:Pages using infobox body of water with unknown parameters (1)
local p = {}
function p.tracking(frame)
local function isblank( val )
return (val == nil) or val:match('^[%s]*$')
end
local function hasnoconvert( val )
local res = nil
val = mw.text.killMarkers(val)
if val:match('[0-9]') then
res = 1
if val:match('[%(][−0-9%.]') and val:match('[%)]') then
res = nil
end
end
return res
end
local cats = ''
local maincats = ''
local args = frame:getParent().args
local AZ = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
local warnmsg = {}
if isblank(args['image']) then
maincats = maincats .. '[[Category:Articles using infobox body of water without image]]'
elseif isblank(args['alt']) then
maincats = maincats .. '[[Category:Articles using infobox body of water without alt]]'
end
if isblank(args['coords']) and isblank(args['coordinates']) then
maincats = maincats .. '[[Category:Articles using infobox body of water without coordinates]]'
end
if (isblank(args['pushpin_map']) ) then
maincats = maincats .. '[[Category:Articles using infobox body of water without pushpin_map]]'
elseif isblank(args['pushpin_map_alt']) then
maincats = maincats .. '[[Category:Articles using infobox body of water without pushpin_map_alt]]'
end
if (isblank(args['image_bathymetry']) ) then
maincats = maincats .. '[[Category:Articles using infobox body of water without image_bathymetry]]'
elseif isblank(args['alt_bathymetry']) then
maincats = maincats .. '[[Category:Articles using infobox body of water without alt_bathymetry]]'
end
local duplicate_parameters = 0
local duplicate_list = {
{'child', 'embed'},
{'name', 'lake_name'},
{'image', 'image_lake'},
{'alt', 'alt_lake'},
{'caption', 'caption_lake'},
{'coordinates', 'coords'},
{'lake_type', 'type'},
{'ocean_type', 'type'},
{'lake_type', 'ocean_type'},
{'part_of', 'parent'},
{'basin_countries', 'countries'},
{'catchment_km2', 'catchment'},
{'length_km', 'length'},
{'width_km', 'width'},
{'area_km2', 'area'},
{'depth_m', 'depth'},
{'max-depth_m', 'max-depth'},
{'volume_km3', 'volume'},
{'shore_km', 'shore'},
{'elevation_m', 'elevation'},
{'settlements', 'cities'},
{'extra', 'nrhp'},
{'extra', 'embedded'},
{'embedded', 'nrhp'}
}
for i, params in ipairs(duplicate_list) do
if args[params[1]] and args[params[2]] then
duplicate_parameters = duplicate_parameters + 1
table.insert(warnmsg, 'Cannot use <code>' .. params[1] .. '</code> and <code>' .. params[2] .. '</code> at the same time.')
end
end
if (duplicate_parameters > 0) then
cats = cats .. '[[Category:Pages using infobox body of water with ' ..
'duplicate parameters|' ..
string.sub(AZ, duplicate_parameters, duplicate_parameters+1) .. ']]'
end
local no_convert_parameters = 0
local dim_list = {
'catchment', 'length', 'width', 'area', 'depth', 'max-depth', 'volume',
'shore', 'elevation', 'temperature_low', 'temperature_high'}
for i, param in ipairs(dim_list) do
if hasnoconvert(args[param] or '') then
no_convert_parameters = no_convert_parameters + 1
table.insert(warnmsg, 'Unconverted dimensions in <code>' .. param .. '</code>')
end
end
if (no_convert_parameters > 0) then
maincats = maincats .. '[[Category:Pages using infobox body of water with a non-automatically converted dimension|' ..
string.sub(AZ,no_convert_parameters, no_convert_parameters+1) .. ']]'
end
if #warnmsg > 0 then
if frame:preprocess( "{{REVISIONID}}" ) == "" then
cats = '<div class="hatnote" style="color:red"><strong>Infobox body of water warning:</strong> ' .. table.concat(warnmsg, '<br>') .. '</div>' .. cats
end
end
if maincats ~= '' and mw.title.getCurrentTitle().namespace == 0 then
cats = cats .. maincats
end
return cats
end
return p