docs-common/packaging/adaptive-index-html .cvsignore, NONE, 1.1 Makefile, NONE, 1.1 index.html.in, NONE, 1.1 mkindex, NONE, 1.1 mkindex.awk, NONE, 1.1 mkindex.map, NONE, 1.1

Tommy Reynolds (jtr) fedora-docs-commits at redhat.com
Tue Sep 19 01:13:06 UTC 2006


Author: jtr

Update of /cvs/docs/docs-common/packaging/adaptive-index-html
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv7681/docs-common/packaging/adaptive-index-html

Added Files:
	.cvsignore Makefile index.html.in mkindex mkindex.awk 
	mkindex.map 
Log Message:
Moving these scripts to the packaging directory; they don't make sense
here in the per-revision directory.



--- NEW FILE .cvsignore ---
*.swp


--- NEW FILE Makefile ---
# The values below will be overriden when this script is invoked from
# Makefile.common with the proper values.

PRI_LANG=en
OTHERS	=de ru it ja_JP pt_BR zh_CN

all::	index.html

index.html:: mkindex mkindex.awk mkindex.map index.html.in
	./mkindex -o $@ ${PRI_LANG} ${OTHERS}

clean::

distclean clobber:: clean
	${RM} index.html

view::	index.html
	htmlview index.html


--- NEW FILE index.html.in ---
<!--
	vim: ts=2 sw=2
  -->
<HTML>
<HEAD>
<SCRIPT language="javascript">
<!--
function getlanguage() {
	language=navigator.language.replace( /-/, "_");
	if( language == "" )	{
		language = "<pri_lang/>";
	}
	prefix = "<prefix/>";
	suffix = "<suffix/>";
	switch( language )	{
	default :
		middle = language;
		switch( middle )	{
			default:
				middle = "<pri_lang/>";
				break;
			<REMAP/>
		}
		break;
		//* These browser languages are directly supported
		<LANGS/>
	}
	window.location=prefix + middle + suffix;
}
// -->
</SCRIPT>
</HEAD>
<BODY onload="javascript:getlanguage();">
	<H1>Fedora Release Notes</H1>
	<PARA>
		In a moment, you should see the release notes in your language.
	</PARA>
	<PARA>
		Depending on your browser, we may not be able to determine the
		proper language to use.
	</PARA>
	<PARA>
		If there is any problem, choose from the list below.
	</PARA>
	<PARA>
		Use the links below to view the Feodra Release Notes in the language 
		of your choice.
	</PARA>
	<DL>
	<ITEMS/>
	</DL>
</BODY>
</HTML>


--- NEW FILE mkindex ---
#!/bin/bash
MYDIR=$(dirname $0)
ME=$(basename $0)
USAGE="usage: ${ME} [-o ofile] [-s skel] lang1 ... langN"

OFILE=
SKEL="${MYDIR}/index.html.in"
MAP="${MYDIR}/${ME}.map"

while getopts :m:s:o: c
do
	case "${c}" in
	s)	SKEL="${OPTARG}";;
	o)	OFILE="${OPTARG}";;
	*)
		echo "${ME}: unknown switch -${OPTARG}" >&2
		exit 1
	esac
done
shift $(expr ${OPTIND} - 1 )
if [ $# -eq 0 ]; then
	echo "${USAGE}" >&2
	exit 1
fi
if [ "${OFILE}" ]; then
	rm -f "${OFILE}"
	exec >"${OFILE}"
fi
LANGS="$@"
SCRIPT="${MYDIR}/${ME}.awk"
set -x
exec /bin/awk -f "${SCRIPT}" -v LANGS="${LANGS}" -v MAP="${MAP}" "${SKEL}"


--- NEW FILE mkindex.awk ---
function trim( s,	v )	{
	v = s
	sub( /^[ \t]*/, "", v )
	sub( /[ \t]*$/, "", v )
	return( v )
}
BEGIN	{
	prefix="/usr/share/doc/fedora-release-5/RELEASE-NOTES-";
	suffix=".html";
	nLangs = split( LANGS, langs );
	for( i = 1; i <= nLangs; ++i )	{
		lang = langs[ i ]
		loc = substr( lang, 1, 2 )
		shorts[ loc ] = lang
	}
	pri_lang = langs[ 1 ]
	# Read in the maps
	while( getline < MAP > 0 )	{
		sub( /#.*$/, "" )
		if( NF >= 2 )	{
			lang = $1
			pseudo = $2
			$1 = ""
			$2 = ""
			note = trim( $0 )
			pseudo2lang[ pseudo ] = lang
			notes[ lang ] = note
			printf "<!-- %s|%s|%s -->\n", lang, pseudo, note
		}
	}
}
# Perform our macro substitutions
{
	gsub( /<prefix\/>/, prefix )
	gsub( /<suffix\/>/, suffix )
	gsub( /<pri_lang\/>/, pri_lang )
}
# Fill in matches for our known ${LANGUAGES}
/<LANGS\/>/	{
	printf "\t// Attempt to match supported locales\n"
	for( i = 1; i <= nLangs; ++i )	{
		lang = langs[ i ]
		printf "\t<!-- %s:%s -->\n", lang, notes[ lang ]
		printf "\tcase \"%s\":\n", lang
		printf "\t\tbreak;\n"
	}
	next
}
# If ${LANGUAGES} matching fails, try to match the short form
/<REMAP\/>/	{
	printf "\t\t\t// Attempt to match generic locales\n"
	for( lang in pseudo2lang )	{
		found = 0
		for( i = 1; i <= nLangs; ++i )	{
			if( lang == langs[i] )	{
				found = 1
				break
			}
		}
		if( !found )	{
			printf "\t\t\tcase \"%s\":\n", lang
			printf "\t\t\t\t//* %s;\n", notes[ lang ]
			printf "\t\t\t\tmiddle = \"%s\";\n", pseudo2lang[ lang ]
			printf "\t\t\t\tbreak;\n"
		}
	}
	next
}
/<ITEMS\/>/	{
	for( i = 1; i <= nLangs; ++i )	{
		lang = langs[ i ]
		print "<DT><PARA>"
		printf "%s - ", lang
		if( lang in notes )	{
			print notes[ lang ]
		}
		if( lang in pseudo2lang )	{
			lang = pseudo2lang[ lang ]
		}
		url = prefix lang suffix
		print "</PARA></DT>"
		print "<DD>"
		printf "\t<a href=\"%s\">%s</a>\n", url, url
		print "</DD>"
	}
	next
}
{
	print
}


--- NEW FILE mkindex.map ---
# Map browser languages into known locales for the Release Notes
#
# Some browsers don't handle the ${LANG} environment very well, if at all.
# To try to accomodate them, we can try to map the "navigator.language"
# value reported by the browser into either the ${PRI_LANG} or ${OTHERS}
# value for which we have release notes.
#
# This isn't very robust, but it's a (perhaps, false) start.
#
# Hint: map the language to itself so you can provide notes
# ${LANG} BROWSER Notes
en	en_US	US English
ru	ru	Russian
de	de	German
it	it	Italian
ja_JP	ja_JP	Japanese
pt_BR	pt_BR	Portuguese (Brasilian)
zh_CN	zh_CN	Chinese (Simplified)




More information about the Fedora-docs-commits mailing list