Модуль:Monument/layout

Материал из Wikivoyage

Модуль был создан для упрощения переиспользования и модификаций конструкций из шаблонов {{monument}} и {{natural monument}} и модулей monument, natural monument, natural monument wikidata (авторы — в истории соответствующих страниц). Пример использования — модуль monument uz.


local p = {}

function p.monument_header(id2, color2, imagelink, imagedesc, bgcolor)
  local id = id2 or ''
  local color = color2 or ''
  local imagelink = imagelink or 'Village without photo.svg|border'
  local imagedesc = imagedesk or 'Нет фото'
  local bgcolor = bgcolor or '#F8F8F8;'

  local tmp = ''
  if color ~= "" then
    tmp = 'style="color:' .. color .. ';"'
  end
  local t = [[{| id=]] .. id .. [[ class="monument" border=0 style="font-size:97%;width:100%;"
 |- valign="top" ]] .. tmp
  t = t .. '\n| width="160px" | ' .. '[[File:' .. imagelink .. '|150x150px|center|' .. imagedesc .. ']]'
  t = t .. '\n| style=" background-color:' .. bgcolor .. ' padding-left:10px;" valign="middle" | '
  return t
end

function p.monument_title(name, icon)
  local name = name or ''
  local icon = icon or "[[File:PorticoIcon.svg|20px|памятник архитектуры]] "
  local unesco = "no"
  local complex = "no"
  local alt = ""
  
  local t = ""
  if icon ~= '' then
    t = t .. icon
  end
  if unesco == 'yes' then
    t = t .. "[[File:Swedish world heritage sign.PNG|18px]] "
  end
  if complex == 'yes' then
    t = t .. '[[File:Location dot darkslategray.svg|10px|главный элемент комплекса]] '
  end
  t = t .. '<span class="monument-name" style="font-size:115%; font-weight:bold">'
  t = t .. name
  return t .. '</span><br>';
  
end

function p.makelabel(title, label, sep)
  return "''" .. title .. ":'' " .. label .. sep
end

function p.logolink(logo, link, text, size)
  return '&nbsp;[[File:' .. logo .. '|' .. size .. 'px|link=//' .. link .. '|' .. text .. ']]'
end

-- Часто встречающиеся варианты
function p.extcoords(link, name)
  return p.logolink("Map mag.png", link, name, "17")
end

function p.wikipedialink(lang, wiki, name)
  return p.logolink("Wikipedia-logo-v2.svg", lang .. '.wikipedia.org/wiki/' .. mw.uri.encode(wiki, "PATH"), name, "19")
end

function p.wikidatalink(wdid, name)
  return p.logolink("Wikidata-logo-without-paddings.svg", 'www.wikidata.org/wiki/' .. mw.uri.encode(wdid, "PATH"), name, "18")
end

function p.commonslink(cat, name)
  return p.logolink("Commons-logo.svg", 'commons.wikimedia.org/wiki/Category:' .. mw.uri.encode(cat, "PATH"), name, "13")
end

function p.externallink(link, name)
  return p.logolink("P geography 3 b.png", mw.uri.encode(link, "PATH"), name, "22")
end
 
-- Полоса загрузки
function p.uploadlink(campaign, uploadbtntext, uploadid, uploadid2, uploaddesc, uploadcat)
  local campaign = campaign or 'wlm-ru'
  local uploadbtntext = uploadbtntext or 'Загрузить&nbsp;фото'
  local uploadid = uploadid or ''
  local uploadid2 = uploadid2 or ''
  local uploaddesc = uploaddesc or ''
  local uploadcat = uploadcat or ''

  local t = ''
  if campaign ~= '' then
    t = t .. '\n| class="plainlinks" style="width:10%; text-align:center; vertical-align:middle; background-color:#FFFACD; padding:0 1em" '
    t = t .. "| [//commons.wikimedia.org/w/index.php?title=Special:UploadWizard&campaign=" .. mw.uri.encode(campaign, "PATH")
    t = t .. [[&id=]] .. mw.uri.encode(uploadid or '', "PATH")
    t = t .. [[&id2=]] .. mw.uri.encode(uploadid2 or '', "PATH")
    t = t .. [[&description=]] .. mw.uri.encode(uploaddesc, "PATH")
    t = t .. [[&categories=]] .. mw.uri.encode(uploadcat or '', "PATH")
    t = t .. '&uselang=ru <span class="mw-ui-button">' .. uploadbtntext .. '</span>]'
  end
  t = t .. "\n|}<hr>\n"
  return t
end

return p;