Module:English Heritage listed building/sandbox

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 ' [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 grades = {i = 1, I = 1, ['1'] = 1, [1] = 1, ['ii*'] = 2, ['II*'] = 2, ['2*'] = 2, ii = 3, II = 3, ['2'] = 3, [2] = 3} local gradeNames = {'I', 'II*', 'II'} 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 gradeColour = '' local div = ' | ' if grades[args.grade] then if grades[args.grade] == 1 then gradeColour = 'FFC0CB' elseif grades[args.grade] == 2 then gradeColour = '87CEEB' else gradeColour = 'ACE1AF' end table.insert(out,'|| style="background-color: "#' .. 	gradeColour .. '"' ..				div ..				'' ..				gradeNames[grades[args.grade]] ..' ')		else			table.insert(out,'|| ' .. 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, ' ') 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, ' ' .. (args.notes or '') .. ' ') end table.insert(out, '\n| ') if notBlank(args.uid) then table.insert(out, ' ' .. NHLE(args.uid) .. ' ') end if notBlank(args.uid2) then table.insert(out, ' ' .. NHLE(args.uid2) .. ' ') end if yesno(args.show_img) then table.insert(out, '|| ') if notBlank(args.image) then table.insert(out,  .. args.image .. 				) if notBlank(args.commonscat) then table.insert(out, ' More images ') 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 ( .. args.wikidata .. ) or '')			.. ' ') end return table.concat(out) end

return p