Перейти к содержанию

Модуль:Monument kg

Материал из Wikivoyage

Для документации этого модуля может быть создана страница Модуль:Monument kg/doc

local p = {}

function p.monument(frame)

  local pArgs = frame:getParent().args
  local lang = pArgs['lang'] or 'ru' 
  local country = pArgs['country']
  local region = pArgs['region'] or ''
  local llanguage = 'kg'
  local campaign = 'wlm-kg' -- пока что нет такой
  local noupload = 'yes'
  local dcat = 'Cultural heritage monuments in Kyrgyzstan'
  
  local rcat = {
  	["Q9361"] = "Cultural heritage monuments in Bishkek",
  	["Q47282"] = "Cultural heritage monuments in Kyrgyzstan", --Ош
  	["Q487631"] = "Cultural heritage monuments in Kyrgyzstan", --Баткенская область
  	["Q487640"] = "Cultural heritage monuments in Kyrgyzstan", --Джалал-Абадская область
	["Q487413"] = "Cultural heritage monuments in Issyk-Kul Region",
  	["Q486375"] = "Cultural heritage monuments in Kyrgyzstan", --Нарынская область
  	["Q231987"] = "Cultural heritage monuments in Kyrgyzstan", --Ошская область
  	["Q109838"] = "Cultural heritage monuments in Kyrgyzstan", --Таласская область
	["Q486370"] = "Cultural heritage monuments in Chüy Region",
	[""] = "Cultural heritage monuments in Kyrgyzstan"
  }
  
  local t = ''

  local background_color = "#F8F8F8;"
  local mwl = mw.language.new( lang )
   
  local pArgs = frame:getParent().args
  local mtype = pArgs['type']
  local address = pArgs["address"]
  local alt = pArgs['alt']
  local author = pArgs["author"]
  local block = pArgs["block"]
  local commonscat = pArgs["commonscat"]
  local complex = pArgs["complex"]
  local description = pArgs["description"]
  local dismissed = pArgs["dismissed"]
  local district = pArgs["district"]
  local document = pArgs['document']
  local document2 = pArgs['document2']
  local image = (pArgs["image"] ~= "") and pArgs["image"] or 'Village without photo.svg'
  local knid = pArgs["knid"]
  local lat = pArgs["lat"]
  local long = pArgs["long"]
  local link = pArgs['link']
  local linkextra = pArgs["linkextra"]
  local municipality = pArgs["municipality"]
  local munid = pArgs["munid"]
  local name = pArgs["name"]
  local noupload = pArgs["noupload"]
  local precise = pArgs["precise"]
  local protection = pArgs["protection"]
  local region = pArgs["region"]
  local sobory = pArgs["sobory"]
  local status = pArgs["status"]
  local style = pArgs["style"]
  local temples = pArgs["temples"]
  local unesco = pArgs["unesco"]
  local wdid = pArgs["wdid"]
  local wiki = pArgs["wiki"]
  local wikivoyage = pArgs['wikivoyage']
  local year = pArgs["year"]

  values = {}

  local layout = require( "Module:Monument/layout" )

	t = t .. layout.monument_header(knid, "", image, "", background_color)
	
	local icon = ''
	local iconsize = '20'
	
	if mtype == 'architecture' then
	    icon = 'PorticoIcon.svg'
	elseif mtype == 'history' then
	    icon = 'HistoryIcon .svg'
	elseif mtype == 'archeology' then
	    icon = 'ArcheologyIcon .svg'
	    iconsize = '22'
	elseif mtype == 'monument' then
	    icon = 'MonumentIcon .svg'
	end
	
	t = t .. layout.monument_title(name, icon, iconsize)
	local full_address = ''
	local addressprecomma = ''
	  if municipality and municipality ~= '' then
	    full_address = full_address .. "''" .. municipality .. "''"
	    addressprecomma = ', '
	  end
	  if munid and munid ~= '' then
	    full_address = full_address .. layout.wikidatalink(munid, municipality)
	  end
	  if address and address ~= '' then
	    full_address = full_address .. addressprecomma .. address
	  end
	  
	t = t .. layout.makelabel("Адрес", full_address, "<br>") 
	t = t .. layout.makelabel("Номер объекта", '<span style="font-size:93%">' .. knid .. "</span>", "&nbsp;&nbsp;&nbsp;&nbsp;")
	local links = ''
	if wiki and wiki ~= '' then
	    links = links .. layout.wikipedialink(lang, wiki, "Статья в Википедии")
	end
	if commonscat and commonscat ~= '' then
	    links = links .. layout.commonslink(commonscat, "Категория на Викискладе")
	end
	if wdid and wdid ~= '' then
	  links = links .. layout.wikidatalink(wdid, "Элемент Викиданных")
	end
	if lat and lat ~= '' and long and long ~= '' then
	    links = links .. '&nbsp;' .. frame:extensionTag{ name = 'maplink',  content = [=[{
	"type": "Feature",
	"geometry": { "type": "Point", "coordinates": []=] .. long .. [=[, ]=] .. lat .. [=[] },
	}]=], args = { ["latitude"] = lat, ["longitude"] = long, ["zoom"] = 15} } .. '\n</div>'
	end    
	t = t .. layout.makelabel("Ссылки", links, "<br>") 
	t = t .. layout.makelabel("Описание", year, "<br>")
	if commonscat == '' then
	    if defaultcat == '' then
	        commonscat = dcat
	    else
	        commonscat = defaultcat
	    end
	end
	if lat ~= '' and long ~= '' then
	    t = t .. '<span class="coords" id="' .. lat .. '_' .. long .. '"></span>'
	end
	if document ~= '' then
			t = t .. layout.makeref(document)
	end
	--t = t .. layout.uploadlink(campaign, "Загрузить&nbsp;файл", wdid, "", name .. ": " .. municipality .. ", " .. address, commonscat)
	t = t .. layout.noupload()
	return t
end

return p;