summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2011-02-25 14:53:40 +0000
committerrandomdan <randomdan@localhost>2011-02-25 14:53:40 +0000
commitde5c956f238430e3915600d790964fe97946b567 (patch)
treeb905a8287edcd0214d1ea9316851349d800e8b93
parentFinally convert ytfs to use boost stuff (untested, but it does build) (diff)
downloadgentoobrowse-de5c956f238430e3915600d790964fe97946b567.tar.bz2
gentoobrowse-de5c956f238430e3915600d790964fe97946b567.tar.xz
gentoobrowse-de5c956f238430e3915600d790964fe97946b567.zip
Build a common base for loading p2 xml scripts with proper error checking
Extend cgiAppEngine to be able to return data documents specifying an error (requires Apache 2.2.16 and to have filter-errordocs set) Allow cgi requests to return a default document, suitable for 'yes, I did that' type responses Updates to GentooBrowse to use these features
-rw-r--r--gentoobrowse/.htaccess1
-rw-r--r--gentoobrowse/.p2config2
-rw-r--r--gentoobrowse/present/ok.xml4
-rw-r--r--gentoobrowse/request/track.xml3
-rw-r--r--gentoobrowse/request/untrack.xml3
-rw-r--r--gentoobrowse/xslt/base.xslt2
-rw-r--r--gentoobrowse/xslt/error.xslt25
7 files changed, 31 insertions, 9 deletions
diff --git a/gentoobrowse/.htaccess b/gentoobrowse/.htaccess
index 9651de7..bcd3d7f 100644
--- a/gentoobrowse/.htaccess
+++ b/gentoobrowse/.htaccess
@@ -1,3 +1,4 @@
+SetEnv filter-errordocs
<Files "p2web">
sethandler fcgid-script
</Files>
diff --git a/gentoobrowse/.p2config b/gentoobrowse/.p2config
new file mode 100644
index 0000000..9adbd90
--- /dev/null
+++ b/gentoobrowse/.p2config
@@ -0,0 +1,2 @@
+errorcontenttype=text/xml-xslt
+errortransformstyle=xslt/error.xslt
diff --git a/gentoobrowse/present/ok.xml b/gentoobrowse/present/ok.xml
deleted file mode 100644
index 4abc040..0000000
--- a/gentoobrowse/present/ok.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<?xml version="1.0"?>
-<view name="ok" root="ok" contenttype="text/xml" xmlns:xi="http://www.w3.org/2001/XInclude"
- xmlns:project2="http://project2.randomdan.homeip.net" />
-
diff --git a/gentoobrowse/request/track.xml b/gentoobrowse/request/track.xml
index 8708daf..2043e80 100644
--- a/gentoobrowse/request/track.xml
+++ b/gentoobrowse/request/track.xml
@@ -1,6 +1,5 @@
<?xml version="1.0"?>
-<request name="track" present="ok" xmlns:xi="http://www.w3.org/2001/XInclude"
- xmlns:project2="http://project2.randomdan.homeip.net">
+<request name="track" xmlns:project2="http://project2.randomdan.homeip.net">
<project2:sqlcheck datasource="postgres-web" testOp="=" testValue="0" present="ok" name="checkNotTracked">
<message>Package already tracked</message>
<sql>
diff --git a/gentoobrowse/request/untrack.xml b/gentoobrowse/request/untrack.xml
index 6604151..ceac001 100644
--- a/gentoobrowse/request/untrack.xml
+++ b/gentoobrowse/request/untrack.xml
@@ -1,6 +1,5 @@
<?xml version="1.0"?>
-<request name="track" present="ok" xmlns:xi="http://www.w3.org/2001/XInclude"
- xmlns:project2="http://project2.randomdan.homeip.net">
+<request name="track" xmlns:project2="http://project2.randomdan.homeip.net">
<project2:sqltask datasource="postgres-web" name="addTrack">
<sql>
DELETE FROM user_packages
diff --git a/gentoobrowse/xslt/base.xslt b/gentoobrowse/xslt/base.xslt
index eecc5de..a17dea3 100644
--- a/gentoobrowse/xslt/base.xslt
+++ b/gentoobrowse/xslt/base.xslt
@@ -4,7 +4,7 @@
<xsl:output encoding="utf-8" method="xml" media-type="text/html" indent="yes"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" />
- <xsl:template match="/gentoo">
+ <xsl:template match="/*">
<html>
<head>
<link rel="stylesheet" href="/css/screen.css" type="text/css" />
diff --git a/gentoobrowse/xslt/error.xslt b/gentoobrowse/xslt/error.xslt
new file mode 100644
index 0000000..50b7777
--- /dev/null
+++ b/gentoobrowse/xslt/error.xslt
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
+ <xsl:import href="base.xslt" />
+ <xsl:output encoding="utf-8" method="xml" media-type="text/html" indent="yes"
+ doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
+ doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" />
+ <xsl:template name="head">
+ <title>Argh! Error! - Gentoo Browse</title>
+ <meta name="google-site-verification" content="f2uqzTiSxj7gbzzRzf4nOCB3WfQuWV9Knfjb9ju69jU" />
+ <meta name="description" content="Error" />
+ </xsl:template>
+ <xsl:template match="/error">
+ <h2>Error</h2>
+ <h3><xsl:value-of select="/error/type" /></h3>
+ <p><xsl:value-of select="/error/what" /></p>
+ </xsl:template>
+ <xsl:template match="/notfound">
+ <h2>Not found</h2>
+ <p>The resource at &quot;<xsl:value-of select="/notfound/resource" />&quot; could not be found.</p>
+ </xsl:template>
+ <xsl:template name="content">
+ <xsl:apply-templates select="/error" />
+ <xsl:apply-templates select="/notfound" />
+ </xsl:template>
+</xsl:stylesheet>