PATCH: produce xhtml output and get rid of evilsedhack
- From: James Henstridge <james jamesh id au>
- To: gnome-web-list gnome org
- Subject: PATCH: produce xhtml output and get rid of evilsedhack
- Date: Thu, 17 Mar 2005 21:42:56 +0800
Attached is a patch for gnomeweb-wml, that replaces evilsedhack with a
small XSLT transformation. This has a number of benefits:
1. author pages in HTML, publish in XHTML. Libxslt's serialisation
routines follow the HTML compatibility rules, so the output can be
treated as HTML too.
2. If the HTML page is not in UTF-8, libxml will transcode it on
input so the output will be UTF-8.
3. Uses the exslt date functions to output the copyright year, so we
don't have to remember to update it each year :)
Some downsides include:
1. if no <meta http-equiv="content-type"> tag is in the source HTML,
libxml will assume it is latin-1.
2. makes the website build depend on libxml2/libxslt
3. is a little more resource intensive than sed (not enormously though).
(1) was an obvious problem for the translated versions of the Gnome 2.10
press release, which I've corrected in the attached patch. I haven't
checked to see if other files are affected.
While this isn't adding much new right now, it should also make it
easier to customise things in the future (it should also result in less
of those "optimised for standards" links spitting out lots of errors ...)
James.
--- /dev/null 2005-03-08 01:58:00.447627904 +0800
+++ include/add-header.xsl 2005-03-17 17:47:21.159255728 +0800
@@ -0,0 +1,119 @@
+<?xml version="1.0"?>
+<!DOCTYPE xsl:stylesheet [
+ <!ENTITY copy "©" >
+ <!ENTITY middot "·" >
+]>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:date="http://exslt.org/dates-and-times"
+ version="1.0" extension-element-prefixes="date">
+
+ <!-- using encoding="US-ASCII" would make the output compatible with
+ both ISO-8859-1 and UTF-8 -->
+ <xsl:output method="xml" encoding="UTF-8" indent="yes"
+ omit-xml-declaration="yes"
+ doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
+ doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" />
+
+ <xsl:template match="html">
+ <html xmlns="http://www.w3.org/1999/xhtml">
+ <xsl:copy-of select="@*" />
+ <xsl:apply-templates />
+ </html>
+ </xsl:template>
+
+ <xsl:template match="head">
+ <head xmlns="http://www.w3.org/1999/xhtml">
+ <link rel="stylesheet" type="text/css" href="/default.css" />
+ <link rel="icon" type="image/png" href="/img/logo/foot-16.png" />
+ <xsl:copy-of select="@*" />
+ <xsl:apply-templates select="node()" />
+ </head>
+ </xsl:template>
+
+ <xsl:template match="body">
+ <body xmlns="http://www.w3.org/1999/xhtml">
+ <div id="body">
+ <xsl:copy-of select="@*" />
+ <xsl:apply-templates select="node()" />
+ </div>
+ <div id="sidebar">
+ <p class="section">Users</p>
+ <ul>
+ <li><b><a href="/about/">What is GNOME?</a></b></li>
+ <li><a href="/start/stable/">Download</a></li>
+ <!--<li><a href="/start/">Get Involved!</a></li>-->
+ <li><a href="http://www.gnomedesktop.org/">Community News</a></li>
+ <li><a href="/softwaremap/">Software Map</a></li>
+ <li><a href="http://foundation.gnome.org/">Foundation</a></li>
+ <li><a href="/press/">Press</a></li>
+ <li><a href="/contact/">Contact</a></li>
+ </ul>
+
+ <p class="section">Developers</p>
+ <ul>
+ <li><a href="http://developer.gnome.org/">Developer Site</a></li>
+ <li><a href="http://mail.gnome.org/">Mailing Lists</a></li>
+ <li><a href="http://bugzilla.gnome.org/">Bugzilla</a></li>
+ <li><a href="http://cvs.gnome.org/lxr/">LXR</a></li>
+ <li><a href="http://cvs.gnome.org/bonsai/">Bonsai</a></li>
+ </ul>
+ </div>
+
+ <div id="hdr">
+ <div id="logo"><a href="/"><img src="/img/spacer" alt="Home" /></a></div>
+ <div id="banner"><img src="/img/spacer" alt="" /></div>
+ <p class="none"></p>
+ <div id="hdrNav">
+ <a href="/about/">About GNOME</a> ·
+ <a href="/start/stable/">Download</a> ·
+ <!--<a href="/start/"><i>Get Involved!</i></a> ·-->
+ <a href="/"><b>Users</b></a> ·
+ <a href="http://art.gnome.org/">Art & Themes</a> ·
+ <a href="http://developer.gnome.org/">Developers</a> ·
+ <a href="http://foundation.gnome.org/">Foundation</a> ·
+ <a href="/contact/">Contact</a>
+ </div>
+ </div>
+
+ <div id="copyright">
+ Copyright © <xsl:value-of select="date:year()" />,
+ <a href="http://www.gnome.org/">The GNOME Project</a>.<br />
+ <a href="http://validator.w3.org/check/referer">Optimised</a> for
+ <a href="http://www.w3.org/">standards</a>.
+ Hosted by <a href="http://www.redhat.com/">Red Hat</a>.
+ </div>
+ </body>
+ </xsl:template>
+
+ <!-- copy elements, adding the XHTML namespace to elements with an
+ empty namespace URI -->
+ <xsl:template match="*">
+ <xsl:choose>
+ <xsl:when test="namespace-uri() = ''">
+ <xsl:element namespace="http://www.w3.org/1999/xhtml"
+ name="{local-name()}">
+ <xsl:copy-of select="@*" />
+ <xsl:apply-templates select="node()" />
+ </xsl:element>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:copy>
+ <xsl:copy-of select="@*" />
+ <xsl:apply-templates select="node()" />
+ </xsl:copy>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <!-- get rid of processing instructions -->
+ <xsl:template match="processing-instruction()">
+ </xsl:template>
+
+ <!-- copy everything else -->
+ <xsl:template match="node()" priority="-1">
+ <xsl:copy>
+ <xsl:apply-templates select="node()" />
+ </xsl:copy>
+ </xsl:template>
+
+</xsl:stylesheet>
Index: rules.common
===================================================================
RCS file: /cvs/gnome/gnomeweb-wml/rules.common,v
retrieving revision 1.15
diff -u -p -r1.15 rules.common
--- rules.common 27 Oct 2003 11:08:34 -0000 1.15
+++ rules.common 17 Mar 2005 09:51:50 -0000
@@ -13,8 +13,8 @@ CLEANFILES = $(BUILT_SOURCES)
# Interesting target stuff
-%.html %.shtml %.php3 %.php %.phtml: %.wml $(top_srcdir)/include/evilsedhack
- @$(top_srcdir)/include/evilsedhack $< $(HTTP_PREFIX)/$(SITE) > $@
+%.html %.shtml %.php3 %.php %.phtml: %.wml $(top_srcdir)/include/add-header.xsl
+ @xsltproc -html $(top_srcdir)/include/add-header.xsl $< > $@
.htaccess: htaccess
@sed -e "s,@SITE@,$(HTTP_PREFIX)/$(SITE),g;s,@pagedir@,$(pagedir),g" $< > $@
Index: www.gnome.org/press/releases/gnome210_press_release.da.wml
===================================================================
RCS file: /cvs/gnome/gnomeweb-wml/www.gnome.org/press/releases/gnome210_press_release.da.wml,v
retrieving revision 1.1
diff -u -p -r1.1 gnome210_press_release.da.wml
--- www.gnome.org/press/releases/gnome210_press_release.da.wml 9 Mar 2005 14:44:23 -0000 1.1
+++ www.gnome.org/press/releases/gnome210_press_release.da.wml 17 Mar 2005 09:51:50 -0000
@@ -1,8 +1,8 @@
-<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html>
+<html lang="da">
<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>GNOME press releases</title>
<meta name="cvsdate" content="$Id: gnome210_press_release.da.wml,v 1.1 2005/03/09 14:44:23 jdub Exp $" />
</head>
Index: www.gnome.org/press/releases/gnome210_press_release.de.wml
===================================================================
RCS file: /cvs/gnome/gnomeweb-wml/www.gnome.org/press/releases/gnome210_press_release.de.wml,v
retrieving revision 1.1
diff -u -p -r1.1 gnome210_press_release.de.wml
--- www.gnome.org/press/releases/gnome210_press_release.de.wml 9 Mar 2005 14:44:23 -0000 1.1
+++ www.gnome.org/press/releases/gnome210_press_release.de.wml 17 Mar 2005 09:51:50 -0000
@@ -1,8 +1,8 @@
-<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html>
+<html lang="de">
<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>GNOME press releases</title>
<meta name="cvsdate" content="$Id: gnome210_press_release.de.wml,v 1.1 2005/03/09 14:44:23 jdub Exp $" />
</head>
Index: www.gnome.org/press/releases/gnome210_press_release.el.wml
===================================================================
RCS file: /cvs/gnome/gnomeweb-wml/www.gnome.org/press/releases/gnome210_press_release.el.wml,v
retrieving revision 1.1
diff -u -p -r1.1 gnome210_press_release.el.wml
--- www.gnome.org/press/releases/gnome210_press_release.el.wml 9 Mar 2005 14:44:23 -0000 1.1
+++ www.gnome.org/press/releases/gnome210_press_release.el.wml 17 Mar 2005 09:51:50 -0000
@@ -1,8 +1,8 @@
-<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html>
+<html lang="el">
<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>GNOME press releases</title>
<meta name="cvsdate" content="$Id: gnome210_press_release.el.wml,v 1.1 2005/03/09 14:44:23 jdub Exp $" />
</head>
Index: www.gnome.org/press/releases/gnome210_press_release.fr.wml
===================================================================
RCS file: /cvs/gnome/gnomeweb-wml/www.gnome.org/press/releases/gnome210_press_release.fr.wml,v
retrieving revision 1.1
diff -u -p -r1.1 gnome210_press_release.fr.wml
--- www.gnome.org/press/releases/gnome210_press_release.fr.wml 9 Mar 2005 14:44:23 -0000 1.1
+++ www.gnome.org/press/releases/gnome210_press_release.fr.wml 17 Mar 2005 09:51:51 -0000
@@ -1,8 +1,8 @@
-<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html>
+<html lang="fr">
<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>GNOME press releases</title>
<meta name="cvsdate" content="$Id: gnome210_press_release.fr.wml,v 1.1 2005/03/09 14:44:23 jdub Exp $" />
</head>
Index: www.gnome.org/press/releases/gnome210_press_release.mk.wml
===================================================================
RCS file: /cvs/gnome/gnomeweb-wml/www.gnome.org/press/releases/gnome210_press_release.mk.wml,v
retrieving revision 1.1
diff -u -p -r1.1 gnome210_press_release.mk.wml
--- www.gnome.org/press/releases/gnome210_press_release.mk.wml 9 Mar 2005 14:44:23 -0000 1.1
+++ www.gnome.org/press/releases/gnome210_press_release.mk.wml 17 Mar 2005 09:51:51 -0000
@@ -1,8 +1,8 @@
-<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html>
+<html lang="mk">
<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>GNOME press releases</title>
<meta name="cvsdate" content="$Id: gnome210_press_release.mk.wml,v 1.1 2005/03/09 14:44:23 jdub Exp $" />
</head>
Index: www.gnome.org/press/releases/gnome210_press_release.nl.wml
===================================================================
RCS file: /cvs/gnome/gnomeweb-wml/www.gnome.org/press/releases/gnome210_press_release.nl.wml,v
retrieving revision 1.1
diff -u -p -r1.1 gnome210_press_release.nl.wml
--- www.gnome.org/press/releases/gnome210_press_release.nl.wml 9 Mar 2005 14:44:23 -0000 1.1
+++ www.gnome.org/press/releases/gnome210_press_release.nl.wml 17 Mar 2005 09:51:51 -0000
@@ -1,8 +1,8 @@
-<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html>
+<html lang="nl">
<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>GNOME press releases</title>
<meta name="cvsdate" content="$Id: gnome210_press_release.nl.wml,v 1.1 2005/03/09 14:44:23 jdub Exp $" />
</head>
Index: www.gnome.org/press/releases/gnome210_press_release.pa.wml
===================================================================
RCS file: /cvs/gnome/gnomeweb-wml/www.gnome.org/press/releases/gnome210_press_release.pa.wml,v
retrieving revision 1.1
diff -u -p -r1.1 gnome210_press_release.pa.wml
--- www.gnome.org/press/releases/gnome210_press_release.pa.wml 9 Mar 2005 14:44:23 -0000 1.1
+++ www.gnome.org/press/releases/gnome210_press_release.pa.wml 17 Mar 2005 09:51:51 -0000
@@ -1,8 +1,8 @@
-<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html>
+<html lang="pa">
<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>GNOME press releases</title>
<meta name="cvsdate" content="$Id: gnome210_press_release.pa.wml,v 1.1 2005/03/09 14:44:23 jdub Exp $" />
</head>
Index: www.gnome.org/press/releases/gnome210_press_release.pt_BR.wml
===================================================================
RCS file: /cvs/gnome/gnomeweb-wml/www.gnome.org/press/releases/gnome210_press_release.pt_BR.wml,v
retrieving revision 1.1
diff -u -p -r1.1 gnome210_press_release.pt_BR.wml
--- www.gnome.org/press/releases/gnome210_press_release.pt_BR.wml 9 Mar 2005 14:44:23 -0000 1.1
+++ www.gnome.org/press/releases/gnome210_press_release.pt_BR.wml 17 Mar 2005 09:51:51 -0000
@@ -1,8 +1,8 @@
-<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html>
+<html lang="pt-BR">
<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>GNOME press releases</title>
<meta name="cvsdate" content="$Id: gnome210_press_release.pt_BR.wml,v 1.1 2005/03/09 14:44:23 jdub Exp $" />
</head>
Index: www.gnome.org/press/releases/gnome210_press_release.sq.wml
===================================================================
RCS file: /cvs/gnome/gnomeweb-wml/www.gnome.org/press/releases/gnome210_press_release.sq.wml,v
retrieving revision 1.1
diff -u -p -r1.1 gnome210_press_release.sq.wml
--- www.gnome.org/press/releases/gnome210_press_release.sq.wml 9 Mar 2005 14:44:23 -0000 1.1
+++ www.gnome.org/press/releases/gnome210_press_release.sq.wml 17 Mar 2005 09:51:51 -0000
@@ -1,8 +1,8 @@
-<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html>
+<html lang="sq">
<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>GNOME press releases</title>
<meta name="cvsdate" content="$Id: gnome210_press_release.sq.wml,v 1.1 2005/03/09 14:44:23 jdub Exp $" />
</head>
Index: www.gnome.org/press/releases/gnome210_press_release.th.wml
===================================================================
RCS file: /cvs/gnome/gnomeweb-wml/www.gnome.org/press/releases/gnome210_press_release.th.wml,v
retrieving revision 1.2
diff -u -p -r1.2 gnome210_press_release.th.wml
--- www.gnome.org/press/releases/gnome210_press_release.th.wml 12 Mar 2005 14:33:50 -0000 1.2
+++ www.gnome.org/press/releases/gnome210_press_release.th.wml 17 Mar 2005 09:51:51 -0000
@@ -1,8 +1,8 @@
-<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html>
+<html lang="th">
<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>GNOME press releases</title>
<meta name="cvsdate" content="$Id: gnome210_press_release.th.wml,v 1.2 2005/03/12 14:33:50 murrayc Exp $" />
</head>
Index: www.gnome.org/press/releases/gnome210_press_release.wml
===================================================================
RCS file: /cvs/gnome/gnomeweb-wml/www.gnome.org/press/releases/gnome210_press_release.wml,v
retrieving revision 1.2
diff -u -p -r1.2 gnome210_press_release.wml
--- www.gnome.org/press/releases/gnome210_press_release.wml 17 Mar 2005 06:15:18 -0000 1.2
+++ www.gnome.org/press/releases/gnome210_press_release.wml 17 Mar 2005 09:51:51 -0000
@@ -1,8 +1,8 @@
-<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html>
+<html lang="en">
<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>GNOME press releases</title>
<meta name="cvsdate" content="$Id: gnome210_press_release.wml,v 1.2 2005/03/17 06:15:18 jamesh Exp $" />
</head>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]