summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2010-06-18 23:41:55 +0000
committerrandomdan <randomdan@localhost>2010-06-18 23:41:55 +0000
commiteba4ba19183d420426538c400f1c4c85cf0cdb9a (patch)
tree770482e08a2556ce88f2de6fe894bc64f2707fb0
parentUse last seen ebuild time instead of NOW() in newebuilds query (diff)
downloadgentoobrowse-eba4ba19183d420426538c400f1c4c85cf0cdb9a.tar.bz2
gentoobrowse-eba4ba19183d420426538c400f1c4c85cf0cdb9a.tar.xz
gentoobrowse-eba4ba19183d420426538c400f1c4c85cf0cdb9a.zip
Use cgicc, add checks, tasks, dynamic loader, atom feed, login page
-rw-r--r--gentoobrowse/atomebuilds.xslt31
-rw-r--r--gentoobrowse/datasources/postgres.xml4
-rw-r--r--gentoobrowse/login.xslt19
-rw-r--r--gentoobrowse/present/accountHome.xml4
-rw-r--r--gentoobrowse/present/atom.xml4
-rw-r--r--gentoobrowse/present/login.xml4
-rw-r--r--gentoobrowse/request/dologin.xml38
-rw-r--r--gentoobrowse/views/categories.xml7
-rw-r--r--gentoobrowse/views/category.xml7
-rw-r--r--gentoobrowse/views/newebuilds.xml6
-rw-r--r--gentoobrowse/views/package.xml27
-rw-r--r--gentoobrowse/views/search.xml7
12 files changed, 130 insertions, 28 deletions
diff --git a/gentoobrowse/atomebuilds.xslt b/gentoobrowse/atomebuilds.xslt
new file mode 100644
index 0000000..67a9fae
--- /dev/null
+++ b/gentoobrowse/atomebuilds.xslt
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+ <xsl:output encoding="utf-8" method="xml" media-type="text/xml" indent="yes"/>
+ <xsl:template match="/gentoo">
+ <rss version="2.0">
+ <xsl:apply-templates match="/gentoo/newebuilds" />
+ </rss>
+ </xsl:template>
+ <xsl:template match="/gentoo/newebuilds">
+ <channel>
+ <title>Gentoo Browse | New ebuilds</title>
+ <link>http://gentoobrowse.randomdan.homeip.net/</link>
+ <description>Unofficial Gentoo package browser</description>
+ <language>en-gb</language>
+ <lastBuildDate>Wed, 16 Jun 2010 14:52:43 GMT</lastBuildDate>
+ <copyright>Copyright: (C) Gentoo Foundation, Inc.</copyright>
+ <ttl>15</ttl>
+ <xsl:apply-templates match="/gentoo/newebuilds/ebuild" />
+ </channel>
+ </xsl:template>
+ <xsl:template match="/gentoo/newebuilds/ebuild">
+ <item>
+ <title><xsl:value-of select="filename" /></title>
+ <description><xsl:value-of select="description" /></description>
+ <link>http://gentoobrowse.randomdan.homeip.net/package/<xsl:value-of select="catname" />/<xsl:value-of select="pkgname" /></link>
+ <guid isPermaLink="false">http://gentoobrowse.randomdan.homeip.net/package/<xsl:value-of select="filename" /></guid>
+ <pubDate><xsl:value-of select="moddate" /></pubDate><!-- Wed, 16 Jun 2010 14:44:42 GMT -->
+ <category>ebuild</category>
+ </item>
+ </xsl:template>
+</xsl:stylesheet>
diff --git a/gentoobrowse/datasources/postgres.xml b/gentoobrowse/datasources/postgres.xml
index 0bb95f2..4e739f2 100644
--- a/gentoobrowse/datasources/postgres.xml
+++ b/gentoobrowse/datasources/postgres.xml
@@ -1,8 +1,8 @@
<?xml version="1.0"?>
-<rdbmsdatasource name="postgres">
+<project2:rdbmsdatasource xmlns:project2="http://project2.randomdan.homeip.net" name="postgres">
<readonly preferlocal="true">
<dsn>Driver=postgresql;Readonly=yes;ServerName=firebrand.random.lan;Username=gentoo;Database=gentoo;Password=gentoo;</dsn>
<dsn>Driver=postgresql;Readonly=yes;ServerName=defiant.random.lan;Username=gentoo;Database=gentoo;Password=gentoo;</dsn>
</readonly>
<masterdsn>Driver=postgresql;Readonly=no;ServerName=postgresql.random.lan;Username=gentoo;Database=gentoo;Password=gentoo;CPTimeOut=60</masterdsn>
-</rdbmsdatasource>
+</project2:rdbmsdatasource>
diff --git a/gentoobrowse/login.xslt b/gentoobrowse/login.xslt
index 4ea8536..ac1b651 100644
--- a/gentoobrowse/login.xslt
+++ b/gentoobrowse/login.xslt
@@ -1,7 +1,24 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:project2="http://project2.randomdan.homeip.net/" exclude-result-prefixes="project2" >
<xsl:import href="base.xslt" />
<xsl:output encoding="utf-8" method="html" media-type="text/html" indent="yes"
doctype-system="http://www.w3.org/TR/html4/loose.dtd"
doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN" />
+ <xsl:template name="content">
+ <h2>Login</h2>
+ <form action="/dologin" method="post">
+ <input type="text" name="username">
+ <xsl:attribute name="value">
+ <xsl:value-of select="/gentoo/project2:params/project2:param[@name='username']" />
+ </xsl:attribute>
+ </input>
+ <input type="password" name="password">
+ <xsl:attribute name="value">
+ <xsl:value-of select="/gentoo/project2:params/project2:param[@name='password']" />
+ </xsl:attribute>
+ </input>
+ <input type="submit" />
+ </form>
+ </xsl:template>
</xsl:stylesheet>
diff --git a/gentoobrowse/present/accountHome.xml b/gentoobrowse/present/accountHome.xml
new file mode 100644
index 0000000..00c239f
--- /dev/null
+++ b/gentoobrowse/present/accountHome.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0"?>
+<view name="index" root="gentoo" style="home.xslt" xmlns:xi="http://www.w3.org/2001/XInclude">
+</view>
+
diff --git a/gentoobrowse/present/atom.xml b/gentoobrowse/present/atom.xml
new file mode 100644
index 0000000..1bd5d24
--- /dev/null
+++ b/gentoobrowse/present/atom.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0"?>
+<view name="atomebuilds" root="gentoo" style="atomebuilds.xslt" xmlns:xi="http://www.w3.org/2001/XInclude">
+ <xi:include href="../views/newebuilds.xml" />
+</view>
diff --git a/gentoobrowse/present/login.xml b/gentoobrowse/present/login.xml
new file mode 100644
index 0000000..88da572
--- /dev/null
+++ b/gentoobrowse/present/login.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0"?>
+<view name="login" root="gentoo" style="login.xslt" xmlns:xi="http://www.w3.org/2001/XInclude">
+</view>
+
diff --git a/gentoobrowse/request/dologin.xml b/gentoobrowse/request/dologin.xml
new file mode 100644
index 0000000..315e65d
--- /dev/null
+++ b/gentoobrowse/request/dologin.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0"?>
+<view name="dologin" present="accountHome" xmlns:xi="http://www.w3.org/2001/XInclude"
+ xmlns:project2="http://project2.randomdan.homeip.net">
+ <xi:include href="../datasources/postgres.xml" />
+ <project2:regexcheck apply-to="username" present="login" name="usernameEntered">
+ <regex>.+</regex>
+ <message>User name required</message>
+ </project2:regexcheck>
+ <project2:regexcheck apply-to="password" present="login" name="passwordLength">
+ <regex>.{6,}</regex>
+ <message>Password too short</message>
+ </project2:regexcheck>
+ <project2:sqlcheck datasource="postgres" testOp="=" testValue="1" present="login" name="checkUserAuth">
+ <message>Invalid username or password</message>
+ <sql>
+ SELECT COUNT(*)
+ FROM users
+ WHERE username = ?
+ AND userpassword = ?
+ </sql>
+ <parameters>
+ <param bind="0" id="username" source="query" />
+ <param bind="1" id="password" source="query" />
+ </parameters>
+ </project2:sqlcheck>
+ <project2:sqltask datasource="postgres" name="auditLogin">
+ <sql>
+ INSERT INTO user_logins(userid, logintime)
+ SELECT userid, NOW()
+ FROM users
+ WHERE username = ?
+ </sql>
+ <parameters>
+ <param bind="0" id="username" source="query" />
+ </parameters>
+ </project2:sqltask>
+</view>
+
diff --git a/gentoobrowse/views/categories.xml b/gentoobrowse/views/categories.xml
index ed53caa..aeceb43 100644
--- a/gentoobrowse/views/categories.xml
+++ b/gentoobrowse/views/categories.xml
@@ -1,7 +1,8 @@
<?xml version="1.0"?>
-<block xmlns:xi="http://www.w3.org/2001/XInclude">
+<block xmlns:xi="http://www.w3.org/2001/XInclude"
+ xmlns:project2="http://project2.randomdan.homeip.net">
<xi:include href="../datasources/postgres.xml" />
- <sqlview name="categories" recordname="category" datasource="postgres">
+ <project2:sqlview name="categories" recordname="category" datasource="postgres">
<sql>
SELECT c.categoryid, MIN(c.name) AS catname, COUNT(*) AS packages
FROM categories c, packages p
@@ -9,5 +10,5 @@
GROUP BY c.categoryid
ORDER BY MIN(c.name)
</sql>
- </sqlview>
+ </project2:sqlview>
</block>
diff --git a/gentoobrowse/views/category.xml b/gentoobrowse/views/category.xml
index 5e4644e..2e1adb9 100644
--- a/gentoobrowse/views/category.xml
+++ b/gentoobrowse/views/category.xml
@@ -1,7 +1,8 @@
<?xml version="1.0"?>
-<block xmlns:xi="http://www.w3.org/2001/XInclude">
+<block xmlns:xi="http://www.w3.org/2001/XInclude"
+ xmlns:project2="http://project2.randomdan.homeip.net">
<xi:include href="../datasources/postgres.xml" />
- <sqlview name="packages" recordname="package" datasource="postgres">
+ <project2:sqlview name="packages" recordname="package" datasource="postgres">
<sql>
SELECT c.name AS catname, p.name AS pkgname, p.description
FROM categories c, packages p
@@ -12,5 +13,5 @@
<parameters>
<param bind="0" id="1" source="uri" />
</parameters>
- </sqlview>
+ </project2:sqlview>
</block>
diff --git a/gentoobrowse/views/newebuilds.xml b/gentoobrowse/views/newebuilds.xml
index 46a64f9..1f0c5f4 100644
--- a/gentoobrowse/views/newebuilds.xml
+++ b/gentoobrowse/views/newebuilds.xml
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
-<block xmlns:xi="http://www.w3.org/2001/XInclude">
+<block xmlns:project2="http://project2.randomdan.homeip.net" xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="../datasources/postgres.xml" />
- <sqlview name="newebuilds" recordname="ebuild" datasource="postgres">
+ <project2:sqlview name="newebuilds" recordname="ebuild" datasource="postgres">
<sql>
SELECT filename, description, moddate, p.name AS pkgname, c.name AS catname,
EXTRACT('day' FROM (SELECT MAX(fm.firstseen) FROM files fm)) - EXTRACT('day' FROM f.firstseen) AS age
@@ -12,5 +12,5 @@
AND f.firstseen &gt; (SELECT MAX(fm.firstseen) - INTERVAL '2.1 days' FROM files fm)
ORDER BY c.name, p.name, e.versioninst
</sql>
- </sqlview>
+ </project2:sqlview>
</block>
diff --git a/gentoobrowse/views/package.xml b/gentoobrowse/views/package.xml
index 8544123..3cc24a2 100644
--- a/gentoobrowse/views/package.xml
+++ b/gentoobrowse/views/package.xml
@@ -1,7 +1,8 @@
<?xml version="1.0"?>
-<block xmlns:xi="http://www.w3.org/2001/XInclude">
+<block xmlns:xi="http://www.w3.org/2001/XInclude"
+ xmlns:project2="http://project2.randomdan.homeip.net">
<xi:include href="../datasources/postgres.xml" />
- <sqlview name="summary" recordname="package" datasource="postgres">
+ <project2:sqlview name="summary" recordname="package" datasource="postgres">
<sql>
SELECT p.packageid, p.name AS pkgname, p.description, p.firstseen, c.name AS catname
FROM packages p, categories c
@@ -13,7 +14,7 @@
<param bind="0" id="1" source="uri" />
<param bind="1" id="2" source="uri" />
</parameters>
- <sqlview name="versions" recordname="version" datasource="postgres">
+ <project2:sqlview name="versions" recordname="version" datasource="postgres">
<sql>
SELECT e.ebuildid, e.version
FROM ebuilds e
@@ -23,8 +24,8 @@
<parameters>
<param bind="0" id="packageid" source="parent" />
</parameters>
- </sqlview>
- <sqlview name="packageUrls" recordname="url" datasource="postgres">
+ </project2:sqlview>
+ <project2:sqlview name="packageUrls" recordname="url" datasource="postgres">
<sql>
SELECT pu.url
FROM package_urls pu
@@ -34,8 +35,8 @@
<parameters>
<param bind="0" id="packageid" source="parent" />
</parameters>
- </sqlview>
- <sqlview name="versionUses" recordname="use" datasource="postgres">
+ </project2:sqlview>
+ <project2:sqlview name="versionUses" recordname="use" datasource="postgres">
<sql>
SELECT u.*
FROM ebuilds e, ebuild_uses u
@@ -46,8 +47,8 @@
<parameters>
<param bind="0" id="packageid" source="parent" />
</parameters>
- </sqlview>
- <sqlview name="versionArchs" recordname="arch" datasource="postgres">
+ </project2:sqlview>
+ <project2:sqlview name="versionArchs" recordname="arch" datasource="postgres">
<sql>
SELECT a.*
FROM ebuilds e, ebuild_archs a
@@ -58,8 +59,8 @@
<parameters>
<param bind="0" id="packageid" source="parent" />
</parameters>
- </sqlview>
- <sqlview name="deps" recordname="package" datasource="postgres">
+ </project2:sqlview>
+ <project2:sqlview name="deps" recordname="package" datasource="postgres">
<sql>
SELECT distinct cd.name AS catname, pd.name AS pkgname, pd.description
FROM ebuilds e, ebuild_deps d, packages pd, categories cd
@@ -72,6 +73,6 @@
<parameters>
<param bind="0" id="packageid" source="parent" />
</parameters>
- </sqlview>
- </sqlview>
+ </project2:sqlview>
+ </project2:sqlview>
</block>
diff --git a/gentoobrowse/views/search.xml b/gentoobrowse/views/search.xml
index 538e852..06b90a6 100644
--- a/gentoobrowse/views/search.xml
+++ b/gentoobrowse/views/search.xml
@@ -1,7 +1,8 @@
<?xml version="1.0"?>
-<block xmlns:xi="http://www.w3.org/2001/XInclude">
+<block xmlns:xi="http://www.w3.org/2001/XInclude"
+ xmlns:project2="http://project2.randomdan.homeip.net">
<xi:include href="../datasources/postgres.xml" />
- <sqlview name="searchResults" recordname="package" datasource="postgres">
+ <project2:sqlview name="searchResults" recordname="package" datasource="postgres">
<sql>
select c.name as catname, p.name as pkgname, description,
ts_rank((setweight(to_tsvector('english', p.name), 'A') || setweight(to_tsvector('english', p.description), 'B')),
@@ -15,5 +16,5 @@
<param bind="0" id="criteria" source="query" />
<param bind="1" id="criteria" source="query" />
</parameters>
- </sqlview>
+ </project2:sqlview>
</block>