Для документации этого модуля может быть создана страница Модуль:Monument-test/doc
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 = '<span style="font-size:90%"><references>' local dt = '' for k, v in ipairs(pArgs) do dt = fdocs.federaldocuments(v) or '{{monument-documents/' .. tostring(dregion) .. '|' .. v ..'}}' t = t .. '<ref name="' .. v ..'">' .. dt .. '</ref>' end t = t .. '</references></span>' local attr = require("Module:Monument/attribution") if attr[dregion] then t = t .. [[ {| align="center" style="text-align:center; margin-top:20px; padding:5px; border:1px solid" | width="10%" | ]] .. '[[File:Spain traffic signal s12.svg|45px]]\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 = [[<div class="monument" border=0 style="font-size: 97%; position: relative; padding: 0 10% 0 160px; display: flex; flex-wrap: wrap; align-content: flex-start; ">]] .. tmp -- Изображение local imagelink = '[[File:Village without photo.svg|border|150x150px|center|Нет фото]]' if image and image ~= '' then imagelink = '[[File:' .. image .. '|150x150px|center|' .. name .. ']]' end t = t .. '\n<div 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</div><div style="display: flex; flex-wrap: wrap; align-content: flex-start; "><div style=" background-color:' .. background_color .. ' padding-left:10px;" valign="middle" > ' -- Архитектурный стиль if style and style ~= '' then t = t .. '<div style="text-align:center; position:relative; float:right; margin-top:-3px; background-color:#F0E68C; font-size: 150%; padding-left:10px; padding-right:10px"><abbr title="Памятник ' if style == 'конструктивизм' or style == 'Конструктивизм' then t = t.. 'советского авангарда">А' elseif style == 'модерн' or style == 'Модерн' then t = t.. 'модерна">М' else t = t .. '">' end t = t .. '</abbr></div>' end -- Иконка памятника t = t .. frame:expandTemplate{ title = 'Якорь', args = { knid } } if m_type == 'architecture' then t = t .. "[[File:PorticoIcon.svg|20px|памятник архитектуры]] " elseif m_type == 'history' then t = t .. "[[File:HistoryIcon .svg|18px|памятник истории]] " elseif m_type == 'archeology' then t = t .. "[[File:ArcheologyIcon .svg|22px|памятник археологии]] " elseif m_type == 'monument' then t = t .. "[[File:MonumentIcon .svg|20px|памятник монументального искусства]] " elseif m_type == 'settlement' then t = t .. "[[File:ArchitectureIcon .svg|20px|историческое поселение]] " end -- Название if unesco and unesco ~= '' then t = t .. "[[File:Swedish world heritage sign.PNG|18px]] " end if knid == complex then t = t .. '[[File:Location dot darkslategray.svg|10px|главный элемент комплекса]] ' end t = t .. '<span class="monument-name" style="font-size:115%; font-weight:bold">' if wikivoyage and wikivoyage ~= '' then t = t .. '[[File:Wikivoyage-logo.svg|15px]] [[' .. wikivoyage .. '|' .. name .. ']]' else t = t .. name end if alt and alt ~= '' then t = t .. ' / ' .. alt end t = t .. '</span><br>' -- Адрес t = t .. "''Адрес:'' " local addressprecomma = ''; if municipality and municipality ~= '' then t = t .. "''" .. municipality .. "''" addressprecomma = ', ' end if munid and munid ~= '' then t = t .. ' [[File:Wikidata-logo.svg|18px|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 .. '<br>' -- Номер t = t .. "''Номер объекта:'' " .. '<span style="font-size:93%"><span id="' .. knid .. '">' .. knid if not knid or knid == '' then t = t .. '<span style="color:red;">Не указан</span>' end if knid_new and knid_new ~= '' then t = t .. ' / <abbr title="15-значный номер в Едином государственном реестре">[https://ru_monuments.toolforge.org/get_info.php?id=' .. knid_new .. ' ' .. knid_new .. ']</abbr>' end if uid and uid ~= '' then t = t .. " / [[:wikipedia:uk:Вікіпедія:Вікі_любить_пам'ятки|" .. uid .. ']]' end t = t .. ' </span></span>' -- Ссылки (пробелы между ними???) t = t .. " ''Ссылки:'' " if lat and long and lat~= '' and long ~= '' then t = t .. ' [[File:Map mag.png|17px|link=//ru_monuments.toolforge.org/monmap/index.htm?lat=' .. lat .. '&long=' .. long .. '&zoom=14&layer=X&no-group-markers=true&name=' .. mw.uri.encode(mw.title.getCurrentTitle().fullText, "WIKI") .. '|Расположение на карте]]' if precise ~= 'yes' then t = t .. '<span style="color:#FF0000">!</span>' end end if wiki and wiki ~= '' then t = t .. ' [[File:Wikipedia-logo-v2.svg|19px|link=//ru.wikipedia.org/wiki/' .. mw.uri.encode(wiki, "PATH") .. '|Статья в Википедии]]' end if commonscat and commonscat ~= '' then t = t .. ' [[File:Commons-logo.svg|13px|link=//commons.wikimedia.org/wiki/Category:' .. mw.uri.encode(commonscat, "PATH") .. '|Категория на Викискладе]]' end if wdid and wdid ~= '' then t = t .. ' [[File:Wikidata-logo-without-paddings.svg|18px|link=//www.wikidata.org/wiki/' .. mw.uri.encode(wdid, "PATH") .. '|Элемент в Викиданных]]' end if sobory and sobory ~= '' then t = t .. ' [[Image:P geography 3 b.png|22px|link=https://sobory.ru/article/?object=' .. sobory .. '|Народный каталог православной архитектуры sobory.ru]]' end if temples and temples ~= '' then t = t .. ' [[Image:P geography 3 b.png|22px|link=http://temples.ru/card.php?ID=' .. temples .. '|Проект «Храмы России» temples.ru]]' end if link and link ~= '' then t = t .. ' [[Image:P geography 3 b.png|22px|link=' .. link .. '|Внешняя ссылка]]' end if linkextra and linkextra ~= '' then t = t .. ' [[Image:P geography 3 b.png|22px|link=' .. linkextra .. '|Внешняя ссылка]]' end t = t .. ' [[:commons:Category:WLM/' .. knid .. '|галерея]]' if mw.title.new('Passport_' .. knid .. '.pdf', 'File').exists == true then t = t .. ", [[:File:Passport_" .. knid .. ".pdf|паспорт объекта]]" end t = t .. "<br>" -- Год, автор 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</div><div 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 <span class="mw-ui-button">Загрузить фото</span>]' end t = t .. "\n</div></div></div><hr>" 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 = '<table>' local ccat = mw.loadData("Module:Monument/commonscat") for key, val in pairs(ccat) do for k1, v1 in pairs(val) do t = t .. '<tr><td>' .. key .. '</td><td>' .. k1 .. '</td><td>' .. v1 .. '</td></tr>' end end t = t .. '</table>' 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;