[BACK]Return to support.awk CVS log [TXT][DIR] Up to [local] / www / build

File: [local] / www / build / support.awk (download)

Revision 1.15, Mon May 27 22:55:27 2019 UTC (5 years ago) by bentley
Branch: MAIN
CVS Tags: HEAD
Changes since 1.14: +11 -14 lines

Substantially clean up and modernize HTML markup across openbsd.org.

This was done with three purposes in mind:
- to reduce the massive amount of inline HTML, to be easier on developers
  adding actual content
- to allow running the HTML validator across the source (doing this found
  many unintentional mistakes in the present code, including at least a
  dozen cases of half- or fully-invisible text)
- to separate content from presentation, so appearance can be controlled
  through stylesheets

Great care was taken to keep all pages, even very old ones, looking the
same, give or take a few pixels of whitespace.

Much review, critique, and improvement from tj@

#!/usr/bin/nawk -f

# Called from makefile to convert from support.dat to ../support.html

# convert data like this (order doesn't matter except 0 at front)
# 0
# C Erewhon
# P Ontario
# T Dictionopolis
# A R R # 1
# Z L0N 1P0
# O Consultant
# I Ian F. Darwin
# M ian@ougge.erewhon
# U http://www.ougge.erewhon/
# N Author of lots of kool stuff.

# into HTML to make nice neat tables.

/^#/ { next; }

$1 == "0" {
	if (country == "" && prov == "")
		next;
	dump();
	reset();
	next;
	}

$1 == "C" { country = substr($0, 3);
	if (country == "USA")
		country = "United States"
	else if (country == "UAE")
		country = "United Arab Emirates"
	if (country != oldCountry) {
		print "<tbody><tr><th colspan=\"2\""
		if (country == "United States") {
			n = split("USA", labels, " ")
		} else if (country == "United Arab Emirates") {
			n = split("UAE", labels, " ")
		} else {
			n = split(country, labels, " ")
		}
		print "id='" labels[1] "'>"
		print country
	 }
	oldCountry = country
	next
}
$1 == "P" { prov = substr($0, 3); next }
$1 == "T" { city = substr($0, 3); next }
$1 == "A" { addr = substr($0, 3); next }
$1 == "Z" { zip = substr($0, 3); next }
$1 == "O" { org = substr($0, 3); next }
$1 == "I" { indv = substr($0, 3); next }
$1 == "B" { phone = substr($0, 3); next }
$1 == "X" { fax = substr($0, 3); next }
$1 == "M" { email = substr($0, 3); next }
$1 == "U" { url = substr($0, 3); next }
$1 == "N" { note = substr($0, 3); next }
$1 == "F" { follow = substr($0, 3); next }

# left over - must be part of note?
	{
	note = note "\n" $0
	next
	}

function dump() {
	print "<tr>"
	print "<td>" 
		if (indv != "")
			print "<i>" indv "</i><br>" 
		if (org != "")
			print "<b>" org "</b><br>" 
		if (addr != "")
			print addr "<br>"
		line = ""
		if (city != "")
			line = city
		if (prov != "") {
			if (line == "")
				line = prov
			else
				line = line ", " prov
		}
		if (zip != "")
			line = line " " zip
		print line "<br>"
		if (phone != "")
			print "Phone: " phone "<br>" 
		if (fax != "")
			print "FAX: " fax "<br>"
		if (email != "")
			print "Email: <a href=\"mailto:" email "\">" email "</a>" "<br>"
		if (follow != "true")
			nofollow = " rel=\"nofollow\"";
		else
			nofollow = "";
		if (url != "")
			print "URL: <a href=\"" url "\"" nofollow ">" url "</a>"
	print "	<td>" note
}

function reset() {
	prov = ""
	city = ""
	addr = ""
	zip = ""
	org = ""
	indv = ""
	email = ""
	phone = ""
	fax = ""
	url = ""
	note = ""
	follow = ""
}

END {
	dump();		# don't forget the last guy!
}