support searching for Windows artifacts

This commit is contained in:
Mike Bonnet 2010-09-21 11:56:05 -04:00
parent a2b91eaa1e
commit c0b34886d8
5 changed files with 24 additions and 4 deletions

View file

@ -8245,13 +8245,14 @@ class RootExports(object):
'user': 'users',
'host': 'host',
'rpm': 'rpminfo',
'maven': 'archiveinfo'}
'maven': 'archiveinfo',
'win': 'archiveinfo'}
def search(self, terms, type, matchType, queryOpts=None):
"""Search for an item in the database matching "terms".
"type" specifies what object type to search for, and must be
one of "package", "build", "tag", "target", "user", "host",
or "rpm". "matchType" specifies the type of search to
"rpm", "maven", or "win". "matchType" specifies the type of search to
perform, and must be one of "glob" or "regexp". All searches
are case-insensitive. A list of maps containing "id" and
"name" will be returned. If no matches are found, an empty
@ -8295,6 +8296,11 @@ class RootExports(object):
joins.append('maven_archives ON archiveinfo.id = maven_archives.archive_id')
clause = "archiveinfo.filename %s %%(terms)s or maven_archives.group_id || '-' || " \
"maven_archives.artifact_id || '-' || maven_archives.version %s %%(terms)s" % (oper, oper)
elif type == 'win':
cols = ('id', "trim(leading '/' from win_archives.relpath || '/' || archiveinfo.filename)")
joins.append('win_archives ON archiveinfo.id = win_archives.archive_id')
clause = "archiveinfo.filename %s %%(terms)s or win_archives.relpath || '/' || " \
"archiveinfo.filename %s %%(terms)s" % (oper, oper)
else:
clause = 'name %s %%(terms)s' % oper

View file

@ -59,6 +59,9 @@
#if $mavenEnabled
<option value="maven">Maven Artifacts</option>
#end if
#if $winEnabled
<option value="win">Windows Artifacts</option>
#end if
</select>
<input type="text" name="terms"/>
<input type="submit" value="Search"/>

View file

@ -2075,7 +2075,8 @@ _infoURLs = {'package': 'packageinfo?packageID=%(id)i',
'user': 'userinfo?userID=%(id)i',
'host': 'hostinfo?hostID=%(id)i',
'rpm': 'rpminfo?rpmID=%(id)i',
'maven': 'archiveinfo?archiveID=%(id)i'}
'maven': 'archiveinfo?archiveID=%(id)i',
'win': 'archiveinfo?archiveID=%(id)i'}
_VALID_SEARCH_CHARS = r"""a-zA-Z0-9"""
_VALID_SEARCH_SYMS = r""" @.,_/\()%+-*?|[]^$"""
@ -2121,6 +2122,13 @@ def search(req, start=None, order='name'):
# (you're feeling lucky)
mod_python.util.redirect(req, infoURL % results[0])
else:
if type == 'maven':
typeLabel = 'Maven artifacts'
elif type == 'win':
typeLabel = 'Windows artifacts'
else:
typeLabel = '%ss' % type
values['typeLabel'] = typeLabel
return _genHTML(req, 'searchresults.chtml')
else:
return _genHTML(req, 'search.chtml')

View file

@ -24,6 +24,9 @@
#if $mavenEnabled
<option value="maven">Maven Artifacts</option>
#end if
#if $winEnabled
<option value="win">Windows Artifacts</option>
#end if
</select>
</td>
</tr>

View file

@ -3,7 +3,7 @@
#include "includes/header.chtml"
<h4>Search Results for ${type}s matching "$terms"</h4>
<h4>Search Results for $typeLabel matching "$terms"</h4>
<table class="data-list">
<tr>