![]() | This module depends on the following other modules: |
Implements {{English Heritage listed building row}}
Usage
{{#invoke:English Heritage listed building|row}}
local p = {}
local getArgs = require('Module:Arguments').getArgs;
local yesno = require('Module:Yesno');
local delink = require('Module:Delink')._delink
local function notBlank(var)
return (var or '') ~= ''
end
local function NHLE(num)
return '[https://HistoricEngland.org.uk/listing/the-list/list-entry/' ..
num .. ' ' .. num .. ']'
end
local function UploadCampaignLink(args)
return '[[File:Missing-monuments-image.svg|60px|link=]]<br/>[https://commons.wikimedia.org/w/index.php?title=Special:UploadWizard&campaign=wlm-gb-eng&id=' ..
mw.uri.encode(args.uid or '') .. '&id2=&descriptionlang=en&description=' ..
mw.uri.encode(notBlank(args.upload_desc) and args.upload_desc or delink(args.name)) ..
'&lat=' .. (args.lat or '') .. '&lon=' .. (args.lon or '') .. '&categories= Upload Photo]'
end
function p.row(frame)
local args = getArgs(frame)
local out = {'|- class="vcard ',
(notBlank(args.image) and 'with_image' or 'without_image'),
'"\n! scope="row" class="fn org" | ',
(args.name or '')}
if yesno(args.show_grade) then
local grades = {I = 1, ['1'] = 1, ['II*'] = 2, ['2*'] = 2, II = 3, ['2'] = 3}
local gradeNames = {'I', 'II*', 'II'}
local gradeColours = {'FFC0CB', '87CEEB', 'ACE1AF'}
local gradeNum = grades[string.upper(args.grade)]
local div = ' |<div class="center" style="width:auto; margin-left:auto; margin-right:auto;">'
if gradeNum then
table.insert(out,'|| style="background-color: #' .. gradeColours[gradeNum] .. '"' ..
div ..
'<span data-sort-value="' .. mw.text.encode(gradeNum .. ' !') .. '">' ..
gradeNames[gradeNum] ..'</span></div>')
else
table.insert(out,'|| ' .. div .. '</div>')
end
end
table.insert(out, '\n| class="label" | ' .. (args.location or '') ..
' || class="category" | ' .. (args.type or '') ..
(yesno(args.show_architect) and ('|| ' .. (args.architect or '')) or '') ..
' || ' .. (args.completed or '') ..
(yesno(args.show_listed) and ('|| ' .. (args.date_listed or '')) or '') ..
' || ')
if notBlank(args.grid_ref) then
local oscoord = require('Module:Ordnance Survey coordinates')._oscoord
table.insert(out, oscoord({args.grid_ref .. '_region:GB_scale:25000',
args.grid_ref,
name = delink({args.name})}))
end
if notBlank(args.lat) and notBlank(args.lon) then
if notBlank(args.grid_ref) then table.insert(out, '<br />') end
local coord = require('Module:Coordinates')._coord;
table.insert(out, coord({args.lat, args.lon, 'region:GB_type:landmark',
format = 'dms', display='inline', name = delink({args.name})}))
end
if yesno(args.show_notes) then
table.insert(out, '|| <span class="note">' .. (args.notes or '') .. '</span>')
end
table.insert(out, '\n| ')
if notBlank(args.uid) then
table.insert(out, '<span class="uid">' .. NHLE(args.uid) .. '</span>')
end
if notBlank(args.uid2) then
table.insert(out, '<br /><span class="uid">' .. NHLE(args.uid2) .. '</span>')
end
if yesno(args.show_img) then
table.insert(out, '|| ')
if notBlank(args.image) then
table.insert(out, '[[File:' .. args.image ..
'|150x150px|center|border|' .. args.name .. ']]')
if notBlank(args.commonscat) then
table.insert(out, '<div class="center" style="width:auto; margin-left:auto; margin-right:auto;">[[c:Category:' ..
args.commonscat .. '|More images]]</div>')
end
else
table.insert(out, 'style="vertical-align:center; text-align:center;" | ' ..
UploadCampaignLink(args))
end
end
if yesno(args.show_ref) then
table.insert(out, '|| ' .. (args.reference or ''))
end
if yesno(args.show_wikidata) then
table.insert(out, '|| ' ..
(notBlank(args.wikidata) and ('[[d:' .. args.wikidata .. '|' .. args.wikidata .. ']]') or '')
.. ' ')
end
return table.concat(out)
end
return p