summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2010-07-30 20:16:23 +0000
committerrandomdan <randomdan@localhost>2010-07-30 20:16:23 +0000
commitb326b543f294f794762a2b1d68a614e1168fa39b (patch)
tree2deb72a1bb5a15de48ff509fb119a66f82c42c69
parentAllow users to track specific packages of their choice (diff)
downloadgentoobrowse-b326b543f294f794762a2b1d68a614e1168fa39b.tar.bz2
gentoobrowse-b326b543f294f794762a2b1d68a614e1168fa39b.tar.xz
gentoobrowse-b326b543f294f794762a2b1d68a614e1168fa39b.zip
Check user is logged in before presenting account pages
Provide a list of currently tracked packages
-rw-r--r--gentoobrowse/checks/loggedIn.xml6
-rw-r--r--gentoobrowse/login.xslt18
-rw-r--r--gentoobrowse/present/accountHome.xml2
-rw-r--r--gentoobrowse/present/accountTracked.xml26
4 files changed, 51 insertions, 1 deletions
diff --git a/gentoobrowse/checks/loggedIn.xml b/gentoobrowse/checks/loggedIn.xml
new file mode 100644
index 0000000..7e83515
--- /dev/null
+++ b/gentoobrowse/checks/loggedIn.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<project2:regexcheck xmlns:project2="http://project2.randomdan.homeip.net" apply-to="%loggedInUserID|" present="login" name="loggedIn">
+ <regex>.</regex>
+ <message>Not logged in</message>
+</project2:regexcheck>
+
diff --git a/gentoobrowse/login.xslt b/gentoobrowse/login.xslt
index 7849fe4..71265ef 100644
--- a/gentoobrowse/login.xslt
+++ b/gentoobrowse/login.xslt
@@ -8,6 +8,22 @@
doctype-system="http://www.w3.org/TR/html4/loose.dtd"
doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN" />
<xsl:template name="content">
- <xsl:apply-templates select="form|para" />
+ <xsl:apply-templates select="form|para|trackedebuilds" />
+ </xsl:template>
+ <xsl:template match="/gentoo/trackedebuilds">
+ <h2>Tracked packages</h2>
+ <ul>
+ <xsl:apply-templates select="ebuild" />
+ </ul>
+ </xsl:template>
+ <xsl:template match="/gentoo/trackedebuilds/ebuild">
+ <li>
+ <a>
+ <xsl:attribute name="href">
+ /package/<xsl:value-of select="catname" />/<xsl:value-of select="pkgname" />
+ </xsl:attribute>
+ <xsl:value-of select="catname" />/<xsl:value-of select="pkgname" />-<xsl:value-of select="latestversion" />
+ </a>
+ </li>
</xsl:template>
</xsl:stylesheet>
diff --git a/gentoobrowse/present/accountHome.xml b/gentoobrowse/present/accountHome.xml
index aea6835..8628d8c 100644
--- a/gentoobrowse/present/accountHome.xml
+++ b/gentoobrowse/present/accountHome.xml
@@ -1,8 +1,10 @@
<?xml version="1.0"?>
<view name="index" root="gentoo" style="login.xslt" xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:project2="http://project2.randomdan.homeip.net">
+ <xi:include href="../checks/loggedIn.xml" />
<project2:rawview>
<form caption="Logout" submit="Logout" action="/dologout" method="post" />
+ <para>View my <a href="/accountTracked">tracked packages</a>.</para>
</project2:rawview>
</view>
diff --git a/gentoobrowse/present/accountTracked.xml b/gentoobrowse/present/accountTracked.xml
new file mode 100644
index 0000000..89e8da8
--- /dev/null
+++ b/gentoobrowse/present/accountTracked.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<view name="index" root="gentoo" style="login.xslt" xmlns:xi="http://www.w3.org/2001/XInclude"
+ xmlns:project2="http://project2.randomdan.homeip.net">
+ <xi:include href="../datasources/postgres.xml" />
+ <xi:include href="../checks/loggedIn.xml" />
+ <project2:sqlview name="trackedebuilds" recordname="ebuild" datasource="postgres">
+ <sql>
+ SELECT c.name AS catname, p.name AS pkgname, (
+ SELECT e.version
+ FROM ebuilds e
+ WHERE e.packageid = p.packageid
+ ORDER BY e.versioninst
+ DESC LIMIT 1) AS latestversion
+ FROM user_packages up, packages p, categories c
+ WHERE up.packageid = p.packageid
+ AND c.categoryid = p.categoryid
+ AND up.userid = ?
+ ORDER BY c.name, p.name
+ </sql>
+ <parameters>
+ <param bind="0" value="%loggedInUserID|0" />
+ </parameters>
+ </project2:sqlview>
+</view>
+
+