Участник:Lzhl/Модуль:Monument

Материал из Wikivoyage

local p = {}

function p.monument_documents(frame)

 local fdocs = require("Module:Monument/federal documents") -- Основные документы федерального уровня со страницы Модуль:Monument/federal documents
 local pArgs = frame:getParent().args
 local dregion = pArgs["region"]
 local t = '

Ошибка цитирования Тег <ref> с именем «' .. v ..'», определённый в <references>, не используется в предшествующем тексте.'

 local attr = require("Module:Monument/attribution")
 if attr[dregion] then
   t = t .. [[
-- Изображение local imagelink = '
Нет фото
Нет фото
'
 if image and image ~=  then
imagelink = '
' .. name .. '
' .. name .. '
'
 end 
 t = t .. '\n| width="160px" | ' .. imagelink

-- Цвет карточки

 local background_color = 
 local isofficial = 1  
 if knid and knid ~=  then
   if tonumber(knid) % 100000000 >= 40000000 and tonumber(knid) % 100000000 <= 49999999 then
     isofficial = 0
     if complex and complex ~=  then
       if complex == knid then
         background_color = "#cdeefe;"
       else
         background_color = "#ebf5f9;"
       end
     else
       background_color = "#f8f8ed;"
     end
     if m_type == 'settlement' then
       background_color = "#CDEEFE;"
     end
   else
     if complex and complex ~=  then
       if complex == knid then
         background_color = "#BAFFC1;"
       else
         background_color = "#E1FFE4;"
       end
     else
       background_color = "#F8F8F8;"
     end
     if m_type == 'settlement' then
       background_color = "#BAFFC1;"
     end
   end
 end
 t = t .. '\n| style=" background-color:' .. background_color .. ' padding-left:10px;" valign="middle" | '

-- Архитектурный стиль

 if style and style ~=  then
t = t .. '
А'
   elseif style == 'модерн' or style == 'Модерн' then
     t = t.. 'модерна">М'
   else
     t = t .. '">'
   end
t = t .. '
'
 end

-- Иконка памятника

 t = t .. frame:expandTemplate{ title = 'Якорь', args = { knid } }
 if m_type == 'architecture' then
   t = t .. "памятник архитектуры "
 elseif m_type == 'history' then
   t = t .. "памятник истории "
 elseif m_type == 'archeology' then
   t = t .. "памятник археологии "
 elseif m_type == 'monument' then
   t = t .. "памятник монументального искусства "
 elseif m_type == 'settlement' then
   t = t .. "историческое поселение "
 end

-- Название

 if unesco and unesco ~=  then
   t = t .. " "
 end
 if knid == complex then
   t = t .. 'главный элемент комплекса '
 end
 t = t .. ''
 if wikivoyage and wikivoyage ~=  then
   t = t .. ' ' .. name .. ''
 else
   t = t .. name
 end
 if alt and alt ~=  then
   t = t .. ' / ' .. alt
 end
 t = t .. '
'

-- Адрес

 t = t .. "Адрес: "
 local addressprecomma = ;
 if municipality and municipality ~=  then
   t = t .. "" .. municipality .. ""
   addressprecomma = ', '
 end
 if munid and munid ~=  then
   t = t .. ' link=//wikidata.org/wiki/' .. mw.uri.encode(munid, "PATH") .. ''
 end
 if block and block ~=  then
   t = t .. ', квартал ' .. block
 end
 if address and address ~=  then
   t = t .. addressprecomma .. address
 end
 t = t .. '
'

-- Номер

 t = t .. "Номер объекта: " .. '' .. knid
 if not knid or knid ==  then
   t = t .. 'Не указан'
 end
 if knid_new and knid_new ~=  then
   t = t .. '  /  .. knid_new .. ' ' .. knid_new .. ''
 end
  if uid and uid ~=  then
   t = t .. "  /  " .. uid .. ''
 end
 t = t .. ' '

-- Ссылки (пробелы между ними???)

 t = t .. "   Ссылки: "
 if lat and long and lat~=  and long ~=  then
   t = t .. ' Расположение на карте'
   if precise ~= 'yes' then
     t = t .. '!'
   end 
 end
 if wiki and wiki ~=  then
   t = t .. ' Статья в Википедии'
 end
 if commonscat and commonscat ~=  then
   t = t .. ' Категория на Викискладе'
 end
 if wdid and wdid ~=  then
   t = t .. ' Элемент в Викиданных'
 end
 if sobory and sobory ~=  then
   t = t .. ' Народный каталог православной архитектуры sobory.ru'
 end
 if temples and temples ~=  then
   t = t .. ' Проект «Храмы России» temples.ru'
 end
 if link and link ~=  then
   t = t .. ' Внешняя ссылка'
 end
 if linkextra and linkextra ~=  then
   t = t .. ' Внешняя ссылка'
 end
 t = t .. ' галерея'
 if mw.title.new('Passport_' .. knid .. '.pdf', 'File').exists == true then
   t = t .. ", паспорт объекта"
 end
 t = t .. "
"

-- Год, автор

 t = t .. "Описание: "
 if year and year ~=  then
   t = t .. year
   if author and author ~=  then
     t = t .. ", " .. author .. "."
   end
   t = t .. " "
 elseif author and author ~=  then
   t = t .. author .. ". "
 end

-- Тип памятника и категория охраны

 typetext = {architecture1 = "Памятник архитектуры", 
             history1 = "Памятник истории", 
             archeology1 = "Памятник археологии", 
             monument1 = "Памятник монументального искусства",
             settlement1 = "Историческое поселение",
             architecture0 = "Обладает признаками памятника архитектуры, не охраняется государством", 
             history0 = "Обладает признаками памятника истории, не охраняется государством", 
             archeology0 = "Обладает признаками памятника археологии, не охраняется государством", 
             monument0 = "Обладает признаками памятника монументального искусства, не охраняется государством",
             settlement0 = "Обладает признаками исторического поселения, не охраняется государством"}
 t = t .. (typetext[(m_type or ) .. tostring(isofficial)] or )
 if protection == "Ф" then
   t = t .. " федерального значения."
 elseif protection == "Р" then
   t = t .. " регионального значения."
 elseif protection == "М" then
   t = t .. " местного значения."
 elseif protection == "В" then
   t = t .. ", выявленный."
 else
   t = t .. "."
 end

-- Документы, статус, описание

 if document and document ~=  then
   t = t .. frame:extensionTag{name = 'ref', , args = {name = document}}
 end
 if document2 and document2 ~=  then
   t = t .. frame:extensionTag{name = 'ref', , args = {name = document2}}
 end
 if status == "destroyed" then
   t = t .. " Утраченный."
 end
 if dismissed and dismissed ~= "" then
   t = t .. " Снят с охраны." .. frame:extensionTag{name = 'ref', , args = {name = dismissed}}
 end
 if unesco and unesco ~=  then
   local unesco_title = 
   if string.sub(unesco, 1, 1) == "Q" then
     unesco_title = mw.wikibase.getEntityObject(unesco).sitelinks['ruwiki'].title
   else
     local unesco_list = require("Module:Monument/unesco")
     unesco_title = unesco_list.unesco(unesco)
   end
   t = t .. " Входит в состав объекта Всемирного наследия ЮНЕСКО «" .. unesco_title .. "»."
 end
 if description and description ~= "" then
   if mw.ustring.sub(description, -1) ~= '.' then
     description = description .. '.'
   end
   t = t .. " " .. description
 end

-- Служебные категории

 if mw.title.getCurrentTitle().namespace == 0 then
   if pArgs["doc"] and pArgs["doc"] ~=  then
     t = t .. 
   end
   if not knid or knid ==  then
     t = t .. 
   end
 end

-- Ссылка на загрузку

 if noupload ~= 'yes' then
   t = t .. '\n| class="plainlinks" style="width:10%; text-align:center; vertical-align:middle; background-color:#FFFACD; padding:0 1em" '
   local campaign = "wlm-ru"
   if region == "ru-km" or region == "ru-sev" then
     campaign = "wlm-crimea"
   end
   t = t .. "| [//commons.wikimedia.org/w/index.php?title=Special:UploadWizard&campaign=" .. mw.uri.encode(campaign, "PATH")
     t = t .. &id= .. mw.uri.encode(knid or , "PATH")
   t = t .. &id2= .. mw.uri.encode(uid or , "PATH")
   local upload_desc = (mw.ustring.gsub(name, '"', )  or ) .. ": "
   if address and address ~=  then
     upload_desc = upload_desc .. address .. ", "
   end
   if municipality and municipality ~=  and (municipality or ) ~= (district or ) then
     upload_desc = upload_desc .. municipality .. ", "
   end
   if district and district ~=  then
     upload_desc = upload_desc .. district .. ", "
   end
   upload_desc = upload_desc .. (p.region_name(region) or )
   t = t .. &description= .. mw.uri.encode(upload_desc, "PATH")
   if not commonscat or commonscat ==  then
     local ccat = mw.loadData("Module:Monument/commonscat")
     if ccat[region] then
       commonscat = ccat[region][(district or ) .. '_' .. (municipality or )] or ccat[region][district] or ccat[region]["default"] 
     end
   end
   t = t .. &categories= .. mw.uri.encode(commonscat or , "PATH")
   t = t .. '&uselang=ru Загрузить фото]'
 end
t = t .. "\n|}
"
 return t

end

-- Названия региона по его коду

 function p.region_name(x)
   local regions = {["ru-ad"] = "Адыгея"

,["ru-ba"] = "Башкортостан" ,["ru-bu"] = "Бурятия" ,["ru-al"] = "Алтай" ,["ru-da"] = "Дагестан" ,["ru-in"] = "Ингушетия" ,["ru-kb"] = "Кабардино-Балкария" ,["ru-kl"] = "Калмыкия" ,["ru-kc"] = "Карачаево-Черкесия" ,["ru-krl"] = "Карелия" ,["ru-ko"] = "Республика Коми" ,["ru-me"] = "Марий Эл" ,["ru-mo"] = "Мордовия" ,["ru-sa"] = "Якутия (Саха)" ,["ru-se"] = "Северная Осетия" ,["ru-ta"] = "Татарстан" ,["ru-ty"] = "Тува" ,["ru-ud"] = "Удмуртия" ,["ru-kk"] = "Хакасия" ,["ru-ce"] = "Чеченская республика" ,["ru-chv"] = "Чувашия" ,["ru-alt"] = "Алтайский край" ,["ru-kda"] = "Краснодарский край" ,["ru-kya"] = "Красноярский край" ,["ru-pri"] = "Приморский край" ,["ru-sta"] = "Ставропольский край" ,["ru-kha"] = "Хабаровский край" ,["ru-amu"] = "Амурская область" ,["ru-ark"] = "Архангельская область" ,["ru-ast"] = "Астраханская область" ,["ru-bel"] = "Белгородская область" ,["ru-bry"] = "Брянская область" ,["ru-vla"] = "Владимирская область" ,["ru-vgg"] = "Волгоградская область" ,["ru-vol"] = "Вологодская область" ,["ru-vor"] = "Воронежская область" ,["ru-iva"] = "Ивановская область" ,["ru-irk"] = "Иркутская область" ,["ru-kal"] = "Калининградская область" ,["ru-klu"] = "Калужская область" ,["ru-kam"] = "Камчатский край" ,["ru-kem"] = "Кемеровская область" ,["ru-kir"] = "Кировская область" ,["ru-kos"] = "Костромская область" ,["ru-kgn"] = "Курганская область" ,["ru-krs"] = "Курская область" ,["ru-len"] = "Ленинградская область" ,["ru-lip"] = "Липецкая область" ,["ru-mag"] = "Магаданская область" ,["ru-mos"] = "Московская область" ,["ru-mur"] = "Мурманская область" ,["ru-niz"] = "Нижегородская область" ,["ru-ngr"] = "Новгородская область" ,["ru-nvs"] = "Новосибирская область" ,["ru-oms"] = "Омская область" ,["ru-ore"] = "Оренбургская область" ,["ru-orl"] = "Орловская область" ,["ru-pnz"] = "Пензенская область" ,["ru-per"] = "Пермский край" ,["ru-psk"] = "Псковская область" ,["ru-ros"] = "Ростовская область" ,["ru-rya"] = "Рязанская область" ,["ru-sam"] = "Самарская область" ,["ru-sar"] = "Саратовская область" ,["ru-sak"] = "Сахалинская область" ,["ru-sve"] = "Свердловская область" ,["ru-smo"] = "Смоленская область" ,["ru-tam"] = "Тамбовская область" ,["ru-tve"] = "Тверская область" ,["ru-tom"] = "Томская область" ,["ru-tul"] = "Тульская область" ,["ru-tyu"] = "Тюменская область" ,["ru-uly"] = "Ульяновская область" ,["ru-che"] = "Челябинская область" ,["ru-zab"] = "Забайкальский край" ,["ru-yar"] = "Ярославская область" ,["ru-mow"] = "Москва" ,["ru-spb"] = "Санкт-Петербург" ,["ru-jew"] = "Еврейская автономная область" ,["ru-km"] = "Крым" ,["ru-nen"] = "Ненецкий автономный округ" ,["ru-khm"] = "Ханты-Мансийский автономный округ" ,["ru-chu"] = "Чукотский автономный округ" ,["ru-yam"] = "Ямало-Ненецкий автономный округ" ,["ru-sev"] = "Севастополь"}

   return regions[x] or 
 end

-- Возможность вывода полного списка категорий из Monument/commonscat как таблицы function p.commonscatdistricts(frame)

t = '
]] .. '\n| '
   t = t .. attr[dregion]
   t = t .. '\n|}'
 end
 return frame:preprocess(t)

end

function p.monument(frame)

 local pArgs = frame:getParent().args

-- Технические ограничения на названия

 local knid_new = pArgs["knid-new"]
 local m_type = 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"]
 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 uid = pArgs["uid"]
 local unesco = pArgs["unesco"]
 local wdid = pArgs["wdid"]
 local wiki = pArgs["wiki"]
 local wikivoyage = pArgs['wikivoyage']
 local year = pArgs["year"]

-- Шапка

 local tmp = 
 if status == "destroyed" then
   tmp = 'style="color:#808080;"'
 end
 local t = [[{| class="monument" border=0 style="font-size:97%;width:100%;"
' local ccat = mw.loadData("Module:Monument/commonscat") for key, val in pairs(ccat) do for k1, v1 in pairs(val) do t = t .. ''

end end

t = t .. '
' .. key .. '' .. k1 .. '' .. v1 .. '

'

return t end

-- Возможность вывода полного списка категорий из Monument/commonscat в формате json function p.commonscatjson(frame) local ccat = mw.loadData("Module:Monument/commonscat") t = mw.text.jsonEncode(ccat) return t end

return p;