Module:Location map: Difference between revisions

From Chalo Chatu, Zambia online encyclopedia
m
1 revision imported
m (Protected "Module:Location map" ([Edit=Allow only autoconfirmed users] (indefinite) [Move=Allow only autoconfirmed users] (indefinite)))
m (1 revision imported)
 
(4 intermediate revisions by the same user not shown)
Line 28: Line 28:
else
else
return mapData[name]
return mapData[name]
end
end
elseif mw.title.new('Template:Location map ' .. map).exists then
local cache = {}
if type(frame) ~= 'table' or type(frame.expandTemplate) ~= 'function' then
error('A frame must be provided when using a legacy location map')
end
return function(name, params)
if params then
return frame:expandTemplate{title = 'Location map ' .. map, args = { name, unpack(params) }}
else
if name == nil then
return 'Template:Location map ' .. map
elseif cache[name] == nil then
cache[name] = frame:expandTemplate{title = 'Location map ' .. map, args = { name }}
end
return cache[name]
end
end
end
end
else
else
error('Unable to find the specified location map definition. Neither "Module:Location map/data/' .. map .. '" nor "Template:Location map ' .. map .. '" exists', 2)
error('Unable to find the specified location map definition: "Module:Location map/data/' .. map .. '" does not exist', 2)
end
end
end
end
Line 210: Line 193:
end
end
local image = getContainerImage(args, map)
local image = getContainerImage(args, map)
local currentTitle = mw.title.getCurrentTitle()
retval = string.format(
retval = string.format(
'%s[[File:%s|%spx|%s%s]]',
'%s[[File:%s|%spx|%s%s]]',
Line 215: Line 199:
image,
image,
width,
width,
args.alt or ((args.label or mw.title.getCurrentTitle().text) .. ' is located in ' .. map('name')),
args.alt or ((args.label or currentTitle.text) .. ' is located in ' .. map('name')),
args.maplink and ('|link=' .. args.maplink) or ''
args.maplink and ('|link=' .. args.maplink) or ''
)
)
if args.caption and args.caption ~= '' then
if args.caption and args.caption ~= '' then
if mw.ustring.find(args.caption, '##') then
if (currentTitle.namespace == 0) and mw.ustring.find(args.caption, '##') then
retval = retval .. '[[Category:Pages using location map with a double number sign in the caption]]'
retval = retval .. '[[Category:Pages using location map with a double number sign in the caption]]'
end
end
Line 238: Line 222:
end
end
local retval = '</div>'
local retval = '</div>'
local currentTitle = mw.title.getCurrentTitle()
if not args.caption or args.border == 'infobox' then
if not args.caption or args.border == 'infobox' then
if args.border then
if args.border then
Line 246: Line 230:
end
end
retval = retval
retval = retval
.. (args.caption or (args.label or mw.title.getCurrentTitle().text) .. ' (' .. map('name') .. ')')
.. (args.caption or (args.label or currentTitle.text) .. ' (' .. map('name') .. ')')
.. '</div>'
.. '</div>'
elseif args.caption ~= ''  then
elseif args.caption ~= ''  then
Line 267: Line 251:
end
end
mw.logObject(args, 'args')
mw.logObject(args, 'args')
retval = retval .. '[[Category:Location maps with removed parameters|caption_undefined]]'
if currentTitle.namespace == 0 then
    retval = retval .. '[[Category:Location maps with removed parameters|caption_undefined]]'
end
end
end
if map('skew') ~= '' or map('lat_skew') ~= '' or map('crosses180') ~= '' or map('type') ~= '' then
if map('skew') ~= '' or map('lat_skew') ~= '' or map('crosses180') ~= '' or map('type') ~= '' then
mw.log('Removed parameter used in map definition ' .. map())
mw.log('Removed parameter used in map definition ' .. map())
local key = (map('skew') ~= '' and 'skew' or '') ..
if currentTitle.namespace == 0 then
    local key = (map('skew') ~= '' and 'skew' or '') ..
(map('lat_skew') ~= '' and 'lat_skew' or '') ..
(map('lat_skew') ~= '' and 'lat_skew' or '') ..
(map('crosses180') ~= '' and 'crosses180' or '') ..
(map('crosses180') ~= '' and 'crosses180' or '') ..
(map('type') ~= '' and 'type' or '')
(map('type') ~= '' and 'type' or '')
retval = retval .. '[[Category:Location maps with removed parameters|' .. key .. ' ]]'
    retval = retval .. '[[Category:Location maps with removed parameters|' .. key .. ' ]]'
end
end
end
if string.find(map('name'), '|', 1, true) then
if string.find(map('name'), '|', 1, true) then
mw.log('Pipe used in name of map definition ' .. map())
mw.log('Pipe used in name of map definition ' .. map())
retval = retval .. '[[Category:Location maps with a name containing a pipe]]'
if currentTitle.namespace == 0 then
  retval = retval .. '[[Category:Location maps with a name containing a pipe]]'
end
end
end
if args.float == 'center' then
if args.float == 'center' then
Line 332: Line 322:
end
end
builder = builder:tag('div')
builder = builder:tag('div')
:css('display', 'inline')
:cssText('padding:1px')
:cssText('padding:1px')
:cssText(spanCss)
:cssText(spanCss)
Line 399: Line 390:
end
end
local builder = mw.html.create()
local currentTitle = mw.title.getCurrentTitle()
if args.coordinates then
if args.coordinates then
-- Temporarily removed to facilitate infobox conversion. See [[Wikipedia:Coordinates in infoboxes]]
-- Temporarily removed to facilitate infobox conversion. See [[Wikipedia:Coordinates in infoboxes]]
Line 413: Line 406:
local value = entity.claims.P625[1].mainsnak.datavalue.value
local value = entity.claims.P625[1].mainsnak.datavalue.value
longitude, latitude = value.longitude, value.latitude
longitude, latitude = value.longitude, value.latitude
end
if args.link and (currentTitle.namespace == 0) then
builder:wikitext('[[Category:Location maps with linked markers with coordinates from Wikidata]]')
end
end
end
end
Line 420: Line 416:
error('No value was provided for latitude')
error('No value was provided for latitude')
end
end
local builder = mw.html.create()
if currentTitle.namespace > 0 then
if (not args.lon_deg) ~= (not args.lat_deg) then
if (not args.lon_deg) ~= (not args.lat_deg) then
builder:wikitext('[[Category:Location maps with different longitude and latitude precisions|Degrees]]')
builder:wikitext('[[Category:Location maps with different longitude and latitude precisions|Degrees]]')
elseif (not args.lon_min) ~= (not args.lat_min) then
elseif (not args.lon_min) ~= (not args.lat_min) then
builder:wikitext('[[Category:Location maps with different longitude and latitude precisions|Minutes]]')
builder:wikitext('[[Category:Location maps with different longitude and latitude precisions|Minutes]]')
elseif (not args.lon_sec) ~= (not args.lat_sec) then
elseif (not args.lon_sec) ~= (not args.lat_sec) then
builder:wikitext('[[Category:Location maps with different longitude and latitude precisions|Seconds]]')
builder:wikitext('[[Category:Location maps with different longitude and latitude precisions|Seconds]]')
elseif (not args.lon_dir) ~= (not args.lat_dir) then
elseif (not args.lon_dir) ~= (not args.lat_dir) then
builder:wikitext('[[Category:Location maps with different longitude and latitude precisions|Hemisphere]]')
builder:wikitext('[[Category:Location maps with different longitude and latitude precisions|Hemisphere]]')
elseif (not args.long) ~= (not args.lat) then
elseif (not args.long) ~= (not args.lat) then
builder:wikitext('[[Category:Location maps with different longitude and latitude precisions|Decimal]]')
builder:wikitext('[[Category:Location maps with different longitude and latitude precisions|Decimal]]')
end
end
end
if args.skew or args.lon_shift or args.markhigh then
if args.skew or args.lon_shift or args.markhigh then
Line 439: Line 436:
end
end
mw.logObject(args, 'args')
mw.logObject(args, 'args')
local key = (args.skew and 'skew' or '') ..
if currentTitle.namespace == 0 then
(args.lon_shift and 'lon_shift' or '') ..
local key = (args.skew and 'skew' or '') ..
(args.markhigh and 'markhigh' or '')
(args.lon_shift and 'lon_shift' or '') ..
builder:wikitext('[[Category:Location maps with removed parameters|' .. key ..' ]]')
(args.markhigh and 'markhigh' or '')
builder:wikitext('[[Category:Location maps with removed parameters|' .. key ..' ]]')
end
end
end
if map('x') ~= '' then
if map('x') ~= '' then
Line 461: Line 460:
end
end
mw.logObject(args, 'args')
mw.logObject(args, 'args')
local key = frame:preprocess('{{FULLPAGENAME}}')
if currentTitle.namespace == 0 then
builder:wikitext('[[Category:Location maps with marks outside map and outside parameter not set|' .. key .. ' ]]')
local key = frame:preprocess('{{FULLPAGENAME}}')
builder:wikitext('[[Category:Location maps with marks outside map and outside parameter not set|' .. key .. ' ]]')
end
end
end
local mark = args.mark or map('mark')
local mark = args.mark or map('mark')
Administrators, upwizcampeditors
0

edits