분류:
Install PlaycityMap module
 
Install PlaycityMap module
 
12번째 줄: 12번째 줄:
end
end


local function buildEmbedUrl(args)
local function buildTagAttributes(args)
   local base = normalizeArg(args.base) or "https://maps.playcity.kr/embed"
  local attrs = {}
   local query = {}
   local base = normalizeArg(args.base)
  if base then
    attrs.base = base
   end
   if normalizeArg(args.mode) then
   if normalizeArg(args.mode) then
     query.mode = args.mode
     attrs.mode = args.mode
   end
   end
   if normalizeArg(args.x) then
   if normalizeArg(args.x) then
     query.x = args.x
     attrs.x = args.x
   end
   end
   if normalizeArg(args.z) then
   if normalizeArg(args.z) then
     query.z = args.z
     attrs.z = args.z
   end
   end
   if normalizeArg(args.center) then
   if normalizeArg(args.center) then
     query.center = args.center
     attrs.center = args.center
   end
   end
   if normalizeArg(args.zoom) then
   if normalizeArg(args.zoom) then
     query.zoom = args.zoom
     attrs.zoom = args.zoom
   end
   end
   local controlValue = normalizeArg(args.control) or normalizeArg(args.controls) or normalizeArg(args.interactive)
   local controlValue = normalizeArg(args.control) or normalizeArg(args.controls) or normalizeArg(args.interactive)
   if controlValue then
   if controlValue then
     query.control = controlValue
     attrs.control = controlValue
   end
   end
   if normalizeArg(args.marker) then
   if normalizeArg(args.marker) then
     query.marker = args.marker
     attrs.marker = args.marker
   end
   end
   if normalizeArg(args.hash) then
   if normalizeArg(args.hash) then
     query.hash = args.hash
     attrs.hash = args.hash
  end
 
  local qs = mw.uri.buildQueryString(query)
  if qs == "" then
    return base
   end
   end
   return base .. "?" .. qs
   attrs.width = normalizeArg(args.width) or "100%"
  attrs.height = normalizeArg(args.height) or "420"
  attrs.loading = normalizeArg(args.loading) or "lazy"
  attrs.referrerpolicy = normalizeArg(args.referrerpolicy) or "no-referrer-when-downgrade"
  return attrs
end
end


function p.embed(frame)
function p.embed(frame)
   local args = (frame.getParent and frame:getParent() or frame).args or {}
   local args = (frame.getParent and frame:getParent() or frame).args or {}
   local width = normalizeArg(args.width) or "100%"
   local tag = mw.html.create("playcitymap")
  local height = normalizeArg(args.height) or "420"
   local attrs = buildTagAttributes(args)
  local loading = normalizeArg(args.loading) or "lazy"
   for key, value in pairs(attrs) do
   local referrerpolicy = normalizeArg(args.referrerpolicy) or "no-referrer-when-downgrade"
     tag:attr(key, value)
 
  end
   local iframe = mw.html.create("iframe")
   return tostring(tag)
    :attr("src", buildEmbedUrl(args))
    :attr("width", width)
    :attr("height", height)
     :attr("loading", loading)
    :attr("referrerpolicy", referrerpolicy)
    :attr("allowfullscreen", "true")
    :css("border", "0")
 
   return tostring(iframe)
end
end


return p
return p

2025년 12월 19일 (금) 16:58 기준 최신판

이 모듈에 대한 설명문서는 모듈:PlaycityMap/설명문서에서 만들 수 있습니다

local p = {}

local function normalizeArg(value)
  if value == nil then
    return nil
  end
  local text = tostring(value)
  if text == "" then
    return nil
  end
  return text
end

local function buildTagAttributes(args)
  local attrs = {}
  local base = normalizeArg(args.base)
  if base then
    attrs.base = base
  end
  if normalizeArg(args.mode) then
    attrs.mode = args.mode
  end
  if normalizeArg(args.x) then
    attrs.x = args.x
  end
  if normalizeArg(args.z) then
    attrs.z = args.z
  end
  if normalizeArg(args.center) then
    attrs.center = args.center
  end
  if normalizeArg(args.zoom) then
    attrs.zoom = args.zoom
  end
  local controlValue = normalizeArg(args.control) or normalizeArg(args.controls) or normalizeArg(args.interactive)
  if controlValue then
    attrs.control = controlValue
  end
  if normalizeArg(args.marker) then
    attrs.marker = args.marker
  end
  if normalizeArg(args.hash) then
    attrs.hash = args.hash
  end
  attrs.width = normalizeArg(args.width) or "100%"
  attrs.height = normalizeArg(args.height) or "420"
  attrs.loading = normalizeArg(args.loading) or "lazy"
  attrs.referrerpolicy = normalizeArg(args.referrerpolicy) or "no-referrer-when-downgrade"
  return attrs
end

function p.embed(frame)
  local args = (frame.getParent and frame:getParent() or frame).args or {}
  local tag = mw.html.create("playcitymap")
  local attrs = buildTagAttributes(args)
  for key, value in pairs(attrs) do
    tag:attr(key, value)
  end
  return tostring(tag)
end

return p

분류