diff options
author | randomdan <randomdan@localhost> | 2011-02-10 22:01:17 +0000 |
---|---|---|
committer | randomdan <randomdan@localhost> | 2011-02-10 22:01:17 +0000 |
commit | 100e4ddbd35b9ce7ee296be1e1d582b4c4832041 (patch) | |
tree | c115cd307c2089ccdf1debfdc32a148967ca9a8d | |
parent | Add a common collection of data containing the poweredBy folk and replace the... (diff) | |
download | gentoobrowse-100e4ddbd35b9ce7ee296be1e1d582b4c4832041.tar.bz2 gentoobrowse-100e4ddbd35b9ce7ee296be1e1d582b4c4832041.tar.xz gentoobrowse-100e4ddbd35b9ce7ee296be1e1d582b4c4832041.zip |
Allow searching for bugs as well as packages
-rw-r--r-- | gentoobrowse/present/search.xml | 55 | ||||
-rw-r--r-- | gentoobrowse/search.xslt | 41 | ||||
-rw-r--r-- | gentoobrowse/views/search.xml | 13 |
3 files changed, 89 insertions, 20 deletions
diff --git a/gentoobrowse/present/search.xml b/gentoobrowse/present/search.xml index de448f3..cb48280 100644 --- a/gentoobrowse/present/search.xml +++ b/gentoobrowse/present/search.xml @@ -3,15 +3,48 @@ xmlns:project2="http://project2.randomdan.homeip.net"> <xi:include href="../views/search.xml" /> <xi:include href="../views/webcommon.xml" /> - <project2:rawview> - <form caption="Search" submit="Search" action="/search" method="get" autofocus="criteria"> - <input type="text" caption="Criteria" name="criteria" - xslvalue="/gentoo/project2:params/project2:param[@name='criteria']/@value" /> - </form> - </project2:rawview> - <project2:view name="searchResults" source="packageSearch" rootname="searchResults" recordname="package" filter="freeText"> - <parameters> - <param name="criteria"><value source="param" name="criteria" default="" /></param> - </parameters> - </project2:view> + + <project2:if name="haveNoBCriteria" mode="and"> + <project2:regexcheck name="criteriaLength" regex="^$"> + <apply-to source="param" name="bcriteria" default="" /> + </project2:regexcheck> + <project2:rawview name="a-packages"> + <form caption="Package Search" submit="Search" action="/search" method="get" autofocus="criteria"> + <input type="text" caption="Criteria" name="criteria" + xslvalue="/gentoo/project2:params/project2:param[@name='criteria']/@value" /> + </form> + </project2:rawview> + </project2:if> + <project2:if name="haveCriteria" mode="and"> + <project2:regexcheck name="criteriaLength" regex=".+"> + <apply-to source="param" name="criteria" default="" /> + </project2:regexcheck> + <project2:view name="searchResults" source="packageSearch" rootname="searchResults" recordname="package" filter="freeText"> + <parameters> + <param name="criteria"><value source="param" name="criteria" default="" /></param> + </parameters> + </project2:view> + </project2:if> + + <project2:if name="haveNoCriteria" mode="and"> + <project2:regexcheck name="criteriaLength" regex="^$"> + <apply-to source="param" name="criteria" default="" /> + </project2:regexcheck> + <project2:rawview name="b-bugs"> + <form caption="Bug Search" submit="Search" action="/search" method="get"> + <input type="text" caption="Criteria" name="bcriteria" + xslvalue="/gentoo/project2:params/project2:param[@name='bcriteria']/@value" /> + </form> + </project2:rawview> + </project2:if> + <project2:if name="haveBCriteria" mode="and"> + <project2:regexcheck name="criteriaLength" regex=".+"> + <apply-to source="param" name="bcriteria" default="" /> + </project2:regexcheck> + <project2:view name="bugSearchResults" source="bugSearch" rootname="bugSearchResults" recordname="bug" filter="freeText"> + <parameters> + <param name="criteria"><value source="param" name="bcriteria" default="" /></param> + </parameters> + </project2:view> + </project2:if> </view> diff --git a/gentoobrowse/search.xslt b/gentoobrowse/search.xslt index 063c0b7..06bd5b7 100644 --- a/gentoobrowse/search.xslt +++ b/gentoobrowse/search.xslt @@ -9,18 +9,41 @@ <xsl:template name="content"> <xsl:apply-templates select="form|para" /> <xsl:apply-templates select="/gentoo/searchResults" /> + <xsl:apply-templates select="/gentoo/bugSearchResults" /> </xsl:template> <xsl:template match="/gentoo/searchResults"> - <xsl:if test="/gentoo/project2:params/project2:param[@name='criteria']/@value != ''"> - <xsl:if test="count(/gentoo/searchResults/package) > 0"> - <h2>Search Results for "<xsl:value-of select="/gentoo/project2:params/project2:param[@name='criteria']/@value"/>"</h2> - <ul> - <xsl:apply-templates select="/gentoo/searchResults/package" /> - </ul> + <xsl:if test="/gentoo/project2:params/project2:param[@name='criteria']/@value != ''"> + <xsl:if test="count(/gentoo/searchResults/package) > 0"> + <h2>Search Results for "<xsl:value-of select="/gentoo/project2:params/project2:param[@name='criteria']/@value"/>"</h2> + <ul> + <xsl:apply-templates select="/gentoo/searchResults/package" /> + </ul> + </xsl:if> + <xsl:if test="count(/gentoo/searchResults/package) = 0"> + <p class="warning">Nothing found</p> + </xsl:if> </xsl:if> - <xsl:if test="count(/gentoo/searchResults/package) = 0"> - <p class="warning">Nothing found</p> + </xsl:template> + <xsl:template match="/gentoo/bugSearchResults"> + <xsl:if test="/gentoo/project2:params/project2:param[@name='bcriteria']/@value != ''"> + <xsl:if test="count(/gentoo/bugSearchResults/bug) > 0"> + <h2>Search Results for "<xsl:value-of select="/gentoo/project2:params/project2:param[@name='bcriteria']/@value"/>"</h2> + <ul> + <xsl:for-each select="/gentoo/bugSearchResults/bug"> + <li> + <a> + <xsl:attribute name="href">http://bugs.gentoo.org/<xsl:value-of select="bugid" /></xsl:attribute> + <xsl:attribute name="title"><xsl:value-of select="summary" /></xsl:attribute> + <xsl:value-of select="bugid" /> + </a> + - <xsl:value-of select="summary" /> + </li> + </xsl:for-each> + </ul> + </xsl:if> + <xsl:if test="count(/gentoo/bugSearchResults/bug) = 0"> + <p class="warning">Nothing found</p> + </xsl:if> </xsl:if> - </xsl:if> </xsl:template> </xsl:stylesheet> diff --git a/gentoobrowse/views/search.xml b/gentoobrowse/views/search.xml index 820c3ea..87ce6eb 100644 --- a/gentoobrowse/views/search.xml +++ b/gentoobrowse/views/search.xml @@ -18,4 +18,17 @@ </filter> </sql> </project2:sqlrows> + <project2:sqlrows name="bugSearch" datasource="postgres-web"> + <sql> + SELECT b.bugid, b.severity, b.status, b.summary, b.firstseen + <filter name="freeText">, + ts_rank(to_tsvector('english', regexp_replace(summary, '-[0-9][^ ]*', '', 'g')), plainto_tsquery('english', <param name="criteria" />)) as rank + </filter> + FROM bugs b + <filter name="freeText"> + WHERE to_tsvector('english', regexp_replace(summary, '-[0-9][^ ]*', '', 'g')) @@ plainto_tsquery('english', <param name="criteria" />) + ORDER BY rank DESC, bugid DESC + </filter> + </sql> + </project2:sqlrows> </block> |