Modul:Location map: Perbedaan antara revisi

Konten dihapus Konten ditambahkan
Angayubagia (bicara | kontrib)
Tidak ada ringkasan suntingan
Baris 1:
require('ModulModule:No globals')
 
local p = {}
 
local getArgs = require('ModulModule:Arguments').getArgs
 
local function round(n, decimals)
Baris 14:
error('The name of the location map definition to use must be specified', 2)
end
local moduletitle = mw.title.new('ModulModule:Location map/data/' .. map)
if not moduletitle then
error(string.format('%q is not a valid name for a location map definition', map), 2)
elseif moduletitle.exists then
local mapData = mw.loadData('ModulModule:Location map/data/' .. map)
return function(name, params)
if name == nil then
return 'ModulModule:Location map/data/' .. map
elseif mapData[name] == nil then
return ''
Baris 30:
end
end
elseif mw.title.new('TemplatTemplate:Location map ' .. map).exists then
local cache = {}
if type(frame) ~= 'table' or type(frame.expandTemplate) ~= 'function' then
Baris 40:
else
if name == nil then
return 'TemplatTemplate:Location map ' .. map
elseif cache[name] == nil then
cache[name] = frame:expandTemplate{title = 'Location map ' .. map, args = { name }}
Baris 48:
end
else
error('Unable to find the specified location map definition. Neither "ModulModule:Location map/data/' .. map .. '" nor "TemplatTemplate:Location map ' .. map .. '" exists', 2)
end
end
Baris 158:
end
local width
local default_as_number = tonumber(mw.ustring.match(tostring(args.default_width),"%d*"))
if not args.width then
width = round((args.default_widthdefault_as_number or 240) * (tonumber(map('defaultscale')) or 1))
elseif mw.ustring.sub(args.width, -2) == 'px' then
width = mw.ustring.sub(args.width, 1, -3)
Baris 165 ⟶ 166:
width = args.width
end
local width_as_number = tonumber(mw.ustring.match(tostring(width),"%d*")) or 0;
if width_as_number == 0 then
-- check to see if width is junk. If it is, then use default calculation
width = round((default_as_number or 240) * (tonumber(map('defaultscale')) or 1))
width_as_number = tonumber(mw.ustring.match(tostring(width),"%d*")) or 0;
end
if args.max_width ~= "" and args.max_width ~= nil then
-- check to see if width bigger than max_width
local max_as_number = tonumber(mw.ustring.match(args.max_width,"%d*")) or 0;
if width_as_number>max_as_number and max_as_number>0 then
width = args.max_width;
end
end
local retval = args.float == 'center' and '<div class="center">' or ''
if args.caption and args.caption ~= '' and args.border ~= 'infobox' then
Baris 201 ⟶ 215:
image,
width,
args.alt or ((args.label or mw.title.getCurrentTitle().text) .. ' berlokasiis dilocated in ' .. map('name')),
args.maplink and ('|link=' .. args.maplink) or ''
)
if args.overlay_image then
return retval .. '<div style="position:absolute;top:0;left:0">[[BerkasFile:' .. args.overlay_image .. '|' .. width .. 'px]]</div>'
else
return retval
Baris 231 ⟶ 245:
elseif args.caption ~= '' then
-- This is not the pipe trick. We're creating a link with no text on purpose, so that CSS can give us a nice image
retval = retval .. '<div class="thumbcaption"><div class="magnify">[[:BerkasFile:' .. getContainerImage(args, map) .. '| ]]</div>' .. args.caption .. '</div>'
end
 
Baris 248 ⟶ 262:
end
mw.logObject(args, 'args')
retval = retval .. '[[Category:Location maps with possibleremoved errorsparameters|Page using removed parametercaption_undefined]]'
end
if map('skew') ~= '' or map('lat_skew') ~= '' or map('crosses180') ~= '' or map('type') ~= '' then
Baris 256 ⟶ 270:
(map('crosses180') ~= '' and 'crosses180' or '') ..
(map('type') ~= '' and 'type' or '')
retval = retval .. '[[Category:Location maps with possibleremoved errorsparameters|Map' using.. removedkey .. ' parameter]]'
end
if string.find(map('name'), '|', 1, true) then
mw.log('Pipe used in name of map definition ' .. map())
retval = retval .. '[[Category:Location maps with possiblea errors|Namename containing a pipe]]'
end
if args.float == 'center' then
Baris 281 ⟶ 295:
if marksize ~= 0 then
builder:wikitext(string.format(
'[[BerkasFile:%s|%dx%dpx|%s|link=%s%s]]',
mark,
marksize,
Baris 341 ⟶ 355:
function p.mark(frame, args, map)
if not args then
args = getArgs(frame, {wrappers = 'TemplatTemplate:Location map~'})
end
if not map then
Baris 392 ⟶ 406:
(args.lon_shift and 'lon_shift' or '') ..
(args.markhigh and 'markhigh' or '')
builder:wikitext('[[Category:Location maps with possibleremoved errorsparameters|Page' using.. removedkey ..' parameter]]')
end
if map('x') ~= '' then
Baris 439 ⟶ 453:
function p.main(frame, args, map)
if not args then
args = getArgs(frame, {wrappers = 'TemplatTemplate:Location map', valueFunc = p.valueFunc})
end
if args.useWikidata == nil then