Modul:Location map: Razlika med redakcijama

Izbrisana vsebina Dodana vsebina
m tn v sporočilu napake
mBrez povzetka urejanja
Oznaka: vrnjeno
Vrstica 1:
require('Modul:No globalsstrict')
 
local p = {}
 
local getArgs = require('ModulModule:Arguments').getArgs
 
local function round(n, decimals)
Vrstica 12:
function p.getMapParams(map, frame)
if not map then
error('ImeThe lokacijskename karteof morathe bitilocation določenomap 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 niis veljavnonot imea zavalid lokacijskoname kartofor 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 ''
Vrstica 28:
else
return mapData[name]
end
end
elseif mw.title.new('Predloga:Lokacijska karta ' .. 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 = 'Lokacijska karta ' .. map, args = { name, unpack(params) }}
else
if name == nil then
return 'Predloga:Lokacijska karta ' .. map
elseif cache[name] == nil then
cache[name] = frame:expandTemplate{title = 'Lokacijska karta ' .. map, args = { name }}
end
return cache[name]
end
end
else
error('NavedenaUnable lokacijskato kartafind nethe obstaja.specified Nitilocation map definition: "ModulModule:Location map/data/' .. map .. '" niti "Predloga:Lokacijska karta ' .. map .. '"does nenot obstajataexist', 2)
end
end
Vrstica 88 ⟶ 71:
return retval
end
error('VrednostThe value "' .. decimal .. '" zaprovided for ' .. direction .. ' niis not veljavnavalid', 2)
elseif seconds and not minutes then
error('Seconds were provided for ' .. direction .. ' without minutes also being provided', 2)
Vrstica 101 ⟶ 84:
decimal = tonumber(degrees)
if not decimal then
error('VrednostThe degree value stopinje"' .. degrees .. '" zaprovided for ' .. direction .. ' niis not veljavnavalid', 2)
elseif minutes and not tonumber(minutes) then
error('VrednostThe minute value "' .. minutes .. '" zaprovided for ' .. direction .. ' niis not veljavnavalid', 2)
elseif seconds and not tonumber(seconds) then
error('VrednostThe sekundesecond value "' .. seconds .. '" zaprovided for ' .. direction .. ' niis not veljavnavalid', 2)
end
decimal = decimal + (minutes or 0)/60 + (seconds or 0)/3600
Vrstica 111 ⟶ 94:
local multiplier = hemisphereMultipliers[direction][hemisphere]
if not multiplier then
error('HemisferaThe hemisphere "' .. hemisphere .. '" zaprovided for ' .. direction .. ' niis not veljavnavalid', 2)
end
decimal = decimal * multiplier
Vrstica 118 ⟶ 101:
end
 
-- Finds a parameter in a transclusion of {{KoordCoord}}.
local function coord2text(para,coord) -- this should be changed for languages which do not use Arabic numerals or the degree sign
local lat, long = mw.ustring.match(coord,'<span class="p%-latitude latitude">([^<]+)</span><span class="p%-longitude longitude">([^<]+)</span>')
if paramslat then
return tonumber(para == 'longitude' and long or lat)
end
local result = mw.text.split(mw.ustring.match(coord,'%-?[%.%d]+°[NS] %-?[%.%d]+°[EW]') or '', '[ °]')
if para == 'longitude' then result = {result[3], result[4]} end
if not tonumber(result[1]) or not result[2] then return error
mw.log('Malformed coordinates value', 2) end
mw.logObject(para, 'para')
mw.logObject(coord, 'coord')
return error('Malformed coordinates value', 2)
end
return tonumber(result[1]) * hemisphereMultipliers[para][result[2]]
end
Vrstica 143 ⟶ 135:
if args.AlternativeMap then
return args.AlternativeMap
elseif args.relief and map('image1') ~= '' then
local digits = mw.ustring.match(args.relief,'^[1-9][0-9]?$') or '1' -- image1 to image99
return map('image1')
if map('image' .. digits) ~= '' then
else
return map('image' .. digits)
end
end
return map('image1image')
end
 
Vrstica 179 ⟶ 173:
end
end
local retval = args.floatframe:extensionTag{name == 'centertemplatestyles', andargs '<div= {src class="center"> 'Module:Location or 'map/styles.css'}}
if args.float == 'center' then
retval = retval .. '<div class="center">'
end
if args.caption and args.caption ~= '' and args.border ~= 'infobox' then
retval = retval .. '<div class="locmap noviewer noresize thumb '
if args.float == '"left"' or args.float == 'left' then
retval = retval .. 'tleft'
Vrstica 197 ⟶ 194:
retval = retval .. '"><div style="position:relative;width:' .. width .. 'px' .. (args.border ~= 'none' and ';border:1px solid lightgray">' or '">')
else
retval = retval .. '<div class="locmap" style="width:' .. width .. 'px;'
if args.float == '"left"' or args.float == 'left' then
retval = retval .. 'float:left;clear:left'
Vrstica 210 ⟶ 207:
end
local image = getContainerImage(args, map)
local currentTitle = mw.title.getCurrentTitle()
retval = string.format(
'%s[[File:%s|%spx|%s%s|class=notpageimage]]',
retval,
image,
width,
args.alt or ((args.label or mw.title.getCurrentTitle()currentTitle.text) .. ' seis nahajalocated vin ' .. map('name')),
args.maplink and ('|link=' .. args.maplink) or ''
)
if args.caption and args.caption ~= '' then
if (currentTitle.namespace == 0) and mw.ustring.find(args.caption, '##') then
retval = retval .. '[[KategorijaCategory:Strani,Pages kiusing uporabljajolocation lokacijskomap kartowith za dvojnimdouble številskimnumber znakomsign vin opisuthe caption]]'
end
end
if args.overlay_image then
return retval .. '<div style="position:absolute;top:0;left:0">[[File:' .. args.overlay_image .. '|' .. width .. 'px|class=notpageimage]]</div>'
else
return retval
Vrstica 238 ⟶ 236:
end
local retval = '</div>'
local currentTitle = mw.title.getCurrentTitle()
if not args.caption or args.border == 'infobox' then
if args.border then
retval = retval .. '<div style="padding-top:0.2em">'
else
retval = retval .. '<div style="font-size:9091%;padding-top:3px">'
end
retval = retval
.. (args.caption or (args.label or mw.title.getCurrentTitle()currentTitle.text) .. ' (' .. map('name') .. ')')
.. '</div>'
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">[[:File:' .. getContainerImage(args, map) .. '|class=notpageimage| ]]</div>' .. args.caption .. '</div>'
end
 
Vrstica 256 ⟶ 254:
retval = retval .. '<span class="switcher-label" style="display:none">' .. args.switcherLabel .. '</span>'
elseif args.autoSwitcherLabel then
retval = retval .. '<span class="switcher-label" style="display:none">Show map of ' .. map('name') .. '</span>'
end
Vrstica 267 ⟶ 265:
end
mw.logObject(args, 'args')
if currentTitle.namespace == 0 then
retval = retval .. '[[KategorijaCategory:LokacijskeLocation kartemaps zwith odstranjenimiremoved parametriparameters|caption_undefined]]'
end
end
if map('skew') ~= '' or map('lat_skew') ~= '' or map('crosses180') ~= '' or map('type') ~= '' then
mw.log('Removed parameter used in map definition ' .. map())
if currentTitle.namespace == 0 then
local key = (map('skew') ~= '' and 'skew' or '') ..
(map('lat_skew') ~= '' and 'lat_skew' or '') ..
(map('crosses180') ~= '' and 'crosses180' or '') ..
(map('type') ~= '' and 'type' or '')
retval = retval .. '[[KategorijaCategory:LokacijskeLocation kartemaps zwith odstranjenimiremoved parametriparameters|' .. key .. ' ]]'
end
end
if string.find(map('name'), '|', 1, true) then
mw.log('Pipe used in name of map definition ' .. map())
if currentTitle.namespace == 0 then
retval = retval .. '[[Kategorija:Lokacijske karte z imenom, ki vsebuje navpičnico]]'
retval = retval .. '[[Category:Location maps with a name containing a pipe]]'
end
end
if args.float == 'center' then
Vrstica 287 ⟶ 291:
end
 
local function markOuterDiv(x, y, imageDiv, labelDiv, label_size)
return mw.html.create('div')
:addClass('od')
:cssText('position:absolute;top:' .. round(y, 3) .. '%;left:' .. round(x, 3) .. '%')
:addClass('notheme') -- T236137
:cssText('position:absolute;top:' .. round(y, 3) .. '%;left:' .. round(x, 3) .. '%;font-size:' .. label_size .. '%')
:node(imageDiv)
:node(labelDiv)
Vrstica 296 ⟶ 302:
local function markImageDiv(mark, marksize, label, link, alt, title)
local builder = mw.html.create('div')
:addClass('id')
:cssText('position:absolute;left:-' .. round(marksize / 2) .. 'px;top:-' .. round(marksize / 2) .. 'px;line-height:0')
:attr('title', title)
if marksize ~= 0 then
builder:wikitext(string.format(
'[[File:%s|%dx%dpx|%s|link=%s%s|class=notpageimage]]',
mark,
marksize,
Vrstica 314 ⟶ 321:
local function markLabelDiv(label, label_size, label_width, position, background, x, marksize)
if tonumber(label_size) == 0 then
return mw.html.create('div'):cssTextaddClass('font-size:0%;position:absolutel0'):wikitext(label)
end
local builder = mw.html.create('div')
:cssText('font-size:' .. label_size .. '%;line-height:110%;position:absolute;width:' .. label_width .. 'em')
local distance = round(marksize / 2 + 1)
local spanCss
if position == 'top' then -- specified top
builder:addClass('pv'):cssText('bottom:' .. distance .. 'px;left:' .. (-label_width / 2) .. 'em;text-align:center')
elseif position == 'bottom' then -- specified bottom
builder:addClass('pv'):cssText('top:' .. distance .. 'px;left:' .. (-label_width / 2) .. 'em;text-align:center')
elseif position == 'left' or (tonumber(x) > 70 and position ~= 'right') then -- specified left or autodetected to left
builder:cssTextaddClass('toppl'):-0.75em;cssText('right:' .. distance .. 'px;text-align:right')
spanCss = 'float:right'
else -- specified right or autodetected to right
builder:cssTextaddClass('toppr'):-0.75em;cssText('left:' .. distance .. 'px;text-align:left')
spanCss = 'float:left'
end
builder = builder:tag('div')
:css('display', 'inline')
:cssText('padding:1px')
:cssText(spanCss)
:wikitext(label)
if background then
Vrstica 400 ⟶ 401:
end
local builder = mw.html.create()
local currentTitle = mw.title.getCurrentTitle()
if args.coordinates then
-- Temporarily removed to facilitate infobox conversion. See [[Wikipedia:Coordinates in infoboxes]]
 
-- if longitude or latitude then
-- error('Coordinates from [[ModulModule:Coordinates]] and individual coordinates cannot both be provided')
-- end
longitude = coord2text('longitude', args.coordinates)
Vrstica 414 ⟶ 417:
local value = entity.claims.P625[1].mainsnak.datavalue.value
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
Vrstica 421 ⟶ 427:
error('No value was provided for latitude')
end
if currentTitle.namespace > 0 then
local builder = mw.html.create()
if (not args.lon_deg) ~= (not args.lat_deg) then
builder:wikitext('[[KategorijaCategory:LokacijskeLocation kartemaps zwith različno natančnostjodifferent longitude inand latitude precisions|StopinjeDegrees]]')
elseif (not args.lon_min) ~= (not args.lat_min) then
builder:wikitext('[[KategorijaCategory:LokacijskeLocation kartemaps zwith različno natančnostjodifferent longitude inand latitude precisions|MinuteMinutes]]')
elseif (not args.lon_sec) ~= (not args.lat_sec) then
builder:wikitext('[[KategorijaCategory:LokacijskeLocation kartemaps zwith različno natančnostjodifferent longitude inand latitude precisions|SekundeSeconds]]')
elseif (not args.lon_dir) ~= (not args.lat_dir) then
builder:wikitext('[[KategorijaCategory:LokacijskeLocation kartemaps zwith različno natančnostjodifferent longitude inand latitude precisions|HemisferaHemisphere]]')
elseif (not args.long) ~= (not args.lat) then
builder:wikitext('[[KategorijaCategory:LokacijskeLocation kartemaps zwith različno natančnostjodifferent longitude inand latitude precisions|Decimal]]')
end
end
if ((tonumber(args.lat_deg) or 0) < 0) and ((tonumber(args.lat_min) or 0) ~= 0 or (tonumber(args.lat_sec) or 0) ~= 0 or (args.lat_dir and args.lat_dir ~='')) then
builder:wikitext('[[Category:Location maps with negative degrees and minutes or seconds]]')
end
if ((tonumber(args.lon_deg) or 0) < 0) and ((tonumber(args.lon_min) or 0) ~= 0 or (tonumber(args.lon_sec) or 0) ~= 0 or (args.lon_dir and args.lon_dir ~= '')) then
builder:wikitext('[[Category:Location maps with negative degrees and minutes or seconds]]')
end
if (((tonumber(args.lat_min) or 0) < 0) or ((tonumber(args.lat_sec) or 0) < 0)) then
builder:wikitext('[[Category:Location maps with negative degrees and minutes or seconds]]')
end
if (((tonumber(args.lon_min) or 0) < 0) or ((tonumber(args.lon_sec) or 0) < 0)) then
builder:wikitext('[[Category:Location maps with negative degrees and minutes or seconds]]')
end
if args.skew or args.lon_shift or args.markhigh then
Vrstica 440 ⟶ 459:
end
mw.logObject(args, 'args')
if currentTitle.namespace == 0 then
local key = (args.skew and 'skew' or '') ..
local key = (args.lon_shiftskew and 'lon_shiftskew' or '') ..
(args.markhighlon_shift and 'markhighlon_shift' or '') ..
local key = (args.skewmarkhigh and 'skewmarkhigh' or '') ..
builder:wikitext('[[KategorijaCategory:LokacijskeLocation kartemaps zwith odstranjenimiremoved parametriparameters|' .. key ..' ]]')
end
end
if map('x') ~= '' then
Vrstica 462 ⟶ 483:
end
mw.logObject(args, 'args')
if currentTitle.namespace == 0 then
local key = frame:preprocess('{{FULLPAGENAME}}')
local key = currentTitle.prefixedText
builder:wikitext('[[Kategorija:Lokacijske karte z oznako izven zemljevida in brez nastavljenega parametra outside|' .. key .. ' ]]')
builder:wikitext('[[Category:Location maps with marks outside map and outside parameter not set|' .. key .. ' ]]')
end
end
local mark = args.mark or map('mark')
Vrstica 471 ⟶ 494:
local marksize = tonumber(args.marksize) or tonumber(map('marksize')) or 8
local imageDiv = markImageDiv(mark, marksize, args.label or mw.title.getCurrentTitle().text, args.link or '', args.alt, args[2])
local label_size = args.label_size or 91
local labelDiv
if args.label and args.position ~= 'none' then
labelDiv = markLabelDiv(args.label, args.label_size or 90, args.label_width or 6, args.position, args.background, x, marksize)
end
return builder:node(markOuterDiv(x, y, imageDiv, labelDiv, label_size))
end